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

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

body {
  min-height: 100dvh;
  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;
  overscroll-behavior: none;
}

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

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

[hidden] {
  display: none !important;
}

.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;
  background-position: center bottom;
  background-repeat: no-repeat;
}

.mute {
  position: absolute;
  z-index: 6;
  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: 4px;
  padding-right: 52px;
  padding-left: 4px;
}

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

.play-logo {
  height: min(48px, 6.5dvh);
  width: auto;
  max-width: min(220px, 68vw);
  object-fit: contain;
  filter: drop-shadow(0 0 8px var(--ak-glow));
}

.turn,
.voice,
.coach,
.why,
.result-card {
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.turn {
  width: 100%;
  padding: 4px 10px 6px;
  text-align: center;
}

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

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

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

.voice,
.coach,
.why {
  flex: 0 0 auto;
  padding: 7px 10px;
  color: var(--ak-ink);
  font-size: 15px;
  line-height: 1.3;
  text-align: center;
}

.voice.is-invite,
.check.is-invite {
  border-color: var(--ak-accent);
}

.card {
  position: relative;
  flex: 0 0 auto;
  min-height: 108px;
  padding: 22px 10px 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
  overflow: hidden;
}

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

.lines {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 6px 8px 6px 28px;
  list-style: decimal;
  background: color-mix(in srgb, var(--ak-ink) 92%, transparent);
  color: var(--ak-bg);
  border-radius: 16px;
  font-family: var(--ak-font-display);
  font-size: clamp(15px, 4.1vw, 18px);
  line-height: 1.28;
}

.lines li {
  padding: 1px 4px;
  border-radius: 10px;
}

.lines li.is-hot,
.lines li.is-guide {
  box-shadow: inset 3px 0 0 var(--ak-accent-2);
  background: color-mix(in srgb, var(--ak-accent) 42%, var(--ak-ink));
}

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

.board {
  position: relative;
  width: min(100cqw, 100cqh);
  max-width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.grid-art,
.route,
.spots {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.grid-art {
  object-fit: cover;
  border-radius: inherit;
  pointer-events: none;
}

.route {
  z-index: 1;
  overflow: visible;
  pointer-events: none;
}

.route path {
  fill: none;
  stroke: var(--ak-accent);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 1px var(--ak-bg)) drop-shadow(0 0 3px var(--ak-glow));
}

.spots {
  z-index: 2;
}

.spot {
  position: absolute;
  width: max(48px, min(64px, 20%));
  height: max(48px, min(64px, 20%));
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transform: translate(-50%, -50%);
  touch-action: manipulation;
}

.spot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.38;
  filter: saturate(0.55) brightness(0.72);
  pointer-events: none;
}

.spot.is-on img,
.spot.is-lit img,
.spot.is-end img {
  opacity: 1;
  filter: drop-shadow(0 0 6px var(--ak-glow));
}

.spot.is-end img {
  filter: drop-shadow(0 0 8px var(--ak-glow)) brightness(1.12);
}

.spot.is-bad img {
  opacity: 0.7;
  filter: grayscale(0.15) brightness(0.42) sepia(1) hue-rotate(185deg) saturate(7);
}

.spot.is-bad::after {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--ak-bg);
  box-shadow: 0 0 0 2px var(--ak-accent-2);
  opacity: 0.72;
  pointer-events: none;
}

.spot:disabled {
  cursor: default;
}

.arrow-anchor {
  position: absolute;
  z-index: 3;
  width: min(84px, 28%);
  height: min(84px, 28%);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.arrow-spin,
.arrow {
  width: 100%;
  height: 100%;
}

.arrow-spin {
  transform: rotate(var(--face, 0deg));
}

.arrow {
  object-fit: contain;
  filter: drop-shadow(0 4px 0 color-mix(in srgb, var(--ak-bg) 70%, transparent));
}

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

.hint,
.check,
.btn-go,
.btn-alt {
  flex: 0 0 auto;
  min-height: 48px;
  width: 100%;
  padding: 0 14px;
  border-radius: var(--ak-radius);
  border: 2px solid var(--ak-outline);
  font-size: 18px;
  font-weight: 700;
  box-shadow: var(--ak-shadow);
  touch-action: manipulation;
}

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

.btn-alt {
  background: var(--ak-surface);
  color: var(--ak-ink);
}

.check:disabled {
  opacity: 0.55;
}

.why {
  position: relative;
  z-index: 5;
  text-align: center;
}

.result {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
}

.result-card {
  padding: 10px;
}

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

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

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

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

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

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

.play.is-ended .voice,
.play.is-ended .card,
.play.is-ended .hint,
.play.is-ended .check,
.play.is-ended .coach {
  display: none;
}

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

.spot:focus-visible {
  outline-offset: 1px;
  z-index: 4;
}

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

  .lines {
    font-size: 15px;
  }

  .check,
  .hint,
  .btn-go,
  .btn-alt {
    font-size: 16px;
  }
}

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

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

  .card {
    min-height: 0;
    padding-top: 16px;
  }

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

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

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

  .turn.is-cue {
    animation: cue 420ms cubic-bezier(0.34, 1.45, 0.64, 1);
  }

  .card.is-reel {
    animation: reel 480ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .lines li.is-guide {
    animation: line-glow 1.3s ease-in-out infinite;
  }

  .spot:not(.is-on):not(.is-lit):not(.is-bad) img {
    animation: breathe 3.2s ease-in-out infinite;
    animation-delay: calc(var(--i, 0) * 160ms);
  }

  .spot.is-flare img {
    animation: flare 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .spot.is-lit img,
  .spot.is-end img {
    animation: lamp-on 380ms cubic-bezier(0.34, 1.4, 0.64, 1) both;
    animation-delay: calc(var(--i, 0) * var(--pace, 120ms));
  }

  .spot.is-bad::after {
    animation: flicker 380ms steps(2, end) 3;
  }

  .spot:active {
    transform: translate(-50%, -50%) scale(0.9);
  }

  .arrow-spin.is-idle .arrow {
    animation: bob 2.6s ease-in-out infinite;
  }

  .arrow-spin.is-hop .arrow {
    animation: hop 480ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .arrow-spin.is-shake .arrow {
    animation: shake 460ms ease-in-out;
  }

  .route.is-draw path {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw 720ms ease-out forwards;
  }

  .play.is-celebrate .board {
    animation: chase 1.05s linear 2;
  }

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

  .mute:active,
  .check:active,
  .hint:active,
  .btn-go:active,
  .btn-alt:active {
    transform: scale(0.96);
  }

  .fx i {
    animation: burst 900ms ease-out forwards;
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

@keyframes hop {
  0% {
    transform: translateY(0) scale(1, 1);
  }

  35% {
    transform: translateY(-12px) scale(0.94, 1.08);
  }

  62% {
    transform: translateY(0) scale(1.08, 0.9);
  }

  100% {
    transform: translateY(0) scale(1, 1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }

  25% {
    transform: translateX(-5px) rotate(-7deg);
  }

  50% {
    transform: translateX(5px) rotate(7deg);
  }

  75% {
    transform: translateX(-3px) rotate(-4deg);
  }
}

@keyframes flare {
  0% {
    transform: scale(0.82);
    filter: brightness(1.8) drop-shadow(0 0 8px var(--ak-glow));
  }

  55% {
    transform: scale(1.16);
  }

  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 6px var(--ak-glow));
  }
}

@keyframes lamp-on {
  0% {
    transform: scale(0.72);
    opacity: 0.4;
  }

  55% {
    transform: scale(1.14);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes flicker {
  50% {
    opacity: 0.12;
  }
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.32;
  }

  50% {
    opacity: 0.52;
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes reel {
  0% {
    transform: translateY(-30%) scaleY(0.86);
  }

  100% {
    transform: translateY(0) scaleY(1);
  }
}

@keyframes cue {
  0% {
    transform: scale(0.96);
  }

  45% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

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

@keyframes line-glow {
  50% {
    background: color-mix(in srgb, var(--ak-accent) 70%, var(--ak-ink));
  }
}

@keyframes chase {
  0% {
    box-shadow: 0 0 0 0 var(--ak-glow);
  }

  40% {
    box-shadow: 0 0 22px 4px var(--ak-glow);
  }

  100% {
    box-shadow: var(--ak-shadow);
  }
}

@keyframes rise {
  0% {
    transform: translateY(12px) scale(0.96);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes burst {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg);
  }

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