/* Air hockey — two players on one phone, or against the phone (js/air-hockey.js).
   Theme-aware like the other game pages: tokens on :root, redefined under body.dark-theme.
   The canvas reads the --ah-* rink colours, so a theme switch repaints the table too. */
:root {
    --ah-accent: #e11d48;
    --ah-page-bg: #f1f5f9;
    --ah-card-bg: #ffffff;
    --ah-card-border: #e2e8f0;
    --ah-muted: #64748b;
    --ah-shadow: 0 10px 30px rgba(15, 23, 42, .12);
    --ah-stage-bg: #dbe4ee;
    --ah-rink: #f4f9fd;
    --ah-line: rgba(30, 64, 120, .16);
    --ah-wall: #1e293b;
    --ah-goal: #020617;
    --ah-mid: rgba(225, 29, 72, .45);
    --ah-puck: #111827;
    --ah-puck-rim: #4b5563;
    --ah-red: #ef4444;
    --ah-red-dark: #b91c1c;
    --ah-blue: #3b82f6;
    --ah-blue-dark: #1d4ed8;
    --ah-overlay: rgba(241, 245, 249, .72);
}

body.dark-theme {
    --ah-accent: #fb7185;
    --ah-page-bg: #0b1120;
    --ah-card-bg: #1e293b;
    --ah-card-border: #334155;
    --ah-muted: #94a3b8;
    --ah-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    --ah-stage-bg: #070b14;
    --ah-rink: #10203a;
    --ah-line: rgba(148, 197, 255, .14);
    --ah-wall: #334155;
    --ah-goal: #000000;
    --ah-mid: rgba(251, 113, 133, .5);
    --ah-puck: #e5e7eb;
    --ah-puck-rim: #9ca3af;
    --ah-red: #f87171;
    --ah-red-dark: #b91c1c;
    --ah-blue: #60a5fa;
    --ah-blue-dark: #1d4ed8;
    --ah-overlay: rgba(7, 11, 20, .7);
}

/* clip, not hidden: the site-wide `body { overflow-x: hidden }` makes <body> a scroll
   container that never scrolls, which silently kills any position: sticky inside. */
.ah-body, body.ah-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--ah-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
body.ah-playing { overscroll-behavior: none; }
body.ah-max { overflow: hidden; }

.ah-main { padding-top: 92px; padding-bottom: 32px; }

/* ---- hero ---- */
.ah-hero { text-align: center; padding: 4px 0 12px; }
.ah-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 4vw, 2.3rem); margin-bottom: 6px; }
.ah-hero h1 svg, .ah-hero h1 i { color: var(--ah-accent); }
.ah-lead { max-width: 640px; margin: 0 auto; color: var(--ah-muted); font-size: 1rem; line-height: 1.55; }

/* ---- the stage: a portrait table, as tall as the window allows ---- */
.ah-stage {
    --ah-h: min(90vh, calc(100vh - 84px));
    position: relative;
    height: var(--ah-h);
    min-height: 420px;
    width: min(100%, calc(var(--ah-h) * .62));
    margin: 0 auto;
    background: var(--ah-stage-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--ah-shadow);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
@supports (height: 100svh) {
    .ah-stage { --ah-h: min(90svh, calc(100svh - 84px)); }
}
@media (max-width: 575.98px) {
    .ah-stage { border-radius: 0; width: 100%; }
}

.ah-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}

/* real fullscreen, and the iPhone fallback that just covers the window */
.ah-stage:fullscreen { width: 100%; height: 100%; max-height: none; min-height: 0; border-radius: 0; }
.ah-stage:-webkit-full-screen { width: 100%; height: 100%; max-height: none; min-height: 0; border-radius: 0; }
.ah-stage.is-max {
    position: fixed;
    inset: 0;
    z-index: 1052;          /* over the site header (1050), under the site's dialogs (1055) */
    width: 100vw;
    height: 100vh;
    min-height: 0;
    border-radius: 0;
    margin: 0;
}
@supports (height: 100dvh) {
    .ah-stage.is-max { height: 100dvh; }
}

/* ---- HUD: two small round buttons on the centre line, against the side walls ---- */
.ah-hud[hidden] { display: none; }
.ah-round {
    position: absolute;
    top: var(--ah-mid-y, 50%);
    transform: translateY(-50%);
    z-index: 2;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--ah-card-border);
    background: var(--ah-card-bg);
    color: var(--text-color);
    display: grid;
    place-items: center;
    font-size: 15px;
    opacity: .82;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    touch-action: manipulation;
    cursor: pointer;
}
.ah-round:hover, .ah-round:focus-visible { opacity: 1; }
.ah-round-left { left: var(--ah-side-x, 8px); }
.ah-round-right { right: var(--ah-side-x, 8px); }
.ah-round span[hidden] { display: none; }

/* ---- overlays (start, pause, game over) ---- */
.ah-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 16px;
    background: var(--ah-overlay);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    touch-action: manipulation;
    overflow-y: auto;
}
.ah-overlay[hidden] { display: none; }
.ah-card {
    width: 100%;
    max-width: 330px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 16px;
    border-radius: 18px;
    background: var(--ah-card-bg);
    border: 1px solid var(--ah-card-border);
    box-shadow: var(--ah-shadow);
    text-align: center;
    color: var(--text-color);
}
.ah-card h2 { font-weight: 800; font-size: 1.45rem; margin: 0; }
.ah-hint { margin: 0; color: var(--ah-muted); font-size: .92rem; line-height: 1.45; }
.ah-red-text { color: var(--ah-red); }
.ah-blue-text { color: var(--ah-blue); }

.ah-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--ah-card-border);
    background: var(--ah-page-bg);
    color: var(--text-color);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color .15s, transform .1s;
}
.ah-btn:hover { border-color: var(--ah-accent); }
.ah-btn:active { transform: scale(.98); }
.ah-btn-primary { background: var(--ah-accent); border-color: var(--ah-accent); color: #fff; }
body.dark-theme .ah-btn-primary { color: #0b1120; }
.ah-btn-ghost { background: transparent; }

.ah-ai { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.ah-ai-label { font-weight: 700; font-size: .95rem; }
.ah-ai-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.ah-switch { display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin: 2px 0 0; font-size: .92rem; color: var(--ah-muted); cursor: pointer; }
.ah-switch input { width: 18px; height: 18px; accent-color: var(--ah-accent); }
.ah-record { margin: 0; font-size: .82rem; color: var(--ah-muted); }

.ah-over-title[data-side="bottom"], .ah-mirror[data-side="bottom"] { color: var(--ah-red); }
.ah-over-title[data-side="top"], .ah-mirror[data-side="top"] { color: var(--ah-blue); }

/* in 2-player mode the top player gets an upside-down copy of the message */
.ah-mirror {
    display: none;
    margin: 0;
    transform: rotate(180deg);
    font-weight: 800;
    font-size: 1.45rem;
    color: var(--text-color);
    text-align: center;
}
.ah-stage.is-2p .ah-mirror { display: block; }

/* ---- help ---- */
.ah-help { padding: 26px 0 6px; }
.ah-help .container { max-width: 760px; }
.ah-help h2 { font-weight: 800; font-size: 1.3rem; }
.ah-help ul { padding-left: 1.2rem; color: var(--ah-muted); line-height: 1.6; }
.ah-help kbd { font-size: .8em; }
.ah-powered { text-align: center; color: var(--ah-muted); font-size: .85rem; margin: 10px 0 0; }
.ah-powered a { color: var(--ah-accent); }
