/* Shared shell for /games — dark by default, light when the OS asks for it. */
:root {
  color-scheme: light dark;
  --bg: #0b1020;
  --bg-glow: radial-gradient(1200px 600px at 50% -10%, #16224a 0%, transparent 60%);
  --panel: #111a2e;
  --panel-2: #0d1526;
  --text: #e6eefb;
  --muted: #9aa8bf;
  --border: #233149;
  --accent: #38bdf8;
  --accent-strong: #7dd3fc;
  --accent-2: #34d399;
  --danger: #fb7185;
  --gold: #fbbf24;
  --radius: 16px;
  --shadow: 0 18px 50px rgb(0 0 0 / 0.35);
  --target: 24px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (pointer: coarse) {
  :root { --target: 44px; }
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f7fc;
    --bg-glow: radial-gradient(1200px 600px at 50% -10%, #dbeafe 0%, transparent 60%);
    --panel: #ffffff;
    --panel-2: #f6f9fd;
    --text: #0f172a;
    --muted: #5a6782;
    --border: #d9e1ee;
    --shadow: 0 18px 50px rgb(15 23 42 / 0.12);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(1rem, 4vw, 2.5rem);
  padding-left: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-left));
  padding-right: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-right));
  padding-bottom: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-bottom));
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-glow);
  background-repeat: no-repeat;
  font-family: var(--font);
  line-height: 1.55;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.2;
  text-wrap: balance;
}

p { text-wrap: pretty; }

a { color: var(--accent); }

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus-visible { transform: none; }

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1080px;
  margin: 0 auto 2rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand .dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
}

main { max-width: 1080px; margin: 0 auto; }

.back {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.back:hover { color: var(--text); }

.game-page { max-width: 780px; margin: 0 auto; }

.game-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.game-head h1 { font-size: clamp(1.7rem, 5vw, 2.3rem); }

.hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel {
  padding: clamp(0.8rem, 2.5vw, 1.2rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.scorebar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.stat {
  min-width: 5.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat strong {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
}

.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--target);
  min-width: var(--target);
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease-out, border-color 150ms ease-out, background 150ms ease-out;
}

.btn:hover { border-color: var(--accent); }
.btn:active { scale: 0.97; }

.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: #04121f;
}

.btn-primary:hover { background: var(--accent-strong); }

.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 18%, var(--panel-2));
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

dialog {
  width: min(92vw, 27rem);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgb(2 6 23 / 0.72);
}

dialog h2 { margin-bottom: 0.5rem; font-size: 1.3rem; }
dialog p { margin: 0.4rem 0 1.1rem; color: var(--muted); }
dialog .actions { margin-top: 0; }

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn { transition: none; }
  .btn:active { scale: none; }
}
