@font-face {
  font-family: "Sagam Display";
  src: url("/fonts/NotoSansDisplay-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Sagam Global";
  src: url("/fonts/DejaVuSans.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Sagam CJK";
  src: url("/fonts/DroidSansFallbackFull.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #100b19;
  --cream: #fff4d8;
  --acid: #dfff4f;
  --violet: #9b6dff;
  --coral: #ff725e;
  --cyan: #6de8ff;
  --muted: #c2b8d2;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ink);
  font-family: "Sagam Global", "Sagam CJK", sans-serif;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(circle at 17% 12%, rgba(155, 109, 255, .27), transparent 35%),
    radial-gradient(circle at 83% 85%, rgba(109, 232, 255, .16), transparent 32%),
    var(--ink);
  color: var(--cream);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: var(--acid);
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 5px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  inset: 1rem auto auto 1rem;
  transform: translateY(-200%);
  padding: .75rem 1rem;
  background: var(--cream);
  color: var(--ink);
}

.skip-link:focus {
  transform: translateY(0);
}

.stage {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100svh;
  padding: clamp(1rem, 2.5vw, 2.25rem) clamp(1rem, 4vw, 4.5rem);
  overflow: hidden;
}

.stage::before {
  position: absolute;
  z-index: -3;
  inset: 0;
  content: "";
  opacity: .16;
  background-image: radial-gradient(circle, var(--cream) 1px, transparent 1.5px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 74%);
}

.spotlight {
  position: absolute;
  z-index: -2;
  top: 45%;
  left: 50%;
  width: min(75vw, 70rem);
  aspect-ratio: 1.5;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(155, 109, 255, .14);
  filter: blur(42px);
}

.masthead,
.footer {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-family: "Sagam Display", "Sagam Global", sans-serif;
  font-size: .75rem;
  letter-spacing: .13em;
}

.site-name {
  color: var(--cream);
  text-decoration: none;
  text-underline-offset: .35em;
}

.site-name:hover {
  text-decoration: underline;
}

.pack-count {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--acid);
}

.pack-count i {
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--acid);
}

.experience {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: minmax(9rem, 1fr) auto auto;
  place-items: center;
  align-self: center;
  width: min(100%, 78rem);
  min-height: min(79svh, 57rem);
  margin-inline: auto;
}

.word-stage {
  display: grid;
  align-self: end;
  place-items: center;
  width: 100%;
  min-height: clamp(8.5rem, 19vw, 14rem);
  padding-inline: 1rem;
  text-align: center;
}

.language-name {
  align-self: end;
  margin-bottom: .55rem;
  color: var(--violet);
  font-family: "Sagam Display", "Sagam Global", sans-serif;
  font-size: clamp(.72rem, 1vw, .9rem);
  letter-spacing: .14em;
}

.kinetic-word {
  display: block;
  max-width: 100%;
  color: var(--cream);
  font-family: "Sagam Display", "Sagam Global", "Sagam CJK", sans-serif;
  font-size: clamp(3rem, 8.6vw, 6rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -.035em;
  text-wrap: balance;
  text-shadow: 0 .08em .5em rgba(0, 0, 0, .35);
  transform-origin: center bottom;
}

.kinetic-word.is-leaving {
  animation: word-out .52s cubic-bezier(.7, 0, .84, 0) forwards;
}

.kinetic-word.is-arriving {
  animation: word-in .76s var(--ease-out) both;
}

.action-zone {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(10rem, 19vw, 13rem);
  aspect-ratio: 1;
  margin-top: clamp(.25rem, 1.4vh, 1rem);
}

.claim-button {
  position: relative;
  z-index: 3;
  display: grid;
  place-content: center;
  width: clamp(8.5rem, 15vw, 10.5rem);
  aspect-ratio: 1;
  border: 2px solid rgba(255, 244, 216, .7);
  border-radius: 50%;
  background: var(--acid);
  box-shadow:
    0 .8rem 2.8rem rgba(0, 0, 0, .36),
    inset 0 .1rem 0 rgba(255, 255, 255, .72);
  color: var(--ink);
  cursor: pointer;
  transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out), background .35s ease;
}

.claim-button > span:not(.tag-hole) {
  font-family: "Sagam Display", "Sagam Global", sans-serif;
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  font-weight: 700;
  letter-spacing: -.025em;
}

.claim-button small {
  margin-top: .35rem;
  font-size: .76rem;
  font-weight: 700;
  opacity: .66;
}

.claim-button:hover {
  transform: translateY(-.4rem) rotate(-2deg) scale(1.035);
  background: #ebff89;
  box-shadow: 0 1.4rem 3.3rem rgba(0, 0, 0, .46), inset 0 .1rem 0 rgba(255, 255, 255, .78);
}

.claim-button:active {
  transform: translateY(-.05rem) scale(.97);
}

.tag-hole {
  position: absolute;
  top: .65rem;
  left: 50%;
  width: .8rem;
  height: .8rem;
  transform: translateX(-50%);
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--cream);
}

.orbit {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 244, 216, .13);
  border-radius: 50%;
  animation: orbit 13s linear infinite;
}

.orbit span {
  position: absolute;
  top: -.9rem;
  left: 50%;
  font-size: 1.65rem;
  filter: drop-shadow(0 .3rem .45rem rgba(0, 0, 0, .32));
}

.orbit-two {
  inset: -1.25rem;
  animation-duration: 17s;
  animation-direction: reverse;
}

.orbit-two span {
  top: 50%;
  right: -1rem;
  left: auto;
}

.orbit-three {
  inset: .7rem;
  animation-duration: 9s;
}

.orbit-three span {
  top: auto;
  bottom: -1rem;
}

.last-dog {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  min-width: min(100%, 21rem);
  min-height: 3.25rem;
  margin-top: clamp(.85rem, 2vh, 1.5rem);
  padding: .75rem 1.1rem;
  border: 1px solid rgba(255, 244, 216, .36);
  border-radius: 14px;
  background: rgba(255, 244, 216, .07);
  color: var(--muted);
  font-size: clamp(.82rem, 1.5vw, 1rem);
  text-align: center;
}

#last-dog-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.last-dog.has-dog {
  border-color: var(--acid);
  background: var(--cream);
  color: var(--ink);
  font-family: "Sagam Display", "Sagam Global", sans-serif;
  font-weight: 700;
}

.status-dot {
  flex: 0 0 auto;
  width: .52rem;
  height: .52rem;
  border-radius: 50%;
  background: var(--violet);
}

.has-dog .status-dot {
  background: #458c00;
}

.footer {
  justify-content: center;
  flex-wrap: wrap;
  color: rgba(255, 244, 216, .55);
  font-size: .7rem;
}

.footer span[aria-hidden] {
  color: var(--coral);
}

.dog-pack {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
}

.dog-pack span {
  position: absolute;
  opacity: .37;
  font-size: clamp(1.1rem, 2.5vw, 2.1rem);
  filter: saturate(.75) drop-shadow(0 .25rem .45rem rgba(0, 0, 0, .4));
  animation: float-dog 7s ease-in-out infinite alternate;
}

.dog-pack span:nth-child(7n + 1) { left: 2%; top: 13%; animation-delay: -1s; }
.dog-pack span:nth-child(7n + 2) { right: 4%; top: 17%; animation-delay: -3.5s; }
.dog-pack span:nth-child(7n + 3) { left: 8%; top: 43%; animation-delay: -5s; }
.dog-pack span:nth-child(7n + 4) { right: 7%; top: 48%; animation-delay: -2s; }
.dog-pack span:nth-child(7n + 5) { left: 4%; bottom: 11%; animation-delay: -4s; }
.dog-pack span:nth-child(7n + 6) { right: 3%; bottom: 13%; animation-delay: -6s; }
.dog-pack span:nth-child(7n) { left: 50%; bottom: 3%; animation-delay: -2.8s; }
.dog-pack span:nth-child(n + 8):nth-child(-n + 14) { transform: translate(1.8rem, .8rem) scale(.7); opacity: .22; }
.dog-pack span:nth-child(n + 15):nth-child(-n + 21) { transform: translate(-2.3rem, -1.4rem) scale(1.2); opacity: .14; }
.dog-pack span:nth-child(n + 22) { transform: translate(3.6rem, 2.2rem) scale(.55); opacity: .26; }

.name-dialog {
  width: min(calc(100% - 2rem), 30rem);
  padding: .25rem;
  border: 1px solid rgba(16, 11, 25, .2);
  border-radius: 16px;
  background: var(--cream);
  box-shadow: 0 2.4rem 8rem rgba(0, 0, 0, .6);
  color: var(--ink);
}

.name-dialog::backdrop {
  background: rgba(16, 11, 25, .76);
  backdrop-filter: blur(9px);
}

.name-dialog[open] {
  animation: dialog-in .48s var(--ease-out) both;
}

.name-form {
  position: relative;
  display: grid;
  padding: clamp(1.5rem, 6vw, 2.75rem);
}

.dialog-dog {
  font-size: 3.5rem;
  line-height: 1;
}

.name-form h2 {
  margin: .85rem 0 .45rem;
  font-family: "Sagam Display", "Sagam Global", sans-serif;
  font-size: clamp(2rem, 8vw, 3.25rem);
  line-height: 1.06;
  letter-spacing: -.035em;
}

.name-form > p:not(.form-error) {
  max-width: 39ch;
  margin: 0 0 1.5rem;
  color: #51465f;
  font-size: .95rem;
  line-height: 1.75;
}

.name-form label {
  margin-bottom: .45rem;
  font-size: .82rem;
  font-weight: 700;
}

.name-form input {
  width: 100%;
  min-height: 3.5rem;
  padding: .8rem 1rem;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fffdf7;
  color: var(--ink);
  caret-color: var(--violet);
}

.name-form input::placeholder {
  color: #766b7e;
}

.form-error {
  min-height: 1.5rem;
  margin: .55rem 0;
  color: #a2251b;
  font-size: .82rem;
}

.submit-name {
  min-height: 3.55rem;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: var(--cream);
  font-weight: 700;
  cursor: pointer;
  transition: background .25s ease, transform .25s var(--ease-out);
}

.submit-name:hover {
  background: #39235b;
  transform: translateY(-2px);
}

.submit-name:disabled {
  cursor: wait;
  opacity: .65;
  transform: none;
}

.dialog-close {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid rgba(16, 11, 25, .18);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1.7rem;
  cursor: pointer;
}

.celebration {
  position: fixed;
  z-index: 80;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.celebration span {
  position: absolute;
  top: -4rem;
  left: 50%;
  --burst-delay: 0ms;
  --burst-spin: 1turn;
  font-size: clamp(1.4rem, 4vw, 2.8rem);
}

.celebration span:nth-child(10n + 1) { left: 4%; }
.celebration span:nth-child(10n + 2) { left: 14%; }
.celebration span:nth-child(10n + 3) { left: 24%; }
.celebration span:nth-child(10n + 4) { left: 34%; }
.celebration span:nth-child(10n + 5) { left: 44%; }
.celebration span:nth-child(10n + 6) { left: 54%; }
.celebration span:nth-child(10n + 7) { left: 64%; }
.celebration span:nth-child(10n + 8) { left: 74%; }
.celebration span:nth-child(10n + 9) { left: 84%; }
.celebration span:nth-child(10n) { left: 94%; }
.celebration span:nth-child(6n + 2) { --burst-delay: 45ms; }
.celebration span:nth-child(6n + 3) { --burst-delay: 90ms; }
.celebration span:nth-child(6n + 4) { --burst-delay: 135ms; }
.celebration span:nth-child(6n + 5) { --burst-delay: 180ms; }
.celebration span:nth-child(6n) { --burst-delay: 225ms; }
.celebration span:nth-child(even) { --burst-spin: -1turn; }

.celebration.is-active span {
  animation: dog-rain 1.55s var(--ease-out) var(--burst-delay) both;
}

.visually-hidden,
.screen-reader-copy {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes word-out {
  to { opacity: 0; filter: blur(16px); transform: translateY(-.38em) skewX(-5deg); clip-path: inset(0 0 100%); }
}

@keyframes word-in {
  from { opacity: 0; filter: blur(20px); transform: translateY(.45em) skewX(5deg); clip-path: inset(100% 0 0); }
  to { opacity: 1; filter: blur(0); transform: translateY(0) skewX(0); clip-path: inset(0); }
}

@keyframes orbit { to { transform: rotate(1turn); } }
@keyframes float-dog { to { margin-top: -1.1rem; rotate: 8deg; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(2rem) scale(.96); } }

@keyframes dog-rain {
  from { opacity: 0; transform: translateY(-8vh) rotate(0); }
  12% { opacity: 1; }
  to { opacity: 0; transform: translateY(112vh) rotate(var(--burst-spin)); }
}

@media (max-width: 700px) {
  .stage {
    padding: 1rem;
  }

  .masthead {
    font-size: .7rem;
  }

  .experience {
    min-height: 80svh;
    grid-template-rows: minmax(8rem, 1fr) auto auto;
  }

  .word-stage {
    min-height: 10rem;
    padding-inline: 0;
  }

  .kinetic-word {
    font-size: clamp(2.75rem, 13.2vw, 4.6rem);
  }

  .action-zone {
    width: 10rem;
  }

  .claim-button {
    width: 8.6rem;
  }

  .last-dog {
    width: min(100%, 22rem);
  }

  .dog-pack span:nth-child(odd) {
    display: none;
  }

  .footer {
    gap: .4rem .7rem;
    font-size: .69rem;
  }
}

@media (max-height: 720px) and (min-width: 701px) {
  .experience {
    min-height: 78svh;
  }

  .word-stage {
    min-height: 7rem;
  }

  .kinetic-word {
    font-size: clamp(3rem, 7vw, 5rem);
  }

  .action-zone {
    width: 9.3rem;
  }

  .claim-button {
    width: 8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
