/* Schi — 3D alpine slalom on a Carpathian slope (js/schi.js). Theme-aware like the other game
   pages: tokens on :root, redefined under body.dark-theme. The slope follows the theme too: a
   sunny day in light, night skiing under the floodlights in dark. */
:root {
    --sc-accent: #0369a1;
    --sc-accent-2: #e11d48;
    --sc-on-accent: #ffffff;
    --sc-page-bg: #f0f7fc;
    --sc-card-bg: #ffffff;
    --sc-card-border: #c7dff0;
    --sc-muted: #4b6074;
    --sc-shadow: 0 10px 30px rgba(12, 74, 110, .15);
    --sc-stage-bg: #9fcbef;
    --sc-overlay: rgba(15, 30, 45, .42);
    --sc-chip-bg: #f0f7fc;
    --sc-glass: rgba(10, 25, 40, .56);
    --sc-good: #16a34a;
    --sc-bad: #dc2626;
    --sc-gold: #f59e0b;
    --sc-silver: #94a3b8;
    --sc-bronze: #b45309;
}

body.dark-theme {
    --sc-accent: #38bdf8;
    --sc-accent-2: #fb7185;
    --sc-on-accent: #04121c;
    --sc-page-bg: #07111b;
    --sc-card-bg: #0f1d2a;
    --sc-card-border: #1f3a52;
    --sc-muted: #a9bfd2;
    --sc-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --sc-stage-bg: #0b1530;
    --sc-overlay: rgba(2, 8, 14, .6);
    --sc-chip-bg: #142638;
    --sc-glass: rgba(2, 8, 16, .62);
    --sc-good: #4ade80;
    --sc-bad: #f87171;
    --sc-gold: #fbbf24;
    --sc-silver: #cbd5e1;
    --sc-bronze: #f59e0b;
}

/* 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. */
.sc-body, body.sc-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--sc-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
body.sc-max { overflow: hidden; }
body.sc-playing { overscroll-behavior: none; }
.sc-main { padding-top: 96px; padding-bottom: 40px; }
.sc-game .container, .sc-hero .container { max-width: 760px; }

/* ---- hero ---- */
.sc-hero { text-align: center; padding: 4px 0 12px; }
.sc-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.3rem); margin: 0 0 6px; display: inline-flex; align-items: center; gap: 12px; }
.sc-hero-icon { width: 46px; height: 46px; border-radius: 14px; display: inline-grid; place-items: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, #0ea5e9, #1e3a8a); box-shadow: var(--sc-shadow); }
.sc-lead { max-width: 600px; margin: 0 auto; color: var(--sc-muted); font-size: 1rem; line-height: 1.55; }

/* ---- the stage: the 3D slope fills it ---- */
.sc-stage {
    --sc-h: clamp(440px, calc(100vh - 150px), 760px);
    position: relative;
    height: var(--sc-h);
    width: 100%;
    margin: 0 auto;
    background: var(--sc-stage-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--sc-shadow);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    color: #fff;
}
@supports (height: 100svh) {
    .sc-stage { --sc-h: clamp(440px, calc(100svh - 150px), 760px); }
}
.sc-stage:focus-visible { box-shadow: 0 0 0 3px var(--sc-accent), var(--sc-shadow); }
@media (max-width: 575.98px) {
    .sc-stage { width: calc(100% + 24px); margin: 0 -12px; border-radius: 0; }
}
.sc-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.sc-stage:fullscreen { width: 100%; height: 100%; border-radius: 0; margin: 0; }
.sc-stage:-webkit-full-screen { width: 100%; height: 100%; border-radius: 0; margin: 0; }
.sc-stage.is-max { position: fixed; inset: 0; z-index: 1052; width: 100vw; height: 100vh; margin: 0; border-radius: 0; }
@supports (height: 100dvh) { .sc-stage.is-max { height: 100dvh; } }

/* ---- HUD ---- */
.sc-hud { position: absolute; left: 10px; right: 62px; top: 10px; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; }
.sc-hud[hidden] { display: none; }
.sc-box { display: flex; flex-direction: column; align-items: flex-start; min-width: 118px; max-width: 100%; padding: 6px 12px 7px; border-radius: 14px; background: var(--sc-glass); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); line-height: 1.1; }
.sc-box-mode { font-size: .74rem; font-weight: 700; opacity: .88; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.sc-box-time { font-size: 1.75rem; font-weight: 900; font-variant-numeric: tabular-nums; min-width: 5.2ch; }
.sc-box-sub { font-size: .8rem; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; font-variant-numeric: tabular-nums; }
.sc-box-sub:empty { display: none; }
.sc-box-sub b { color: #fca5a5; }
.sc-split { padding: 4px 10px; border-radius: 999px; font-weight: 800; font-size: .9rem; font-variant-numeric: tabular-nums; background: var(--sc-glass); opacity: 0; transition: opacity .25s; }
.sc-split.is-on { opacity: 1; }
.sc-split.is-ahead { background: rgba(22, 163, 74, .88); }
.sc-split.is-behind { background: rgba(220, 38, 38, .85); }

.sc-tools { position: absolute; right: 10px; top: 10px; z-index: 4; display: flex; flex-direction: column; gap: 8px; }
.sc-round { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--sc-glass); color: #fff; font-size: 16px; cursor: pointer; touch-action: manipulation; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.sc-round:hover, .sc-round:focus-visible { background: rgba(3, 105, 161, .9); }
.sc-round:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.sc-round[hidden], .sc-round span[hidden] { display: none; }

.sc-speed { position: absolute; left: 10px; bottom: 12px; z-index: 2; display: flex; align-items: baseline; gap: 4px; padding: 5px 12px; border-radius: 14px; background: var(--sc-glass); font-variant-numeric: tabular-nums; pointer-events: none; }
.sc-speed[hidden] { display: none; }
.sc-speed strong { font-size: 1.35rem; font-weight: 900; min-width: 2.6ch; text-align: right; line-height: 1.1; }
.sc-speed small { font-size: .74rem; opacity: .85; }

.sc-brake { position: absolute; right: 12px; bottom: 12px; z-index: 3; width: 76px; height: 76px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .55); background: var(--sc-glass); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-weight: 800; font-size: .78rem; touch-action: none; cursor: pointer; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.sc-brake svg, .sc-brake i { font-size: 1.3rem; }
.sc-brake[hidden] { display: none; }
.sc-brake.is-on { background: rgba(220, 38, 38, .85); border-color: #fff; }

/* ---- big messages ---- */
.sc-banner { position: absolute; left: 50%; top: 30%; z-index: 3; transform: translate(-50%, -50%) scale(.9); margin: 0; padding: 10px 22px; border-radius: 18px; max-width: 92%; text-align: center; color: #fff; font-weight: 900; font-size: clamp(1.4rem, 7vw, 2.4rem); line-height: 1.15; letter-spacing: .02em; text-shadow: 0 3px 12px rgba(0, 0, 0, .45); background: rgba(10, 25, 40, .55); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.sc-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.sc-banner small { display: block; font-size: .5em; font-weight: 700; letter-spacing: 0; opacity: .92; }
.sc-banner.is-good { background: linear-gradient(135deg, rgba(14, 165, 233, .92), rgba(30, 58, 138, .9)); }
.sc-banner.is-bad { background: linear-gradient(135deg, rgba(225, 29, 72, .92), rgba(153, 27, 27, .9)); }
.sc-banner.is-gold { background: linear-gradient(135deg, rgba(245, 158, 11, .95), rgba(217, 119, 6, .92)); }
.sc-banner.is-count { font-size: clamp(2.6rem, 14vw, 4.4rem); padding: 6px 30px; }

.sc-hint { position: absolute; left: 50%; bottom: 100px; z-index: 2; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 14px; background: var(--sc-glass); font-weight: 700; font-size: .92rem; text-align: center; width: max-content; max-width: calc(100% - 24px); pointer-events: none; line-height: 1.35; }
.sc-hint[hidden] { display: none; }
.sc-loading { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; margin: 0; padding: 20px; text-align: center; color: #fff; font-weight: 700; background: linear-gradient(#8cc4ec, #eef6fc); text-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.sc-loading[hidden] { display: none; }
body.dark-theme .sc-loading { background: linear-gradient(#0b1530, #1e3550); }

/* ---- overlays (setup, pause, pass-the-phone, finish) ---- */
.sc-overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 14px; background: var(--sc-overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto; touch-action: manipulation; color: var(--text-color); }
.sc-overlay[hidden] { display: none; }
.sc-card { width: 100%; max-width: 400px; margin: auto; display: flex; flex-direction: column; gap: 10px; padding: 18px 16px; border-radius: 18px; background: var(--sc-card-bg); border: 1px solid var(--sc-card-border); box-shadow: var(--sc-shadow); color: var(--text-color); text-align: center; }
.sc-card h2 { font-weight: 800; font-size: 1.4rem; margin: 0; }
.sc-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sc-mode { min-height: 60px; padding: 8px; border: 1px solid var(--sc-card-border); border-radius: 12px; background: var(--sc-chip-bg); color: inherit; font-weight: 800; font-size: .92rem; line-height: 1.15; display: flex; align-items: center; gap: 8px; cursor: pointer; touch-action: manipulation; text-align: left; }
.sc-mode > svg, .sc-mode > i { flex: none; width: 1.1em; font-size: 1.05rem; color: var(--sc-accent); }
.sc-mode small { display: block; margin-top: 2px; font-weight: 500; font-size: .74rem; color: var(--sc-muted); }
.sc-mode[aria-checked="true"] { background: var(--sc-accent); border-color: var(--sc-accent); color: var(--sc-on-accent); }
.sc-mode[aria-checked="true"] > svg, .sc-mode[aria-checked="true"] > i { color: inherit; }
.sc-mode[aria-checked="true"] small { color: inherit; opacity: .85; }
.sc-opt { display: flex; flex-direction: column; gap: 6px; }
.sc-opt[hidden] { display: none; }
.sc-label { font-weight: 700; font-size: .9rem; color: var(--sc-muted); }
.sc-chips { display: flex; gap: 6px; justify-content: center; }
.sc-chips-wrap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sc-chip { flex: 1; min-height: 44px; padding: 4px 8px; border-radius: 12px; border: 1px solid var(--sc-card-border); background: var(--sc-chip-bg); color: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.sc-chip[hidden] { display: none; }
.sc-chip[aria-checked="true"] { background: var(--sc-accent); border-color: var(--sc-accent); color: var(--sc-on-accent); }
.sc-courses { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.sc-course { min-height: 54px; padding: 6px 8px; border-radius: 12px; border: 1px solid var(--sc-card-border); background: var(--sc-chip-bg); color: inherit; text-align: left; cursor: pointer; touch-action: manipulation; display: flex; align-items: center; gap: 8px; line-height: 1.2; min-width: 0; overflow: hidden; }
.sc-course > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.sc-course strong { font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-course small { font-size: .74rem; color: var(--sc-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-course[aria-checked="true"] { background: var(--sc-accent); border-color: var(--sc-accent); color: var(--sc-on-accent); }
.sc-course[aria-checked="true"] small { color: inherit; opacity: .88; }
.sc-piste { flex: none; width: 16px; height: 16px; border-radius: 4px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .8), 0 1px 3px rgba(0, 0, 0, .35); }
.sc-piste.is-verde { background: #16a34a; }
.sc-piste.is-albastru { background: #2563eb; }
.sc-piste.is-roșu { background: #dc2626; }
.sc-piste.is-negru { background: #111827; }
.sc-medal { display: inline-block; width: .8em; height: .8em; border-radius: 50%; vertical-align: -.05em; margin-right: 5px; }
.sc-medal.is-aur { background: var(--sc-gold); }
.sc-medal.is-argint { background: var(--sc-silver); }
.sc-medal.is-bronz { background: var(--sc-bronze); }
.sc-names { display: grid; gap: 6px; }
.sc-names[hidden] { display: none; }
.sc-name { display: flex; align-items: center; gap: 8px; margin: 0; }
.sc-name input { flex: 1; min-width: 0; min-height: 44px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--sc-card-border); background: var(--sc-chip-bg); color: inherit; font-size: 1rem; }
.sc-name input:focus { outline: 2px solid var(--sc-accent); outline-offset: 1px; }
.sc-dot { width: 14px; height: 14px; flex: none; border-radius: 50%; background: var(--c, #e11d48); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.sc-mode-note { margin: 0; font-size: .85rem; color: var(--sc-muted); line-height: 1.4; }
.sc-mode-note:empty { display: none; }
.sc-mode:focus-visible, .sc-chip:focus-visible, .sc-btn:focus-visible, .sc-course:focus-visible, .sc-brake:focus-visible { outline: 2px solid var(--sc-accent); outline-offset: 2px; }

.sc-btn { min-height: 48px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--sc-card-border); background: var(--sc-card-bg); color: inherit; font-weight: 700; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; touch-action: manipulation; }
.sc-btn:hover { border-color: var(--sc-accent); }
.sc-btn[hidden] { display: none; }
.sc-btn-primary { background: var(--sc-accent); border-color: var(--sc-accent); color: var(--sc-on-accent); }
.sc-btn-ghost { background: transparent; border-color: transparent; color: var(--sc-muted); }
.sc-over-icon { width: 54px; height: 54px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 24px; color: #fff; background: linear-gradient(135deg, #f59e0b, #d97706); }
.sc-over-icon.is-cool { background: linear-gradient(135deg, #0ea5e9, #1e3a8a); }
.sc-over-icon.is-crash { background: linear-gradient(135deg, #16a34a, #14532d); }
.sc-over-icon span[hidden] { display: none; }
.sc-over-big { margin: 0; font-size: 2.6rem; font-weight: 900; line-height: 1; color: var(--sc-accent); font-variant-numeric: tabular-nums; }
.sc-over-big:empty { display: none; }
.sc-over-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sc-over-list:empty { display: none; }
.sc-over-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--sc-chip-bg); font-weight: 700; text-align: left; }
.sc-over-list li .sc-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-over-list li strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.sc-over-list li.is-win { background: linear-gradient(135deg, rgba(245, 158, 11, .25), rgba(14, 165, 233, .18)); }
.sc-over-sub { margin: 0; color: var(--sc-muted); font-size: .92rem; }
.sc-over-sub:empty { display: none; }

.sc-actions { display: flex; justify-content: center; margin: 14px 0 10px; }
.sc-actions .sc-btn { min-width: 180px; }

/* ---- records table ---- */
.sc-records { margin: 4px auto 0; padding: 10px 12px; border-radius: 14px; background: var(--sc-card-bg); border: 1px solid var(--sc-card-border); }
.sc-records h3 { font-size: 1rem; font-weight: 800; margin: 0 0 6px; }
.sc-records table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.sc-records th, .sc-records td { padding: 5px 4px; border-top: 1px solid var(--sc-card-border); text-align: left; }
.sc-records th { font-size: .76rem; color: var(--sc-muted); font-weight: 700; border-top: 0; }
.sc-records td:nth-child(n+2), .sc-records th:nth-child(n+2) { text-align: right; white-space: nowrap; }
.sc-records td:first-child { display: flex; align-items: center; gap: 6px; }
.sc-records .sc-piste { width: 12px; height: 12px; }
.sc-records-sub { margin: 6px 0 0; font-size: .84rem; color: var(--sc-muted); }
.sc-reset-wrap { text-align: center; margin: 2px 0 12px; }
.sc-link { border: 0; background: none; padding: 6px; color: var(--sc-muted); font-size: .85rem; text-decoration: underline; cursor: pointer; }

/* ---- help ---- */
.sc-help { margin: 8px auto 0; padding: 12px 14px; border-radius: 14px; background: var(--sc-card-bg); border: 1px solid var(--sc-card-border); }
.sc-help summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.sc-help ul { margin: 10px 0 4px; padding-left: 20px; line-height: 1.55; }
.sc-help li { margin-bottom: 4px; }
.sc-credit { margin: 8px 0 0; font-size: .82rem; color: var(--sc-muted); }
.sc-credit a, .sc-powered a { color: var(--sc-accent); }
.sc-powered { text-align: center; color: var(--sc-muted); font-size: .85rem; margin: 22px 0 0; }
body.dark-theme .sc-help kbd { background: #1f3a52; }

body.dark-theme .sc-box, body.dark-theme .sc-round, body.dark-theme .sc-speed, body.dark-theme .sc-hint, body.dark-theme .sc-split { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }

@media (max-width: 420px) {
    .sc-main { padding-top: 88px; }
    .sc-mode { font-size: .86rem; gap: 6px; padding: 7px 6px; min-height: 56px; }
    .sc-mode small { font-size: .7rem; }
    .sc-course { padding: 5px 6px; gap: 6px; }
    .sc-course strong { font-size: .8rem; }
    .sc-chip { font-size: .9rem; padding: 4px 6px; }
}
@media (max-width: 359.98px) {
    .sc-courses, .sc-chips-wrap { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .sc-banner, .sc-split { transition: none; }
}
