html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: var(--ak-bg);
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
}

.play,
.play * {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.play {
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  justify-content: center;
  background-image: var(--ak-backdrop-layer);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.monitor {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: min(6px, 0.8dvh);
  width: min(420px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  padding:
    max(8px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  overflow: hidden;
  border: 3px solid var(--ak-outline);
  background: transparent;
  box-shadow: var(--ak-shadow), inset 0 0 28px color-mix(in srgb, var(--ak-glow) 35%, transparent);
  touch-action: manipulation;
}

.mute {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  z-index: 6;
  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;
  touch-action: manipulation;
}

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

.mute-x {
  display: none;
}

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

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

.power {
  position: absolute;
  top: max(18px, calc(env(safe-area-inset-top) + 10px));
  right: max(16px, calc(env(safe-area-inset-right) + 8px));
  z-index: 6;
  width: 12px;
  height: 12px;
  background: var(--ak-accent-2);
  box-shadow: 0 0 8px var(--ak-accent-2);
  pointer-events: none;
}

.top {
  display: flex;
  justify-content: center;
  min-height: 48px;
  padding: 0 56px;
}

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

.turn,
.tagline,
.voice,
.hint,
.note,
.why,
.need,
.result-says {
  margin: 0;
}

.turn {
  font-family: var(--ak-font-display);
  font-size: clamp(26px, 7vw, 34px);
  font-weight: var(--ak-title-weight);
  line-height: 1;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--ak-ink);
}

.turn.is-you {
  color: var(--ak-accent);
}

.turn.is-them {
  color: var(--ak-accent-2);
}

.tagline,
.need {
  color: var(--ak-ink-muted);
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
}

.voice,
.hint,
.note,
.why {
  padding: 7px 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: clamp(13px, 3.5vw, 15px);
  line-height: 1.3;
}

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

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

.why.is-good {
  border-color: var(--ak-accent-2);
}

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

.glass {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 4px;
  touch-action: manipulation;
}

.scan,
.burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scan {
  z-index: 2;
  opacity: 0.28;
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
}

.burst {
  z-index: 4;
  overflow: hidden;
}

.rows {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: min(10px, 1.4dvh);
  width: 100%;
}

.row {
  position: relative;
  width: 100%;
}

.row.is-far {
  width: 92%;
  margin: 0 auto 2px;
  transform: perspective(560px) rotateX(18deg);
  transform-origin: center bottom;
}

.row.is-near {
  z-index: 1;
}

.rack {
  position: relative;
  width: 100%;
}

.rack-art {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.slots {
  position: absolute;
  left: 7%;
  right: 8%;
  bottom: 30%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  justify-items: center;
}

.stone {
  position: relative;
  width: 100%;
  max-width: 68px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.pebble {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

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

.stone.is-picked {
  z-index: 2;
  transform: translateY(-16px);
}

.stone.is-picked .pebble {
  filter: brightness(1.45) drop-shadow(0 0 6px var(--ak-glow));
}

.stone.is-picked::after {
  content: '';
  position: absolute;
  left: 24%;
  right: 24%;
  top: 5%;
  height: 18%;
  background: var(--ak-ink);
  box-shadow: 0 0 8px var(--ak-glow);
  pointer-events: none;
}

.cursor {
  position: absolute;
  left: 4px;
  top: 18%;
  width: 18px;
  height: 18px;
  border: 2px solid var(--ak-accent);
  box-shadow: 0 0 8px var(--ak-glow);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

.row.is-live .cursor {
  opacity: 1;
}

.bezel {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 2px solid var(--ak-outline);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.take {
  width: 64px;
  height: 64px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.take img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.take.is-ready {
  filter: drop-shadow(0 0 8px var(--ak-glow));
}

.score {
  min-width: 0;
}

.lamps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.lamp {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}

.lamp img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.shade {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 18%;
  bottom: 22%;
  background: var(--ak-bg);
  pointer-events: none;
  transform-origin: top center;
}

.lamp.is-win .shade {
  opacity: 0;
}

.lamp.is-win {
  filter: drop-shadow(0 0 6px var(--ak-glow));
}

.need {
  margin-top: 2px;
}

.note:empty {
  display: none;
}

.result {
  position: relative;
  z-index: 4;
}

.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 {
  font-family: var(--ak-font-display);
  font-size: clamp(22px, 6vw, 30px);
  font-weight: var(--ak-title-weight);
  line-height: 1.05;
  color: var(--ak-ink);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.btn {
  flex: 1 1 140px;
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  box-shadow: var(--ak-shadow);
  font-family: var(--ak-font-display);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

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

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

.bit {
  position: absolute;
  top: 46%;
  width: 8px;
  height: 12px;
  border: 2px solid var(--ak-outline);
}

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

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

.bit.is-c {
  background: var(--ak-ink);
}

.ghost {
  position: fixed;
  z-index: 30;
  pointer-events: none;
}

.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;
}

@media (max-width: 360px) {
  .monitor {
    padding-right: max(8px, env(safe-area-inset-right));
    padding-left: max(8px, env(safe-area-inset-left));
  }

  .play-logo {
    max-height: 44px;
  }

  .turn {
    font-size: 26px;
  }
}

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

  .top {
    min-height: 36px;
  }

  .tagline {
    font-size: 11px;
  }

  .monitor.is-over .tagline,
  .monitor.is-over .hint {
    display: none;
  }
}

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

  .power {
    animation: power-pulse 1.8s ease-in-out infinite;
  }

  .scan {
    animation: scan-drift 7s linear infinite;
  }

  .stone .pebble {
    animation: stone-bob 2.8s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.14s);
  }

  .row.is-invite .stone:not(.is-picked) .pebble {
    animation: invite 1.05s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
  }

  .stone.is-picked .pebble {
    animation: cap 0.5s ease-in-out infinite;
  }

  .stone.is-picked::after {
    animation: capflash 0.5s ease-in-out infinite;
  }

  .stone.is-deal {
    animation: deal 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation-delay: calc(var(--i) * 45ms);
  }

  .stone.is-pop .pebble {
    animation: pop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .stone.is-sliding {
    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .stone:active {
    transform: translateY(3px) scale(0.96, 0.92);
  }

  .stone.is-picked:active {
    transform: translateY(-4px) scale(0.98, 0.9);
  }

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

  .take.is-ready {
    animation: ready 0.9s ease-in-out infinite;
  }

  .row.is-live .cursor {
    animation: blink 1.05s steps(1, end) infinite, snap 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

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

  .voice.is-shake,
  .stone.is-shake,
  .take.is-shake {
    animation: shake 0.32s ease-in-out;
  }

  .lamp .shade {
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.45s ease;
  }

  .lamp.is-win .shade {
    transform: scaleY(0);
  }

  .lamp.is-chase {
    filter: drop-shadow(0 0 10px var(--ak-glow));
  }

  .lamp.is-chase .shade {
    opacity: 0.15;
  }

  .ghost {
    animation: hop 0.42s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
  }

  .monitor.is-celebrate {
    animation: bezel 1.2s ease-in-out 1;
  }

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

  .result-card {
    animation: card-in 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
}

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

@keyframes power-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--ak-accent-2); }
  50% { opacity: 0.45; box-shadow: 0 0 2px var(--ak-accent-2); }
}

@keyframes scan-drift {
  from { background-position: 0 0; }
  to { background-position: 0 28px; }
}

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

@keyframes invite {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  40% { transform: translateY(-8px) scale(1.06, 0.92); }
  70% { transform: translateY(-2px) scale(0.98, 1.04); }
}

@keyframes cap {
  0%, 100% { filter: brightness(1.15) drop-shadow(0 0 4px var(--ak-glow)); }
  50% { filter: brightness(1.8) drop-shadow(0 0 10px var(--ak-glow)); }
}

@keyframes capflash {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

@keyframes deal {
  0% { transform: translateY(-18px) scale(1.08, 0.82); }
  100% { transform: translateY(0) scale(1, 1); }
}

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

@keyframes hop {
  0% { transform: translateY(0) scale(1, 1); opacity: 1; }
  35% { transform: translateY(-34px) scale(0.86, 1.16); opacity: 1; }
  100% { transform: translateY(-78px) scale(1.12, 0.7); opacity: 0; }
}

@keyframes ready {
  0%, 100% { transform: translateY(0); filter: drop-shadow(0 0 0 transparent); }
  50% { transform: translateY(-4px); filter: drop-shadow(0 0 10px var(--ak-glow)); }
}

@keyframes blink {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes snap {
  0% { transform: scale(1.45); }
  100% { transform: scale(1); }
}

@keyframes turn-pop {
  0% { transform: scale(0.86, 1.08); }
  55% { transform: scale(1.08, 0.92); }
  100% { transform: scale(1, 1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes bezel {
  0% { box-shadow: var(--ak-shadow); }
  35% { box-shadow: 0 0 0 2px var(--ak-accent), 0 0 22px var(--ak-glow); }
  70% { box-shadow: 0 0 0 2px var(--ak-accent-2), 0 0 18px var(--ak-glow); }
  100% { box-shadow: var(--ak-shadow); }
}

@keyframes burst {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-90px) rotate(40deg) scale(0.6); opacity: 0; }
}

@keyframes card-in {
  0% { transform: translateY(12px) scale(0.96); }
  100% { transform: translateY(0) scale(1); }
}
