/* 이진 퍼즐(타쿠주·비나이로) — 시카쿠(css/shikaku.css)와 같은 셸·테마, 접두어 bp-
   (자체 테마. 사이트 라이트/다크 모드와 무관하게 같은 모습). 칸·원·잠금 점 = SVG 도형(이모지 비의존) */
#bp-game {
    --ink:#1f2a44; --sub:#5a6683; --line:#d6ddec; --accent:#2f62d6; --accent2:#f0a830; --bad:#d1293d; --ok:#2f8f5f;
    position:relative; width:100%; margin:0 auto; border:1px solid var(--line); border-radius:20px; overflow:hidden;
    background:linear-gradient(180deg,#f9fbff,#edf1fa); color:var(--ink); box-shadow:0 14px 36px rgba(30,50,110,.10); user-select:none; -webkit-user-select:none; }
#bp-game, #bp-game * { box-sizing:border-box; }
#bp-game [hidden] { display:none !important; }
#bp-game button { font-family:inherit; }
#bp-game button:focus-visible { outline:3px solid #4b7bea; outline-offset:2px; }

/* 브랜드 아이콘(SVG 2×2 원 — 주황·파랑 엇갈림) */
.bp-ico { display:inline-block; width:28px; height:28px; flex:none; background:no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28'%3E%3Crect x='1' y='1' width='26' height='26' rx='7' fill='%231f2a44'/%3E%3Ccircle cx='9.5' cy='9.5' r='4.6' fill='%23f28c28'/%3E%3Ccircle cx='18.5' cy='9.5' r='4.6' fill='%233a78e0'/%3E%3Ccircle cx='9.5' cy='18.5' r='4.6' fill='%233a78e0'/%3E%3Ccircle cx='18.5' cy='18.5' r='4.6' fill='%23f28c28'/%3E%3C/svg%3E"); }

.bp-toolbar { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:12px 16px; background:linear-gradient(110deg,#eef3ff,#e2e9f8); border-bottom:1px solid var(--line); }
.bp-brand { display:flex; align-items:center; gap:10px; font-weight:900; letter-spacing:.14em; font-size:.72rem; color:#22448f; }
.bp-brand small { display:block; margin-top:2px; font-size:.65rem; font-weight:600; color:#6475a0; letter-spacing:.02em; }
.bp-tools { display:flex; gap:6px; }
.bp-tools button { border:1px solid #c9d3ea; background:#fff; color:#28427d; border-radius:8px; padding:7px 10px; font-size:.72rem; font-weight:700; cursor:pointer; white-space:nowrap; }
.bp-tools button b { font-weight:800; color:var(--accent); }
.bp-tools button[aria-pressed="false"] b { color:#9aa6c0; }

.bp-hud { display:grid; grid-template-columns:repeat(5,1fr); gap:6px; padding:12px 12px 8px; align-items:center; }
.bp-hud > div { text-align:center; border-left:1px solid var(--line); min-width:0; }
.bp-hud > div:first-child { border-left:0; }
.bp-hud small { display:block; font-size:.62rem; font-weight:600; color:#6475a0; letter-spacing:.02em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bp-hud strong { display:block; line-height:1.4; font-size:1.05rem; font-weight:800; font-variant-numeric:tabular-nums; white-space:nowrap; }
.bp-hud .bp-scorebox strong { color:var(--accent); font-size:1.35rem; }
#bp-time.warn { color:var(--bad); }
.bp-lives { display:flex !important; justify-content:center; gap:3px; height:1.47em; align-items:center; }
.bp-lives i { width:15px; height:14px; background:no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath d='M12 21S1.5 14.3 1.5 7.4A5.4 5.4 0 0 1 12 4.6a5.4 5.4 0 0 1 10.5 2.8C22.5 14.3 12 21 12 21z' fill='%23e0485a'/%3E%3C/svg%3E"); }
.bp-lives i.off { opacity:.18; filter:grayscale(1); }
.bp-track { margin:0 16px 12px; height:6px; border-radius:3px; background:#dbe2f2; overflow:hidden; }
#bp-progress { display:block; height:100%; width:0; border-radius:3px; background:linear-gradient(90deg,#3a78e0,#f28c28); transition:width .3s ease; }

#bp-stage { position:relative; margin:0 12px; padding:10px; border:1px solid var(--line); border-radius:14px; background:#fff; }
.bp-goal { display:flex; justify-content:center; gap:18px; margin:0 0 8px; font-size:.78rem; font-weight:700; color:var(--sub); }
.bp-goal b { color:var(--ink); font-variant-numeric:tabular-nums; }
.bp-goal b.full { color:var(--ok); }
.bp-goal b.warn { color:var(--bad); }

/* 판 — 정사각 SVG. 폭은 화면·70vh·560px 중 작은 값. 탭은 누른 칸에서 그대로 뗄 때만(판 위에서 스크롤 가능) */
#bp-board { position:relative; width:min(100%, 70vh, 560px); aspect-ratio:1; margin:0 auto; border-radius:10px; overflow:hidden;
    background:#fdfcf7; box-shadow:inset 0 0 0 2px #3c4f7d;
    touch-action:manipulation; -webkit-touch-callout:none; -webkit-tap-highlight-color:transparent; cursor:pointer; }
#bp-board:empty { background:linear-gradient(180deg,#eef2fb,#e2e8f6); box-shadow:none; }
.bp-svg { display:block; width:100%; height:100%; }

/* 칸 — 빈칸은 옅은 타일, 주황·파랑은 원 */
.bp-bg { fill:#e9edf6; stroke:none; transition:fill .12s; }
.bp-disc { fill:transparent; stroke:transparent; stroke-width:.05; transition:fill .1s, stroke .1s; }
.bp-c.a .bp-disc { fill:#f28c28; stroke:#c86812; }
.bp-c.b .bp-disc { fill:#3a78e0; stroke:#2152a8; }
.bp-c.a .bp-bg { fill:#fde9d4; }
.bp-c.b .bp-bg { fill:#dde8fb; }
/* 처음 주어진 칸 — 진한 테두리 + 가운데 흰 점 */
.bp-c.lock .bp-disc { stroke-width:.08; }
.bp-c.lock.a .bp-disc { stroke:#9a4c08; }
.bp-c.lock.b .bp-disc { stroke:#173d80; }
.bp-c.lock .bp-bg { fill:#dfe4ef; }
.bp-pin { fill:rgba(255,255,255,.92); pointer-events:none; }
/* 규칙 위반 — 3연속 칸은 빨간 고리, 줄 위반(개수 초과·같은 줄)은 빨간 띠 */
.bp-c.bad .bp-bg { fill:#ffd9de; }
.bp-c.bad .bp-disc { stroke:var(--bad); stroke-width:.1; }
.bp-band { fill:rgba(209,41,61,.13); stroke:var(--bad); stroke-width:.05; stroke-dasharray:.16 .1; pointer-events:none; }
.bp-bands { pointer-events:none; }
.bp-c.hl .bp-bg { stroke:#f2b705; stroke-width:.1; animation:bpGlow 1.6s ease-out; }
@keyframes bpGlow { 0%,40% { stroke-opacity:1; } 100% { stroke-opacity:.5; } }
.bp-c.nope { animation:bpNope .35s ease-out; transform-box:fill-box; transform-origin:center; }
@keyframes bpNope { 0%,100% { transform:translateX(0); } 25% { transform:translateX(-.06px); } 75% { transform:translateX(.06px); } }

/* 단계 완성 — 원이 통통 */
#bp-board.clear .bp-disc { animation:bpPop .6s ease-out both; transform-box:fill-box; transform-origin:center; }
@keyframes bpPop { 0% { transform:scale(1); } 40% { transform:scale(1.12); } 100% { transform:scale(1); } }
@media (prefers-reduced-motion:reduce) { #bp-board.clear .bp-disc, .bp-c.hl .bp-bg, .bp-c.nope { animation:none !important; } }

#bp-hint { margin:10px 6px 0; text-align:center; font-size:.78rem; font-weight:600; color:#5a6683; min-height:18px; }

.bp-controls { display:grid; grid-template-columns:repeat(6,1fr); gap:8px; padding:12px; }
.bp-controls button { grid-column:span 2; min-width:0; min-height:50px; border-radius:10px; border:1px solid #c9d3ea; background:#fff; color:#24396d; font-size:.86rem; font-weight:800; cursor:pointer; touch-action:manipulation; box-shadow:0 3px 0 #d5dcee; transition:transform .08s; }
.bp-controls #bp-newboard, .bp-controls #bp-giveup { grid-column:span 3; }
.bp-controls button:active { transform:translateY(2px); box-shadow:0 1px 0 #d5dcee; }
.bp-controls button:disabled { opacity:.42; cursor:default; box-shadow:none; }
.bp-controls button small { display:block; margin-top:3px; font-size:.62rem; font-weight:600; opacity:.7; }
#bp-hintbtn { background:#fff8e3; border-color:#ecdba6; }
#bp-giveup { background:#fbf1ee; border-color:#ebcfc6; }

#bp-toast { position:absolute; left:50%; bottom:40px; transform:translate(-50%,10px); z-index:11; max-width:86%; padding:9px 15px; border-radius:999px; background:#1f2a44e8; color:#fff; font-size:.76rem; font-weight:700; text-align:center; opacity:0; pointer-events:none; transition:opacity .18s,transform .18s; }
#bp-toast.on { opacity:1; transform:translate(-50%,0); }

.bp-overlay { position:absolute; inset:0; z-index:12; display:none; align-items:center; justify-content:center; padding:22px; background:linear-gradient(180deg,#f7f9ffb3,#e9eef9f0 45%); backdrop-filter:blur(2px); -webkit-backdrop-filter:blur(2px); }
.bp-overlay.on { display:flex; }
.bp-panel { width:100%; max-width:400px; max-height:100%; overflow:auto; text-align:center; padding:22px 20px; border:1px solid var(--line); border-radius:16px; background:#fff; box-shadow:0 16px 40px rgba(30,50,110,.16); }
.bp-eyebrow { display:block; font-size:.66rem; font-weight:800; letter-spacing:.12em; color:var(--accent); margin-bottom:10px; }
.bp-panel h2 { margin:0 0 12px; font-size:1.32rem; font-weight:900; color:var(--ink); }
.bp-panel p { margin:0 0 14px; font-size:.86rem; line-height:1.65; color:#4a5674; }
.bp-panel p b { color:var(--accent); }
.bp-panel p small { color:#6475a0; }
.bp-panel > small { color:#6475a0; font-size:.74rem; }
.bp-best { min-height:1em; margin-bottom:6px; font-size:.78rem; font-weight:700; color:var(--accent); }
.bp-primary { width:100%; min-height:52px; margin-top:6px; border:0; border-radius:12px; background:linear-gradient(135deg,#3f74e8,#2449a8); color:#fff; font-size:1rem; font-weight:900; cursor:pointer; box-shadow:0 4px 0 #1a3478; }
.bp-primary:active { transform:translateY(2px); box-shadow:0 2px 0 #1a3478; }

/* 인트로 미니 도해 — 첫 6×6 판의 정답 */
.bp-demo { width:150px; aspect-ratio:1; margin:2px auto 14px; border-radius:8px; overflow:hidden; background:#fdfcf7; box-shadow:inset 0 0 0 2px #3c4f7d; }

#bp-newrecord { display:table; margin:0 auto 8px; padding:4px 12px; border-radius:999px; background:#f2c14e; color:#4a3700; font-size:.68rem; font-weight:900; letter-spacing:.08em; }
#bp-final { display:inline-block; font-size:3rem; font-weight:900; line-height:1.1; color:var(--accent); }
.bp-final-unit { font-size:1rem; font-weight:800; color:var(--accent); margin-left:3px; }
#bp-grade { margin:6px 0 4px; font-size:1.05rem; font-weight:900; color:var(--ink); }
#bp-detail { margin:10px 0 4px; font-size:.8rem; line-height:1.7; color:#4f5a76; }
#bp-detail b { color:var(--accent); }
.bp-chips { display:grid; grid-template-columns:repeat(4,1fr); gap:5px; margin:10px 0 6px; font-size:.7rem; line-height:1.4; font-variant-numeric:tabular-nums; }
.bp-chip { padding:5px 2px; border-radius:8px; background:#eef2fb; border:1px solid #d9e0f0; color:#4f5a76; }
.bp-chip i { display:block; font-style:normal; font-weight:900; color:#24396d; }
.bp-chip.hinted { background:#fff8e3; border-color:#ecdba6; }
.bp-chip.retry { background:#fbf1ee; border-color:#ebcfc6; }

/* 규칙 안내 — 전역 .answer_shadow 는 가운데 정렬·17.6px 이라 눌러 준다 */
.bp-guide { text-align:left; line-height:1.7; margin-top:16px; }
.bp-guide h3 { font-size:1rem; margin:0 0 8px; }
.bp-guide p { font-size:.88rem; margin:0 0 8px; }
.bp-guide small { display:block; font-size:.8rem; opacity:.85; }

@media (max-width:420px) {
    .bp-toolbar { padding:10px 10px; }
    .bp-brand { gap:7px; font-size:.64rem; letter-spacing:.08em; }
    .bp-tools button { padding:6px 8px; font-size:.68rem; }
    .bp-hud { gap:3px; padding:10px 4px 6px; }
    .bp-hud small { font-size:.56rem; letter-spacing:0; }
    .bp-hud strong { font-size:.9rem; }
    .bp-hud .bp-scorebox strong { font-size:1.1rem; }
    .bp-lives i { width:12px; height:11px; }
    .bp-track { margin:0 10px 10px; }
    #bp-stage { margin:0 2px; padding:8px 2px; border-radius:12px; }
    .bp-controls { padding:10px 6px; gap:6px; }
    .bp-controls button { min-height:46px; font-size:.78rem; }
}
/* 좁은 폰(≤360px) — 12×12 칸이 24px(WCAG 2.2 최소 터치 크기) 아래로 내려가지 않게 판 둘레 여백을 걷어 낸다 */
@media (max-width:360px) {
    #bp-stage { margin:0; padding:8px 0; border-left:0; border-right:0; border-radius:0; }
    #bp-board { border-radius:6px; }
}

/* ── PC(≥860px) 2단 배치 — 판은 왼쪽, HUD·조작은 오른쪽 세로 열 ── */
@media (min-width:860px) {
    #bp-game { display:grid; grid-template-columns:minmax(0,1fr) 290px; grid-template-rows:auto auto auto minmax(0,1fr);
        grid-template-areas:"tb tb" "st hud" "st tr" "st ct"; }
    .bp-toolbar { grid-area:tb; }
    #bp-stage { grid-area:st; margin:12px 0 12px 12px; padding:14px 12px 12px; display:flex; flex-direction:column; justify-content:center; }
    .bp-hud { grid-area:hud; grid-template-columns:1fr 1fr; gap:8px; padding:14px 14px 6px 12px; align-content:start; }
    .bp-hud > div { border-left:0; padding:9px 6px 8px; border-radius:10px; background:#fff; border:1px solid var(--line); }
    .bp-hud .bp-scorebox { grid-column:1 / -1; order:-1; padding:10px 6px; }
    .bp-hud strong { font-size:1.12rem; }
    .bp-hud .bp-scorebox strong { font-size:1.7rem; }
    .bp-track { grid-area:tr; margin:8px 14px 8px 12px; }
    .bp-controls { grid-area:ct; grid-template-columns:1fr 1fr; align-self:end; gap:8px; padding:8px 14px 14px 12px; }
    .bp-controls button, .bp-controls #bp-newboard, .bp-controls #bp-giveup { grid-column:auto; }
    .bp-controls #bp-hintbtn { grid-column:1 / -1; }
}
