/* 섬 다리 잇기 — 테마는 body.t-* 변수로 */
:root {
  --bg: #062033; --bg2: #0e4a6b; --panel: #0b2a40; --panel2: #123a55; --line: rgba(125, 211, 252, 0.2);
  --text: #f0f9ff; --dim: #9fc3d8; --accent: #7dd3fc; --accent2: #bae6fd; --acc-rgb: 125, 211, 252; --ink: #062033; --good: #0e7490; --bad: #f87171; --gold: #facc15;
  --r: 16px;
  --sea: #0d5a7d; --sea2: #0a4866; --dot: rgba(255, 255, 255, 0.16);
  --isl: #fde68a; --isl-line: #b45309; --isl-txt: #422006; --isl-ok: #34d399; --isl-ok-txt: var(--ink); --bridge: #f5deb3; --bridge-edge: #7c4a1e;
}
body.t-sunset { --bg: #1f0b0b; --bg2: #6b2410; --panel: #2c1210; --panel2: #3d1a14; --line: rgba(253, 186, 116, 0.22); --accent: #fdba74; --accent2: #fed7aa; --acc-rgb: 253, 186, 116; --ink: #2c1210; --good: #c2410c;
  --sea: #7c2d12; --sea2: #5c210d; --dot: rgba(254, 215, 170, 0.18); --isl: #fef3c7; --isl-line: #92400e; --isl-ok: #fb923c; --isl-ok-txt: #2c1210; --bridge: #fde68a; --bridge-edge: #451a03; }
body.t-ice { --bg: #0b1626; --bg2: #2b4c70; --panel: #12233a; --panel2: #1a304d; --line: rgba(224, 242, 254, 0.24); --accent: #e0f2fe; --accent2: #f0f9ff; --acc-rgb: 224, 242, 254; --ink: #0b1626; --good: #0369a1;
  --sea: #bfdbfe; --sea2: #93c5fd; --dot: rgba(30, 64, 175, 0.2); --isl: #f8fafc; --isl-line: #1e3a8a; --isl-txt: #1e3a8a; --isl-ok: #38bdf8; --isl-ok-txt: #082f49; --bridge: #475569; --bridge-edge: #0f172a; }
body.t-night { --bg: #050816; --bg2: #1d2453; --panel: #101633; --panel2: #182045; --line: rgba(196, 181, 253, 0.22); --accent: #c4b5fd; --accent2: #ddd6fe; --acc-rgb: 196, 181, 253; --ink: #101633; --good: #6d28d9;
  --sea: #0c1233; --sea2: #070b24; --dot: rgba(196, 181, 253, 0.2); --isl: #fef9c3; --isl-line: #a16207; --isl-ok: #fde047; --isl-ok-txt: #1c1917; --bridge: #a5b4fc; --bridge-edge: #1e1b4b; }
body.t-reef { --bg: #04211f; --bg2: #0f5e58; --panel: #0a2f2c; --panel2: #10403b; --line: rgba(251, 113, 133, 0.24); --accent: #fda4af; --accent2: #fecdd3; --acc-rgb: 253, 164, 175; --ink: #3f0a14; --good: #0f766e;
  --sea: #0f766e; --sea2: #0b5a54; --dot: rgba(255, 255, 255, 0.18); --isl: #fecdd3; --isl-line: #9f1239; --isl-txt: #4c0519; --isl-ok: #fb7185; --isl-ok-txt: #4c0519; --bridge: #fef3c7; --bridge-edge: #713f12; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(circle at 50% 0%, var(--bg2) 0%, var(--bg) 62%, #05080f 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
body.t-night { background: radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.07) 0 1px, transparent 2px) 0 0 / 60px 60px, radial-gradient(circle at 50% 0%, var(--bg2) 0%, var(--bg) 62%, #03050d 100%); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  background: rgba(56, 189, 248, 0.12); border: 1px solid rgba(56, 189, 248, 0.3); color: #7dd3fc;
  text-decoration: none; font-size: 0.85rem; font-weight: 700;
}
.back-btn:hover { background: rgba(56, 189, 248, 0.22); }
.total { margin-left: auto; font-weight: 800; }
.tools { display: flex; gap: 6px; }
.mini { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-weight: 800; }

/* ── 메뉴 ── */
.screen { flex: 1; overflow-y: auto; padding: 4px 16px 32px; }
.screen > * { max-width: 680px; margin-left: auto; margin-right: auto; }
.logo { text-align: center; margin: 2px auto 12px; }
.logo-art { display: inline-block; padding: 6px; border-radius: 12px; background: var(--sea); line-height: 0; }
.mini-board { display: inline-block; padding: 6px; border-radius: 12px; background: var(--sea); line-height: 0; margin: 6px auto; }
h1 { margin: 10px 0 2px; font-size: 1.6rem; letter-spacing: -0.02em; }
h1 span { color: var(--accent); }
.tagline { margin: 0; color: var(--dim); font-size: 0.9rem; }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.tab { padding: 9px 2px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-weight: 700; font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab.on { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.dim { color: var(--dim); }
.small { font-size: 0.82rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.btn { padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); font-weight: 800; }
.btn.go { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.btn.small { padding: 6px 10px; font-size: 0.85rem; }
.btn.wide { width: 100%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.continue {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; margin-bottom: 12px;
  border-radius: var(--r); border: 1px solid rgba(var(--acc-rgb), 0.5); background: linear-gradient(135deg, rgba(var(--acc-rgb), 0.2), rgba(var(--acc-rgb), 0.05));
}
.continue .ci { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--ink); }
.continue b { display: block; } .continue small { color: var(--dim); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; margin: 8px 0; }
.kpis div { background: var(--panel2); border-radius: 12px; padding: 8px 2px; }
.kpis b { display: block; font-size: 1.2rem; } .kpis small { color: var(--dim); font-size: 0.72rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.cal span { aspect-ratio: 1; border-radius: 6px; background: var(--panel2); display: grid; place-items: center; font-size: 0.7rem; color: var(--dim); }
.cal .w { background: var(--good); color: #fff; font-weight: 800; } .cal .t { outline: 2px solid var(--accent); }
.cal button { aspect-ratio: 1; border-radius: 6px; background: var(--panel2); display: grid; place-items: center; font: inherit; font-size: 0.7rem; color: var(--dim); border: 1px dashed rgba(163, 191, 174, 0.45); padding: 0; cursor: pointer; touch-action: manipulation; }
.cal button.w { border-style: solid; border-color: transparent; }
.cal button.pw { background: #6d28d9; color: #fff; font-weight: 800; border-color: transparent; }
.cal button:hover, .cal button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-note { margin: 8px 0 0; }
.wk { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 0.66rem; color: var(--dim); text-align: center; margin-top: 8px; }

.zone { margin-bottom: 14px; }
.zone-h { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.zone-h .zi { font-size: 1.4rem; }
.zone-h b { font-size: 1rem; } .zone-h .zs { margin-left: auto; font-weight: 800; color: var(--accent2); font-size: 0.85rem; white-space: nowrap; }
.zone-d { margin: 0 0 6px; font-size: 0.78rem; color: var(--dim); }
.sts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.st { aspect-ratio: 1.6; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; padding: 0; font-size: 0.85rem; }
.st small { font-size: 0.55rem; color: var(--gold); letter-spacing: -1px; min-height: 0.9em; }
.st.done { background: var(--panel2); border-color: rgba(var(--acc-rgb), 0.4); }
.st.next { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--acc-rgb), 0.25) inset; }
.locked { opacity: 0.42; }
.achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.ach { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 12px; background: var(--panel2); font-size: 0.8rem; }
.ach .ai { font-size: 1.3rem; } .ach b { display: block; font-size: 0.85rem; } .ach small { color: var(--dim); }
.ach.off { opacity: 0.45; filter: grayscale(1); }
.opt { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.opt:first-of-type { border-top: 0; }
.opt div { flex: 1; } .opt small { display: block; color: var(--dim); }
.sw { width: 50px; height: 28px; border-radius: 999px; border: 1px solid var(--line); background: #3b4558; position: relative; flex: none; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.sw.on { background: var(--good); } .sw.on::after { transform: translateX(22px); }
.themes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.th { padding: 6px 2px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); font-size: 0.68rem; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.th i { width: 34px; height: 34px; border-radius: 8px; display: block; border: 2px solid rgba(0, 0, 0, 0.3); }
.th.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--acc-rgb), 0.3) inset; }
.th-sea { background: linear-gradient(#0e7490, #fde68a); } .th-sunset { background: linear-gradient(#7c2d12, #fb923c); } .th-ice { background: linear-gradient(#1e3a5f, #e0f2fe); }
.th-night { background: linear-gradient(#1d2453, #070a17); } .th-reef { background: linear-gradient(#0f766e, #fb7185); }

/* ── 판 ── */
#play { flex: 1; display: flex; flex-direction: column; min-height: 0; padding-bottom: env(safe-area-inset-bottom); }
.p-head { display: flex; align-items: center; gap: 8px; padding: 2px 12px 4px; max-width: 640px; width: 100%; margin: 0 auto; }
.p-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.p-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .p-title small { color: var(--dim); font-size: 0.76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.moves { text-align: center; min-width: 54px; padding: 4px 8px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); line-height: 1.05; }
.moves b { display: block; font-size: 1.25rem; } .moves small { font-size: 0.66rem; color: var(--dim); }
.goal { text-align: center; font-size: 0.8rem; color: var(--dim); min-height: 1.3em; padding: 0 12px; }
.goal .gs { color: var(--gold); letter-spacing: 1px; font-weight: 800; }
.board-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; padding: 6px 8px; }
.board { padding: 8px; border-radius: 16px; background: radial-gradient(circle at 50% 40%, var(--sea), var(--sea2)); border: 2px solid var(--line); box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.25), 0 10px 30px rgba(0, 0, 0, 0.3); touch-action: none; line-height: 0; -webkit-touch-callout: none; }
.board svg { display: block; overflow: visible; cursor: pointer; }
.dots { stroke: var(--dot); stroke-width: 0.5; stroke-linecap: round; fill: none; }
.br { stroke: var(--bridge); stroke-width: 1.15; stroke-linecap: round; filter: drop-shadow(0 0.3px 0 var(--bridge-edge)); }
.br.flash { animation: brin 0.25s ease-out; }
@keyframes brin { from { stroke-width: 2.4; opacity: 0.4; } }
.pre { stroke: var(--bridge); stroke-width: 1; stroke-dasharray: 1.4 1.2; opacity: 0.75; stroke-linecap: round; }
.pre.no, .warn { stroke: var(--bad); stroke-width: 1.4; stroke-dasharray: none; opacity: 0.9; animation: blink 0.3s 2; }
@keyframes blink { 50% { opacity: 0.2; } }
.isl circle { fill: var(--isl); stroke: var(--isl-line); stroke-width: 0.55; transition: fill 0.2s; }
.isl text { font: 800 4.9px system-ui, -apple-system, 'Apple SD Gothic Neo', sans-serif; fill: var(--isl-txt); text-anchor: middle; pointer-events: none; }
.isl.ok circle { fill: var(--isl-ok); } .isl.ok text { fill: var(--isl-ok-txt); }
body.nofull .isl.ok circle { fill: var(--isl); } body.nofull .isl.ok text { fill: var(--isl-txt); }
.isl.over circle { fill: #fecaca; stroke: #dc2626; stroke-width: 0.9; } .isl.over text { fill: #7f1d1d; }
.isl.hid circle { stroke-dasharray: 1.2 0.8; }
.isl.sel circle { stroke: #fff; stroke-width: 1.1; filter: drop-shadow(0 0 1.6px #fff); }
.isl.cand circle { stroke: var(--accent); stroke-width: 0.9; }
.isl { transform-box: fill-box; transform-origin: center; }
.isl.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-0.6px); } 75% { transform: translateX(0.6px); } }
.isl.hint circle { animation: hintp 0.9s ease-in-out 2; }
@keyframes hintp { 50% { stroke: var(--gold); stroke-width: 1.6; } }
.board.won .isl { animation: wonp 0.6s ease-out both; animation-delay: calc(var(--d, 0) * 70ms); }
@keyframes wonp { 40% { transform: scale(1.25); filter: brightness(1.3); } 100% { transform: none; filter: none; } }
.board.won .br { stroke: var(--gold); transition: stroke 0.6s 0.3s; }
.cbtn.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--panel)); }
.toast { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); background: #f1f5f9; color: #0f172a; padding: 8px 14px; border-radius: 10px; font-weight: 800; font-size: 0.88rem; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); z-index: 7; max-width: calc(100% - 24px); text-align: center; pointer-events: none; }
.toast.bad { background: #fee2e2; color: #7f1d1d; }
.ctrl { display: flex; gap: 8px; justify-content: center; padding: 4px 12px 12px; max-width: 440px; width: 100%; margin: 0 auto; }
.cbtn { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; padding: 6px 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 1.15rem; line-height: 1.15; }
.cbtn span { font-size: 0.7rem; color: var(--dim); }
.cbtn.used { border-color: rgba(250, 204, 21, 0.5); }

/* ── 모달 ── */
.modal { position: fixed; inset: 0; background: rgba(3, 6, 12, 0.7); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-box { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); }
.modal-box h2 { margin: 0 0 8px; font-size: 1.25rem; }
.modal-box p { line-height: 1.5; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.modal-btns .btn { flex: 1; white-space: nowrap; padding: 10px 8px; }
.err { font-family: ui-monospace, monospace; font-size: 0.75rem; background: #060a12; padding: 8px; border-radius: 8px; white-space: pre-wrap; color: #fecaca; max-height: 140px; overflow: auto; user-select: text; -webkit-user-select: text; }
.win { text-align: center; }
.win-ico { font-size: 2.6rem; animation: rise 0.5s ease-out; }
@keyframes rise { from { transform: scale(0.6) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }
.stars { font-size: 2rem; color: var(--gold); letter-spacing: 4px; }
.stars i { font-style: normal; color: #475569; }
.win-line { margin: 4px 0; font-weight: 700; }
.ach-got { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.ach-got span { padding: 5px 10px; border-radius: 999px; background: rgba(186, 230, 253, 0.12); border: 1px solid rgba(186, 230, 253, 0.45); font-size: 0.82rem; font-weight: 700; }
.help ul { margin: 6px 0; padding-left: 20px; font-size: 0.88rem; line-height: 1.55; }
.noscript { padding: 20px; text-align: center; }

@media (max-width: 400px) { .back-txt { display: none; } .tab { font-size: 0.74rem; } .sts { gap: 3px; } }
@media (max-height: 620px) { .cbtn span { display: none; } .p-title small { display: none; } .logo-art { display: none; } }
.help .center { text-align: center; }
