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

button,
.col,
.rail-chip {
  font: inherit;
}

.play[hidden] {
  display: none !important;
}

.play {
  --pad-top: max(6px, env(safe-area-inset-top, 0px));
  --pad-right: max(8px, env(safe-area-inset-right, 0px));
  --pad-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  --pad-left: max(8px, env(safe-area-inset-left, 0px));
  position: relative;
  width: min(420px, 100%);
  height: 100dvh;
  margin: 0 auto;
  padding: var(--pad-top) var(--pad-right) var(--pad-bottom) var(--pad-left);
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) 72px auto auto;
  gap: 4px;
  overflow: hidden;
  touch-action: manipulation;
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer);
  background-size: cover;
  background-position: center top;
}

.play.is-card {
  padding-bottom: calc(var(--pad-bottom) + 168px);
}

.mute {
  position: absolute;
  top: var(--pad-top);
  right: var(--pad-right);
  z-index: 9;
  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;
}

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

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

.turn {
  min-width: 0;
}

.turn-who,
.trip-pip,
.goal,
.voice,
.why,
.route,
.result-says {
  margin: 0;
}

.turn-who {
  font-family: var(--ak-font-display);
  font-size: 13px;
  font-weight: var(--ak-title-weight);
  letter-spacing: 0.04em;
  color: var(--ak-accent);
}

.trip-pip {
  font-size: 12px;
  color: var(--ak-ink-muted);
}

.goal {
  grid-row: 2;
  font-family: var(--ak-font-display);
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: var(--ak-accent-2);
}

.voice {
  grid-row: 3;
  min-height: 2.5em;
  font-size: 13px;
  line-height: 1.25;
  color: var(--ak-ink);
}

.why {
  grid-row: 4;
  display: none;
  padding: 6px 8px;
  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: 13px;
  line-height: 1.3;
}

.why.is-on {
  display: block;
}

.stage {
  grid-row: 5;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) 8px;
  gap: 4px;
  min-height: 0;
}

.slates {
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 4px;
  min-height: 0;
}

.conduit {
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 4px;
  min-height: 0;
}

.conduit b {
  display: block;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ak-accent) 28%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ak-accent-2) 35%, transparent);
}

.conduit b.is-on {
  background: var(--ak-accent);
  box-shadow: 0 0 10px var(--ak-glow);
}

.slate {
  position: relative;
  display: grid;
  grid-template-columns: minmax(52px, 64px) repeat(3, minmax(48px, 1fr));
  grid-template-rows: 16px minmax(48px, 1.4fr) minmax(16px, 0.8fr) minmax(16px, 0.8fr);
  gap: 2px;
  min-height: 0;
  padding: 5px;
  overflow: hidden;
  border-radius: var(--ak-radius);
  background-color: var(--ak-surface);
  background-image: url('./art/time-board.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  box-shadow: var(--ak-shadow);
}

.slate::before {
  content: '';
  position: absolute;
  inset: 6px;
  z-index: 0;
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-bg) 74%, transparent);
  pointer-events: none;
}

.line-name,
.stops,
.col {
  position: relative;
  z-index: 1;
}

.line-name {
  grid-column: 1 / -1;
  grid-row: 1;
  margin: 0;
  overflow: hidden;
  color: var(--ak-accent);
  font-family: var(--ak-font-display);
  font-size: 10px;
  font-weight: var(--ak-title-weight);
  letter-spacing: 0.04em;
  line-height: 16px;
  white-space: nowrap;
}

.stops {
  grid-column: 1;
  grid-row: 2 / span 3;
  display: grid;
  grid-template-rows: minmax(48px, 1.4fr) minmax(16px, 0.8fr) minmax(16px, 0.8fr);
  min-width: 0;
}

.stop {
  display: grid;
  align-items: center;
  overflow: hidden;
  padding-right: 2px;
  background: color-mix(in srgb, var(--ak-bg) 82%, transparent);
  color: var(--ak-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.col {
  grid-row: 2 / span 3;
  display: grid;
  grid-template-rows: minmax(48px, 1.4fr) minmax(16px, 0.8fr) minmax(16px, 0.8fr);
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--ak-radius);
  background: transparent;
  color: var(--ak-ink);
  cursor: pointer;
  touch-action: manipulation;
}

.col:disabled {
  opacity: 1;
  cursor: default;
}

.slot {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: clamp(10px, 2.8vw, 13px);
  line-height: 1;
}

.slot:first-child {
  min-height: 48px;
}

.chip-art {
  width: 100%;
  height: 48px;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.slot-time {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 1px;
  padding: 1px 0;
  background: color-mix(in srgb, var(--ak-bg) 78%, transparent);
  color: var(--ak-ink);
  font-size: clamp(10px, 2.7vw, 12px);
  font-weight: var(--ak-title-weight);
  text-align: center;
}

.slot:not(:first-child) {
  background: color-mix(in srgb, var(--ak-bg) 84%, transparent);
}

.slot.is-dash {
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.col.is-in {
  border-color: var(--ak-accent);
  background: color-mix(in srgb, var(--ak-accent) 16%, transparent);
  box-shadow: 0 0 12px var(--ak-glow);
}

.col.is-invite {
  border-color: var(--ak-glow);
  box-shadow: 0 0 0 2px var(--ak-glow), var(--ak-shadow);
}

.col.is-fault {
  border-color: var(--ak-ink);
}

.slot.is-fault,
.slot.is-miss {
  box-shadow: inset 0 0 0 2px var(--ak-ink);
}

.slot.is-hit {
  box-shadow: inset 0 0 0 2px var(--ak-accent);
}

.slot.is-tick::after {
  content: '';
  position: absolute;
  top: 15%;
  left: 18%;
  width: 2px;
  height: 70%;
  background: var(--ak-ink);
  box-shadow: 0 0 6px var(--ak-ink);
}

.rail-wrap {
  grid-row: 6;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  align-items: center;
  gap: 6px;
  height: 72px;
  min-height: 72px;
  overflow: hidden;
  padding: 4px 6px 4px 8px;
  border-radius: var(--ak-radius);
  background-color: var(--ak-surface);
  background-image: url('./art/plan-rail.png');
  background-repeat: no-repeat;
  background-position: center right;
  background-size: cover;
  box-shadow: var(--ak-shadow);
}

.rail-chips {
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 48px;
  min-width: 0;
}

.rail-chip {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 2px solid var(--ak-accent);
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-surface) 80%, transparent);
  box-shadow: 0 0 10px var(--ak-glow);
  cursor: pointer;
  touch-action: manipulation;
}

.rail-chip:disabled {
  opacity: 1;
  cursor: default;
}

.rail-chip img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.rail-chip b {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 1px;
  background: color-mix(in srgb, var(--ak-bg) 78%, transparent);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 10px;
  font-weight: var(--ak-title-weight);
  text-align: center;
}

.pip {
  display: grid;
  place-items: center;
  align-content: center;
  width: 76px;
  min-height: 48px;
  border: 2px solid var(--ak-accent-2);
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-bg) 62%, transparent);
  box-shadow: 0 0 12px var(--ak-glow);
}

.pip-cap {
  color: var(--ak-ink-muted);
  font-size: 10px;
  letter-spacing: 0.06em;
  line-height: 1;
}

.pip-time {
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 15px;
  font-weight: var(--ak-title-weight);
  line-height: 1.2;
}

.route {
  grid-row: 7;
  position: relative;
  z-index: 3;
  min-height: 0;
  padding: 0;
  color: var(--ak-ink);
  font-size: 13px;
  line-height: 1.3;
}

.route:not(:empty) {
  padding: 4px 6px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  box-shadow: var(--ak-shadow);
}

.check {
  grid-row: 8;
  min-height: 48px;
  padding: 0 12px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  box-shadow: var(--ak-shadow);
  font-family: var(--ak-font-display);
  font-size: 15px;
  font-weight: var(--ak-title-weight);
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
}

.check,
.check.is-ready {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}

.check[hidden] {
  display: none !important;
}

.col:focus-visible,
.rail-chip:focus-visible,
.check:focus-visible,
.mute:focus-visible,
.btn-go:focus-visible,
.btn-alt:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 2px;
}

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

.burst i {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 8px;
  height: 8px;
  border-radius: 1px;
  background: var(--ak-accent);
  opacity: 0;
}

.burst i:nth-child(odd) {
  background: var(--ak-accent-2);
}

.result[hidden] {
  display: none !important;
}

.result {
  position: absolute;
  z-index: 8;
  left: var(--pad-left);
  right: var(--pad-right);
  bottom: var(--pad-bottom);
}

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

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

.btn-go,
.btn-alt {
  flex: 1 1 140px;
  min-height: 48px;
  padding: 0 10px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  box-shadow: var(--ak-shadow);
  font-family: var(--ak-font-display);
  font-size: 14px;
  font-weight: var(--ak-title-weight);
  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);
}

.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 (prefers-reduced-motion: no-preference) {
  .play-logo {
    animation: logo-idle 3.2s ease-in-out infinite;
  }

  .col:not(.is-in):not(.is-invite) .chip-art {
    animation: bob 3.4s ease-in-out infinite;
  }

  .col[data-col="1"] .chip-art {
    animation-delay: 0.2s;
  }

  .col[data-col="2"] .chip-art {
    animation-delay: 0.45s;
  }

  .col.is-invite .chip-art {
    animation: invite 1.05s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
  }

  .col:active {
    transform: scale(0.96);
  }

  .col.is-locking .chip-art {
    animation: tip-lock 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .col.is-locking::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--ak-glow);
    opacity: 0;
    animation: violet-flash 420ms ease;
    pointer-events: none;
  }

  .col.is-returning .chip-art {
    animation: hop-back 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .rail-chip.is-lock {
    animation: lock-on 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  .rail-wrap.is-neat .rail-chip {
    animation: neat 480ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .rail-wrap.is-neat .rail-chip:nth-child(2) {
    animation-delay: 70ms;
  }

  .rail-wrap.is-neat .rail-chip:nth-child(3) {
    animation-delay: 140ms;
  }

  .pip {
    animation: pip-glow 2.8s ease-in-out infinite;
  }

  .pip.is-shake {
    animation: pip-shake 420ms ease;
  }

  .slot.is-tick::after {
    animation: tick-fade 1.2s ease forwards;
  }

  .conduit b.is-on {
    animation: conduit-run 1.1s linear infinite;
  }

  .play.is-won .conduit b {
    animation: chase 900ms linear infinite;
  }

  .play.is-won .conduit b:nth-child(2) {
    animation-delay: 140ms;
  }

  .play.is-won .conduit b:nth-child(3) {
    animation-delay: 280ms;
  }

  .play.is-clear .rail-wrap {
    box-shadow: 0 0 18px var(--ak-glow), var(--ak-shadow);
  }

  .check:active,
  .mute:active,
  .btn-go:active,
  .btn-alt:active,
  .rail-chip:active {
    transform: translateY(2px) scale(0.98);
  }

  .burst i {
    animation: burst 900ms cubic-bezier(0.16, 0.84, 0.32, 1) forwards;
  }
}

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

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

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

@keyframes tip-lock {
  0% { transform: translateY(0) rotateX(0); }
  40% { transform: translateY(-8px) rotateX(16deg) scale(1.06); }
  100% { transform: translateY(0) rotateX(0) scale(1); }
}

@keyframes violet-flash {
  0% { opacity: 0.7; }
  100% { opacity: 0; }
}

@keyframes hop-back {
  0% { transform: translateY(-12px) scale(1.08); }
  70% { transform: translateY(3px) scale(0.94); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes lock-on {
  0% { transform: translateY(14px) scale(0.8, 1.1); }
  60% { transform: translateY(-5px) scale(1.08, 0.92); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes neat {
  0% { transform: translateX(-8px) scale(0.92); }
  100% { transform: translateX(0) scale(1); }
}

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

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

@keyframes tick-fade {
  0% { transform: scaleY(0.2); opacity: 0; }
  25% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}

@keyframes conduit-run {
  0% { background-position: 0 -40px; filter: brightness(1); }
  50% { filter: brightness(1.5); }
  100% { filter: brightness(1); }
}

@keyframes chase {
  0%,
  100% { filter: brightness(1); transform: scaleY(0.92); }
  40% { filter: brightness(1.8); transform: scaleY(1); }
}

@keyframes burst {
  0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) scale(0.6) rotate(var(--r)); }
}
