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

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

body {
  min-height: 100dvh;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-size: 16px;
  line-height: 1.3;
  background-color: var(--ak-bg);
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
}

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

[hidden] {
  display: none !important;
}

.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));
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(100%, 430px);
  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-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(8px, 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: 22px;
  height: 22px;
}

.mute-icon .slash {
  display: none;
}

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

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

.top,
.voice,
.tip,
.goal,
.why,
.meta,
.board-slot {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
}

.why {
  z-index: 5;
}

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

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

.turn {
  min-width: 0;
}

.turn-who {
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: clamp(20px, 5.4vw, 28px);
  font-weight: var(--ak-title-weight);
  line-height: 1;
  color: var(--ak-accent);
}

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

.voice,
.tip,
.goal,
.why {
  margin: 0;
  padding: 7px 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-surface) 92%, transparent);
  box-shadow: var(--ak-shadow);
}

.voice {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ak-ink);
}

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

.tip,
.goal {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ak-ink);
}

.why {
  color: var(--ak-accent);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.meta {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-height: 48px;
}

.stat,
.preview,
.hint {
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.stat {
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 8px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ak-ink-muted);
  line-height: 1;
}

.stat-value {
  font-family: var(--ak-font-display);
  font-size: clamp(18px, 5vw, 26px);
  font-weight: var(--ak-title-weight);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--ak-ink);
}

.preview {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 4px;
}

.mini {
  position: relative;
  width: 48px;
  height: 48px;
  background: var(--ak-bg);
}

.mini-art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.mini-hole {
  position: absolute;
  left: 75%;
  top: 75%;
  width: 25%;
  height: 25%;
  background: var(--ak-bg);
  box-shadow: inset 0 0 0 1px var(--ak-outline);
}

.hint {
  flex: 0 0 auto;
  min-width: 72px;
  min-height: 48px;
  padding: 0 12px;
  font-family: var(--ak-font-display);
  font-size: 18px;
  font-weight: var(--ak-title-weight);
  color: var(--ak-btn-ink);
  background: var(--ak-btn-fill);
  border-color: var(--ak-outline);
}

.hint.is-offer {
  box-shadow: var(--ak-shadow), 0 0 0 3px color-mix(in srgb, var(--ak-accent) 35%, transparent);
}

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

.board {
  position: relative;
  width: min(100%, 100cqw);
  aspect-ratio: 381 / 384;
}

@supports (width: 1cqw) {
  .board {
    width: min(100cqw, calc(100cqh * 381 / 384));
  }
}

.board-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.grid,
.streaks,
.chase {
  position: absolute;
  inset: 0;
}

.grid {
  z-index: 3;
  touch-action: manipulation;
}

.streaks {
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.streak {
  position: absolute;
  background: var(--ak-ink);
  opacity: 0.5;
}

.tile,
.gap-mark {
  position: absolute;
  width: 15.223%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: transparent;
}

.tile {
  z-index: 3;
  container-type: size;
  touch-action: manipulation;
}

.tile.is-coach {
  z-index: 4;
}

.tile:disabled {
  cursor: default;
}

.pop {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

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

.tile.is-picture .art {
  z-index: 2;
  clip-path: polygon(evenodd,
    0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%,
    6% 6%, 6% 94%, 94% 94%, 94% 6%, 6% 6%);
}

.plate,
.slice {
  position: absolute;
  z-index: 1;
}

.plate {
  inset: 4%;
  display: grid;
  place-items: center;
  background: var(--ak-bg);
}

.slice {
  inset: 6%;
  background-repeat: no-repeat;
  background-size: 400% 400%;
}

.numeral {
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: 28px;
  line-height: 0.85;
  color: var(--ak-ink);
}

@supports (font-size: 1cqmin) {
  .numeral {
    font-size: 58cqmin;
  }

  .tile[data-digits="2"] .numeral {
    font-size: 42cqmin;
  }
}

.badge {
  display: none;
  position: absolute;
  z-index: 3;
  top: 7%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 5px;
  border: 2px solid var(--ak-outline);
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 11px;
  font-weight: var(--ak-title-weight);
  line-height: 1.35;
  letter-spacing: 0.04em;
}

.tile.is-coach .badge {
  display: block;
}

.tile.is-coach .pop {
  outline: 3px solid var(--ak-accent);
  outline-offset: 0;
}

.gap-mark {
  z-index: 1;
  background: var(--ak-bg);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ak-accent) 45%, transparent);
  pointer-events: none;
}

.gap-mark::after {
  content: "";
  position: absolute;
  inset: 34%;
  border: 2px solid var(--ak-accent);
  opacity: 0.75;
}

.seal {
  position: absolute;
  z-index: 5;
  left: 87.1%;
  top: 84.8%;
  width: 9.8%;
  aspect-ratio: 1;
  background: var(--ak-accent);
  border: 2px solid var(--ak-outline);
  box-shadow: var(--ak-shadow);
  opacity: 0;
  pointer-events: none;
}

.seal.is-on {
  opacity: 1;
}

.seal::after {
  content: "";
  position: absolute;
  inset: 22%;
  border: 2px solid var(--ak-btn-ink);
}

.chase {
  z-index: 4;
  pointer-events: none;
  border: 3px solid transparent;
}

.chase.is-on {
  border-color: var(--ak-accent);
}

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

.bit {
  position: absolute;
  top: 46%;
  left: 48%;
  width: 10px;
  height: 16px;
  background: var(--ak-surface);
  border: 2px solid var(--ak-outline);
}

.bit.is-ink {
  background: var(--ak-accent-2);
  border-color: var(--ak-accent-2);
}

.bit.is-vermilion {
  background: var(--ak-accent);
  border-color: var(--ak-ink);
}

.result {
  position: absolute;
  z-index: 7;
  left: max(8px, env(safe-area-inset-left, 0px));
  right: max(8px, env(safe-area-inset-right, 0px));
  bottom: max(8px, env(safe-area-inset-bottom, 0px));
}

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

.result-says {
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: clamp(20px, 5vw, 28px);
  font-weight: var(--ak-title-weight);
  line-height: 1.15;
  color: var(--ak-ink);
}

.result-score {
  margin: 6px 0 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ak-accent);
}

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

.btn-go,
.btn-alt {
  flex: 1 1 140px;
  min-height: 48px;
  padding: 0 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: 16px;
  font-weight: var(--ak-title-weight);
  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);
}

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

.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 (hover: hover) {
  .hint:hover,
  .btn-go:hover {
    background: var(--ak-btn-hover);
  }

  .btn-alt:hover,
  .mute:hover {
    background: var(--ak-choice-bg);
  }
}

@media (max-width: 359px) {
  .play {
    --pad-x: 6px;
    gap: 4px;
  }

  .goal,
  .tip {
    font-size: 12px;
  }
}

@keyframes squash {
  0% { transform: scale(1.08, 0.88); }
  55% { transform: scale(0.96, 1.06); }
  100% { transform: scale(1, 1); }
}

@keyframes wobble {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  30% { transform: translateX(-5px) rotate(-2deg); }
  70% { transform: translateX(5px) rotate(2deg); }
}

@keyframes streak-fade {
  0% { opacity: 0.55; }
  100% { opacity: 0; }
}

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

@keyframes breathe {
  0%, 100% { transform: scale(0.86); opacity: 0.55; }
  50% { transform: scale(1); opacity: 1; }
}

@keyframes invite {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.03); }
}

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

@keyframes tick-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes turn-cue {
  0% { transform: translateX(0); }
  35% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}

@keyframes stamp {
  0% { opacity: 0; transform: scale(1.85); }
  60% { opacity: 1; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes chase {
  0% { box-shadow: 8px 0 0 var(--ak-accent), 0 0 12px var(--ak-glow); }
  25% { box-shadow: 0 8px 0 var(--ak-accent), 0 0 12px var(--ak-glow); }
  50% { box-shadow: -8px 0 0 var(--ak-accent), 0 0 12px var(--ak-glow); }
  75% { box-shadow: 0 -8px 0 var(--ak-accent), 0 0 12px var(--ak-glow); }
  100% { box-shadow: 8px 0 0 var(--ak-accent), 0 0 12px var(--ak-glow); }
}

@keyframes burst {
  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.6); }
}

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

  .gap-mark::after {
    animation: breathe 2.8s ease-in-out infinite;
  }

  .play.is-still .gap-mark::after,
  .play.is-still .tile .pop {
    animation: none;
  }

  .play.is-still .tile .pop.is-settle {
    animation: squash 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .tile.is-coach .pop {
    animation: invite 1.05s ease-in-out infinite;
  }

  .tile.is-move .pop {
    animation: none;
  }

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

  .pop.is-wobble,
  .gap-mark.is-wobble {
    animation: wobble 0.36s ease-in-out;
  }

  .hint.is-offer {
    animation: offer 1.15s ease-in-out infinite;
  }

  .stat-value.is-tick {
    animation: tick-pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

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

  .streak {
    animation: streak-fade 0.42s ease-out forwards;
  }

  .seal.is-on {
    animation: stamp 0.46s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .chase.is-on {
    animation: chase 0.7s linear 3;
  }

  .bit {
    animation: burst 0.9s ease-out forwards;
  }

  .tile:active .pop,
  .hint:active,
  .mute:active,
  .btn-go:active,
  .btn-alt:active {
    transform: scale(0.94);
  }
}
