/* /play/: hub and game pages. Builds on theme.css tokens and classes.
   DOM motion is transform/opacity only; everything else is on canvas. */

.play-page {
  padding-bottom: 72px;
}
.play-page [hidden] {
  display: none !important;
}
.play-page .container {
  max-width: 880px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 28px;
  font-size: 13px;
  color: var(--muted);
}
.back:hover {
  color: var(--accent);
}
.bad {
  color: #ff8a7a;
}
kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--border-strong);
  padding: 1px 6px;
  color: var(--muted);
}
.linklike {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.sep {
  color: var(--border-strong);
}

/* ---------- hub ---------- */
.hub__head {
  padding: 64px 0 36px;
}
.hub__title {
  font-size: clamp(30px, 6vw, 48px);
  font-weight: 600;
  margin: 10px 0 10px;
  letter-spacing: 1px;
}
.hub__sub {
  color: var(--muted);
  margin: 0 0 26px;
}
.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  /* Keep the shared .reveal fade alongside the hover border. */
  transition: border-color 0.25s var(--ease), opacity var(--dur-reveal) var(--ease),
    transform var(--dur-reveal) var(--ease);
}
a.card:hover,
a.card:focus-visible {
  border-color: var(--border-strong);
}
.card__art {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-bottom: 1px solid var(--border);
}
.card__body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.card__name {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.card__hook {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0;
  flex: 1;
}
.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12px;
  color: var(--muted);
}
.card__tags .tag {
  color: var(--accent);
}
.card__status {
  font-size: 12px;
  color: var(--text);
  min-height: 1.6em;
}
.card.is-soon {
  opacity: 0.55;
}
.hub__actions {
  margin: 30px 0 0;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.hub__soft {
  margin: 64px 0 0;
  font-size: 13.5px;
  color: var(--muted);
}
.hub__soft a {
  color: var(--text);
}
.hub__soft a:hover {
  color: var(--accent);
}

/* ---------- game page ---------- */
.game-head {
  margin: 8px 0 16px;
}
.game-head h1 {
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 600;
  margin: 0 0 6px;
}
.game-head h1 .muted {
  font-weight: 400;
}
.game-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}
.strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px 0;
  font-size: 12.5px;
  color: var(--muted);
}
.strip button {
  min-height: 36px;
  font: inherit;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  padding: 4px 12px;
  cursor: pointer;
}
.strip button:hover,
.strip button[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}
.stage {
  position: relative;
  margin: 16px 0 0;
  touch-action: none;
}
.stage canvas {
  display: block;
  width: 100%;
  height: min(42dvh, 340px);
}
.stage__intro {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  background: rgba(5, 5, 5, 0.72);
}
.stage__intro p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}
.btn--primary {
  border-color: var(--accent);
  color: var(--accent);
  min-height: 44px;
}
.stage__tools {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}
.stage__tools button {
  min-height: 44px;
}

/* markovle: trajectory sequence and candidate graphs */
.seq {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 6px;
  min-height: 2.2em;
  margin: 6px 0 0;
  font-size: 14px;
  font-weight: 600;
}
.seq__s {
  opacity: 0.12;
  transition: opacity var(--dur-micro) var(--ease-ui);
}
.seq__s.is-shown {
  opacity: 0.9;
}
.seq__s.is-now {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 14px 0 0;
  align-content: start;
}
/* Wide screens: trajectory left, candidates right, all above the fold. */
@media (min-width: 821px) {
  .board {
    display: grid;
    grid-template-columns: 1fr minmax(0, 400px);
    gap: 28px;
    align-items: start;
  }
  .board .choices {
    margin-top: 16px;
  }
}
.choice {
  position: relative;
  font-family: var(--font-mono);
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color var(--dur-micro) var(--ease-ui);
}
.choice canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.choice:hover:not(:disabled),
.choice:focus-visible {
  border-color: var(--accent);
}
.choice:disabled {
  cursor: default;
}
.choice__key {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 11px;
  color: var(--muted);
}
.choice.is-right {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.choice.is-right .choice__key::after {
  content: " ✓ true chain";
  color: var(--accent);
}
.choice.is-wrong {
  border-color: #ff8a7a;
}
.choice.is-wrong .choice__key::after {
  content: " ✕ your pick";
  color: #ff8a7a;
}
.choice:disabled:not(.is-right):not(.is-wrong) {
  opacity: 0.45;
}
.feedback {
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
.feedback__line {
  margin: 0;
  font-size: 13.5px;
}

/* lost-without-gps: map, readout, legend, explainer */
.stage--map canvas {
  height: min(52dvh, 520px);
  cursor: crosshair;
}
.map-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 12px 0 0;
  min-height: 44px;
}
.map-readout,
.map-legend {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.lg--truth {
  color: var(--text);
}
.lg--filter,
.lg--beat {
  color: var(--accent);
}
.lg--you {
  color: #ff8a7a;
}
.explainer {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.explainer p {
  margin: 0 0 8px;
  font-size: 13.5px;
  color: var(--muted);
  max-width: 68ch;
}
.explainer .end__title {
  margin-bottom: 10px;
}

/* drift: run canvas, challenge banner, top 5 */
.stage--run {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.stage--run canvas {
  height: min(56dvh, 460px);
}
.stage--run:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}
.stage__intro--soft {
  background: rgba(5, 5, 5, 0.5);
  pointer-events: none;
}
.banner {
  margin: 0 0 10px;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 14px;
}
.top5 {
  margin: 0;
  padding: 0 0 0 22px;
  font-size: 13px;
}
.top5 li {
  padding: 2px 0;
}
.top5 li span + span {
  margin-left: 14px;
}
.top5 li.is-this {
  color: var(--accent);
}

/* end screen (shared) */
.end {
  margin: 24px 0 0;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.end__title {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 1px;
}
.end__line {
  margin: 0;
  font-size: 17px;
}
.end__cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin: 12px 0 2px;
  padding: 14px 18px;
  font: inherit;
  font-size: 14px;
  text-align: left;
  color: #050505;
  background: var(--accent);
  border: 0;
  cursor: pointer;
}
.end__cta .arrow {
  transition: transform 0.25s var(--ease);
}
.end__cta:hover .arrow,
.end__cta:focus-visible .arrow {
  transform: translateX(4px);
}
.end__cta:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}
.end__again {
  align-self: flex-start;
  min-height: 44px;
}
.end__row {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.end__row a,
.end__row .linklike {
  display: inline-block;
  padding: 10px 0;
  color: var(--text);
}
.end__row a:hover,
.end__row .linklike:hover {
  color: var(--accent);
}
.end__note {
  margin: 0;
  min-height: 1.4em;
  font-size: 12.5px;
  color: var(--accent);
}
.end__meta {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}
.end__extra {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.cal {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.cal__d {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-strong);
}
.cal__d.is-good {
  background: var(--accent);
  border-color: var(--accent);
}
.cal__d.is-ok {
  background: rgba(89, 243, 176, 0.45);
  border-color: transparent;
}
.cal__d.is-low {
  background: rgba(89, 243, 176, 0.15);
  border-color: transparent;
}
.play-another {
  margin: 40px 0 0;
  font-size: 13px;
}
.play-another a {
  display: inline-block;
  padding: 10px 0;
}
.play-another a:hover {
  color: var(--accent);
}
.noscript {
  border: 1px solid var(--border-strong);
  padding: 16px;
  color: var(--muted);
  margin: 16px 0 0;
}

@media (max-width: 820px) {
  .hub__head {
    padding: 40px 0 26px;
  }
  .choices {
    gap: 10px;
  }
  .stage canvas {
    height: min(34dvh, 300px);
  }
  /* drift: full width, enough look-ahead (180 units across, 100 tall). */
  .stage--run {
    margin-left: -22px;
    margin-right: -22px;
  }
  .stage--run canvas {
    height: auto;
    aspect-ratio: 9 / 5;
  }
  /* The map keeps its 3:2 aspect and uses the full screen width. */
  .stage--map {
    margin-left: -22px;
    margin-right: -22px;
  }
  .stage--map canvas {
    height: auto;
    aspect-ratio: 3 / 2;
  }
  .end {
    padding: 18px;
  }
}

/* ---------- quick games ---------- */
.hub__group {
  margin: 44px 0 14px;
}
.hub__group:first-of-type {
  margin-top: 0;
}
.hub__group .section-label {
  margin: 0 0 4px;
}
.hub__group p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* how many?: dot field, guess form */
.stage--dots canvas {
  height: auto;
  aspect-ratio: 3 / 2;
  max-height: min(50dvh, 460px);
}
.guess {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin: 14px 0 0;
}
.guess label {
  font-size: 14px;
}
.guess input {
  width: 7.5em;
  min-height: 44px;
  padding: 6px 12px;
  font: inherit;
  font-size: 18px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 0;
}
.guess input:focus {
  outline: none;
  border-color: var(--accent);
}
.guess__hint {
  font-size: 12.5px;
  flex-basis: 100%;
  min-height: 1.2em;
}
.hm-pairs {
  font-size: 13px;
}

/* echo: four shapes on a square stage, buttons over the shapes */
.stage--echo {
  width: min(100%, 440px);
  aspect-ratio: 1;
  margin-left: auto;
  margin-right: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.stage--echo canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.pad {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 26%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pad:disabled {
  cursor: default;
}
.pad:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -4px;
}
.stage--echo.is-yours {
  outline: 1px solid var(--border-strong);
}
.echo-msg {
  min-height: 1.6em;
  margin: 8px 0 0;
  text-align: center;
  font-size: 14px;
}

/* reflex: the box is the game */
.stage--tap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: min(46dvh, 380px);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
}
.stage--tap:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}
.tap__big {
  margin: 0;
  font-size: clamp(26px, 7vw, 46px);
  font-weight: 600;
}
.tap__small {
  margin: 0;
  min-height: 1.4em;
  font-size: 13.5px;
  color: var(--muted);
}
.stage--tap[data-state="wait"] {
  background: #14100c;
  border-color: #3a2a1c;
}
.stage--tap[data-state="go"] {
  background: var(--accent);
  border-color: var(--accent);
}
.stage--tap[data-state="go"] .tap__big {
  color: #050505;
}
.stage--tap[data-state="early"] {
  border-color: #ff8a7a;
}
.stage--tap[data-state="early"] .tap__big {
  color: #ff8a7a;
}
.stage--tap[data-state="shown"] .tap__big,
.stage--tap[data-state="done"] .tap__big {
  color: var(--accent);
}
.tap__times {
  list-style: none;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 12px 0 0;
  padding: 0;
  font-size: 13px;
  color: var(--muted);
}
.tap__times li.is-done {
  color: var(--text);
}
@media (max-width: 820px) {
  .stage--dots {
    margin-left: -22px;
    margin-right: -22px;
  }
}
