/* 텐트 퍼즐 — 차분한 캠핑장 녹색 테마(자체 테마. 사이트 라이트/다크 모드와 무관하게 같은 모습 — queens 와 같은 방식)
   나무·텐트·잔디는 전부 CSS data-URI SVG(이모지 비의존) */
#tn-game {
    --ink:#24372a; --sub:#5f7564; --line:#d5e2d2; --accent:#2f7d4a; --accent2:#c86a2c; --bad:#d1293d; --ok:#3f8f4f;
    --sand:#f4efdc; --sandline:#e3dbc0; --grass:#b5dc98; --treebg:#d6ebc4;
    position:relative; width:100%; margin:0 auto; border:1px solid var(--line); border-radius:20px; overflow:hidden;
    background:linear-gradient(180deg,#fbfdf8,#eef5ea); color:var(--ink); box-shadow:0 14px 36px rgba(30,70,40,.10); user-select:none; -webkit-user-select:none; }
#tn-game, #tn-game * { box-sizing:border-box; }
#tn-game [hidden] { display:none !important; }
#tn-game button { font-family:inherit; }
#tn-game button:focus-visible { outline:3px solid #3c8d55; outline-offset:2px; }

/* 아이콘(SVG) */
.tn-ico { display:inline-block; width:26px; height:26px; background:no-repeat center/contain; flex:none; }
.tn-ico-tent, .tn-cell.tent::after, .tn-demo .tn-cell.tent::after { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M1.8 20.6h20.4' stroke='%238a6a3a' stroke-width='1.4' stroke-linecap='round'/%3E%3Cpath d='M3 20L12 4.2 21 20z' fill='%23e3773a' stroke='%23a3481b' stroke-width='1.1' stroke-linejoin='round'/%3E%3Cpath d='M12 4.2L16.6 20H12z' fill='%23c85f27'/%3E%3Cpath d='M12 9.6L8.7 20h6.6z' fill='%236e2e12'/%3E%3C/svg%3E"); }
.tn-ico-tree, .tn-cell.tree::after { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='10.5' y='13.5' width='3' height='8' rx='.9' fill='%237a4f2a'/%3E%3Ccircle cx='12' cy='9.4' r='7' fill='%23379445' stroke='%23246b32' stroke-width='1'/%3E%3Ccircle cx='9.4' cy='7.3' r='2.4' fill='%235cbd62' opacity='.85'/%3E%3Ccircle cx='14.6' cy='11.6' r='1.5' fill='%232c7d3a' opacity='.7'/%3E%3C/svg%3E"); }
.tn-cell.grass::after, .tn-demo .tn-cell.grass::after { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233c7d2c' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M6.5 18.5c.3-2.6-.3-4.6-2-6.3M10 18.5c-.2-3.6.7-6.4 2.6-8.6M13.6 18.5c.1-2.8-.6-4.8-2.1-6.2M17 18.5c.3-2.9 1.6-5 3.4-6.4'/%3E%3C/svg%3E"); }
.tn-cell.tent.bad::after { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M1.8 20.6h20.4' stroke='%238a1b28' stroke-width='1.4' stroke-linecap='round'/%3E%3Cpath d='M3 20L12 4.2 21 20z' fill='%23e0394a' stroke='%238a1b28' stroke-width='1.1' stroke-linejoin='round'/%3E%3Cpath d='M12 4.2L16.6 20H12z' fill='%23bd2535'/%3E%3Cpath d='M12 9.6L8.7 20h6.6z' fill='%235a0f18'/%3E%3C/svg%3E"); }

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

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

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

/* 판 — (n+1)×(n+1) 격자: 왼쪽 위 빈칸 + 위 칸 숫자 + 왼쪽 줄 숫자 + n×n 칸. 폭은 화면·70vh·560px 중 작은 값 */
#tn-board { display:grid; width:min(100%, 70vh, 560px); aspect-ratio:1; margin:0 auto; gap:0;
    touch-action:none; -webkit-touch-callout:none; -webkit-tap-highlight-color:transparent; }
#tn-board:empty { background:#eef3ea; border-radius:10px; }
.tn-corner { min-width:0; min-height:0; }
.tn-clue { display:flex; align-items:center; justify-content:center; min-width:0; min-height:0; padding:0; border:0; background:none; cursor:pointer;
    font-weight:900; font-variant-numeric:tabular-nums; color:var(--ink); font-size:clamp(.8rem, 3.6vw, 1.15rem); touch-action:manipulation; }
#tn-board[data-n="9"] .tn-clue, #tn-board[data-n="10"] .tn-clue { font-size:clamp(.74rem, 3.2vw, 1.05rem); }
.tn-clue.tn-cr { justify-content:flex-end; padding-right:5%; }
.tn-clue.tn-cc { align-items:flex-end; padding-bottom:5%; }
.tn-clue span { display:inline-flex; align-items:center; justify-content:center; min-width:1.6em; height:1.6em; border-radius:999px; transition:color .15s, background .15s, opacity .15s; }
@media (hover:hover) { .tn-clue:hover span { background:#e6f1e1; } }
.tn-clue.done span { color:var(--ok); opacity:.55; }
.tn-clue.over span, .tn-clue.short span { color:#fff; background:var(--bad); opacity:1; }
.tn-clue.flash span { background:#fff1c2; }

.tn-cell { position:relative; min-width:0; min-height:0; cursor:pointer; background:var(--sand);
    border-top:1px solid var(--sandline); border-left:1px solid var(--sandline); }
.tn-cell.c0 { border-left:2px solid #9cb79a; }
.tn-cell.r0 { border-top:2px solid #9cb79a; }
.tn-cell.cl { border-right:2px solid #9cb79a; }
.tn-cell.rl { border-bottom:2px solid #9cb79a; }
.tn-cell.r0.c0 { border-top-left-radius:8px; }
.tn-cell.r0.cl { border-top-right-radius:8px; }
.tn-cell.rl.c0 { border-bottom-left-radius:8px; }
.tn-cell.rl.cl { border-bottom-right-radius:8px; }
.tn-cell::after { content:''; position:absolute; inset:6%; background:no-repeat center/contain; pointer-events:none; }
.tn-cell.tree { background:var(--treebg); cursor:default; }
.tn-cell.tree::after { inset:4%; }
.tn-cell.grass { background:var(--grass); }
.tn-cell.grass::after { inset:22%; opacity:.9; }
.tn-cell.tent::after { inset:8%; animation:tnDrop .16s ease-out; }
.tn-cell.tent.bad { background:#f9d6da; box-shadow:inset 0 0 0 2px var(--bad); }
.tn-cell.tree.bad { box-shadow:inset 0 0 0 2px var(--bad); background:#f6dcd6; }
.tn-cell.hl { animation:tnHint 1.4s ease-out; z-index:1; }
@keyframes tnDrop { from { transform:scale(.5); opacity:.2; } to { transform:scale(1); opacity:1; } }
@keyframes tnHint { 0%,60% { box-shadow:inset 0 0 0 3px #f2b705, 0 0 14px 3px #f2b70599; } 100% { box-shadow:inset 0 0 0 0 #f2b70500; } }
@media (hover:hover) { #tn-board:not(.clear) .tn-cell:not(.tree):hover { filter:brightness(1.04) saturate(1.1); } }
/* 단계 완성 — 텐트가 반짝이고 판이 초록으로 번진다 */
#tn-board.clear .tn-cell:not(.tree):not(.tent) { background:#cfe9bc; transition:background .45s; }
#tn-board.clear .tn-cell:not(.tree):not(.tent)::after { opacity:0; transition:opacity .3s; }
#tn-board.clear .tn-cell.tent::after { animation:tnPop .6s ease-out both; }
@keyframes tnPop { 0% { transform:scale(1); } 40% { transform:scale(1.24) translateY(-6%); } 100% { transform:scale(1); } }
@media (prefers-reduced-motion:reduce) { .tn-cell.tent::after, #tn-board.clear .tn-cell.tent::after, .tn-cell.hl { animation:none !important; } }

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

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

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

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

/* 인트로 미니 도해 — 첫 6×6 판의 정답 */
.tn-demo { display:grid; width:150px; aspect-ratio:1; margin:2px auto 14px; border-radius:8px; overflow:hidden; }
.tn-demo .tn-cell { cursor:default; border-top-width:1px; border-left-width:1px; border-radius:0 !important; }
.tn-demo .tn-cell::after { animation:none; }

#tn-newrecord { display:inline-block; margin-bottom:8px; padding:4px 12px; border-radius:999px; background:#f2c14e; color:#4a3700; font-size:.68rem; font-weight:900; letter-spacing:.08em; }
#tn-final { display:inline-block; font-size:3rem; font-weight:900; line-height:1.1; color:var(--accent); }
.tn-final-unit { font-size:1rem; font-weight:800; color:var(--accent); margin-left:3px; }
#tn-grade { margin:6px 0 4px; font-size:1.05rem; font-weight:900; color:var(--ink); }
#tn-detail { margin:10px 0 4px; font-size:.8rem; line-height:1.7; color:#55695a; }
#tn-detail b { color:var(--accent); }
.tn-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; }
.tn-chip { padding:5px 2px; border-radius:8px; background:#f1f7ee; border:1px solid #dfeadb; color:#55695a; }
.tn-chip i { display:block; font-style:normal; font-weight:900; color:#2f4a35; }
.tn-chip.hinted { background:#fff8e3; border-color:#ecdba6; }
.tn-chip.retry { background:#fbf1ee; border-color:#ebcfc6; }

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

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

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