/* 다리 놓기 퍼즐 — 바다 위 섬 테마(자체 테마. 사이트 라이트/다크 모드와 무관하게 같은 모습 — tents 와 같은 방식)
   바다 = CSS 배경, 섬·다리 = SVG 도형(이모지 비의존) */
#hs-game {
    --ink:#173a42; --sub:#557079; --line:#cfe1e3; --accent:#13808a; --accent2:#c98a3f; --bad:#d1293d; --ok:#2f8f6f;
    --sea1:#3fb5b8; --sea2:#1f8e9c; --sand:#f3e2b4; --sandline:#c9a46a; --wood:#b07a43; --woodseam:#6f4521;
    position:relative; width:100%; margin:0 auto; border:1px solid var(--line); border-radius:20px; overflow:hidden;
    background:linear-gradient(180deg,#f8fcfc,#ebf4f4); color:var(--ink); box-shadow:0 14px 36px rgba(20,70,80,.10); user-select:none; -webkit-user-select:none; }
#hs-game, #hs-game * { box-sizing:border-box; }
#hs-game [hidden] { display:none !important; }
#hs-game button { font-family:inherit; }
#hs-game button:focus-visible { outline:3px solid #2a9aa3; outline-offset:2px; }

/* 브랜드 아이콘(SVG 다리) */
.hs-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='%232aa3ab'/%3E%3Cpath d='M7 14h14' stroke='%23b07a43' stroke-width='4'/%3E%3Cpath d='M7 14h14' stroke='%236f4521' stroke-width='4' stroke-dasharray='.8 3'/%3E%3Ccircle cx='7' cy='14' r='4.4' fill='%23f3e2b4' stroke='%23c9a46a' stroke-width='1.2'/%3E%3Ccircle cx='21' cy='14' r='4.4' fill='%23f3e2b4' stroke='%23c9a46a' stroke-width='1.2'/%3E%3C/svg%3E"); }

.hs-toolbar { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:12px 16px; background:linear-gradient(110deg,#e9f6f6,#dcefef); border-bottom:1px solid var(--line); }
.hs-brand { display:flex; align-items:center; gap:10px; font-weight:900; letter-spacing:.14em; font-size:.72rem; color:#185e66; }
.hs-brand small { display:block; margin-top:2px; font-size:.65rem; font-weight:600; color:#5e8a90; letter-spacing:.02em; }
.hs-tools { display:flex; gap:6px; }
.hs-tools button { border:1px solid #c3dcde; background:#fff; color:#1e5961; border-radius:8px; padding:7px 10px; font-size:.72rem; font-weight:700; cursor:pointer; white-space:nowrap; }
.hs-tools button b { font-weight:800; color:var(--accent); }
.hs-tools button[aria-pressed="false"] b { color:#97aaad; }

.hs-hud { display:grid; grid-template-columns:repeat(5,1fr); gap:6px; padding:12px 12px 8px; align-items:center; }
.hs-hud > div { text-align:center; border-left:1px solid var(--line); min-width:0; }
.hs-hud > div:first-child { border-left:0; }
.hs-hud small { display:block; font-size:.62rem; font-weight:600; color:#5e8a90; letter-spacing:.02em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.hs-hud strong { display:block; line-height:1.4; font-size:1.05rem; font-weight:800; font-variant-numeric:tabular-nums; white-space:nowrap; }
.hs-hud .hs-scorebox strong { color:var(--accent); font-size:1.35rem; }
#hs-time.warn { color:var(--bad); }
.hs-lives { display:flex !important; justify-content:center; gap:3px; height:1.47em; align-items:center; }
.hs-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"); }
.hs-lives i.off { opacity:.18; filter:grayscale(1); }
.hs-track { margin:0 16px 12px; height:6px; border-radius:3px; background:#d6e8e9; overflow:hidden; }
#hs-progress { display:block; height:100%; width:0; border-radius:3px; background:linear-gradient(90deg,#3fb5b8,#c98a3f); transition:width .3s ease; }

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

/* 판 — 정사각 SVG. 폭은 화면·70vh·560px 중 작은 값 */
#hs-board { position:relative; width:min(100%, 70vh, 560px); aspect-ratio:1; margin:0 auto; border-radius:12px; overflow:hidden;
    background:radial-gradient(120% 90% at 30% 20%, var(--sea1), var(--sea2)); box-shadow:inset 0 0 0 1px rgba(10,70,80,.25), inset 0 6px 18px rgba(255,255,255,.12);
    touch-action:none; -webkit-touch-callout:none; -webkit-tap-highlight-color:transparent; cursor:pointer; }
#hs-board:empty { background:linear-gradient(180deg,#d9eeee,#c9e4e5); }
.hs-svg { display:block; width:100%; height:100%; }
.hs-dot { fill:rgba(255,255,255,.26); }

/* 다리 — 나무 판자(바탕 + 이음매 점선) */
.hs-plank { stroke:var(--wood); stroke-linecap:butt; }
.hs-seam { stroke:var(--woodseam); stroke-dasharray:.03 .14; stroke-linecap:butt; opacity:.75; }
.hs-edge.bad .hs-plank { stroke:var(--bad); }
.hs-edge.blocked .hs-plank { stroke:#ff6b7d; animation:hsBlink .7s ease-out; }
.hs-edge.hl .hs-plank { stroke:#f2b705; }
.hs-edge.hl .hs-seam { stroke:#8a5a00; }
.hs-ghost { stroke:#ffffff; stroke-width:.09; stroke-dasharray:.14 .1; stroke-linecap:round; opacity:0; pointer-events:none; }
.hs-ghost.on { opacity:.85; }
@keyframes hsBlink { 0%,50% { opacity:1; } 25%,75% { opacity:.35; } 100% { opacity:1; } }

/* 섬 */
.hs-ring { fill:rgba(10,60,70,.18); }
.hs-sand { fill:var(--sand); stroke:var(--sandline); stroke-width:.05; transition:fill .15s, opacity .15s; }
.hs-num { font-size:.44px; font-weight:900; fill:#4a3416; font-family:inherit; pointer-events:none; transition:fill .15s, opacity .15s; }
#hs-board[data-n="11"] .hs-num, #hs-board[data-n="12"] .hs-num { font-size:.46px; }
.hs-isl.done .hs-sand { fill:#e9e2cc; opacity:.72; }
.hs-isl.done .hs-num { fill:#8c8268; opacity:.75; }
.hs-isl.over .hs-sand { fill:var(--bad); stroke:#8a1b28; }
.hs-isl.over .hs-num { fill:#fff; }
.hs-isl.sel .hs-ring { fill:#ffe08a; }
.hs-isl.sel .hs-sand { stroke:#d99a00; stroke-width:.08; }
.hs-isl.nbr .hs-ring { fill:rgba(255,236,170,.55); }
.hs-isl.hl .hs-ring { fill:#f2b705; }
@media (hover:hover) { #hs-board:not(.clear) .hs-isl:hover .hs-sand { filter:brightness(1.05); } }
/* 단계 완성 — 섬이 차례로 통통 */
#hs-board.clear .hs-isl .hs-sand { fill:#fff1c6; opacity:1; }
#hs-board.clear .hs-isl .hs-num { fill:#4a3416; opacity:1; }
#hs-board.clear .hs-plank { stroke:#c58a4c; }
#hs-board.clear .hs-isl { animation:hsPop .6s ease-out both; transform-box:fill-box; transform-origin:center; }
@keyframes hsPop { 0% { transform:scale(1); } 40% { transform:scale(1.18); } 100% { transform:scale(1); } }
@media (prefers-reduced-motion:reduce) { #hs-board.clear .hs-isl, .hs-edge.blocked .hs-plank { animation:none !important; } }

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

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

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

.hs-overlay { position:absolute; inset:0; z-index:12; display:none; align-items:center; justify-content:center; padding:22px; background:linear-gradient(180deg,#f6fbfbb3,#e9f3f3f0 45%); backdrop-filter:blur(2px); -webkit-backdrop-filter:blur(2px); }
.hs-overlay.on { display:flex; }
.hs-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(20,70,80,.16); }
.hs-eyebrow { display:block; font-size:.66rem; font-weight:800; letter-spacing:.12em; color:var(--accent); margin-bottom:10px; }
.hs-panel h2 { margin:0 0 12px; font-size:1.32rem; font-weight:900; color:var(--ink); }
.hs-panel p { margin:0 0 14px; font-size:.86rem; line-height:1.65; color:#48636a; }
.hs-panel p b { color:var(--accent); }
.hs-panel p small { color:#5e8a90; }
.hs-panel > small { color:#5e8a90; font-size:.74rem; }
.hs-best { min-height:1em; margin-bottom:6px; font-size:.78rem; font-weight:700; color:var(--accent); }
.hs-primary { width:100%; min-height:52px; margin-top:6px; border:0; border-radius:12px; background:linear-gradient(135deg,#1f9aa4,#146c78); color:#fff; font-size:1rem; font-weight:900; cursor:pointer; box-shadow:0 4px 0 #0f4f58; }
.hs-primary:active { transform:translateY(2px); box-shadow:0 2px 0 #0f4f58; }

/* 인트로 미니 도해 — 첫 7×7 판의 정답 */
.hs-demo { width:150px; aspect-ratio:1; margin:2px auto 14px; border-radius:10px; overflow:hidden; background:radial-gradient(120% 90% at 30% 20%, var(--sea1), var(--sea2)); }
.hs-demo .hs-isl.done .hs-sand { fill:var(--sand); opacity:1; }
.hs-demo .hs-isl.done .hs-num { fill:#4a3416; opacity:1; }

#hs-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; }
#hs-final { display:inline-block; font-size:3rem; font-weight:900; line-height:1.1; color:var(--accent); }
.hs-final-unit { font-size:1rem; font-weight:800; color:var(--accent); margin-left:3px; }
#hs-grade { margin:6px 0 4px; font-size:1.05rem; font-weight:900; color:var(--ink); }
#hs-detail { margin:10px 0 4px; font-size:.8rem; line-height:1.7; color:#4e676d; }
#hs-detail b { color:var(--accent); }
.hs-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; }
.hs-chip { padding:5px 2px; border-radius:8px; background:#eef6f6; border:1px solid #d7e8e9; color:#4e676d; }
.hs-chip i { display:block; font-style:normal; font-weight:900; color:#1d4d54; }
.hs-chip.hinted { background:#fff8e3; border-color:#ecdba6; }
.hs-chip.retry { background:#fbf1ee; border-color:#ebcfc6; }

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

@media (max-width:420px) {
    .hs-toolbar { padding:10px 10px; }
    .hs-brand { gap:7px; font-size:.64rem; letter-spacing:.08em; }
    .hs-tools button { padding:6px 8px; font-size:.68rem; }
    .hs-hud { gap:3px; padding:10px 4px 6px; }
    .hs-hud small { font-size:.56rem; letter-spacing:0; }
    .hs-hud strong { font-size:.9rem; }
    .hs-hud .hs-scorebox strong { font-size:1.1rem; }
    .hs-lives i { width:12px; height:11px; }
    .hs-track { margin:0 10px 10px; }
    #hs-stage { margin:0 4px; padding:8px 4px; border-radius:12px; }
    .hs-controls { padding:10px 6px; gap:6px; }
    .hs-controls button { min-height:46px; font-size:.78rem; }
}

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