:root {
  --bg: #0c110f; --panel: #131a17; --panel-2: #18211d; --line: #24312b; --line-hi: #3b5a4b;
  --text: #d3e0d9; --muted: #8b9e95; --accent: #52b98a; --accent-hi: #7fd3aa;
  --ok: #5fc28f; --warn: #d8b25e; --bad: #e07c7c; --chip: #1c2622;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); display: flex; flex-direction: column;
       padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
       -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
[hidden] { display: none !important; }
a { color: var(--accent-hi); }
.dim { color: var(--muted); } .small { font-size: 0.85rem; }
.spacer, .grow { flex: 1; min-width: 0; }
.pad { padding: 0.9rem; }

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 46rem; margin: 0 auto; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; }
.bar { display: flex; align-items: center; gap: 0.6rem; min-height: 52px; padding: 0 0.75rem; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; }
.brand { font: 600 1rem var(--mono); color: var(--accent-hi); letter-spacing: 0.05em; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud { font: 600 0.9rem var(--mono); color: var(--accent-hi); white-space: nowrap; }
.hud.warn { color: var(--warn); }

button { font: 600 0.95rem var(--sans); cursor: pointer; color: #0c110f; background: var(--accent); border: 1px solid var(--accent);
         border-radius: 8px; padding: 0.55rem 1rem; min-height: 44px; touch-action: manipulation; }
button:active { background: var(--accent-hi); }
button.ghost { background: transparent; color: var(--text); border-color: var(--line-hi); font-weight: 500; }
button.back { font-size: 1.5rem; line-height: 1; padding: 0.2rem 0.8rem; }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }

/* menu */
.game-card { display: grid; grid-template-columns: 4.2rem 1fr; grid-template-rows: auto auto auto; column-gap: 0.9rem; row-gap: 0.15rem;
             width: 100%; text-align: left; color: var(--text); background: var(--panel); border: 1px solid var(--line);
             border-radius: 12px; padding: 1rem; margin-bottom: 0.9rem; font-weight: 400; }
.game-card:active { background: var(--panel-2); }
.game-card:hover { border-color: var(--line-hi); }
.game-card .title { grid-column: 2; font: 600 1.1rem var(--mono); color: var(--accent-hi); }
.game-card .text { grid-column: 2; font-size: 0.92rem; color: var(--text); }
.game-card .status { grid-column: 2; font-size: 0.82rem; color: var(--muted); }
.game-card .glyphs, .game-card .rails { grid-row: 1 / span 3; align-self: center; width: 4.2rem; height: 4.2rem; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.glyphs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; padding: 0.55rem; }
.glyphs i { display: block; border-radius: 4px; }
.glyphs .g1 { background: var(--accent); border-radius: 50%; } .glyphs .g2 { background: var(--warn); }
.glyphs .g3 { background: #6aa8e0; transform: rotate(45deg) scale(0.75); } .glyphs .g4 { background: var(--bad); border-radius: 50%; }
.rails { position: relative; overflow: hidden; }
.rails::before, .rails::after { content: ""; position: absolute; left: 50%; top: -10%; bottom: -10%; width: 0.5rem; transform: translateX(-50%); }
.rails::before { width: 1.6rem; background: repeating-linear-gradient(180deg, #3d4a43 0 0.25rem, transparent 0.25rem 0.75rem); }
.rails::after { border-left: 3px solid var(--accent); border-right: 3px solid var(--accent); width: 1.2rem; }
.note { margin-top: 0.5rem; }

/* game screens */
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0.5rem; }
canvas { display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.foot { padding: 0.6rem 0.75rem 0.8rem; border-top: 1px solid var(--line); flex: none; }
.info { margin: 0 0 0.5rem; text-align: center; min-height: 1.3em; }
.info.ok { color: var(--ok); } .info.bad { color: var(--bad); } .info.warn { color: var(--warn); }
