*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100dvh;
  font-family: var(--ak-font-body);
  font-size: 16px;
  line-height: 1.3;
  color: var(--ak-ink);
  background-color: var(--ak-bg);
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
}

[hidden] {
  display: none !important;
}

button,
input {
  font: inherit;
  touch-action: manipulation;
}

.play {
  --pad-top: max(6px, env(safe-area-inset-top, 0px));
  --pad-bot: max(8px, env(safe-area-inset-bottom, 0px));
  --pad-x: max(10px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(100%, 430px);
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  padding: var(--pad-top) var(--pad-x) var(--pad-bot);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  background-image: var(--ak-backdrop-layer);
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
}

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

.mute {
  position: absolute;
  top: var(--pad-top);
  right: max(8px, env(safe-area-inset-right, 0px));
  z-index: 8;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 3px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: var(--ak-shadow);
  cursor: pointer;
}

.mute-svg {
  width: 26px;
  height: 26px;
}

.mute .slash {
  display: none;
}

.mute.is-muted .wave {
  display: none;
}

.mute.is-muted .slash {
  display: block;
}

.top,
.voice,
.why,
.lane,
.dock,
.result {
  position: relative;
  z-index: 1;
}

.why,
.result {
  z-index: 6;
}

.top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding-right: 52px;
  flex: 0 0 auto;
}

.play-logo {
  display: block;
  width: auto;
  height: 44px;
  max-width: 46%;
  object-fit: contain;
}

.turn {
  min-width: 0;
  padding: 4px 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-surface) 90%, transparent);
  box-shadow: var(--ak-shadow);
}

.turn-who {
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: clamp(18px, 5vw, 26px);
  font-weight: var(--ak-title-weight);
  line-height: 1;
  color: var(--ak-accent);
}

.turn-sub {
  margin: 2px 0 0;
  color: var(--ak-ink-muted);
  font-size: 14px;
  font-weight: 700;
}

.voice,
.why {
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 10px;
  border: 3px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-surface) 92%, transparent);
  box-shadow: var(--ak-shadow);
  font-size: 15px;
  line-height: 1.25;
}

.voice {
  min-height: 44px;
}

.why {
  border-color: var(--ak-accent);
  font-weight: 700;
}

.lane {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  border: 3px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-surface) 35%, transparent);
  box-shadow: var(--ak-shadow);
}

.drift {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.drift i {
  position: absolute;
  top: 18%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ak-surface);
  border: 1px solid var(--ak-accent-2);
}

.drift i:nth-child(1) { left: 8%; top: 22%; }
.drift i:nth-child(2) { left: 24%; top: 12%; width: 5px; height: 5px; }
.drift i:nth-child(3) { left: 46%; top: 28%; }
.drift i:nth-child(4) { left: 63%; top: 16%; width: 5px; height: 5px; }
.drift i:nth-child(5) { left: 78%; top: 30%; }
.drift i:nth-child(6) { left: 90%; top: 14%; width: 4px; height: 4px; }

.lane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 0;
  flex: 0 0 auto;
}

.kind {
  margin: 0;
  min-height: 32px;
  padding: 2px 12px;
  display: grid;
  place-items: center;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: 16px;
  line-height: 1;
  color: var(--ak-btn-ink);
  background: var(--ak-accent);
  border: 2px solid var(--ak-outline);
  border-radius: 999px;
  box-shadow: var(--ak-shadow);
}

.pips {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ak-surface);
  border: 2px solid var(--ak-outline);
}

.pip.is-now {
  width: 16px;
  border-radius: 8px;
  background: var(--ak-accent-2);
}

.pip.is-right {
  background: var(--ak-accent-2);
}

.pip.is-miss {
  background: var(--ak-accent);
}

.blocks {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  width: 100%;
  margin-top: auto;
  margin-bottom: -6px;
  padding: 0 8px;
}

.block {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 64px;
  aspect-ratio: 384 / 364;
}

.block.is-gap {
  margin-left: 18px;
}

.blocks.is-tight .block.is-gap {
  margin-left: 8px;
}

.blocks.is-tight .glyph {
  font-size: 12px;
  border-radius: 4px;
}

.cube {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.glyph {
  position: absolute;
  left: 16%;
  right: 16%;
  top: 20%;
  bottom: 24%;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: clamp(12px, 4.4vw, 26px);
  line-height: 1;
}

.block.is-hot .glyph {
  background: var(--ak-accent);
  color: var(--ak-btn-ink);
  box-shadow: 0 0 0 2px var(--ak-glow), 0 0 0 3px var(--ak-accent);
}

.blocks.is-vowels .glyph {
  box-shadow: 0 0 0 2px var(--ak-accent-2);
}

.rail-art {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: clamp(72px, 18dvh, 132px);
  flex: 0 1 auto;
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
}

.boot {
  position: absolute;
  z-index: 3;
  right: -4px;
  bottom: -10px;
  width: auto;
  height: min(28%, 88px);
  max-width: 78px;
  object-fit: contain;
  object-position: right bottom;
  pointer-events: none;
}

.finale {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(0, 1fr);
  gap: 4px;
  overflow: hidden;
}

.slot {
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 10px;
}

.slot-rail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.slot-phrase {
  position: relative;
  z-index: 1;
  max-width: 100%;
  margin: 4px;
  padding: 2px 4px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ak-surface) 92%, transparent);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: 12px;
  line-height: 1.15;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bare-wrap {
  position: relative;
  z-index: 1;
  width: 46px;
  height: 44px;
}

.slot-bare {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bare-face {
  position: absolute;
  left: 22%;
  top: 24%;
  width: 52%;
  height: 46%;
  border-radius: 4px;
  background: var(--ak-surface);
}

.slot-boot {
  position: absolute;
  right: -10px;
  bottom: -6px;
  width: 38px;
  height: auto;
}

.dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.worked,
.answer {
  width: 100%;
  min-height: 48px;
  margin: 0;
  border: 3px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
  color: var(--ak-ink);
}

.worked {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: center;
  padding: 4px 8px;
  text-align: center;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1;
  white-space: nowrap;
  user-select: text;
}

.worked .vowel {
  color: var(--ak-accent-2);
}

.answer {
  padding: 8px 12px;
  font-family: var(--ak-font-body);
  font-size: 16px;
  font-weight: 700;
  user-select: text;
}

.answer::placeholder {
  color: var(--ak-ink-muted);
  font-weight: 600;
}

.answer.is-invite {
  border-color: var(--ak-accent);
  box-shadow: var(--ak-shadow), 0 0 0 3px var(--ak-glow);
}

.answer.is-bad {
  border-color: var(--ak-accent);
  background: color-mix(in srgb, var(--ak-accent) 12%, var(--ak-surface));
}

.answer.is-lock {
  background: color-mix(in srgb, var(--ak-accent-2) 20%, var(--ak-surface));
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn {
  min-height: 48px;
  padding: 8px 10px;
  border: 3px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  box-shadow: var(--ak-shadow);
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: clamp(16px, 4.6vw, 20px);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.btn-go {
  grid-column: 1 / -1;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}

.btn-go:active {
  background: var(--ak-btn-active);
}

.btn-hint,
.btn-skip,
.btn-alt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  border-color: var(--ak-choice-border);
}

.hint-art {
  width: 28px;
  height: 36px;
  object-fit: contain;
  pointer-events: none;
}

.btn:focus-visible,
.answer:focus-visible,
.mute:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 2px;
}

.fx {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.powder,
.flake,
.puff {
  position: absolute;
  pointer-events: none;
}

.powder {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ak-surface);
  border: 2px solid var(--ak-accent-2);
}

.flake {
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--ak-surface);
  border: 2px solid var(--ak-accent);
}

.flake:nth-child(3n) {
  background: var(--ak-accent-2);
  border-color: var(--ak-outline);
}

.flake:nth-child(3n + 1) {
  background: var(--ak-accent);
  border-color: var(--ak-outline);
}

.puff {
  left: 50%;
  bottom: 30%;
  z-index: 5;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  border-radius: 50%;
  background: var(--ak-surface);
  border: 2px solid var(--ak-accent-2);
}

.result {
  flex: 0 0 auto;
}

.result-card {
  padding: 12px;
  border: 3px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.result-says {
  margin: 0 0 10px;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.2;
  color: var(--ak-ink);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-actions .btn {
  width: 100%;
}

.play.is-ended .lane-head,
.play.is-ended .blocks,
.play.is-ended .rail-art,
.play.is-ended .boot,
.play.is-ended .drift {
  display: none;
}

.play.is-ended .lane {
  justify-content: stretch;
  background: color-mix(in srgb, var(--ak-surface) 72%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
  .drift i {
    animation: drift 7.5s linear infinite;
  }

  .drift i:nth-child(2) { animation-duration: 9s; animation-delay: -2s; }
  .drift i:nth-child(3) { animation-duration: 6.5s; animation-delay: -1s; }
  .drift i:nth-child(4) { animation-duration: 8s; animation-delay: -3s; }
  .drift i:nth-child(5) { animation-duration: 10s; animation-delay: -4s; }
  .drift i:nth-child(6) { animation-duration: 7s; animation-delay: -2.5s; }

  .block.is-hop {
    animation: hop 0.48s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .lane.is-shake {
    animation: shake 0.42s ease;
  }

  .lane.is-yes {
    animation: bounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .boot {
    animation: idle-boot 3.2s ease-in-out infinite;
  }

  .boot.is-stomp {
    animation: stomp 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .hint-art {
    animation: idle-mitt 3.4s ease-in-out infinite;
  }

  .answer.is-invite,
  .play.is-example .btn-go.is-ready {
    animation: invite 1.4s ease-in-out infinite;
  }

  .turn.is-cue {
    animation: cue 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .puff {
    animation: puff 0.48s ease forwards;
  }

  .powder {
    animation: shed 0.6s ease forwards;
  }

  .flake {
    animation: burst 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }

  .play.is-win .lane {
    animation: chase 1.1s linear 2;
  }

  .play.is-win .slot {
    animation: hop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .btn:active,
  .mute:active {
    transform: translateY(2px) scale(0.97);
  }
}

@keyframes drift {
  from { transform: translateX(-12px); }
  to { transform: translateX(28px); }
}

@keyframes hop {
  0% { transform: translateY(-16px) scale(0.92, 1.08); }
  60% { transform: translateY(0) scale(1.06, 0.94); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px) rotate(-0.4deg); }
  75% { transform: translateX(7px) rotate(0.4deg); }
}

@keyframes bounce {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-6px) scale(1.03, 0.97); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes stomp {
  0% { transform: translateY(-28px) rotate(-8deg) scale(1.05, 0.95); }
  55% { transform: translateY(4px) rotate(4deg) scale(0.96, 1.06); }
  100% { transform: translateY(0) rotate(0) scale(1); }
}

@keyframes idle-boot {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-4px) rotate(2deg); }
}

@keyframes idle-mitt {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(5deg); }
}

@keyframes invite {
  0%, 100% { box-shadow: var(--ak-shadow), 0 0 0 0 var(--ak-glow); }
  50% { box-shadow: var(--ak-shadow), 0 0 0 4px var(--ak-accent-2); }
}

@keyframes cue {
  0% { transform: scale(0.96); }
  55% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes puff {
  0% { transform: scale(0.4); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

@keyframes shed {
  to { transform: translate(var(--x), var(--y)); opacity: 0; }
}

@keyframes burst {
  to { transform: translate(var(--x), var(--y)) rotate(160deg); opacity: 0; }
}

@keyframes chase {
  0% { box-shadow: 0 0 0 3px var(--ak-accent), 0 0 16px var(--ak-glow); }
  50% { box-shadow: 0 0 0 3px var(--ak-accent-2), 0 0 16px var(--ak-glow); }
  100% { box-shadow: 0 0 0 3px var(--ak-accent), 0 0 16px var(--ak-glow); }
}
