/* Game player pages (/play/<game>/). Same tokens and type as the homepage (../../styles.css). */

:root {
  --ink: #f3f5fa;
  --muted: #a9b3c5;
  --purple: #a995ff;
  --paper: #0d1017;
  --line: #2a3242;
  --surface: #171c27;
  --accent: #6ce5d2;
  --head: 72px;
  --site-nav-height: 52px;
  color-scheme: dark;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
h1, h2, h3, p { margin-top: 0; }

/* Header */
.player-head {
  height: var(--head);
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.back {
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
}
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #17312f;
  border: 1px solid #3b6a69;
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -3px;
}
.brand-mark span { color: var(--accent); font-size: 19px; margin-top: 8px; }
.game-name { min-width: 0; border-left: 1px solid var(--line); padding-left: 18px; }
.game-name .eyebrow { margin: 0 0 2px; font-size: 10px; letter-spacing: 1.6px; font-weight: 700; color: var(--muted); }
.game-name h1 {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 22px;
  letter-spacing: -.8px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.head-actions { margin-left: auto; display: flex; gap: 8px; }
.head-actions button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.head-actions button { background: var(--surface); }
.head-actions button:hover { background: #26303e; color: var(--accent); border-color: #4b7776; }
.head-actions svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Game stage */
.player { max-width: 1240px; margin: 0 auto; padding: 0 16px 48px; }
.stage {
  position: relative;
  height: calc(100dvh - var(--head) - var(--site-nav-height) - 16px);
  min-height: 460px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--stage-bg);
  color: var(--stage-ink);
}
body[data-shape='portrait'] .stage {
  /* Phone-shaped game: a portrait frame on wide screens. */
  width: auto;
  max-width: 100%;
  aspect-ratio: 9 / 16;
  margin: 0 auto;
}
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }

.state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: var(--stage-bg);
}
.stage[data-state='ready'] .state,
.stage:not([data-state='loading']) .loading,
.stage:not([data-state='error']) .error { display: none; }
.state h2 { margin: 0; font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 24px; letter-spacing: -.8px; }
.state p { margin: 0; max-width: 340px; font-size: 14px; line-height: 1.6; opacity: .75; }
.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid color-mix(in srgb, var(--stage-ink) 18%, transparent);
  border-top-color: var(--stage-accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.slow { display: none; }
.stage[data-slow] .slow { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.state-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
}
.button.primary { background: var(--accent); color: #0d1017; }
.button.primary:hover { background: #a0f7e8; }
.button.secondary { border: 1px solid currentColor; }

/* How to play */
.game-info {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 48px;
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}
.game-info h2, .help-dialog h2 {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 28px;
  letter-spacing: -1px;
  margin-bottom: 18px;
}
.game-info h3 { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 18px; letter-spacing: -.4px; margin-bottom: 10px; }
.steps { margin: 0 0 22px; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 0 0 14px 44px; line-height: 1.6; color: var(--muted); }
.steps li strong { color: var(--ink); }
.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--purple);
}
.notes { margin: 0 0 24px; padding: 0; list-style: none; }
.notes li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.55; color: var(--muted); }
.notes li strong { color: var(--ink); }
kbd {
  font: 600 12px/1 system-ui, -apple-system, 'Segoe UI', sans-serif;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}
.back-link { display: inline-flex; min-height: 44px; align-items: center; font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }

.help-dialog {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 40px 36px 32px;
  width: min(560px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  color: var(--ink);
  background: var(--surface);
}
.help-dialog::backdrop { background: #05070bc9; backdrop-filter: blur(5px); }
.help-dialog .close { position: absolute; right: 14px; top: 10px; width: 44px; height: 44px; border-radius: 50%; font-size: 30px; }
.help-dialog .button { width: 100%; margin-top: 8px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 760px) {
  :root { --head: 60px; --site-nav-height: 96px; }
  .player-head { gap: 12px; padding: 0 10px; }
  .back-label, .head-actions .label { display: none; }
  .game-name { padding-left: 12px; }
  .game-name h1 { font-size: 18px; }
  .head-actions button { width: 44px; padding: 0; justify-content: center; }
  .player { padding: 0 0 40px; }
  .stage, body[data-shape='portrait'] .stage { height: calc(100dvh - var(--head) - var(--site-nav-height)); min-height: 380px; width: 100%; aspect-ratio: auto; border-radius: 0; }
  .game-info { grid-template-columns: 1fr; gap: 8px; margin: 28px 16px 0; padding-top: 24px; }
  .help-dialog { padding: 36px 22px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}
/* Fullscreen always uses the viewport, including after the mobile stage rule. */
.stage:fullscreen { width: 100vw; height: 100dvh; min-height: 0; max-width: none; aspect-ratio: auto; border-radius: 0; }
.stage:-webkit-full-screen { width: 100vw; height: 100dvh; min-height: 0; max-width: none; aspect-ratio: auto; border-radius: 0; }
