*,
*::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);
  overscroll-behavior: none;
}

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

[hidden] {
  display: none !important;
}

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

.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,
.why,
.actions {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
}

.why {
  z-index: 7;
}

.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;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--ak-glow) 70%, transparent));
}

.turn {
  min-width: 0;
}

.turn-who {
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: clamp(18px, 5vw, 26px);
  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,
.why {
  margin: 0;
  padding: 8px 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-surface) 88%, transparent);
  box-shadow: var(--ak-shadow);
}

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

.voice.is-invite {
  border-color: var(--ak-accent);
  background: color-mix(in srgb, var(--ak-accent) 16%, var(--ak-surface));
}

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

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

.why {
  color: var(--ak-accent-2);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  background: color-mix(in srgb, var(--ak-surface) 92%, transparent);
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  touch-action: manipulation;
}

.board {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
}

.goal {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--ak-glow) 45%, transparent));
}

.goal-fill {
  fill: color-mix(in srgb, var(--ak-bg) 78%, var(--ak-surface));
}

.goal-line {
  fill: none;
  stroke: var(--ak-accent-2);
  stroke-width: 3;
  stroke-linejoin: round;
}

.goal.is-glow .goal-line {
  stroke: var(--ak-ink);
  filter: drop-shadow(0 0 10px var(--ak-glow));
}

.goal-art {
  pointer-events: none;
}

.hole {
  fill: var(--ak-accent);
  stroke: var(--ak-ink);
  stroke-width: 2;
}

.tray {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 116px;
  padding: 6px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-surface) 84%, transparent);
  box-shadow: var(--ak-shadow);
}

.slot {
  width: 58px;
  height: 56px;
  min-width: 48px;
  min-height: 48px;
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-bg) 55%, transparent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ak-accent-2) 35%, transparent);
}

.slot.is-wide {
  width: 104px;
}

.layer,
.coach,
.puff,
.fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.layer {
  z-index: 3;
}

.tile {
  position: absolute;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  touch-action: none;
  pointer-events: auto;
  transform: translateY(0) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1));
  transform-origin: 0 100%;
  filter: drop-shadow(2px 3px 0 #040810);
}

.tile img {
  display: block;
  width: 112%;
  height: 112%;
  margin: -6%;
  object-fit: fill;
  pointer-events: none;
}

.tile.is-tri {
  clip-path: polygon(0% 100%, 100% 100%, 0% 0%);
}

.tile.is-para {
  clip-path: polygon(0% 100%, 50% 100%, 100% 0%, 50% 0%);
}

.tile.is-drag {
  z-index: 6;
  transform: translateY(-8px) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1.06);
  filter: drop-shadow(3px 8px 0 #040810) drop-shadow(0 0 12px var(--ak-glow));
}

.tile.is-next {
  filter: drop-shadow(0 0 8px var(--ak-accent)) drop-shadow(2px 3px 0 #040810);
}

.tile:focus-visible,
.act:focus-visible,
.mute:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 2px;
}

.coach {
  z-index: 5;
  width: 28px;
  height: 22px;
  margin-left: -14px;
}

.coach::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 16px solid var(--ak-accent);
  filter: drop-shadow(0 0 6px var(--ak-glow));
}

.puff {
  z-index: 4;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ak-ink) 0%, var(--ak-accent-2) 40%, transparent 72%);
  opacity: 0;
}

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

.bit {
  position: absolute;
  top: 42%;
  width: 8px;
  height: 12px;
  border-radius: 2px;
}

.actions {
  display: flex;
  gap: 8px;
}

.act {
  flex: 1;
  min-width: 48px;
  min-height: 48px;
  padding: 8px 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
  box-shadow: var(--ak-shadow);
}

.act-clue {
  background: var(--ak-surface);
  color: var(--ak-accent-2);
  border-color: var(--ak-accent-2);
}

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

.act:disabled {
  opacity: 0.45;
}

.result {
  position: absolute;
  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));
  z-index: 6;
}

.result-card {
  padding: 14px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-surface) 94%, transparent);
  box-shadow: var(--ak-shadow), 0 0 24px color-mix(in srgb, var(--ak-glow) 35%, transparent);
}

.result-says {
  margin: 0 0 12px;
  font-family: var(--ak-font-display);
  font-size: clamp(18px, 4.8vw, 24px);
  font-weight: var(--ak-title-weight);
  line-height: 1.2;
  color: var(--ak-accent-2);
}

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

@media (prefers-reduced-motion: no-preference) {
  .turn.is-cue {
    animation: turnpop 0.42s cubic-bezier(0.34, 1.4, 0.64, 1);
  }

  .goal-line {
    animation: rim 3.2s ease-in-out infinite;
  }

  .goal.is-glow .goal-line {
    animation: glowchase 0.9s ease-in-out 3;
  }

  .tile.is-parked {
    animation: bob 2.8s ease-in-out infinite;
  }

  .tile.is-wobble {
    animation: wobble 0.38s cubic-bezier(0.34, 1.4, 0.64, 1);
  }

  .tile.is-settle {
    animation: settle 0.32s cubic-bezier(0.34, 1.4, 0.64, 1);
  }

  .tile.is-bounce {
    animation: bounce2 0.62s cubic-bezier(0.34, 1.4, 0.64, 1);
  }

  .tile.is-flip {
    animation: cardflip 0.42s ease-in-out;
  }

  .tile.is-hop {
    animation: hop 0.48s cubic-bezier(0.34, 1.4, 0.64, 1);
  }

  .tile.is-flash {
    animation: flash 0.38s ease-in-out 3;
  }

  .tile.is-drag,
  .tile.is-return {
    animation: none;
  }

  .tile.is-return {
    transition:
      left 0.45s cubic-bezier(0.22, 1.2, 0.36, 1),
      top 0.45s cubic-bezier(0.22, 1.2, 0.36, 1),
      width 0.45s cubic-bezier(0.22, 1.2, 0.36, 1),
      height 0.45s cubic-bezier(0.22, 1.2, 0.36, 1);
  }

  .coach.is-on::before {
    animation: point 0.9s ease-in-out infinite;
  }

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

  .act:active {
    transform: translateY(2px) scale(0.98);
  }

  .puff.is-on {
    animation: puff 0.55s ease-out;
  }

  .hole {
    animation: blink 0.42s ease-in-out 3;
  }

  .bit {
    animation: burst 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  }

  .play-logo {
    animation: logo-idle 3.2s ease-in-out infinite;
  }
}

@keyframes turnpop {
  0% { transform: scale(1); }
  40% { transform: scale(1.07); }
  100% { transform: scale(1); }
}

@keyframes rim {
  0%, 100% { stroke-opacity: 0.72; }
  50% { stroke-opacity: 1; filter: drop-shadow(0 0 6px var(--ak-glow)); }
}

@keyframes glowchase {
  0%, 100% { stroke: var(--ak-accent-2); filter: drop-shadow(0 0 4px var(--ak-glow)); }
  50% { stroke: var(--ak-ink); filter: drop-shadow(0 0 14px var(--ak-accent)) drop-shadow(0 0 8px var(--ak-glow)); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)); }
  50% { transform: translateY(-4px) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)); }
}

@keyframes wobble {
  0% { transform: rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1); }
  40% { transform: rotate(calc(var(--rot) * -45deg + 8deg)) scaleY(var(--flip, 1)) scale(1.08, 0.9); }
  100% { transform: rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1); }
}

@keyframes settle {
  0% { transform: translateY(0) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1); }
  45% { transform: translateY(4px) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1.08, 0.88); }
  100% { transform: translateY(0) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1); }
}

@keyframes bounce2 {
  0% { transform: translateY(0) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1); }
  18% { transform: translateY(6px) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1.1, 0.86); }
  40% { transform: translateY(-12px) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(0.94, 1.08); }
  62% { transform: translateY(0) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1.06, 0.92); }
  80% { transform: translateY(-6px) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1); }
  100% { transform: translateY(0) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1); }
}

@keyframes cardflip {
  0% { transform: rotate(calc(var(--rot) * -45deg)) scaleY(calc(var(--flip, 1) * -1)); }
  45% { transform: rotate(calc(var(--rot) * -45deg)) scaleY(0.08) scaleX(1.08); }
  100% { transform: rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)); }
}

@keyframes hop {
  0%, 100% { transform: translateY(0) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)); }
  45% { transform: translateY(-16px) rotate(calc(var(--rot) * -45deg)) scaleY(var(--flip, 1)) scale(1.06, 0.9); }
}

@keyframes flash {
  0%, 100% { filter: drop-shadow(2px 3px 0 #040810); }
  50% { filter: brightness(1.85) drop-shadow(0 0 12px var(--ak-accent)); }
}

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

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

@keyframes puff {
  0% { opacity: 0.95; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(2.4); }
}

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

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

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

@media (max-width: 360px) {
  .slot {
    width: 52px;
    height: 52px;
  }

  .slot.is-wide {
    width: 100px;
  }

  .voice,
  .why,
  .act {
    font-size: 14px;
  }
}
