/* Shared terminalcount game pages. Board and learning styles load afterwards. */
:root {
  color-scheme: dark;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --paper: #101a28;
  --surface: #192638;
  --raised: #223249;
  --ink: #f3f5fa;
  --muted: #a9b7ca;
  --line: #3e5068;
  --accent: #b9b2ff;
  --accent-hover: #d3ceff;
  --accent-soft: #313451;
  --on-accent: #1d2040;
  --accent-ring: #b9b2ff26;
  --success: #a7e8be;
  --success-bg: #203c35;
  --success-line: #537d64;
  --success-ring: #a7e8be20;
  --blue: #9dc9ef;
  --tube-line: #8193ac;
  --shadow: #07101b66;
  --overlay: #08111ddd;
  font-family: var(--font);
  font-synthesis: none;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 0; background: var(--paper); color: var(--ink); -webkit-font-smoothing: antialiased; }
::selection { background: var(--accent); color: var(--on-accent); }
button, select, input { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, [tabindex="-1"]:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
button svg { display: block; }
a { color: inherit; }
h1, h2, p { margin-top: 0; }
select option { background: var(--surface); color: var(--ink); }
[hidden] { display: none !important; }

.site-shell { max-width: 1280px; margin: 0 auto; padding: 0 52px; }
.site-header { min-height: 106px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.wordmark { display: flex; align-items: center; gap: 9px; font-size: 23px; letter-spacing: -1.2px; font-weight: 800; text-decoration: none; }
.wordmark-dot { color: var(--accent); margin-left: -9px; }
.brand-mark { display: inline-flex; width: 29px; height: 29px; align-items: center; justify-content: center; border-radius: 6px; background: var(--accent); color: var(--on-accent); font-size: 21px; font-weight: 650; letter-spacing: -5px; padding-right: 4px; }
.brand-mark span { font-size: 13px; transform: translateY(4px); }
.header-right { display: flex; align-items: center; gap: 26px; }
.games-link { display: inline-flex; align-items: center; min-height: 44px; font-size: 12px; text-decoration: none; border: 1px solid var(--line); border-radius: 5px; padding: 9px 11px; }
.games-link:hover { border-color: var(--accent); color: var(--accent); }
.text-button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-height: 44px; border: 0; background: none; padding: 9px 0; font-size: 13px; font-weight: 550; text-decoration: none; }
.text-button:hover:not(:disabled) { color: var(--accent); }
.introduction { padding: 44px 0 32px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 1.4px; color: var(--muted); margin: 0; }
.introduction .eyebrow { color: var(--accent); }
.introduction h1 { font-size: clamp(44px, 5.5vw, 68px); font-weight: 650; letter-spacing: -3px; line-height: 1.12; margin: 14px 0 11px; }
.subtitle { font-size: 17px; color: var(--muted); line-height: 1.6; margin: 0; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 36px; align-items: start; }
.play-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 4px 0 var(--shadow); }
.play-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 25px; border-bottom: 1px solid var(--line); }
.game-option { display: flex; align-items: center; gap: 12px; min-width: 0; }
.game-option > span { font-size: 10px; font-weight: 700; letter-spacing: 1px; color: var(--muted); }
.game-option select { min-height: 44px; max-width: 150px; padding: 9px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 13px; color-scheme: dark; cursor: pointer; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 11px 15px; border: 1px solid var(--accent); border-radius: 7px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 600; white-space: nowrap; }
.primary-button:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary-button > span { font-size: 16px; }
.game-status { max-width: 470px; min-height: 36px; margin: 17px auto 0; font-size: 13px; line-height: 1.6; color: var(--muted); text-align: center; }
.game-actions { display: flex; align-items: center; justify-content: center; gap: 9px; border-top: 1px solid var(--line); padding: 14px 24px; }
.action-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 12px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--muted); font-size: 13px; font-weight: 550; }
.action-button > span { font-size: 20px; line-height: 1; font-weight: 400; }
.action-button:hover:not(:disabled) { background: var(--raised); border-color: var(--line); color: var(--ink); }

.puzzle-sidebar { padding-top: 9px; min-width: 0; }
.stats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin: 24px 0 18px; }
.stat { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.stat-label { font-size: 12px; color: var(--muted); line-height: 1.4; }
.stat strong { font-size: 36px; letter-spacing: -1px; font-weight: 550; line-height: 1.2; font-variant-numeric: tabular-nums; }
.puzzle-meta { font-size: 12px; line-height: 1.7; color: var(--muted); margin: 0 0 20px; }
.secondary-stat { display: flex; align-items: baseline; gap: 12px; font-size: 12px; color: var(--muted); margin: 0 0 20px; }
.secondary-stat strong { font-size: 22px; font-weight: 550; line-height: 1.2; color: var(--ink); font-variant-numeric: tabular-nums; }
.rule-note { margin: 22px 0; padding-left: 15px; border-left: 2px solid var(--line); font-size: 13px; line-height: 1.9; color: var(--muted); }
.puzzle-identity { display: flex; flex-direction: column; align-items: start; gap: 8px; padding: 21px 0 13px; border-top: 1px solid var(--line); min-width: 0; }
.small-label { display: block; font-size: 10px; font-weight: 700; letter-spacing: 1.1px; color: var(--muted); }
.seed-label { display: block; max-width: 100%; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.share-button { justify-content: flex-start; color: var(--accent); }
.sidebar-links { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sidebar-button { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; width: 100%; padding: 12px 0; border: 0; background: none; color: var(--muted); text-align: left; font-size: 13px; }
.sidebar-button + .sidebar-button { border-top: 1px solid var(--line); }
.sidebar-button > span:last-child { font-size: 18px; font-weight: 400; }
.sidebar-button:hover:not(:disabled) { color: var(--accent); }
.completed-note { display: flex; align-items: center; gap: 8px; margin-top: 18px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.completed-note strong { font-weight: 600; }
.completion-mark { font-size: 15px; color: var(--success); }
.assisted-note, .storage-note { font-size: 12px; line-height: 1.6; color: var(--muted); margin: 16px 0 0; }
.storage-note { color: var(--blue); }

.win-panel { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 22px 25px; border-top: 1px solid var(--success-line); background: var(--success-bg); }
.win-panel .eyebrow { color: var(--success); }
.win-panel h2 { font-size: 24px; letter-spacing: -.5px; font-weight: 600; margin: 8px 0; }
.win-panel p:last-child { margin: 0; color: var(--ink); font-size: 13px; line-height: 1.65; }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 44px; padding: 25px 0 30px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.7; }
.site-footer > span:first-child { font-size: 10px; letter-spacing: 1px; }
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-underline-offset: 4px; }

.help-dialog { width: min(560px, calc(100% - 32px)); max-height: 85vh; overflow: auto; padding: 28px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: 0 25px 80px var(--shadow); }
.help-dialog::backdrop { background: var(--overlay); backdrop-filter: blur(4px); }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 19px; }
.dialog-top h2 { font-size: 22px; margin: 0; }
.close-button { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 7px; background: var(--raised); font-size: 25px; }
.help-dialog > h2 { font-size: 27px; font-weight: 600; letter-spacing: -.7px; margin-bottom: 24px; }
.instructions { padding-left: 23px; margin: 0; }
.instructions li { padding-left: 7px; margin-bottom: 17px; color: var(--accent); }
.instructions p { color: var(--muted); font-size: 14px; line-height: 1.75; margin: 0; }
.instructions strong { color: var(--ink); }
.keyboard-note { font-size: 12px; line-height: 1.7; color: var(--muted); margin: 22px 0 0; }
.help-footnote { padding: 17px; margin-top: 20px; border-radius: 8px; background: var(--raised); }
.help-footnote p { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 0; }
.help-footnote .keyboard-note { margin-top: 12px; }
.share-input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); font-size: 13px; }
.noscript-note { max-width: 600px; margin: 20px auto; padding: 20px; color: var(--ink); }

@media (max-width: 1050px) {
  .site-shell { padding: 0 32px; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 220px; gap: 25px; }
  .play-toolbar { padding: 16px 20px; }
  .game-option { display: block; }
  .game-option > span { display: block; margin-bottom: 5px; }
}
@media (max-width: 820px) {
  .site-shell { max-width: 720px; padding: 0 25px; }
  .site-header { min-height: 90px; }
  .header-right { gap: 18px; }
  .game-layout { grid-template-columns: 1fr; gap: 28px; }
  .introduction { padding: 32px 0 27px; }
  .puzzle-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 28px; padding-top: 4px; }
  .puzzle-sidebar > .eyebrow { grid-column: 1 / -1; }
  .stats { grid-column: 1; grid-row: 2; }
  .puzzle-meta { grid-column: 1; grid-row: 3; margin-bottom: 15px; }
  .secondary-stat { grid-column: 1; grid-row: 4; margin-bottom: 15px; }
  .rule-note { grid-column: 1; grid-row: 5; margin: 4px 0 22px; }
  .puzzle-identity { grid-column: 2; grid-row: 2 / 6; margin: 24px 0 22px; padding: 0 0 0 24px; border-top: 0; border-left: 1px solid var(--line); }
  .sidebar-links, .completed-note, .assisted-note, .storage-note { grid-column: 1 / -1; }
  .site-footer { flex-wrap: wrap; margin-top: 36px; }
}
@media (max-width: 560px) {
  .site-shell { padding: 0 18px; }
  .site-header { flex-wrap: wrap; min-height: 0; gap: 9px; padding: 17px 0 10px; }
  .wordmark { font-size: 21px; }
  .header-right { justify-content: space-between; width: 100%; gap: 20px; }
  .games-link { padding: 8px 10px; }
  .header-right .text-button { font-size: 12px; }
  .introduction { padding: 26px 0 24px; }
  .introduction h1 { font-size: 44px; letter-spacing: -2px; margin: 11px 0 9px; }
  .subtitle { font-size: 15px; }
  .play-card { border-radius: 12px; }
  .play-toolbar { padding: 14px 13px; gap: 10px; }
  .game-option > span { font-size: 9px; }
  .game-option select { max-width: 135px; padding: 8px 6px; font-size: 12px; }
  .primary-button { padding: 10px 11px; font-size: 12px; }
  .game-status { margin-top: 15px; font-size: 12px; }
  .game-actions { gap: 4px; padding: 10px; }
  .action-button { padding: 10px 11px; font-size: 12px; gap: 7px; }
  .action-button > span { font-size: 19px; }
  .puzzle-sidebar { display: block; padding-top: 4px; }
  .stats { gap: 16px; margin: 21px 0 16px; }
  .stat strong { font-size: 36px; }
  .rule-note { margin: 20px 0; font-size: 12px; }
  .puzzle-identity { margin: 0; padding: 20px 0 12px; border-left: 0; border-top: 1px solid var(--line); }
  .win-panel { display: block; padding: 20px 17px; }
  .win-panel h2 { font-size: 23px; }
  .win-panel .primary-button { margin-top: 16px; }
  .site-footer { gap: 11px; align-items: start; }
  .site-footer > span:first-child { width: 100%; }
  .help-dialog { padding: 22px; }
  .help-dialog > h2 { font-size: 25px; }
  .instructions p { font-size: 13px; }
}
@media (max-width: 359px) {
  .site-shell { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
