/* Baschet — shooting hoops in 3D on a park court (js/baschet.js). Theme-aware like the other
   game pages: tokens on :root, redefined under body.dark-theme. The park itself follows the
   theme too: a sunny afternoon in light, the floodlights at night in dark. */
:root {
    --bk-accent: #ea580c;
    --bk-accent-2: #2563eb;
    --bk-on-accent: #ffffff;
    --bk-page-bg: #fff7ed;
    --bk-card-bg: #ffffff;
    --bk-card-border: #fed7aa;
    --bk-muted: #6b5b4e;
    --bk-shadow: 0 10px 30px rgba(124, 45, 18, .14);
    --bk-stage-bg: #8ec5ea;
    --bk-overlay: rgba(28, 25, 23, .45);
    --bk-chip-bg: #fff7ed;
    --bk-glass: rgba(20, 16, 12, .58);
    --bk-good: #16a34a;
    --bk-miss: #94a3b8;
    --bk-gold: #f59e0b;
}

body.dark-theme {
    --bk-accent: #fb923c;
    --bk-accent-2: #60a5fa;
    --bk-on-accent: #1c1007;
    --bk-page-bg: #120d0a;
    --bk-card-bg: #1f1813;
    --bk-card-border: #3f2e22;
    --bk-muted: #c4b2a3;
    --bk-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --bk-stage-bg: #0b1220;
    --bk-overlay: rgba(8, 6, 4, .6);
    --bk-chip-bg: #2a2018;
    --bk-glass: rgba(8, 6, 4, .62);
    --bk-good: #4ade80;
    --bk-miss: #64748b;
    --bk-gold: #fbbf24;
}

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

/* ---- hero ---- */
.bk-hero { text-align: center; padding: 4px 0 12px; }
.bk-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; }
.bk-hero-icon { width: 46px; height: 46px; border-radius: 14px; display: inline-grid; place-items: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, #f97316, #b91c1c); box-shadow: var(--bk-shadow); }
.bk-lead { max-width: 600px; margin: 0 auto; color: var(--bk-muted); font-size: 1rem; line-height: 1.55; }

/* ---- the stage: the 3D court fills it ---- */
.bk-stage {
    --bk-h: clamp(440px, calc(100vh - 150px), 760px);
    position: relative;
    height: var(--bk-h);
    width: 100%;
    margin: 0 auto;
    background: var(--bk-stage-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--bk-shadow);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    color: #fff;
}
@supports (height: 100svh) {
    .bk-stage { --bk-h: clamp(440px, calc(100svh - 150px), 760px); }
}
.bk-stage:focus-visible { box-shadow: 0 0 0 3px var(--bk-accent), var(--bk-shadow); }
@media (max-width: 575.98px) {
    .bk-stage { width: calc(100% + 24px); margin: 0 -12px; border-radius: 0; }
}
.bk-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.bk-stage[data-phase="setup"] .bk-canvas, .bk-stage[data-phase="over"] .bk-canvas { cursor: default; }

.bk-stage:fullscreen { width: 100%; height: 100%; border-radius: 0; margin: 0; }
.bk-stage:-webkit-full-screen { width: 100%; height: 100%; border-radius: 0; margin: 0; }
.bk-stage.is-max { position: fixed; inset: 0; z-index: 1052; width: 100vw; height: 100vh; margin: 0; border-radius: 0; }
@supports (height: 100dvh) { .bk-stage.is-max { height: 100dvh; } }

/* ---- HUD ---- */
.bk-hud { position: absolute; left: 10px; right: 62px; top: 10px; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
.bk-hud[hidden] { display: none; }
.bk-box { display: flex; flex-direction: column; align-items: flex-start; min-width: 92px; max-width: 64%; padding: 6px 12px 7px; border-radius: 14px; background: var(--bk-glass); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); line-height: 1.1; }
.bk-box-mode { font-size: .74rem; font-weight: 700; opacity: .85; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.bk-box-score { font-size: 1.7rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.bk-box-sub { font-size: .8rem; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bk-box-sub:empty { display: none; }
.bk-box.is-fire { background: linear-gradient(135deg, rgba(234, 88, 12, .9), rgba(185, 28, 28, .9)); box-shadow: 0 0 18px rgba(249, 115, 22, .65); }
.bk-clock { display: flex; align-items: baseline; gap: 3px; padding: 6px 12px; border-radius: 14px; background: var(--bk-glass); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); font-variant-numeric: tabular-nums; }
.bk-clock[hidden] { display: none; }
.bk-clock-n { font-size: 1.7rem; font-weight: 900; line-height: 1.1; min-width: 2ch; text-align: right; }
.bk-clock small { font-size: .75rem; opacity: .8; }
.bk-clock.is-low { background: rgba(185, 28, 28, .85); animation: bk-pulse 1s ease-in-out infinite; }
@keyframes bk-pulse { 50% { transform: scale(1.06); } }

/* duel scoreboard */
.bk-duel { position: absolute; left: 10px; right: 62px; top: 10px; z-index: 2; display: grid; gap: 4px; pointer-events: none; }
.bk-duel[hidden] { display: none; }
.bk-drow { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 12px; background: var(--bk-glass); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); border: 2px solid transparent; }
.bk-drow.is-cur { border-color: var(--c, #f97316); }
.bk-drow-name { flex: 0 1 auto; min-width: 0; max-width: 40%; font-weight: 800; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-drow-dots { flex: 1; display: flex; gap: 3px; justify-content: flex-start; min-width: 0; flex-wrap: nowrap; overflow: hidden; }
.bk-drow-dots i { flex: none; width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .45); font-style: normal; }
.bk-drow-dots i.is-in { background: var(--c, #f97316); box-shadow: none; }
.bk-drow-dots i.is-out { background: rgba(255, 255, 255, .18); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .2); position: relative; }
.bk-drow-dots i.is-out::after { content: ""; position: absolute; left: 2px; right: 2px; top: 5px; height: 1.5px; background: rgba(255, 255, 255, .7); transform: rotate(-45deg); }
.bk-drow-dots i.is-three { border-radius: 3px; }
.bk-drow-dots i.is-now { box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px rgba(255, 255, 255, .35); }
.bk-drow-score { font-weight: 900; font-size: 1.1rem; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.bk-dot { width: 14px; height: 14px; flex: none; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .65), transparent 45%), var(--c, #f97316); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }

/* three-point contest racks */
.bk-racks { position: absolute; left: 10px; top: 92px; z-index: 2; display: flex; flex-direction: column; gap: 4px; padding: 7px 8px; border-radius: 12px; background: var(--bk-glass); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); pointer-events: none; }
.bk-racks[hidden] { display: none; }
.bk-rack { display: flex; gap: 3px; align-items: center; opacity: .55; }
.bk-rack.is-cur { opacity: 1; }
.bk-rack i { width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5); }
.bk-rack i.is-money { box-shadow: inset 0 0 0 2px var(--bk-gold); }
.bk-rack i.is-in { background: #f97316; box-shadow: none; }
.bk-rack i.is-in.is-money { background: var(--bk-gold); }
.bk-rack i.is-out { background: rgba(255, 255, 255, .2); box-shadow: none; }

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

.bk-spot { position: absolute; left: 50%; bottom: 10px; z-index: 2; transform: translateX(-50%); margin: 0; padding: 5px 12px; border-radius: 999px; background: var(--bk-glass); font-weight: 700; font-size: .85rem; white-space: nowrap; pointer-events: none; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
.bk-spot:empty { display: none; }

/* ---- big messages ---- */
.bk-banner { position: absolute; left: 50%; top: 27%; 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, .5); background: rgba(20, 16, 12, .55); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.bk-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.bk-banner small { display: block; font-size: .5em; font-weight: 700; letter-spacing: 0; opacity: .92; }
.bk-banner.is-good { background: linear-gradient(135deg, rgba(234, 88, 12, .92), rgba(185, 28, 28, .9)); }
.bk-banner.is-gold { background: linear-gradient(135deg, rgba(245, 158, 11, .95), rgba(234, 88, 12, .9)); }
.bk-banner.is-cool { background: linear-gradient(135deg, rgba(37, 99, 235, .9), rgba(14, 165, 233, .9)); }

/* power gauge (after a shot, or while charging with the keyboard) */
.bk-gauge { position: absolute; left: 50%; bottom: 46px; z-index: 2; width: min(300px, calc(100% - 40px)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; opacity: 0; transition: opacity .3s; pointer-events: none; }
.bk-gauge.is-on { opacity: 1; }
.bk-gauge-bar { position: relative; width: 100%; height: 12px; border-radius: 999px; background: linear-gradient(90deg, rgba(96, 165, 250, .85), rgba(255, 255, 255, .55) 50%, rgba(248, 113, 113, .85)); box-shadow: 0 0 0 2px rgba(0, 0, 0, .25); }
.bk-gauge-zone { position: absolute; top: -3px; bottom: -3px; border-radius: 6px; background: rgba(34, 197, 94, .85); box-shadow: 0 0 0 2px rgba(255, 255, 255, .8); display: none; }
.bk-gauge.has-zone .bk-gauge-zone { display: block; }
.bk-gauge-mark { position: absolute; top: -6px; width: 6px; height: 24px; margin-left: -3px; border-radius: 3px; background: #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, .55); left: 50%; transition: left .12s; }
.bk-gauge-txt { padding: 3px 10px; border-radius: 999px; background: var(--bk-glass); font-weight: 800; font-size: .85rem; white-space: nowrap; }
.bk-gauge-txt:empty { display: none; }

.bk-swipe { position: absolute; left: 50%; bottom: 46px; z-index: 2; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 999px; background: var(--bk-glass); font-weight: 700; font-size: .95rem; white-space: nowrap; pointer-events: none; }
.bk-swipe[hidden] { display: none; }
.bk-swipe-icon { display: inline-block; animation: bk-swipe 1.6s ease-in-out infinite; }
@keyframes bk-swipe { 0%, 15% { transform: translateY(6px); opacity: .4; } 60% { transform: translateY(-8px); opacity: 1; } 100% { transform: translateY(-8px); opacity: 0; } }
.bk-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(#5aa7dd, #2f6f4f); }
.bk-loading[hidden] { display: none; }

/* ---- overlays (setup, pause, game over) ---- */
.bk-overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 14px; background: var(--bk-overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto; touch-action: manipulation; color: var(--text-color); }
.bk-overlay[hidden] { display: none; }
.bk-card { width: 100%; max-width: 380px; margin: auto; display: flex; flex-direction: column; gap: 10px; padding: 18px 16px; border-radius: 18px; background: var(--bk-card-bg); border: 1px solid var(--bk-card-border); box-shadow: var(--bk-shadow); color: var(--text-color); text-align: center; }
.bk-card h2 { font-weight: 800; font-size: 1.4rem; margin: 0; }
.bk-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bk-mode { min-height: 64px; padding: 8px 8px; border: 1px solid var(--bk-card-border); border-radius: 12px; background: var(--bk-chip-bg); color: inherit; font-weight: 800; font-size: .9rem; line-height: 1.15; display: flex; align-items: center; gap: 8px; cursor: pointer; touch-action: manipulation; text-align: left; }
.bk-mode > svg, .bk-mode > i { flex: none; width: 1.1em; font-size: 1.05rem; color: var(--bk-accent); }
.bk-mode small { display: block; margin-top: 2px; font-weight: 500; font-size: .74rem; color: var(--bk-muted); }
.bk-mode[aria-checked="true"] { background: var(--bk-accent); border-color: var(--bk-accent); color: var(--bk-on-accent); }
.bk-mode[aria-checked="true"] > svg, .bk-mode[aria-checked="true"] > i { color: inherit; }
.bk-mode[aria-checked="true"] small { color: inherit; opacity: .85; }
.bk-opt { display: flex; flex-direction: column; gap: 6px; }
.bk-opt[hidden] { display: none; }
.bk-label { font-weight: 700; font-size: .9rem; color: var(--bk-muted); }
.bk-chips { display: flex; gap: 6px; justify-content: center; }
.bk-chip { flex: 1; min-height: 44px; padding: 4px 8px; border-radius: 12px; border: 1px solid var(--bk-card-border); background: var(--bk-chip-bg); color: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.bk-chip[aria-checked="true"] { background: var(--bk-accent); border-color: var(--bk-accent); color: var(--bk-on-accent); }
.bk-names { display: grid; gap: 6px; }
.bk-name { display: flex; align-items: center; gap: 8px; margin: 0; }
.bk-name[hidden] { display: none; }
.bk-name input { flex: 1; min-width: 0; min-height: 44px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--bk-card-border); background: var(--bk-chip-bg); color: inherit; font-size: 1rem; }
.bk-name input:focus { outline: 2px solid var(--bk-accent); outline-offset: 1px; }
.bk-mode-note { margin: 0; font-size: .85rem; color: var(--bk-muted); line-height: 1.4; }
.bk-mode-note:empty { display: none; }
.bk-mode:focus-visible, .bk-chip:focus-visible, .bk-btn:focus-visible, .bk-spotbtn:focus-visible { outline: 2px solid var(--bk-accent); outline-offset: 2px; }

.bk-btn { min-height: 48px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--bk-card-border); background: var(--bk-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; }
.bk-btn:hover { border-color: var(--bk-accent); }
.bk-btn[hidden] { display: none; }
.bk-btn-primary { background: var(--bk-accent); border-color: var(--bk-accent); color: var(--bk-on-accent); }
.bk-btn-ghost { background: transparent; border-color: transparent; color: var(--bk-muted); }
.bk-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, #ea580c); }
.bk-over-big { margin: 0; font-size: 2.6rem; font-weight: 900; line-height: 1; color: var(--bk-accent); font-variant-numeric: tabular-nums; }
.bk-over-big:empty { display: none; }
.bk-over-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bk-over-list:empty { display: none; }
.bk-over-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--bk-chip-bg); font-weight: 700; text-align: left; }
.bk-over-list li .bk-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-over-list li strong { font-size: 1.15rem; }
.bk-over-list li.is-win { background: linear-gradient(135deg, rgba(245, 158, 11, .25), rgba(234, 88, 12, .2)); }
.bk-over-sub { margin: 0; color: var(--bk-muted); font-size: .92rem; }
.bk-over-sub:empty { display: none; }

/* ---- practice: the spot picker ---- */
.bk-practice { margin: 12px 0 0; padding: 10px 12px 12px; border-radius: 14px; background: var(--bk-card-bg); border: 1px solid var(--bk-card-border); }
.bk-practice[hidden] { display: none; }
.bk-practice-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.bk-switch { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; font-size: .9rem; cursor: pointer; min-height: 32px; }
.bk-switch input { width: 20px; height: 20px; accent-color: var(--bk-accent); }
.bk-spots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.bk-spotbtn { min-height: 48px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--bk-card-border); background: var(--bk-chip-bg); color: inherit; text-align: left; cursor: pointer; touch-action: manipulation; display: flex; flex-direction: column; justify-content: center; line-height: 1.2; }
.bk-spotbtn strong { font-size: .9rem; }
.bk-spotbtn small { font-size: .76rem; color: var(--bk-muted); font-variant-numeric: tabular-nums; }
.bk-spotbtn[aria-checked="true"] { background: var(--bk-accent); border-color: var(--bk-accent); color: var(--bk-on-accent); }
.bk-spotbtn[aria-checked="true"] small { color: inherit; opacity: .85; }

.bk-actions { display: flex; justify-content: center; margin: 14px 0 10px; }
.bk-actions .bk-btn { min-width: 180px; }
.bk-record { margin: 12px 0 0; text-align: center; color: var(--bk-muted); font-size: .9rem; line-height: 1.6; }
.bk-record:empty { display: none; }
.bk-reset-wrap { text-align: center; margin: 2px 0 12px; }
.bk-link { border: 0; background: none; padding: 6px; color: var(--bk-muted); font-size: .85rem; text-decoration: underline; cursor: pointer; }

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

body.dark-theme .bk-box, body.dark-theme .bk-clock, body.dark-theme .bk-round, body.dark-theme .bk-racks, body.dark-theme .bk-spot, body.dark-theme .bk-gauge-txt, body.dark-theme .bk-swipe { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
body.dark-theme .bk-drow:not(.is-cur) { border-color: rgba(255, 255, 255, .16); }

@media (max-width: 420px) {
    .bk-main { padding-top: 88px; }
    .bk-mode { font-size: .84rem; gap: 6px; padding: 7px 6px; min-height: 60px; }
    .bk-mode small { font-size: .7rem; }
    .bk-spots { grid-template-columns: 1fr 1fr; }
    .bk-drow-dots i { width: 10px; height: 10px; }
    .bk-drow-dots { gap: 2px; }
}
@media (max-width: 359.98px) {
    .bk-modes { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .bk-swipe-icon, .bk-clock.is-low { animation: none; }
    .bk-banner { transition: none; }
}
