/* The page around the game. The touch-control rules below are copied from the site's main.css at build time. */
:root {
    --bg: #0b2239; --bg-2: #0f2d4a; --bg-3: #163d62;
    --line: rgba(190, 218, 240, 0.16); --line-strong: rgba(190, 218, 240, 0.34); --grid: rgba(190, 218, 240, 0.055);
    --text: #e8f1f8; --muted: #9db6cb; --amber: #ffb347; --amber-ink: #231400; --danger: #ff8a7a;
    --font-display: "Big Shoulders Display", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
    --font-body: "Hanken Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
body {
    margin: 0; min-height: 100vh; color: var(--text); font: 400 1rem/1.5 var(--font-body);
    background-color: var(--bg);
    background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 32px 32px;
}
.game-page { display: flex; flex-direction: column; align-items: center; padding: max(1.25rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom)); }
.game-title { margin: 0 0 1rem; font: 800 clamp(2rem, 7vw, 3.25rem)/1 var(--font-display); letter-spacing: 0.02em; text-transform: uppercase; text-align: center; }
.help { max-width: 34rem; margin: 1rem 0 0; color: var(--muted); font-size: 0.9rem; text-align: center; }
.help.error { color: var(--danger); }
kbd { padding: 0.05rem 0.4rem; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--bg-2); font: 700 0.8rem var(--font-body); color: var(--text); }
.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin: 1rem 0 0; }
.btn { font: 700 0.9rem var(--font-body); color: var(--amber-ink); background: var(--amber); border: 1px solid var(--amber); padding: 0.55rem 1rem; cursor: pointer; }
.btn.quiet { color: var(--text); background: transparent; border-color: var(--line-strong); }
.btn:hover { filter: brightness(1.08); }
.btn:focus-visible, .touch-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.game-frame { display: inline-block; max-width: 100%; overflow: auto; padding: 0.75rem; border: 1px solid var(--line-strong); background: var(--bg-2); }
.game-frame canvas { display: block; background: #000; width: min(400px, calc(100vw - 4.5rem)); height: auto; aspect-ratio: 1; }

/* On-screen controls: only on touch screens. They send ordinary key events (see components/TouchControls.js). */
.touch-controls, .touch-help { display: none; }
@media (pointer: coarse) {
    .touch-controls {
        display: flex; align-items: center; justify-content: space-between; gap: 1rem;
        width: min(400px, calc(100vw - 4.5rem)); margin-top: 0.75rem; padding: 0 0.75rem 0 0.25rem;
        user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
    }
    .touch-controls * { -webkit-tap-highlight-color: transparent; }
    /* Keep the game and its pad on one screen: the keyboard instructions and menu buttons move out of the way. */
    .game-page .page-head { margin-bottom: 0.9rem; }
    .game-page .lede, .game-page .game-buttons { display: none; }
    .touch-help { display: block; margin-top: 1rem; color: var(--muted); font-size: 0.9rem; }
}
.dpad { position: relative; width: 9.5rem; height: 9.5rem; border-radius: 50%; background: var(--bg-2); border: 1px solid var(--line-strong); touch-action: none; flex: none; }
.dpad-arm { position: absolute; background: var(--bg-3); border: 1px solid var(--line-strong); transition: background-color 0.06s; }
.dpad-arm.up, .dpad-arm.down { left: 50%; width: 2.9rem; margin-left: -1.45rem; height: 3.6rem; }
.dpad-arm.left, .dpad-arm.right { top: 50%; height: 2.9rem; margin-top: -1.45rem; width: 3.6rem; }
.dpad-arm.up { top: 0.35rem; border-radius: 0.6rem 0.6rem 0 0; }
.dpad-arm.down { bottom: 0.35rem; border-radius: 0 0 0.6rem 0.6rem; }
.dpad-arm.left { left: 0.35rem; border-radius: 0.6rem 0 0 0.6rem; }
.dpad-arm.right { right: 0.35rem; border-radius: 0 0.6rem 0.6rem 0; }
.dpad-arm.on { background: var(--amber); border-color: var(--amber); }
.dpad-hub { position: absolute; left: 50%; top: 50%; width: 2.9rem; height: 2.9rem; margin: -1.45rem 0 0 -1.45rem; background: var(--bg-3); }
.dpad-arm::after { content: ""; position: absolute; left: 50%; top: 50%; border: solid transparent; border-width: 0.4rem; }
.dpad-arm.up::after { border-bottom-color: var(--text); margin: -0.6rem 0 0 -0.4rem; }
.dpad-arm.down::after { border-top-color: var(--text); margin: -0.2rem 0 0 -0.4rem; }
.dpad-arm.left::after { border-right-color: var(--text); margin: -0.4rem 0 0 -0.6rem; }
.dpad-arm.right::after { border-left-color: var(--text); margin: -0.4rem 0 0 -0.2rem; }
.dpad-arm.on::after { border-bottom-color: var(--amber-ink); }
.dpad-arm.down.on::after { border-bottom-color: transparent; border-top-color: var(--amber-ink); }
.dpad-arm.left.on::after { border-bottom-color: transparent; border-right-color: var(--amber-ink); }
.dpad-arm.right.on::after { border-bottom-color: transparent; border-left-color: var(--amber-ink); }
.touch-side { display: flex; flex-direction: column; align-items: flex-end; gap: 1.1rem; min-width: 0; }
.touch-main { display: flex; gap: 0.9rem; align-items: flex-end; }
.touch-small { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.3rem; }
.touch-btn { font: inherit; font-weight: 700; color: var(--text); background: var(--bg-3); border: 1px solid var(--line-strong); touch-action: none; cursor: pointer; }
.touch-btn.on { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.touch-btn.round { width: 4rem; height: 4rem; border-radius: 50%; font-size: 1.25rem; }
.touch-btn.round.a { margin-bottom: 1.4rem; }
.touch-btn.small { padding: 0.4rem 0.5rem; border-radius: 999px; font-size: 0.65rem; letter-spacing: 0.03em; text-transform: uppercase; }
.game-buttons { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0 0; }

/* A bigger picture than the 400px the site uses, but never wider than the screen. */
.game-frame canvas { width: min(560px, calc(100vw - 2.5rem)); }
.touch-controls { width: min(560px, calc(100vw - 2.5rem)); }
@media (pointer: coarse) {
    .keyboard-help { display: none; }
    .game-page .buttons { display: none; }
    .game-title { font-size: 1.75rem; margin-bottom: 0.75rem; }
}
@media (pointer: fine) { .touch-help { display: none; } }
