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

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

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

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

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

[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(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%, 440px);
  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;
  background-position: center top;
  background-repeat: no-repeat;
}

.mute {
  position: absolute;
  top: var(--pad-top);
  right: max(4px, env(safe-area-inset-right, 0px));
  z-index: 8;
  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);
  cursor: pointer;
}

.mute-icon {
  width: 22px;
  height: 22px;
}

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

.mute.is-muted::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 3px;
  background: var(--ak-accent-2);
  transform: rotate(-35deg);
}

.top,
.lamps,
.voice,
.plate-slot,
.readout,
.console,
.actions,
.why,
.recap,
.result {
  position: relative;
  z-index: 2;
  min-width: 0;
  flex: 0 0 auto;
}

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

.play-logo {
  height: 40px;
  width: auto;
  max-width: 46%;
  object-fit: contain;
  filter: drop-shadow(0 0 8px var(--ak-glow));
}

.turn {
  min-width: 0;
  min-height: 48px;
  padding: 4px 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.turn-who,
.turn-sub {
  margin: 0;
}

.turn-who {
  font-family: var(--ak-font-display);
  font-size: clamp(16px, 4.6vw, 22px);
  font-weight: var(--ak-title-weight);
  line-height: 1.05;
  color: var(--ak-ink);
}

.turn-sub {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ak-accent-2);
}

.lamps {
  width: min(78%, 250px);
  margin: 0 auto;
  aspect-ratio: 384 / 172;
}

.lamps img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lamp {
  position: absolute;
  left: var(--x);
  top: 50.4%;
  width: 11%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.lamps .lamp:nth-child(2) { --x: 16.4%; }
.lamps .lamp:nth-child(3) { --x: 33%; }
.lamps .lamp:nth-child(4) { --x: 50%; }
.lamps .lamp:nth-child(5) { --x: 66.6%; }
.lamps .lamp:nth-child(6) { --x: 83.5%; }

.lamp.is-lit {
  background: radial-gradient(circle, var(--ak-ink) 0%, var(--ak-accent-2) 48%, transparent 72%);
  box-shadow: 0 0 10px var(--ak-accent-2);
}

.lamp.is-close {
  box-shadow: 0 0 0 3px var(--ak-accent), 0 0 12px var(--ak-glow);
}

.lamp.is-close::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 3px solid var(--ak-accent);
  box-shadow: 0 0 10px var(--ak-glow);
}

.voice {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  padding: 6px 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;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.plate-slot {
  container-type: size;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
}

.plate {
  position: relative;
  width: min(78%, 260px);
  aspect-ratio: 287 / 384;
  max-height: 100%;
}

@supports (width: 1cqw) {
  .plate {
    width: min(100cqw, calc(100cqh * 287 / 384), 300px);
  }
}

.plate img {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.plate-copy {
  position: absolute;
  left: 16%;
  right: 16%;
  top: 15%;
  bottom: 16%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
  text-align: center;
  color: var(--ak-bg);
}

.prompt,
.truth,
.source,
.points {
  margin: 0;
}

.prompt {
  font-size: clamp(13px, 3.4vw, 16px);
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.plate.is-open .prompt {
  -webkit-line-clamp: 3;
  font-size: clamp(12px, 3vw, 14px);
}

.truth {
  font-family: var(--ak-font-display);
  font-size: clamp(18px, 5vw, 26px);
  font-weight: var(--ak-title-weight);
  line-height: 1.1;
}

.source {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ak-btn-active);
}

.points {
  font-size: 13px;
  font-weight: 700;
  color: var(--ak-btn-fill);
}

.readout {
  align-self: center;
  max-width: 100%;
  margin: 0;
  padding: 4px 12px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
  font-family: var(--ak-font-display);
  font-size: clamp(18px, 6vw, 34px);
  font-weight: var(--ak-title-weight);
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-align: center;
  color: var(--ak-ink);
  white-space: nowrap;
}

.console {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rail {
  position: relative;
  width: min(100%, calc(22dvh * 3.41));
  max-width: 100%;
  aspect-ratio: 491 / 144;
  margin: 0 auto;
  touch-action: manipulation;
  cursor: pointer;
}

.rail.is-fallback {
  background: url("./art/guess-rail.png") center / contain no-repeat;
}

.track,
.knob {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.knob {
  z-index: 2;
}

.streak {
  position: absolute;
  z-index: 1;
  height: 16%;
  border-radius: 99px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, transparent, var(--ak-accent-2));
  box-shadow: 0 0 8px var(--ak-ink), 0 0 12px var(--ak-glow);
  pointer-events: none;
}

.thumb {
  position: absolute;
  z-index: 2;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--ak-outline);
  background: radial-gradient(circle at 40% 35%, var(--ak-ink), var(--ak-accent-2) 46%, var(--ak-accent));
  box-shadow: var(--ak-shadow);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.ring {
  position: absolute;
  z-index: 4;
  width: max(72px, 28%);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px solid var(--ak-accent);
  box-shadow: 0 0 0 2px var(--ak-bg), 0 0 16px var(--ak-glow);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.coach {
  position: absolute;
  z-index: 5;
  width: 0;
  height: 0;
  margin-left: -11px;
  margin-top: 36px;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-bottom: 16px solid var(--ak-accent);
  filter: drop-shadow(0 0 6px var(--ak-glow));
  pointer-events: none;
}

.scale {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--ak-font-display);
  font-size: 12px;
  color: var(--ak-ink);
}

.scale span {
  padding: 2px 8px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.btn-hint,
.btn-next,
.btn-go,
.btn-alt {
  min-height: 48px;
  width: 100%;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  box-shadow: var(--ak-shadow);
  font-family: var(--ak-font-display);
  font-size: 18px;
  font-weight: var(--ak-title-weight);
  letter-spacing: 0.04em;
  cursor: pointer;
}

.btn-hint,
.btn-next,
.btn-go {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}

.btn-alt {
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-size: 16px;
  font-weight: 700;
}

.check,
.btn-next {
  width: min(86%, 320px);
  align-self: flex-end;
}

.check {
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 0;
  cursor: pointer;
}

.check img {
  width: 100%;
  height: auto;
  max-height: min(168px, 20dvh);
  object-fit: contain;
  object-position: right center;
  filter: drop-shadow(0 0 10px var(--ak-glow));
}

.why {
  margin: 0;
  padding: 8px 10px;
  border: 2px solid var(--ak-accent);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
  color: var(--ak-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.recap {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.recap-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  column-gap: 6px;
  align-items: center;
  padding: 3px 6px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid transparent;
}

.recap-row.is-close .mark {
  border-color: var(--ak-accent);
  background: var(--ak-accent-2);
  box-shadow: 0 0 8px var(--ak-glow);
}

.recap-row > span:last-child {
  display: block;
  min-width: 0;
}

.recap-main,
.recap-source {
  display: block;
  min-width: 0;
}

.recap-main {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.recap-source {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ak-ink-muted);
}

.play.is-ended .plate-slot,
.play.is-ended .readout,
.play.is-ended .console,
.play.is-ended .actions,
.play.is-ended .voice {
  display: none;
}

.play.is-ended .result {
  margin-top: 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: 0 0 8px;
  font-family: var(--ak-font-display);
  font-size: 18px;
  font-weight: var(--ak-title-weight);
  line-height: 1.25;
  text-align: center;
  color: var(--ak-ink);
}

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

.rail:focus-visible,
.check:focus-visible,
.btn-hint:focus-visible,
.btn-next:focus-visible,
.btn-go:focus-visible,
.btn-alt:focus-visible,
.mute:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 3px;
}

.check:active img,
.btn-next:active,
.btn-hint:active,
.btn-go:active,
.btn-alt:active,
.mute:active {
  filter: brightness(1.14);
}

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

.fx i {
  position: absolute;
  width: 10px;
  height: 14px;
  border: 2px solid var(--ak-outline);
  opacity: 0;
}

@media (max-height: 740px) {
  .play {
    gap: 3px;
  }

  .play-logo {
    height: 30px;
  }

  .lamps {
    width: min(50%, 156px);
  }

  .voice {
    min-height: 32px;
    padding: 3px 8px;
    font-size: 13px;
  }

  .turn-who {
    font-size: 16px;
  }

  .scale {
    font-size: 11px;
  }

  .scale span {
    padding: 1px 6px;
  }

  .plate-slot {
    flex: 1 1 auto;
    min-height: 96px;
    max-height: 148px;
    overflow: hidden;
  }

  .plate {
    width: 100%;
    height: 100%;
    max-height: 100%;
    aspect-ratio: auto;
  }

  .plate img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
  }

  .plate-copy {
    left: 9%;
    right: 9%;
    top: 12%;
    bottom: 12%;
  }

  .prompt {
    font-size: 14px;
    -webkit-line-clamp: 5;
  }

  .check img {
    max-height: min(96px, 15dvh);
  }

  .result-says {
    font-size: 16px;
    margin-bottom: 6px;
  }
}

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

  .track {
    animation: idle-glow 3.4s ease-in-out infinite;
  }

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

  .coach {
    animation: point 0.7s ease-in-out infinite;
  }

  .rail:not(.is-dragging) .knob {
    transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .readout.is-tick {
    animation: tick 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

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

  .check.is-flash img {
    animation: press 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

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

  .ring.is-on {
    animation: ring-snap 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .lamp.is-fresh {
    animation: lamp-on 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

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

  .plate.is-open .truth {
    animation: pop-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .play.is-celebrate .lamp.is-lit {
    animation: chase 0.55s ease 3;
  }

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

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

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

  @keyframes idle-glow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.12); }
  }

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

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

  @keyframes tick {
    0% { transform: scale(1, 1); }
    40% { transform: scale(1.08, 0.92); }
    100% { transform: scale(1); }
  }

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

  @keyframes press {
    0% { transform: scale(1); filter: brightness(1); }
    35% { transform: scale(0.94, 0.9); filter: brightness(1.7); }
    100% { transform: scale(1); filter: brightness(1); }
  }

  @keyframes ring-snap {
    0% { transform: translate(-50%, -50%) scale(1.4); opacity: 0.35; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  }

  @keyframes lamp-on {
    0% { transform: translate(-50%, -50%) scale(0.4); }
    60% { transform: translate(-50%, -50%) scale(1.18); }
    100% { transform: translate(-50%, -50%) scale(1); }
  }

  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(2px); }
  }

  @keyframes pop-in {
    0% { transform: scale(0.6); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
  }

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

  @keyframes rise {
    0% { transform: translateY(16px) scale(0.96); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
  }

  @keyframes burst {
    0% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(18deg) scale(0.5); }
  }
}
