/* Curling — stones on ice in 3D (js/curling.js). Theme-aware like the other game pages: tokens on
   :root, redefined under body.dark-theme. The arena follows the theme too: a bright hall in light,
   a dim hall under spotlights in dark. */
:root {
    --cu-accent: #0369a1;
    --cu-accent-2: #dc2626;
    --cu-on-accent: #ffffff;
    --cu-page-bg: #f0f9ff;
    --cu-card-bg: #ffffff;
    --cu-card-border: #bae6fd;
    --cu-muted: #4b5d6b;
    --cu-shadow: 0 10px 30px rgba(3, 60, 100, .16);
    --cu-stage-bg: #cfe3f1;
    --cu-overlay: rgba(10, 20, 30, .42);
    --cu-chip-bg: #f0f9ff;
    --cu-glass: rgba(8, 20, 34, .62);
    --cu-t0: #dc2626;
    --cu-t1: #eab308;
    --cu-gold: #f59e0b;
}

body.dark-theme {
    --cu-accent: #38bdf8;
    --cu-accent-2: #f87171;
    --cu-on-accent: #04253a;
    --cu-page-bg: #06111b;
    --cu-card-bg: #0d1b28;
    --cu-card-border: #1e3a52;
    --cu-muted: #a5bccd;
    --cu-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --cu-stage-bg: #0b1620;
    --cu-overlay: rgba(2, 6, 10, .62);
    --cu-chip-bg: #12273a;
    --cu-glass: rgba(2, 8, 14, .66);
    --cu-t0: #f87171;
    --cu-t1: #facc15;
    --cu-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. */
.cu-body, body.cu-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--cu-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
body.cu-max { overflow: hidden; }
body.cu-playing { overscroll-behavior: none; }
.cu-main { padding-top: 96px; padding-bottom: 40px; }
.cu-game .container, .cu-hero .container { max-width: 760px; }

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

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

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

/* ---- scoreboard ---- */
.cu-board { position: absolute; left: 10px; right: 62px; top: 10px; z-index: 2; display: grid; gap: 4px; pointer-events: none; }
.cu-board[hidden] { display: none; }
.cu-row { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 12px; background: var(--cu-glass); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); border: 2px solid transparent; min-height: 34px; }
.cu-row.is-cur { border-color: var(--c, #dc2626); }
.cu-row-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; }
.cu-row-ham { flex: none; width: 1.1em; font-size: .8rem; color: var(--cu-gold); }
.cu-row-ham.is-off { visibility: hidden; }
.cu-row-dots { flex: 1; display: flex; gap: 3px; min-width: 0; overflow: hidden; }
.cu-row-dots i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .55); font-style: normal; }
.cu-row-dots i.is-used { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .35); }
.cu-row-score { font-weight: 900; font-size: 1.15rem; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.cu-info { justify-self: start; padding: 3px 10px; border-radius: 999px; background: var(--cu-glass); font-weight: 700; font-size: .78rem; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.cu-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, #dc2626); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }

/* the house seen from above */
.cu-map { position: absolute; left: 10px; top: 128px; z-index: 2; width: 96px; height: 150px; border-radius: 10px; background: rgba(240, 248, 255, .92); box-shadow: 0 2px 10px rgba(0, 0, 0, .25); cursor: pointer; touch-action: none; }
.cu-map[hidden] { display: none; }
body.dark-theme .cu-map { background: rgba(214, 228, 240, .9); }

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

/* ---- big messages ---- */
.cu-banner { position: absolute; left: 50%; top: 38%; 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.3rem, 6.5vw, 2.2rem); line-height: 1.15; letter-spacing: .02em; text-shadow: 0 3px 12px rgba(0, 0, 0, .5); background: rgba(8, 20, 34, .6); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.cu-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.cu-banner small { display: block; font-size: .5em; font-weight: 700; letter-spacing: 0; opacity: .92; }
.cu-banner.is-good { background: linear-gradient(135deg, rgba(22, 163, 74, .94), rgba(21, 128, 61, .92)); }
.cu-banner.is-bad { background: linear-gradient(135deg, rgba(220, 38, 38, .92), rgba(153, 27, 27, .9)); }
.cu-banner.is-gold { background: linear-gradient(135deg, rgba(245, 158, 11, .95), rgba(234, 88, 12, .9)); }
.cu-banner.is-cool { background: linear-gradient(135deg, rgba(3, 105, 161, .92), rgba(14, 165, 233, .9)); }

.cu-hint { position: absolute; left: 50%; bottom: 12px; z-index: 2; transform: translateX(-50%); margin: 0; padding: 7px 14px; border-radius: 999px; background: var(--cu-glass); font-weight: 700; font-size: .88rem; white-space: nowrap; pointer-events: none; max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; }
.cu-hint[hidden] { display: none; }

.cu-loading { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; margin: 0; padding: 20px; text-align: center; color: #0c4a6e; font-weight: 700; background: linear-gradient(#e0f2fe, #f8fafc); }
.cu-loading[hidden] { display: none; }

/* ---- shot controls ---- */
.cu-ctrl { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 3; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 16px; background: var(--cu-glass); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); max-width: 520px; margin: 0 auto; }
.cu-ctrl[hidden] { display: none; }
.cu-ctrl-row { display: flex; align-items: center; gap: 8px; }
.cu-turn { display: flex; gap: 6px; flex: 1; }
.cu-turn .cu-chip { min-height: 42px; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .22); color: #fff; }
.cu-turn .cu-chip[aria-checked="true"] { background: #0ea5e9; border-color: #0ea5e9; color: #fff; }
.cu-wname { flex: none; min-width: 7.2em; text-align: right; font-weight: 800; font-size: .95rem; }
.cu-weight { position: relative; display: block; margin: 0; padding: 0 2px; }
.cu-weight input { width: 100%; height: 40px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; touch-action: pan-y; }
.cu-weight input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; border-radius: 8px; }
.cu-weight input::-webkit-slider-runnable-track { height: 14px; border-radius: 999px; background: linear-gradient(90deg, #64748b 0 13%, #38bdf8 13% 39%, #22c55e 39% 63%, #f59e0b 63% 72%, #ef4444 72% 100%); box-shadow: 0 0 0 2px rgba(0, 0, 0, .25); }
.cu-weight input::-moz-range-track { height: 14px; border-radius: 999px; background: linear-gradient(90deg, #64748b 0 13%, #38bdf8 13% 39%, #22c55e 39% 63%, #f59e0b 63% 72%, #ef4444 72% 100%); box-shadow: 0 0 0 2px rgba(0, 0, 0, .25); }
.cu-weight input::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -8px; border-radius: 50%; background: #f8fafc; border: 3px solid #0c4a6e; box-shadow: 0 2px 6px rgba(0, 0, 0, .45); }
.cu-weight input::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #f8fafc; border: 3px solid #0c4a6e; box-shadow: 0 2px 6px rgba(0, 0, 0, .45); }
.cu-wbands { display: grid; grid-template-columns: 26fr 24fr 9fr 28fr; margin-top: -4px; font-size: .68rem; font-weight: 700; opacity: .85; text-align: center; padding-left: 13%; }
.cu-wbands span { white-space: nowrap; overflow: hidden; }
.cu-ctrl .cu-aimbtn { flex: none; width: 52px; padding: 0; background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .22); color: #fff; }
.cu-go { flex: 1; }

/* ---- sweeping ---- */
.cu-sweep { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 3; display: flex; flex-direction: column; gap: 8px; max-width: 520px; margin: 0 auto; }
.cu-sweep[hidden] { display: none; }
.cu-sweep-meter { height: 10px; border-radius: 999px; background: var(--cu-glass); overflow: hidden; box-shadow: 0 0 0 2px rgba(0, 0, 0, .2); }
.cu-sweep-meter span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #38bdf8, #22c55e 60%, #facc15); transition: width .12s linear; }
.cu-sweep-btn { min-height: 76px; font-size: 1.35rem; font-weight: 900; flex-direction: column; gap: 0; line-height: 1.1; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.cu-sweep-btn small { font-size: .72rem; font-weight: 700; opacity: .85; }
.cu-sweep-btn.is-hit { transform: scale(.97); }

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

.cu-btn { min-height: 48px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--cu-card-border); background: var(--cu-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; }
.cu-btn:hover { border-color: var(--cu-accent); }
.cu-btn[hidden] { display: none; }
.cu-btn-primary { background: var(--cu-accent); border-color: var(--cu-accent); color: var(--cu-on-accent); }
.cu-btn-ghost { background: transparent; border-color: transparent; color: var(--cu-muted); }
.cu-ctrl .cu-btn-primary, .cu-sweep .cu-btn-primary { background: #0284c7; border-color: #0284c7; color: #fff; }
.cu-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, #0369a1); }
.cu-over-big { margin: 0; font-size: 2.6rem; font-weight: 900; line-height: 1; color: var(--cu-accent); font-variant-numeric: tabular-nums; }
.cu-over-big:empty { display: none; }
.cu-over-sub { margin: 0; color: var(--cu-muted); font-size: .92rem; }
.cu-over-sub:empty { display: none; }

/* ---- the ends table ---- */
.cu-table-wrap { overflow-x: auto; max-width: 100%; }
.cu-table-wrap:empty { display: none; }
.cu-table { border-collapse: collapse; margin: 0 auto; font-size: .82rem; font-variant-numeric: tabular-nums; }
.cu-table th, .cu-table td { padding: 4px 5px; border: 1px solid var(--cu-card-border); text-align: center; min-width: 1.9em; }
.cu-table th:first-child, .cu-table td:first-child { text-align: left; max-width: 8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cu-table td.is-tot { font-weight: 900; }
.cu-table td.is-pts { font-weight: 800; color: var(--cu-accent); }
.cu-score { margin: 12px 0 0; padding: 10px 12px; border-radius: 14px; background: var(--cu-card-bg); border: 1px solid var(--cu-card-border); }
.cu-score[hidden] { display: none; }

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

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

body.dark-theme .cu-round, body.dark-theme .cu-hint, body.dark-theme .cu-info { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
body.dark-theme .cu-row:not(.is-cur) { border-color: rgba(255, 255, 255, .16); }

@media (max-width: 420px) {
    .cu-main { padding-top: 88px; }
    .cu-mode { font-size: .84rem; gap: 6px; padding: 7px 6px; min-height: 60px; }
    .cu-mode small { font-size: .7rem; }
    .cu-wname { min-width: 6.4em; font-size: .88rem; }
    .cu-turn .cu-chip { padding: 4px 6px; font-size: .9rem; }
    .cu-map { width: 84px; height: 131px; }
}
@media (max-width: 359.98px) {
    .cu-modes { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .cu-banner { transition: none; }
    .cu-sweep-meter span { transition: none; }
}
