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

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

body {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  color: var(--ak-ink);
  background-color: var(--ak-bg);
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
  font-family: var(--ak-font-body);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

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

img {
  display: block;
  max-width: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

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

.play {
  --pad-top: max(8px, env(safe-area-inset-top, 0px));
  --pad-bot: max(10px, env(safe-area-inset-bottom, 0px));
  --pad-x: max(12px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(100%, 420px);
  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-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer);
  background-size: cover, cover;
  background-position: center top;
  background-repeat: no-repeat;
}

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

.mute svg {
  width: 22px;
  height: 22px;
}

.mute .slash {
  display: none;
}

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

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

.top {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-right: 52px;
  padding-left: 8px;
}

.logo-wrap {
  margin: 0;
  line-height: 0;
}

.play-logo {
  height: min(56px, 8dvh);
  width: auto;
  max-width: min(240px, 70vw);
  object-fit: contain;
}

.turn {
  width: 100%;
  padding: 6px 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
  text-align: center;
}

.turn-who,
.turn-sub,
.voice,
.coach,
.why,
.result-says,
.tag p {
  margin: 0;
}

.turn-who {
  font-family: var(--ak-font-display);
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ak-ink);
}

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

.voice,
.why,
.coach {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
  color: var(--ak-ink);
  font-size: 15px;
  line-height: 1.35;
}

.coach {
  position: relative;
  border-color: var(--ak-accent-2);
}

.coach::after {
  content: '';
  position: absolute;
  left: 28px;
  bottom: -8px;
  width: 12px;
  height: 12px;
  background: var(--ak-surface);
  border-right: 2px solid var(--ak-accent-2);
  border-bottom: 2px solid var(--ak-accent-2);
  transform: rotate(45deg);
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  padding-bottom: 2px;
}

.rail,
.end-rail {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

.rail {
  gap: min(2.4vw, 10px);
  padding: 0 2px 2px;
}

.rail::before {
  content: '';
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 16px;
  height: 0;
  border-top: 2px dashed color-mix(in srgb, var(--ak-ink) 45%, transparent);
  pointer-events: none;
}

.rail-bed {
  flex: 0 0 auto;
  height: 10px;
  margin: -2px 10px 0;
  border: 2px solid var(--ak-outline);
  border-radius: 999px;
  background: linear-gradient(var(--ak-accent), var(--ak-btn-active));
  box-shadow: var(--ak-shadow);
}

.pin,
.end-pin {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pin > img,
.end-pin img,
.try img {
  width: 100%;
  height: 72px;
  max-height: 72px;
  object-fit: cover;
  object-position: center;
  filter: drop-shadow(0 6px 0 color-mix(in srgb, var(--ak-ink) 28%, transparent));
}

.cup-clip {
  position: relative;
  width: 100%;
  height: 72px;
  overflow: hidden;
}

.cup-clip img {
  position: absolute;
  width: 270%;
  max-width: none;
  height: auto;
  max-height: none;
  left: 50%;
  top: -2px;
  transform: translateX(-50%);
  object-fit: fill;
  filter: drop-shadow(0 6px 0 color-mix(in srgb, var(--ak-ink) 28%, transparent));
}

.pin::after,
.end-pin::after {
  content: '';
  width: 8px;
  height: 12px;
  margin-top: -8px;
  border-radius: 2px;
  background: var(--ak-accent);
  box-shadow: 1px 1px 0 var(--ak-outline);
}

.num {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  min-width: 1.5em;
  padding: 1px 5px 0;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-surface) 92%, white);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: clamp(18px, 5vw, 30px);
  line-height: 1.05;
  text-align: center;
  box-shadow: var(--ak-shadow);
}

.pin.is-hot .num,
.pin.is-hot .cup-clip {
  border-color: var(--ak-accent-2);
  box-shadow: var(--ak-shadow), 0 0 0 3px color-mix(in srgb, var(--ak-accent-2) 65%, transparent);
}

.ring {
  position: absolute;
  left: 50%;
  top: 4px;
  z-index: 2;
  width: 46%;
  height: 18px;
  transform: translateX(-50%);
  border: 3px solid var(--ak-accent-2);
  border-radius: 50%;
  pointer-events: none;
}

.try {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 3;
  height: 72px;
}

.try img {
  width: 100%;
  max-height: min(24dvh, 150px);
}

.tag {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}

.tag img {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  object-fit: contain;
  transform-origin: 50% 0;
}

.tag p {
  flex: 1 1 auto;
  padding: 8px 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
  color: var(--ak-ink);
  font-size: 15px;
}

.answer-form {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.guess,
.check,
.clue,
.btn-go,
.btn-alt {
  min-height: 48px;
  border-radius: var(--ak-radius);
  border: 2px solid var(--ak-outline);
  box-shadow: var(--ak-shadow);
}

.guess {
  flex: 0 1 112px;
  min-width: 88px;
  width: 112px;
  padding: 0 10px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 28px;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}

.guess::placeholder {
  color: var(--ak-ink-muted);
  font-family: var(--ak-font-body);
  font-size: 16px;
  font-weight: 600;
}

.guess.is-bad {
  border-color: var(--ak-accent-2);
}

.check,
.btn-go {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 16px;
  letter-spacing: 0.02em;
}

.check {
  flex: 1 1 auto;
  padding: 0 12px;
}

.clue,
.btn-alt {
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  font-family: var(--ak-font-display);
  font-size: 16px;
}

.clue {
  flex: 0 0 auto;
  width: 100%;
  padding: 0 12px;
}

.check:disabled,
.guess:disabled {
  opacity: 0.62;
}

.clue:disabled {
  color: var(--ak-ink-muted);
  box-shadow: none;
  transform: translateY(2px);
}

.why {
  text-align: center;
}

.result {
  flex: 0 0 auto;
}

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

.result-says {
  margin-bottom: 8px;
  font-size: 16px;
  text-align: center;
  color: var(--ak-ink);
}

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

.btn-go,
.btn-alt {
  width: 100%;
  padding: 0 12px;
}

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

.fx i {
  position: absolute;
  top: 38%;
  width: 9px;
  height: 12px;
  border-radius: 2px;
  opacity: 0;
}

.fx i.is-a {
  background: var(--ak-accent-2);
}

.fx i.is-b {
  background: var(--ak-accent);
}

.end-rail {
  gap: 4px;
  align-items: flex-end;
  min-height: 72px;
}

.end-pin {
  max-width: 44px;
  overflow: hidden;
}

.end-pin img {
  height: 48px;
  max-height: 48px;
}

.end-pin.is-cup,
.end-pin .cup-clip {
  height: 48px;
}

.end-pin .ring {
  top: 1px;
  width: 62%;
  height: 12px;
}

.end-pin.is-cup img {
  position: absolute;
  width: 250%;
  max-width: none;
  height: auto;
  max-height: none;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  object-fit: fill;
}

.end-pin .num {
  font-size: 14px;
  min-width: 1.2em;
  padding: 0 3px;
  top: 38%;
}

.play.is-ended .stage {
  flex: 0 0 auto;
}

button:focus-visible,
.guess:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 2px;
}

@media (max-width: 360px) {
  .play {
    --pad-x: max(8px, env(safe-area-inset-left, 0px));
    gap: 6px;
  }

  .check,
  .clue,
  .btn-go,
  .btn-alt {
    font-size: 15px;
  }

  .num {
    font-size: 18px;
  }
}

@media (max-height: 700px) {
  .play-logo {
    height: 40px;
  }

  .voice,
  .why,
  .coach {
    font-size: 14px;
    padding: 6px 8px;
  }

  .pin > img,
  .try img,
  .cup-clip,
  .try {
    height: 58px;
    max-height: 58px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .play-logo {
    animation: bob 3.2s ease-in-out infinite;
  }

  .pin.is-cup .ring {
    animation: cup-pulse 1.25s ease-in-out infinite;
  }

  .pin.is-drop {
    animation: drop-in 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: var(--d, 0ms);
  }

  .pin.is-seat {
    animation: seat 520ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation-delay: var(--d, 0ms);
  }

  .pin.is-wrong .try {
    animation: rattle 680ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  }

  .tag.is-swing img {
    animation: tag-swing 720ms cubic-bezier(0.22, 1, 0.36, 1);
  }

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

  .guess.is-invite {
    animation: invite-ring 1.4s ease-in-out infinite;
  }

  .check:active,
  .clue:active,
  .btn-go:active,
  .btn-alt:active,
  .mute:active {
    transform: translateY(2px) scale(0.98);
  }

  .end-rail.is-shut {
    animation: shut 700ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .play.is-celebrate .end-pin {
    animation: chase 0.55s ease 3;
    animation-delay: calc(var(--i) * 70ms);
  }

  .result-card.is-in {
    animation: rise 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .fx i {
    animation: burst 900ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }

  .voice.is-invite {
    animation: bob 1.8s ease-in-out infinite;
  }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes cup-pulse {
  0%, 100% { opacity: 0.45; transform: translateX(-50%) scale(0.92); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.06); }
}

@keyframes drop-in {
  0% { transform: translateY(-28px) scale(1.08, 0.88); opacity: 0; }
  70% { transform: translateY(4px) scale(0.96, 1.05); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes seat {
  0% { transform: translateY(-26px) scale(1.12, 0.84); }
  55% { transform: translateY(5px) scale(0.94, 1.08); }
  78% { transform: translateY(-7px) scale(1.05, 0.95); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes rattle {
  0% { transform: translateX(0) rotate(0); opacity: 1; }
  18% { transform: translateX(-6px) rotate(-5deg); }
  36% { transform: translateX(6px) rotate(5deg); }
  52% { transform: translateX(-4px) rotate(-3deg); }
  100% { transform: translateY(-34px) scale(0.94); opacity: 0; }
}

@keyframes tag-swing {
  0% { transform: rotate(16deg); }
  40% { transform: rotate(-12deg); }
  70% { transform: rotate(6deg); }
  100% { transform: rotate(0); }
}

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

@keyframes invite-ring {
  0%, 100% { box-shadow: var(--ak-shadow); }
  50% { box-shadow: var(--ak-shadow), 0 0 0 4px color-mix(in srgb, var(--ak-accent-2) 75%, transparent); }
}

@keyframes shut {
  from { gap: 16px; transform: scaleX(1.06); }
  to { gap: 4px; transform: scaleX(1); }
}

@keyframes chase {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); }
  50% { filter: drop-shadow(0 0 8px var(--ak-accent-2)); }
}

@keyframes rise {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes burst {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; }
}
