/* Bule colorate — bubble shooter on a canvas (js/bule-colorate.js, rules in js/bule-colorate-rules.js).
   Theme-aware like the other game pages: tokens on :root, redefined under body.dark-theme. */
:root {
    --bc-accent: #6d28d9;
    --bc-accent-2: #7c3aed;
    --bc-accent-soft: #ede9fe;
    --bc-on-accent: #ffffff;
    --bc-hot: #db2777;
    --bc-page-bg: #f6f4fb;
    --bc-card-bg: #ffffff;
    --bc-card-border: #e2dcf0;
    --bc-muted: #5f5873;
    --bc-shadow: 0 10px 30px rgba(60, 30, 110, .12);
    --bc-field-1: #2a1f4f;
    --bc-field-2: #11162f;
    --bc-bar-bg: #1b1538;
    --bc-bar-fg: #f3f0ff;
    --bc-overlay: rgba(18, 10, 40, .58);
    --bc-gold: #f59e0b;
    --bc-bad: #e11d48;
}

body.dark-theme {
    --bc-accent: #a78bfa;
    --bc-accent-2: #c4b5fd;
    --bc-accent-soft: #261c45;
    --bc-on-accent: #160b33;
    --bc-hot: #f472b6;
    --bc-page-bg: #0e0b19;
    --bc-card-bg: #191430;
    --bc-card-border: #332a55;
    --bc-muted: #aea6c9;
    --bc-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --bc-field-1: #1a1336;
    --bc-field-2: #07091a;
    --bc-bar-bg: #120d27;
    --bc-overlay: rgba(4, 2, 12, .66);
    --bc-gold: #fbbf24;
    --bc-bad: #fb7185;
}

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

/* ---- hero ---- */
.bc-hero { text-align: center; padding: 4px 0 10px; }
.bc-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.2rem); margin: 0 0 6px; display: inline-flex; align-items: center; gap: 12px; }
.bc-hero-icon { width: 46px; height: 46px; border-radius: 14px; display: inline-grid; place-items: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, #7c3aed, #db2777); box-shadow: var(--bc-shadow); }
.bc-lead { max-width: 620px; margin: 0 auto; color: var(--bc-muted); font-size: .98rem; line-height: 1.5; }

/* ---- stage ---- */
.bc-stage {
    --bc-h: clamp(520px, calc(100vh - 110px), 860px);
    position: relative;
    width: 100%;
    max-width: 560px;
    height: var(--bc-h);
    /* no taller than the field needs: 22 × 27.6 units plus the two bars */
    height: min(var(--bc-h), calc(min(100vw, 560px) * 1.2545 + 118px));
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    border-radius: 22px;
    overflow: hidden;
    background: linear-gradient(180deg, var(--bc-field-1), var(--bc-field-2));
    box-shadow: var(--bc-shadow);
    color: var(--bc-bar-fg);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
@supports (height: 100svh) { .bc-stage { --bc-h: clamp(520px, calc(100svh - 110px), 860px); } }
@media (max-width: 575.98px) {
    .bc-stage { width: calc(100% + 24px); margin: 0 -12px; border-radius: 0; }
}
.bc-stage:fullscreen { max-width: none; width: 100%; height: 100%; border-radius: 0; margin: 0; }
.bc-stage:-webkit-full-screen { max-width: none; width: 100%; height: 100%; border-radius: 0; margin: 0; }
.bc-stage.is-max { position: fixed; inset: 0; z-index: 1052; max-width: none; width: 100vw; height: 100vh; margin: 0; border-radius: 0; }
@supports (height: 100dvh) { .bc-stage.is-max { height: 100dvh; } }

.bc-top, .bc-bottom { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bc-bar-bg); }
.bc-info { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.bc-level { font-weight: 800; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-score { font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums; color: #fde68a; margin-left: auto; padding-right: 4px; }
.bc-tools { display: flex; gap: 6px; }
.bc-round { width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .16); display: grid; place-items: center; background: rgba(255, 255, 255, .08); color: #fff; font-size: 16px; cursor: pointer; touch-action: manipulation; padding: 0; }
.bc-round:hover { background: rgba(124, 58, 237, .8); }
.bc-round:focus-visible, .bc-tool:focus-visible, .bc-btn:focus-visible, .bc-lv:focus-visible { outline: 3px solid #fde68a; outline-offset: 2px; }
.bc-round span[hidden], .bc-round[hidden] { display: none; }

.bc-view { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.bc-canvas { display: block; touch-action: none; cursor: crosshair; outline: none; }
.bc-banner { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%) scale(.9); margin: 0; padding: 10px 18px; border-radius: 16px; background: rgba(15, 10, 35, .78); color: #fff; font-weight: 800; font-size: 1.3rem; text-align: center; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.bc-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.bc-bottom { gap: 8px; }
.bc-meter { flex: 1.2; min-width: 0; display: flex; align-items: center; gap: 6px; }
.bc-meter-icon { color: #f0abfc; font-size: 15px; }
.bc-meter-bar { flex: 1; height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.bc-meter-fill { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, #f472b6, #a78bfa, #60a5fa); transition: width .3s; }
.bc-meter.is-full .bc-meter-fill { animation: bc-glow 1s ease-in-out infinite alternate; }
@keyframes bc-glow { from { filter: brightness(1); } to { filter: brightness(1.5); } }
.bc-drop { flex: none; display: flex; align-items: center; gap: 5px; }
.bc-drop-icon { color: #fca5a5; font-size: 14px; }
.bc-drop-dots { display: flex; gap: 3px; }
.bc-drop-dots span { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .85); }
.bc-drop-dots span.is-used { background: rgba(255, 255, 255, .18); }
.bc-drop.is-close .bc-drop-dots span:not(.is-used) { background: #fb7185; }
.bc-tool { flex: none; min-height: 44px; min-width: 44px; padding: 4px 10px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .08); color: #fff; font-weight: 700; font-size: .85rem; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; touch-action: manipulation; }
.bc-tool:hover { background: rgba(124, 58, 237, .8); }
.bc-tool:disabled { opacity: .45; cursor: default; }
@media (max-width: 420px) {
    .bc-tool-label { display: none; }
    .bc-tool { padding: 4px 8px; }
}
.bc-tool b { font-variant-numeric: tabular-nums; }

/* ---- overlays (inside the stage, so they work in full screen too) ---- */
.bc-overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 12px; background: var(--bc-overlay); animation: bc-fade .2s ease-out; }
.bc-overlay[hidden] { display: none; }
@keyframes bc-fade { from { opacity: 0; } to { opacity: 1; } }
.bc-card { width: 100%; max-width: 380px; max-height: 100%; overflow: auto; padding: 18px 16px 16px; border-radius: 22px; background: var(--bc-card-bg); color: var(--text-color); text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: 9px; }
.bc-card-wide { max-width: 520px; }
.bc-card h2 { font-weight: 800; font-size: 1.35rem; margin: 0; font-style: normal; font-family: inherit; }
.bc-sub { margin: 0; color: var(--bc-muted); line-height: 1.45; }
.bc-sub b { color: var(--text-color); }
.bc-over-icon { font-size: 36px; color: var(--bc-gold); line-height: 1; }
.bc-over-icon.is-bad { color: var(--bc-bad); }
.bc-over-icon span[hidden] { display: none; }
.bc-stars { margin: 0; font-size: 30px; letter-spacing: 6px; color: var(--bc-gold); min-height: 36px; }
.bc-stars .is-off { color: var(--bc-card-border); }

.bc-btn { min-height: 48px; padding: 8px 16px; border-radius: 14px; border: 1px solid var(--bc-card-border); background: var(--bc-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; }
.bc-btn:hover { border-color: var(--bc-accent); }
.bc-btn[hidden] { display: none; }
.bc-btn small { font-weight: 600; opacity: .85; }
.bc-btn-primary { background: var(--bc-accent); border-color: var(--bc-accent); color: var(--bc-on-accent); }
.bc-btn-primary:hover { background: var(--bc-accent-2); border-color: var(--bc-accent-2); }
.bc-btn-accent { background: linear-gradient(135deg, #7c3aed, #db2777); border: 0; color: #fff; }
.bc-btn-ghost { background: transparent; border-color: transparent; color: var(--bc-muted); }
.bc-wide { width: 100%; }

.bc-levels { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; max-height: min(52vh, 420px); overflow-y: auto; padding: 2px; }
@media (min-width: 480px) { .bc-levels { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.bc-lv { position: relative; min-height: 52px; border-radius: 12px; border: 1px solid var(--bc-card-border); background: var(--bc-page-bg); color: inherit; font-weight: 800; font-size: 1.05rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 2px; touch-action: manipulation; }
.bc-lv:not(:disabled) { border-color: var(--bc-accent); background: var(--bc-accent-soft); }
.bc-lv:hover:not(:disabled) { border-color: var(--bc-accent-2); }
.bc-lv small { font-size: .62rem; letter-spacing: 1px; color: var(--bc-gold); line-height: 1; min-height: .7rem; }
.bc-lv small .is-off { color: var(--bc-card-border); }
.bc-lv:disabled { opacity: .45; cursor: default; }
.bc-lv.is-cur { background: var(--bc-accent); border-color: var(--bc-accent); color: var(--bc-on-accent); }
.bc-lv.is-cur small, .bc-lv.is-cur small .is-off { color: var(--bc-on-accent); }

.bc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }

/* ---- below the stage ---- */
.bc-record { text-align: center; color: var(--bc-muted); margin: 12px 0 0; font-size: .92rem; min-height: 1.4em; }
.bc-record b { color: var(--text-color); }
.bc-reset-wrap { text-align: center; margin: 2px 0 0; }
.bc-reset-wrap[hidden] { display: none; }
.bc-link { border: 0; background: none; color: var(--bc-muted); text-decoration: underline; font-size: .85rem; cursor: pointer; padding: 6px; }
.bc-help { max-width: 640px; margin: 16px auto 0; padding: 12px 16px; border-radius: 16px; background: var(--bc-card-bg); border: 1px solid var(--bc-card-border); }
.bc-help summary { font-weight: 800; cursor: pointer; min-height: 32px; display: flex; align-items: center; gap: 8px; }
.bc-help summary svg, .bc-help summary i { color: var(--bc-accent); }
.bc-help ul { margin: 10px 0 0; padding-left: 20px; line-height: 1.55; }
.bc-help li { margin-bottom: 6px; }
.bc-help kbd { background: var(--bc-accent-soft); color: inherit; border: 1px solid var(--bc-card-border); border-radius: 6px; padding: 1px 6px; font-size: .85em; }
.bc-credit { color: var(--bc-muted); font-size: .84rem; margin: 8px 0 0; line-height: 1.45; }
.bc-powered { text-align: center; color: var(--bc-muted); font-size: .88rem; margin: 18px 0 0; }
.bc-powered a { color: var(--bc-accent); }

@media (prefers-reduced-motion: reduce) {
    .bc-overlay, .bc-banner, .bc-meter-fill { animation: none !important; transition: none !important; }
}
