*,
*::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: 700;
  line-height: 1.25;
  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;
  cursor: pointer;
}

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(8px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --face: clamp(64px, min(24vw, 15dvh), 108px);
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(72px, 0.62fr) minmax(0, 1.5fr) auto;
  gap: 6px;
  width: min(100vw, 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: transparent;
  background-image: var(--ak-backdrop-layer);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.play.is-ended {
  grid-template-rows: auto auto auto;
  align-content: center;
  gap: 10px;
}

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

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

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

.mute.is-muted::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 26px;
  border-radius: 2px;
  background: var(--ak-accent);
  transform: rotate(40deg);
}

.top {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding-right: 52px;
}

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

.play-logo {
  height: min(44px, 6.5dvh);
  width: auto;
  max-width: min(132px, 36vw);
  object-fit: contain;
  filter: drop-shadow(0 2px 0 color-mix(in srgb, var(--ak-ink) 35%, transparent));
}

.turn {
  min-width: 0;
  padding: 6px 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: 18px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.turn-sub {
  margin-top: 2px;
  color: var(--ak-ink-muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
}

.voice {
  margin: 0;
  padding: 8px 12px;
  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);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  max-height: 3.8em;
  overflow: hidden;
}

.voice.is-hint {
  max-height: none;
  font-size: 14px;
  line-height: 1.25;
}

.stage {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
  justify-items: center;
}

.play.is-ended .stage {
  grid-template-rows: auto auto auto;
  align-content: center;
  justify-items: center;
  gap: 10px;
  overflow: hidden;
}

.play.is-ended .scene {
  height: auto;
  min-height: 0;
}

.scene {
  position: relative;
  width: min(100%, 280px);
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  perspective: 760px;
}

.cube {
  --half: calc(var(--face) / 2);
  width: var(--face);
  height: var(--face);
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-28deg) rotateY(-38deg);
}

.face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 18%;
  border: 3px solid var(--ak-outline);
  backface-visibility: hidden;
  background:
    radial-gradient(circle at 30% 22%, color-mix(in srgb, var(--ak-btn-ink) 70%, transparent) 0 10%, transparent 42%),
    linear-gradient(155deg, var(--ak-accent-2), color-mix(in srgb, var(--ak-accent) 32%, var(--ak-accent-2)));
  box-shadow: inset 0 -6px 0 color-mix(in srgb, var(--ak-ink) 18%, transparent);
}

.face.is-chev {
  border: none;
  background: transparent;
  box-shadow: none;
}

.face-front { transform: translateZ(var(--half)); }
.face-back { transform: rotateY(180deg) translateZ(var(--half)); }
.face-right { transform: rotateY(90deg) translateZ(var(--half)); }
.face-left { transform: rotateY(-90deg) translateZ(var(--half)); }
.face-top { transform: rotateX(90deg) translateZ(var(--half)); }
.face-bottom { transform: rotateX(-90deg) translateZ(var(--half)); }

.shadow {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: min(46%, 120px);
  height: 16px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ak-ink) 28%, transparent);
  transform: translateX(-50%);
  filter: blur(1px);
}

.mark {
  position: absolute;
  inset: 0;
  transform: rotate(calc(var(--rot) * 90deg));
}

.mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stripe {
  position: absolute;
  width: 26%;
  height: 62%;
  left: 37%;
  top: 19%;
  border-radius: 999px;
  background: var(--ak-ink);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--ak-btn-ink) 35%, transparent);
}

.pip {
  position: absolute;
  width: 32%;
  height: 32%;
  left: 34%;
  top: 7%;
  border-radius: 50%;
  background: var(--ak-accent);
  box-shadow:
    inset 0 -3px 0 color-mix(in srgb, var(--ak-ink) 28%, transparent),
    inset 0 3px 0 color-mix(in srgb, var(--ak-btn-ink) 45%, transparent);
}

.tray {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  border: 3px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-surface) 78%, transparent);
  box-shadow: var(--ak-shadow);
  position: relative;
}

.shape {
  container-type: size;
  position: relative;
  min-width: 48px;
  min-height: 48px;
  padding: 2px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: inherit;
  display: grid;
  place-items: center;
}

.shape.is-picked {
  border-color: var(--ak-accent);
  background: color-mix(in srgb, var(--ak-accent-2) 42%, var(--ak-surface));
  box-shadow: var(--ak-shadow);
}

.shape.is-spent {
  filter: saturate(0.7);
  opacity: 0.72;
}

.shape.is-yes {
  border-color: var(--ak-accent-2);
  background: color-mix(in srgb, var(--ak-accent-2) 55%, var(--ak-surface));
}

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

.shape-body {
  --cell: min(46px, calc((100cqi - 8px) / var(--cols)), calc((100cqb - 8px) / var(--rows)));
  position: relative;
  width: calc(var(--cols) * var(--cell));
  height: calc(var(--rows) * var(--cell));
  perspective: 420px;
}

.sq {
  position: absolute;
  width: var(--cell);
  height: var(--cell);
  left: calc(var(--c) * var(--cell));
  top: calc(var(--r) * var(--cell));
  border-radius: 22%;
  overflow: hidden;
  border: 2px solid var(--ak-outline);
  background:
    radial-gradient(circle at 30% 22%, color-mix(in srgb, var(--ak-btn-ink) 72%, transparent) 0 12%, transparent 46%),
    linear-gradient(155deg, var(--ak-accent-2), color-mix(in srgb, var(--ak-accent) 34%, var(--ak-accent-2)));
  box-shadow: 1px 2px 0 var(--ak-outline);
}

.sq.is-chev {
  border: none;
  background: transparent;
  box-shadow: none;
}

.sq.is-blame {
  outline: 3px solid var(--ak-accent);
  outline-offset: 1px;
  z-index: 3;
}

.hinge {
  position: absolute;
  z-index: 2;
  background: var(--ak-ink);
  border-radius: 99px;
  left: calc(var(--c) * var(--cell));
  top: calc(var(--r) * var(--cell));
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.hinge-h {
  width: calc(var(--cell) * 0.36);
  height: 5px;
}

.hinge-v {
  width: 5px;
  height: calc(var(--cell) * 0.36);
}

.finger {
  position: absolute;
  z-index: 4;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 16px 10px 0;
  border-color: var(--ak-accent) transparent transparent;
  background: transparent;
  filter: drop-shadow(0 2px 0 var(--ak-outline));
  pointer-events: none;
}

.tray > .finger {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.shape > .finger {
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  align-content: start;
}

.actions.is-pair {
  grid-template-columns: 1.4fr 0.8fr;
}

.actions.is-fold {
  grid-template-columns: 1fr 1fr;
}

.btn-go,
.btn-alt {
  min-height: 48px;
  width: 100%;
  padding: 0 12px;
  border: 3px 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: 800;
  letter-spacing: 0.01em;
}

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

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

.btn-go.is-point {
  position: relative;
}

.why {
  margin: 0;
  width: min(100%, 420px);
  padding: 8px 12px;
  border: 3px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
  text-align: center;
  font-family: var(--ak-font-display);
  font-size: clamp(16px, 4.4vw, 22px);
  font-weight: 800;
  line-height: 1.2;
}

.results {
  width: min(100%, 420px);
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
}

.chip {
  min-height: 32px;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid var(--ak-outline);
  background: var(--ak-surface);
  box-shadow: 1px 2px 0 var(--ak-outline);
}

.chip.is-yes {
  background: var(--ak-accent-2);
}

.chip.is-no {
  background: var(--ak-accent);
}

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

.result-card {
  padding: 10px 12px 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;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
}

.result-says:focus {
  outline: none;
}

.result-says:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 3px;
}

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

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

.fx i {
  position: absolute;
  width: 9px;
  height: 14px;
  border-radius: 3px;
  opacity: 0;
}

.fx i.is-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

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

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

  .cube.is-live {
    animation: floaty 3.6s ease-in-out infinite;
  }

  .shape-body {
    animation: bob 3.1s ease-in-out infinite;
  }

  .shape:nth-child(2) .shape-body { animation-delay: -0.5s; }
  .shape:nth-child(3) .shape-body { animation-delay: -1.1s; }
  .shape:nth-child(4) .shape-body { animation-delay: -1.7s; }

  .tray.is-hop .shape-body {
    animation: hop 560ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .tray.is-hop .shape:nth-child(2) .shape-body { animation-delay: 70ms; }
  .tray.is-hop .shape:nth-child(3) .shape-body { animation-delay: 140ms; }
  .tray.is-hop .shape:nth-child(4) .shape-body { animation-delay: 210ms; }

  .shape:active .shape-body,
  .shape.is-press .shape-body {
    animation: none;
    scale: 0.94 0.86;
    translate: 0 3px;
  }

  .shape.is-no {
    animation: shake 480ms ease-in-out;
  }

  .shape.is-yes .shape-body {
    animation: snap 520ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .shape.is-fold .sq {
    animation: lift 640ms cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--d) * 110ms);
    transform-origin: center bottom;
  }

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

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

  .finger {
    animation: poke 0.9s ease-in-out infinite;
  }

  .btn-go.is-point,
  .tray.is-point {
    animation: invite 1.3s ease-in-out infinite;
  }

  .cube.is-turn {
    animation: quarter 820ms cubic-bezier(0.34, 1.2, 0.64, 1) both;
  }

  .play.is-win .face:not(.is-chev) {
    animation: chase 1.3s ease-in-out infinite;
  }

  .play.is-win .chip.is-yes {
    animation: chase 1.3s ease-in-out infinite;
  }

  .play.is-win .chip:nth-child(2) { animation-delay: 0.08s; }
  .play.is-win .chip:nth-child(3) { animation-delay: 0.16s; }
  .play.is-win .chip:nth-child(4) { animation-delay: 0.24s; }
  .play.is-win .chip:nth-child(5) { animation-delay: 0.32s; }
  .play.is-win .chip:nth-child(6) { animation-delay: 0.4s; }
  .play.is-win .chip:nth-child(7) { animation-delay: 0.48s; }
  .play.is-win .chip:nth-child(8) { animation-delay: 0.56s; }

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

  .fx i {
    animation: sprinkle 980ms ease-out forwards;
  }

  .mute:active,
  .btn-go:active,
  .btn-alt:active {
    transform: translateY(3px);
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cube.is-turn {
    transform: rotateX(-28deg) rotateY(-128deg);
  }
}

@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -4px; }
}

@keyframes floaty {
  0%, 100% { transform: rotateX(-28deg) rotateY(-38deg) translateY(0); }
  50% { transform: rotateX(-28deg) rotateY(-38deg) translateY(-7px); }
}

@keyframes hop {
  0% { translate: 0 12px; scale: 0.92 1.06; }
  50% { translate: 0 -12px; scale: 1.08 0.9; }
  100% { translate: 0 0; scale: 1 1; }
}

@keyframes shake {
  0%, 100% { translate: 0 0; }
  15% { translate: -8px 0; }
  30% { translate: 7px 0; }
  50% { translate: -6px 0; }
  70% { translate: 5px 0; }
  85% { translate: -2px 0; }
}

@keyframes snap {
  0% { scale: 1 1; }
  35% { scale: 1.1 0.84; }
  68% { scale: 0.96 1.1; }
  100% { scale: 1 1; }
}

@keyframes lift {
  0% { transform: translateY(0) rotateX(0deg) scale(1, 1); }
  40% { transform: translateY(-8px) rotateX(58deg) scale(1.04, 0.9); }
  100% { transform: translateY(-16px) rotateX(88deg) scale(0.72, 0.45); opacity: 0.2; }
}

@keyframes invite {
  0%, 100% { box-shadow: var(--ak-shadow), 0 0 0 3px color-mix(in srgb, var(--ak-accent-2) 45%, transparent); }
  50% { box-shadow: var(--ak-shadow), 0 0 0 6px color-mix(in srgb, var(--ak-accent) 55%, transparent); }
}

@keyframes cue {
  0% { scale: 0.94 1.06; }
  55% { scale: 1.06 0.94; }
  100% { scale: 1 1; }
}

@keyframes poke {
  0%, 100% { margin-top: 0; }
  50% { margin-top: 7px; }
}

@keyframes quarter {
  0% { transform: rotateX(-28deg) rotateY(-38deg) scale(1); }
  55% { transform: rotateX(-22deg) rotateY(-132deg) scale(1.08, 0.94); }
  100% { transform: rotateX(-28deg) rotateY(-128deg) scale(1); }
}

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

@keyframes card-in {
  from { translate: 0 18px; opacity: 0; }
  to { translate: 0 0; opacity: 1; }
}

@keyframes sprinkle {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.55); }
}
