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

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

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

[hidden] {
  display: none !important;
}

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

.play {
  --pad-top: max(6px, env(safe-area-inset-top, 0px));
  --pad-bot: max(8px, env(safe-area-inset-bottom, 0px));
  --pad-x: max(10px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --hand: 0deg;
  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;
}

.strips,
.fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.strips { z-index: 0; }
.fx { z-index: 7; }

.strips i {
  position: absolute;
  width: 12px;
  height: 28px;
  background: var(--ak-surface);
  border: 2px solid var(--ak-outline);
  box-shadow: var(--ak-shadow);
}

.strips i:nth-child(1) { left: 18%; top: 15%; height: 34px; rotate: -14deg; }
.strips i:nth-child(2) { left: 34%; top: 12%; width: 16px; height: 22px; rotate: 8deg; }
.strips i:nth-child(3) { left: 52%; top: 18%; height: 40px; rotate: -4deg; background: var(--ak-accent); }
.strips i:nth-child(4) { left: 68%; top: 11%; width: 10px; height: 26px; rotate: 16deg; }
.strips i:nth-child(5) { left: 80%; top: 16%; height: 32px; rotate: -10deg; background: var(--ak-accent-2); border-color: var(--ak-accent-2); }

.mute,
.top,
.voice,
.why,
.hang,
.slug,
.pool,
.coach,
.hint,
.result {
  position: relative;
  z-index: 1;
}

.why { z-index: 6; }

.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 {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding-right: 52px;
}

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

.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,
.coach {
  margin: 0;
  padding: 8px 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);
  font-size: 16px;
  line-height: 1.25;
}

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

.why {
  color: var(--ak-accent);
  font-weight: 700;
}

.hang {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  margin-top: 4px;
}

.clock {
  position: relative;
  flex: 0 0 auto;
  width: min(26vw, 104px);
  min-width: 72px;
  aspect-ratio: 1;
}

.clock-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.face {
  position: absolute;
  left: 50%;
  top: 47%;
  width: 38%;
  height: 38%;
  transform: translate(-50%, -54%);
  border-radius: 50%;
  background: var(--ak-btn-ink);
  display: grid;
  place-items: center;
}

.hand {
  position: absolute;
  left: 50%;
  top: 6%;
  width: 16px;
  height: 48%;
  color: var(--ak-accent);
  transform-origin: 50% 92%;
  transform: translateX(-50%) rotate(var(--hand));
}

.clock-num {
  position: relative;
  z-index: 1;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: clamp(16px, 4.6vw, 26px);
  line-height: 1;
  color: var(--ak-ink);
}

.clock.is-low .clock-num {
  color: var(--ak-accent);
}

.rail {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.rule {
  position: relative;
  height: 8px;
  background: var(--ak-accent);
  box-shadow: var(--ak-shadow);
  overflow: hidden;
}

.jobs {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  min-height: 52px;
}

.job {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  transform-origin: top center;
}

.job::before {
  content: "";
  display: block;
  width: 2px;
  height: 8px;
  margin: 0 auto;
  background: var(--ak-ink);
}

.job-art {
  display: block;
  width: 100%;
  height: 36px;
  object-fit: cover;
  object-position: center bottom;
}

.job.is-now .job-art {
  outline: 3px solid var(--ak-accent);
  outline-offset: 1px;
}

.job-name {
  position: absolute;
  left: 1px;
  right: 1px;
  top: 12px;
  overflow: hidden;
  padding: 1px 0;
  text-align: center;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: 11px;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--ak-ink);
  background: var(--ak-btn-ink);
  white-space: nowrap;
}

.slug {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
  height: min(16dvh, 128px);
  min-height: 104px;
}

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

.slots {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 10px;
  height: 64px;
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.slot-open,
.slot-btn,
.tile {
  position: relative;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
}

.slot-open,
.slot-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
}

.slot-btn {
  display: grid;
  place-items: center;
}

.slot-open {
  background: var(--ak-btn-ink);
  border: 2px solid var(--ak-accent);
  box-shadow: var(--ak-shadow);
}

.pool {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding-top: 8px;
}

.tile {
  flex: 1 1 0;
  width: auto;
  max-width: 84px;
  aspect-ratio: 1;
}

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

.slot-btn .pop {
  width: min(100%, 68px);
  height: min(100%, 68px);
  aspect-ratio: 1;
}

.pop img,
.hint img,
.clock-art,
.slug-art,
.job-art,
.play-logo {
  pointer-events: none;
}

.pop img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.glyph {
  position: absolute;
  z-index: 1;
  left: 12%;
  top: 13%;
  width: 72%;
  height: 72%;
  display: grid;
  place-items: center;
  background: var(--ak-btn-ink);
  box-shadow: 0 0 0 4px var(--ak-btn-ink);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: clamp(24px, 8vw, 40px);
  line-height: 1;
}

.badge {
  position: absolute;
  z-index: 2;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 5px;
  background: var(--ak-accent);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-body);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.tile.is-coach {
  z-index: 2;
  outline: 3px solid var(--ak-accent);
  outline-offset: 2px;
  box-shadow: var(--ak-glow), var(--ak-shadow);
}

.hint {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  min-width: 48px;
  padding: 4px 10px 4px 4px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: var(--ak-shadow);
}

.hint img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex: 0 0 auto;
}

.hint-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.hint-name {
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: 22px;
  line-height: 1;
  color: var(--ak-accent);
}

.hint-cost {
  font-size: 14px;
  font-weight: 700;
  color: var(--ak-ink-muted);
}

.hint.is-spent {
  opacity: 0.72;
}

.tile:focus-visible,
.slot-btn: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;
}

.result {
  position: absolute;
  z-index: 5;
  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));
  max-height: min(48dvh, calc(100dvh - 250px));
  overflow: auto;
}

.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(16px, 4.4vw, 22px);
  font-weight: var(--ak-title-weight);
  line-height: 1.35;
  color: var(--ak-ink);
}

.result-score {
  margin: 8px 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);
  cursor: pointer;
}

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

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

.play.is-ended .slug {
  transform: translateY(2px) scaleY(0.94);
}

.play.is-win .slug {
  box-shadow: 0 0 0 3px var(--ak-accent), var(--ak-glow);
}

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

.bit {
  position: absolute;
  top: 28%;
  left: 46%;
  width: 12px;
  height: 22px;
  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-cobalt {
  background: var(--ak-accent);
  border-color: var(--ak-ink);
}

@media (max-height: 700px) {
  .play { gap: 4px; }
  .slug { height: 96px; min-height: 92px; }
  .clock { width: 72px; min-width: 64px; }
  .voice,
  .why,
  .coach { padding: 6px 8px; }
  .job-art { height: 32px; }
}

@media (hover: hover) {
  .btn-go:hover { background: var(--ak-btn-hover); }
}

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

  .strips i {
    animation: sway 2.8s ease-in-out infinite;
  }

  .strips i:nth-child(2) { animation-delay: -0.5s; }
  .strips i:nth-child(3) { animation-delay: -1.1s; }
  .strips i:nth-child(4) { animation-delay: -1.7s; }
  .strips i:nth-child(5) { animation-delay: -0.8s; }

  .play.is-flutter .strips i {
    animation: fall 1.15s ease-in forwards;
  }

  .clock:not(.is-frozen) {
    animation: wobble 0.9s ease-in-out infinite;
  }

  .clock.is-squish {
    animation: squish 0.28s ease-out;
  }

  .clock.is-frozen:not(.is-squish) {
    animation: none;
  }

  .hand {
    transition: transform 0.25s linear;
  }

  .tile .pop {
    animation: bob 2.6s ease-in-out infinite;
  }

  .tile:nth-child(2) .pop { animation-delay: -0.45s; }
  .tile:nth-child(3) .pop { animation-delay: -0.9s; }
  .tile:nth-child(4) .pop { animation-delay: -1.3s; }
  .tile:nth-child(5) .pop { animation-delay: -1.8s; }

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

  .tile.is-snap .pop,
  .slot-btn.is-snap .pop {
    animation: snap 0.42s ease-in-out;
  }

  .tile.is-back .pop {
    animation: back 0.4s cubic-bezier(0.34, 1.4, 0.64, 1);
  }

  .slot-btn.is-hop .pop {
    animation: hop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .slot-btn.is-slide .pop {
    animation: slide 0.48s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .slug.is-flash::after {
    content: "";
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--ak-accent) 42%, transparent);
    pointer-events: none;
    animation: flash 0.45s ease-out forwards;
  }

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

  .job.is-swing {
    animation: swing 0.55s ease-in-out;
  }

  .job.is-stamp {
    animation: job-stamp 0.36s cubic-bezier(0.34, 1.4, 0.64, 1);
  }

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

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

  .clock.is-low .clock-num {
    animation: hurry 0.7s ease-in-out infinite;
  }

  .play.is-win .rule::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 28%;
    background: var(--ak-btn-ink);
    animation: chase 0.7s linear 3;
  }

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

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

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

@keyframes sway {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(4px) rotate(8deg); }
}

@keyframes fall {
  to { transform: translateY(72dvh) rotate(28deg); opacity: 0.15; }
}

@keyframes wobble {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

@keyframes squish {
  0% { transform: scale(1, 1); }
  40% { transform: scale(1.12, 0.82); }
  100% { transform: scale(1, 1); }
}

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

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

@keyframes snap {
  0% { transform: translateY(-28px) scale(1.05); }
  35% { transform: translateX(-8px) rotate(-6deg); }
  70% { transform: translateX(7px) rotate(5deg); }
  100% { transform: translate(0, 0) rotate(0); }
}

@keyframes back {
  0% { transform: translateY(-18px) scale(0.9, 1.08); }
  60% { transform: translateY(3px) scale(1.04, 0.96); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes hop {
  0% { transform: translateY(34px) scale(0.82, 1.12); }
  55% { transform: translateY(-10px) scale(1.08, 0.9); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes slide {
  0% { transform: translateX(-36px) scale(0.9); }
  70% { transform: translateX(4px) scale(1.04); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes flash {
  0% { opacity: 0.95; }
  100% { opacity: 0; }
}

@keyframes stamp {
  0% { transform: translateY(-8px) scale(1.04, 0.9); }
  50% { transform: translateY(3px) scale(0.97, 1.06); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes job-stamp {
  0% { transform: translateY(-8px) scale(1.08, 0.88); }
  55% { transform: translateY(2px) scale(0.96, 1.06); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes swing {
  0% { transform: rotate(-8deg); }
  45% { transform: rotate(5deg); }
  100% { transform: rotate(0); }
}

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

@keyframes turn-cue {
  0% { transform: scale(1); }
  40% { transform: scale(1.06) rotate(-1deg); }
  100% { transform: scale(1); }
}

@keyframes hurry {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes chase {
  from { left: -30%; }
  to { left: 110%; }
}

@keyframes burst {
  to {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot));
    opacity: 0;
  }
}
