:root {
  --bg: #f6f1e4;
  --paper: #fffdf7;
  --ink: #23302a;
  --muted: #5f6b64;
  --line: #ddd3bd;
  --brand: #2f6b4f;
  --brand-ink: #ffffff;
  --brand-soft: #e3efe6;
  --accent: #c8642c;
  --good: #2e7d4f;
  --bad: #b5402b;
  --warn: #a8761c;
  --shadow: 0 1px 2px rgba(40, 30, 10, .08), 0 4px 14px rgba(40, 30, 10, .07);
  --radius: 14px;
  --t-grass: #cfe3b4;
  --t-forest: #8fbf7f;
  --t-river: #9cc8e6;
  --t-mountain: #c9b79c;
  --t-market: #f0cf7a;
  --t-tower: #c8b4e0;
  --t-fog: #e8e1d0;
  --i-forest: #3f7a45; --i-mountain: #8a7458; --i-tower: #6f569a; --i-market: #c0532f; --i-grass: #7fa865; --i-river: #5c9fd0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161b18; --paper: #1f2622; --ink: #e8efe9; --muted: #a3b0a8; --line: #34403a;
    --brand: #5fb38a; --brand-ink: #0d1a13; --brand-soft: #22342b; --accent: #e08a55;
    --good: #6cc48f; --bad: #ec8470; --warn: #e0b45c;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
    --t-grass: #3d5a35; --t-forest: #2e5233; --t-river: #2f5672; --t-mountain: #5e5241; --t-market: #6f5c25; --t-tower: #4e3f66; --t-fog: #252c28; --i-forest: #79b77a; --i-mountain: #b5a185; --i-tower: #a990d4; --i-market: #e0805a; --i-grass: #5f8a4c; --i-river: #4c88b8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161b18; --paper: #1f2622; --ink: #e8efe9; --muted: #a3b0a8; --line: #34403a;
  --brand: #5fb38a; --brand-ink: #0d1a13; --brand-soft: #22342b; --accent: #e08a55;
  --good: #6cc48f; --bad: #ec8470; --warn: #e0b45c;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  --t-grass: #3d5a35; --t-forest: #2e5233; --t-river: #2f5672; --t-mountain: #5e5241; --t-market: #6f5c25; --t-tower: #4e3f66; --t-fog: #252c28; --i-forest: #79b77a; --i-mountain: #b5a185; --i-tower: #a990d4; --i-market: #e0805a; --i-grass: #5f8a4c; --i-river: #4c88b8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* 태블릿에서 빠르게 두 번 누를 때 화면이 확대되지 않게(손가락 탭은 그대로 빠르게) */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
* { -webkit-tap-highlight-color: transparent; }
.playstage { overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%;
  word-break: keep-all; overflow-wrap: anywhere;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--paper); font-weight: 600; text-decoration: none; color: inherit;
}
.btn.primary { background: var(--brand); color: var(--brand-ink) !important; border-color: var(--brand); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 600; }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.grid-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.choice { min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); font-weight: 700; font-size: 17px; }
.choice[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.input { width: 100%; min-height: 52px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); font-size: 18px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--line); }
.list button.item { width: 100%; text-align: left; background: none; border: 0; padding: 12px 4px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.error { color: var(--bad); font-weight: 600; }
.foot { margin-top: 24px; font-size: 13px; color: var(--muted); }
.foot a { color: inherit; }

/* 첫 화면 */
.hero { text-align: center; padding: 28px 0 12px; }
.logo { font-size: 40px; font-weight: 800; letter-spacing: -1px; color: var(--brand); margin: 0; }
.logo small { display: block; font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-top: 4px; }
main.wrap { counter-reset: s; } /* 단계 번호는 화면 전체에서 1, 2, 3… */
.step-label { font-weight: 700; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.step-label::before { counter-increment: s; content: counter(s); display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: 13px; }
.contests { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.contest { text-align: left; padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); min-height: 84px; }
.contest[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.contest:disabled { opacity: .6; }
.contest b { display: block; font-size: 17px; }

/* 상단 줄 */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.top .wrap { padding-top: 10px; padding-bottom: 10px; }
.top .who { font-weight: 700; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs a { flex: none; padding: 8px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px; }
.tabs a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }

/* 지도 */
.mapbox { position: relative; height: min(62vh, 520px); min-height: 320px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--t-fog); touch-action: none; user-select: none; -webkit-user-select: none; }
/* 지도: 구운 그림 한 장(.mapimg) + 가벼운 층(.mapover)을 담은 상자를 통째로 옮긴다. 화면보다 25%씩 크게 */
.maplayer, .pm-layer { position: absolute; left: -25%; top: -25%; width: 150%; height: 150%; touch-action: none; cursor: grab; will-change: transform; transform-origin: 50% 50%; -webkit-user-select: none; user-select: none; }
.mapimg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; }
.mapover { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.hex-sel { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linejoin: round; }
.maplayer.dragging, .pm-layer.dragging { cursor: grabbing; }
.mapctl { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.mapctl button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font-size: 20px; font-weight: 700; box-shadow: var(--shadow); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.15); }
.hex { stroke: rgba(60, 50, 30, .18); stroke-width: 1; stroke-linejoin: round; }
.layer { pointer-events: none; }
.hex.sel { stroke: var(--accent); stroke-width: 4; }
.hex.reach { stroke: var(--brand); stroke-width: 2; stroke-dasharray: 4 3; }
.own { pointer-events: none; }
.tlabel { font-size: 9px; font-weight: 700; pointer-events: none; fill: var(--ink); text-anchor: middle; }
.tglyph { font-size: 10px; pointer-events: none; text-anchor: middle; fill: var(--muted); }
.hqmark { font-size: 15px; pointer-events: none; text-anchor: middle; }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--paper); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.15); max-height: 78vh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
.sheet .wrap { padding-top: 12px; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 10px; }
.hp { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.hp > i { display: block; height: 100%; background: var(--brand); transition: width .3s; }
.hp.enemy > i { background: var(--bad); }
.news li { padding: 8px 0; font-size: 15px; }
.news time { color: var(--muted); font-size: 13px; margin-right: 6px; }
.goal { display: flex; gap: 12px; align-items: center; }
.ring { --p: 0; width: 52px; height: 52px; border-radius: 50%; background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; flex: none; }
.ring > span { width: 40px; height: 40px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; font-weight: 800; font-size: 14px; }

/* 문제 풀이 */
.play { max-width: 520px; margin: 0 auto; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); min-height: 100dvh; display: flex; flex-direction: column; gap: 12px; }
.play-head { display: flex; align-items: center; gap: 10px; }
.play-head .x { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font-size: 18px; flex: none; }
.dots { display: flex; gap: 4px; flex: 1; }
.dots i { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.dots i.ok { background: var(--good); }
.dots i.no { background: var(--bad); }
.dots i.now { background: var(--accent); }
.streak { font-weight: 800; color: var(--accent); min-width: 48px; text-align: right; flex: none; }
.tilebar { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); }
.tilebar .hp { flex: 1; }
.question { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 22px 16px; text-align: center; min-height: 150px; display: flex; flex-direction: column; justify-content: center; gap: 10px; box-shadow: var(--shadow); }
.q-text { font-size: 30px; font-weight: 800; line-height: 1.35; }
.q-text.long { font-size: 20px; font-weight: 700; text-align: left; }
.q-prev { font-size: 14px; color: var(--muted); }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; margin: 0 2px; font-size: .8em; }
.frac > span:first-child { border-bottom: 2px solid currentColor; padding: 0 3px; }
.box { display: inline-block; min-width: 1.4em; border: 2px dashed var(--accent); border-radius: 6px; color: var(--accent); }
.answer-row { display: flex; gap: 8px; justify-content: center; align-items: center; }
.slot { min-width: 96px; min-height: 56px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); font-size: 26px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.slot.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.slot.empty { color: var(--muted); font-weight: 500; font-size: 16px; }
.fracin { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.fracin hr { width: 100%; border: 0; border-top: 3px solid var(--ink); margin: 0; }
.fracin .slot { min-width: 76px; min-height: 46px; font-size: 22px; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad button { min-height: 58px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); font-size: 24px; font-weight: 700; box-shadow: var(--shadow); }
.pad button.ok { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-size: 19px; }
.pad button.fn { font-size: 17px; color: var(--muted); }
.yesno { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.yesno button { min-height: 72px; font-size: 20px; }
.feedback { border-radius: 14px; padding: 12px 14px; font-weight: 600; }
.feedback.ok { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.feedback.no { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.feedback.info { background: var(--brand-soft); color: var(--brand); }
.groups { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.groups .g { display: grid; grid-template-columns: repeat(5, 10px); gap: 3px; padding: 6px; border: 2px solid currentColor; border-radius: 10px; }
.groups .g i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.pop { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
.shake { animation: shake .35s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .pop, .shake { animation: none; } .hp > i { transition: none; } }

/* 숙달 지도 */
.mtable { display: grid; grid-template-columns: 34px repeat(9, 1fr); gap: 3px; font-size: 13px; }
.mtable > div { aspect-ratio: 1; display: grid; place-items: center; border-radius: 6px; background: var(--line); font-weight: 700; }
.mtable > .h { background: transparent; color: var(--muted); }
.st-new { background: var(--t-fog) !important; color: var(--muted); }
.st-practice { background: color-mix(in srgb, var(--warn) 35%, var(--paper)) !important; }
.st-learned { background: color-mix(in srgb, var(--good) 45%, var(--paper)) !important; }
.typelist li { padding: 10px 0; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.bar7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 110px; }
.bar7 > div { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: 12px; color: var(--muted); }
.bar7 b { display: block; width: 100%; max-width: 28px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }

/* 표 */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
.tablewrap { overflow-x: auto; }
.rank li { display: flex; gap: 10px; align-items: center; padding: 8px 0; }
.rank .n { width: 26px; text-align: right; font-weight: 800; color: var(--muted); flex: none; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 50; max-width: calc(100% - 32px); pointer-events: none; }

/* ── 풀이 화면: 실시간 지도 위에 문제·연습장 창 ───────────── */
.playstage { position: fixed; inset: 0; overflow: hidden; background: var(--bg); }
.pmap { position: absolute; inset: 0; overflow: hidden; }
.pm-target { fill: none; stroke: #ffd23f; stroke-width: 4; stroke-dasharray: 6 4; animation: pmdash 1.2s linear infinite; pointer-events: none; }
.pm-hit { fill: #e5383b; fill-opacity: .35; stroke: #e5383b; stroke-width: 4; animation: pmhit 0.9s ease-in-out infinite alternate; pointer-events: none; }
.pm-hiticon { font-size: 16px; text-anchor: middle; pointer-events: none; }
@keyframes pmdash { to { stroke-dashoffset: -20; } }
@keyframes pmhit { from { fill-opacity: .15; } to { fill-opacity: .55; } }
.pm-bar { position: absolute; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); z-index: 5; }
.pm-bar button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 18px; }
.pm-stat { font-size: 13px; color: var(--muted); white-space: nowrap; }
.pm-alert { position: absolute; left: 50%; top: calc(10px + env(safe-area-inset-top)); transform: translateX(-50%); max-width: calc(100% - 24px); padding: 8px 8px 8px 14px; border-radius: 14px; background: #e5383b; color: #fff; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.3); z-index: 8; display: flex; align-items: center; gap: 8px; }
.pm-alert[hidden] { display: none; }
.pm-alert .pm-go { border: 0; border-radius: 10px; background: #fff; color: #e5383b; font: inherit; font-weight: 700; padding: 6px 12px; }

.float { position: absolute; z-index: 10; display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 32px rgba(0,0,0,.28); overflow: hidden; container-type: inline-size; }
.float.front { z-index: 11; }
.float[hidden] { display: none; }
.float-head { flex: none; display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 14px; min-height: 36px; background: var(--brand-soft); font-weight: 700; font-size: 14px; cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none; }
.float-head span { flex: 1; }
.float-head span::before { content: '⠿ '; color: var(--muted); }
.float-head button { width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--ink); font-size: 16px; }
.float.min { height: auto !important; }
.float.min > :not(.float-head) { display: none; }
.float.min [data-min] { transform: rotate(-90deg); }
.float-rs { position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; cursor: nwse-resize; touch-action: none; background: linear-gradient(135deg, transparent 55%, var(--muted) 55%, var(--muted) 62%, transparent 62%, transparent 72%, var(--muted) 72%, var(--muted) 79%, transparent 79%); opacity: .7; }
.float .play { flex: 1; min-height: 0; overflow: auto; max-width: none; margin: 0; padding: 10px 12px 16px; gap: 10px; }
.float .question { min-height: 0; padding: 14px 12px; }
@container (min-width: 460px) { .float .pad { grid-template-columns: repeat(6, 1fr); } }
.float .note { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 8px 10px 12px; }

.note-open-btn { margin-left: auto; min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; font-weight: 700; }
.note-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.note-tools button { min-height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; font-size: 14px; }
.note-tools button.on { background: var(--brand-soft); border-color: var(--brand); font-weight: 700; }
.note-tools [data-act="clear"] { margin-left: auto; }
.note-paper { position: relative; flex: 1; min-height: 120px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); overflow: hidden; }
.note-paper.grid { background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 32px 32px; background-position: -1px -1px; }
.note-paper canvas { position: absolute; inset: 0; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
.note-empty { position: absolute; inset: auto 0 12px; text-align: center; color: var(--muted); font-size: 14px; pointer-events: none; margin: 0; }
.q-alert { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 12px; background: #e5383b; color: #fff; font-weight: 700; font-size: 14px; }
.q-alert[hidden] { display: none; }
.q-alert span { flex: 1; }
.q-alert .pm-go { border: 0; border-radius: 8px; background: #fff; color: #e5383b; font: inherit; font-size: 13px; font-weight: 700; padding: 6px 10px; white-space: nowrap; }

/* ── 게임 효과 ── */
.fx-num { font-size: 22px; font-weight: 900; text-anchor: middle; fill: #ffd23f; stroke: #3a2a00; stroke-width: 4px; paint-order: stroke; animation: fxup 1.3s ease-out forwards; }
.fx-num.win { font-size: 26px; fill: #fff; stroke: #2f6b4f; }
.fx-spark { animation: fxspark .9s ease-out forwards; }
.fx-ring { fill: none; stroke-width: 4; animation: fxring 1s ease-out forwards; }
.fx-ring.hit { stroke: #e5383b; }
.fx-flag { font-size: 30px; text-anchor: middle; animation: fxflag 1.4s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes fxup { 0% { transform: translateY(6px) scale(.6); opacity: 0; } 15% { transform: translateY(0) scale(1.15); opacity: 1; } 100% { transform: translateY(-44px) scale(1); opacity: 0; } }
@keyframes fxspark { from { transform: translate(0, 0); opacity: 1; } to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
@keyframes fxring { from { transform: scale(.5); opacity: 1; } to { transform: scale(5); opacity: 0; } }
@keyframes fxflag { 0% { transform: translateY(-40px) scale(.4); opacity: 0; } 40% { transform: translateY(0) scale(1.2); opacity: 1; } 80% { transform: scale(1); opacity: 1; } 100% { opacity: 0; } }
.fx-num, .fx-spark, .fx-ring, .fx-flag { transform-box: fill-box; transform-origin: center; }
.streak.fire { color: #ff7a1a; font-weight: 900; transform: scale(calc(1 + var(--s) * .03)); animation: firepulse .8s ease-in-out infinite alternate; }
@keyframes firepulse { from { filter: drop-shadow(0 0 0 #ff7a1a); } to { filter: drop-shadow(0 0 6px #ffb347); } }
@media (prefers-reduced-motion: reduce) { .fx-num, .fx-spark, .fx-ring, .fx-flag, .streak.fire { animation-duration: .01s; } }

/* 정답을 보여 준 뒤 다음 문제로(자동 넘김 남은 시간 막대) */
.next-big { position: sticky; bottom: 0; z-index: 2; overflow: hidden; min-height: 64px; font-size: 21px; font-weight: 800; box-shadow: 0 -10px 16px var(--paper); }
.next-big .cd { position: absolute; left: 0; bottom: 0; height: 5px; width: 100%; background: rgba(255,255,255,.75); transform-origin: left; animation: nextcd linear forwards; }
@keyframes nextcd { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ── 차지할 수 있는 땅 ── 층 전체를 천천히 깜빡(그래픽 칩이 처리, 지도 움직임에 부담 없음) */
.mapreach { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; will-change: opacity; animation: reachpulse 1.4s ease-in-out infinite alternate; }
@keyframes reachpulse { from { opacity: .55; } to { opacity: 1; } }
/* 차지할 수 있는 땅: 엷게 칠하고 점선(아직 우리 땅이 아님). 우리 땅은 진한 칠 + 흰 테 실선 */
.rc { stroke: none; }
.rc.new { fill: #fff6c2; fill-opacity: .2; }
.rc.atk { fill: #ff8a80; fill-opacity: .2; }
/* 바깥 둘레 점선: 화면 기준 굵기(확대해도 그대로) */
.rc-edge { fill: none; stroke-width: 1.2px; vector-effect: non-scaling-stroke; stroke-dasharray: 4 4; stroke-linecap: round; }
.rc-edge.new { stroke: #ffe066; }
.rc-edge.atk { stroke: #ff6b6b; }
.rci circle { stroke: #fff; stroke-width: 1.5; }
.rci path { stroke: #fff; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.rci.new circle { fill: #e0a800; }
.rci.atk circle { fill: #e53935; }
.rci text { font-size: 12px; font-weight: 900; fill: #fff; text-anchor: middle; font-family: -apple-system, system-ui, 'Segoe UI Symbol', sans-serif; }
.reach-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; margin: 0 2px 8px; }
.rh-chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.rh-chip.new { background: #fff3bf; color: #7a5b00; }
.rh-chip.atk { background: #ffe0dd; color: #b3261e; }
.rh-glow { animation: reachpulse 1.4s ease-in-out infinite alternate; }
@media (prefers-reduced-motion: reduce) { .mapreach, .rh-glow { animation: none; } }
.rc-link { fill: none; stroke: #fff; stroke-width: 3; stroke-dasharray: 2 6; stroke-linecap: round; opacity: .95; }
.rh-chip.river { background: #d7f0ff; color: #0b5c8a; }
.river-note { background: #e3f4ff; color: #0b5c8a; padding: 8px 10px; border-radius: 10px; margin: 0 0 8px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .river-note { background: #10324a; color: #bfe6ff; } }
:root[data-theme="dark"] .river-note { background: #10324a; color: #bfe6ff; }

/* ── 세계 유산·가방 ── */
.her-card { background: linear-gradient(135deg, #fff4c9, #ffe7a3); color: #4a3300; border: 2px dashed #e0a800; border-radius: 12px; padding: 10px 12px; margin: 8px 0; display: grid; gap: 4px; font-size: 14px; }
.her-chip { display: inline-block; background: #fff1bf; color: #6b4b00; border: 1px solid #e8c252; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; }
.her-powers { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.bag { margin: 0 2px 10px; }
.bag-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-btn { position: relative; width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); font-size: 22px; display: grid; place-items: center; }
.item-btn span { position: absolute; right: -4px; bottom: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); font-size: 12px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; }
.item-btn:disabled { opacity: .4; }
.item-btn.on { outline: 3px solid var(--accent); }
.horn-chip { background: #ffe8d6; color: #8a3b00; border-radius: 999px; padding: 2px 9px; font-size: 13px; font-weight: 700; }
.use-hint { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--brand-soft); font-weight: 700; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.pick-card { display: grid; gap: 6px; justify-items: center; text-align: center; padding: 14px 10px; border-radius: 16px; border: 2px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; }
.pick-card:hover:not(:disabled) { border-color: var(--brand); }
.pick-card:disabled { opacity: .45; }
.pick-ic { font-size: 40px; }

/* ── 시작 화면 ── */
.title-screen { position: relative; min-height: 100dvh; display: grid; align-items: center; overflow: hidden; background: #0d2b2b; }
.title-bg { position: absolute; inset: 0; background-size: cover; background-position: 70% center; filter: saturate(1.05); }
.title-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(8,20,18,.78) 0%, rgba(8,20,18,.45) 45%, rgba(8,20,18,0) 75%); }
.title-box { position: relative; z-index: 1; max-width: 440px; padding: 28px 24px 80px; margin-left: max(16px, 6vw); display: grid; gap: 14px; color: #fff; }
.title-kicker { margin: 0; font-weight: 700; color: #ffe08a; letter-spacing: .02em; }
.title-logo { margin: 0; line-height: 1; }
.title-logo img { display: block; width: min(440px, 82vw); height: auto; margin: 0 auto; filter: drop-shadow(0 8px 18px rgba(0,0,0,.35)); }
.title-sub { margin: 0; font-size: 18px; color: #f3ead2; }
.title-go { min-height: 68px; font-size: 24px; font-weight: 900; border-radius: 18px; box-shadow: 0 6px 0 #1f4d38, 0 10px 24px rgba(0,0,0,.35); text-decoration: none; display: grid; place-items: center; }
.title-row { display: flex; gap: 8px; flex-wrap: wrap; }
.title-row .btn { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.35); text-decoration: none; }
.title-steps { display: flex; gap: 14px; margin: 6px 0 0; color: #e8e2cf; font-weight: 700; }
.title-foot { position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; margin: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); font-size: 12px; color: rgba(255,255,255,.7); background: linear-gradient(0deg, rgba(0,0,0,.45), transparent); }
.title-foot a { color: #fff; }
@media (max-width: 699px) { .title-bg { background-position: 62% center; } .title-bg::after { background: linear-gradient(0deg, rgba(8,20,18,.88) 0%, rgba(8,20,18,.55) 55%, rgba(8,20,18,.1) 100%); } .title-box { margin: auto 0 0; align-self: end; } }
/* 게임 방법 · 처음 안내 */
.sheet.guide h3 { margin: 18px 0 6px; }
.sheet.guide ul { padding-left: 0; }
.sheet.guide li { padding: 4px 0; font-size: 15px; }
.intro-back { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; }
.intro { width: min(420px, 100%); background: var(--paper); color: var(--ink); border-radius: 22px; padding: 18px 18px 16px; display: grid; gap: 10px; justify-items: center; text-align: center; box-shadow: 0 18px 50px rgba(0,0,0,.4); }
.intro h2 { margin: 4px 0 0; }
.intro p { margin: 0; }
.intro .dots { display: flex; gap: 6px; }
.intro .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.intro .dots i.now { background: var(--brand); }
.ipic { width: 100%; height: 150px; border-radius: 16px; background: linear-gradient(160deg, #cfe9b8, #8fc77a); display: flex; align-items: center; justify-content: center; gap: 10px; position: relative; overflow: hidden; }
.ihex { width: 70px; height: 78px; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); display: grid; place-items: center; font-size: 30px; font-weight: 900; }
.ihex.mine { background: #2f6b4f; }
.ihex.glow { background: #ffe066; color: #7a5b00; animation: reachpulse 1.2s ease-in-out infinite alternate; }
.ihex.dim { background: rgba(0,0,0,.18); }
.ibig { font-size: 34px; font-weight: 900; color: #23302a; background: #fff; padding: 10px 18px; border-radius: 14px; }
.ipop { position: absolute; right: 22%; top: 18px; font-size: 26px; font-weight: 900; color: #ffd23f; text-shadow: 0 2px 0 #7a5b00; animation: fxup 1.4s ease-out infinite; }
.iimg { height: 120px; }
.ibag { font-size: 30px; background: #fff; border-radius: 14px; padding: 6px 10px; }

/* ── 명예의 전당 · 다시 보기 ── */
.hall-grade { padding: 10px 0; border-top: 1px solid var(--line); }
.hall-grade:first-of-type { border-top: 0; }
.hall-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.hall-medal { font-size: 22px; }
.hall-logo { height: 26px; max-width: 120px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px 4px; }
.hall-name { flex: 1; min-width: 0; }
.hall-tiles { white-space: nowrap; }
.replay { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto auto; gap: 8px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }
.replay-top { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.replay canvas { width: 100%; height: 100%; min-height: 300px; border-radius: 16px; background: var(--paper); }
.replay-bar { display: flex; align-items: center; gap: 10px; }
.replay-bar input { flex: 1; }
.replay-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; padding: 0; margin: 0; font-size: 14px; }
.replay-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.online { margin-top: 4px; font-size: 13px; color: var(--brand); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.online i { width: 8px; height: 8px; border-radius: 50%; background: #34c759; box-shadow: 0 0 0 3px rgba(52,199,89,.25); animation: reachpulse 1.2s ease-in-out infinite alternate; }
.event-bar { margin: 0 2px 10px; padding: 10px 12px; border-radius: 12px; background: linear-gradient(135deg, #ffe08a, #ffc46b); color: #4a2a00; font-size: 14px; }

.xcode { margin-top: 10px; display: grid; justify-items: center; gap: 4px; padding: 12px; border-radius: 14px; background: var(--brand-soft); }
.xcode b { font-size: 40px; letter-spacing: .08em; font-variant-numeric: tabular-nums; }

/* ── 문제 창 크기에 맞춰 내용도 함께(창 너비 = 컨테이너 단위 cqi) ──
   글자는 창 너비에 맞춰 줄고, 키패드·확인 단추는 비율을 지킨다. 세로로 모자라면 눌리지 않고 창 안에서 넘겨 본다. */
.enter-btn { min-height: 56px; font-size: 19px; }
.float .play > * { flex-shrink: 0; }
.float .question { padding: clamp(8px, 3cqi, 16px) clamp(8px, 3cqi, 14px); }
.float .q-text { font-size: clamp(17px, 7cqi, 32px); word-break: keep-all; overflow-wrap: anywhere; }
.float .q-text.long { font-size: clamp(15px, 4.6cqi, 22px); }
.float .tilebar { font-size: clamp(12px, 3.6cqi, 14px); gap: clamp(4px, 2cqi, 10px); }
.float .play-head { gap: clamp(4px, 2cqi, 10px); }
.float .play-head .x { width: clamp(32px, 10cqi, 40px); height: clamp(32px, 10cqi, 40px); }
.float .note-open-btn { min-height: clamp(30px, 9cqi, 36px); padding: 0 clamp(6px, 2.5cqi, 12px); font-size: clamp(12px, 3.8cqi, 15px); }
.float .streak { font-size: clamp(12px, 4cqi, 16px); }
.float .slot { min-width: clamp(64px, 22cqi, 110px); min-height: clamp(38px, 12cqi, 58px); font-size: clamp(18px, 6.5cqi, 28px); }
.float .slot.empty { font-size: clamp(13px, 4cqi, 17px); }
.float .fracin .slot { min-width: clamp(56px, 18cqi, 86px); min-height: clamp(34px, 10cqi, 50px); font-size: clamp(16px, 5.5cqi, 24px); }
.float .pad { gap: clamp(4px, 1.6cqi, 8px); }
.float .pad button { min-height: 34px; max-height: 66px; aspect-ratio: 2 / 1; font-size: clamp(16px, 6.5cqi, 26px); border-radius: clamp(10px, 3cqi, 14px); }
.float .pad button.fn { font-size: clamp(12px, 4cqi, 17px); }
@container (min-width: 460px) { .float .pad button { aspect-ratio: 1.6 / 1; font-size: clamp(18px, 4cqi, 26px); } .float .pad button.fn { font-size: clamp(13px, 2.6cqi, 17px); } }
.float .enter-btn { min-height: clamp(40px, 12cqi, 60px); font-size: clamp(16px, 5cqi, 20px); }
.float .yesno button { min-height: clamp(48px, 15cqi, 72px); font-size: clamp(15px, 5cqi, 20px); }
.float .next-big { min-height: clamp(48px, 15cqi, 64px); font-size: clamp(16px, 5.5cqi, 21px); }
.float .feedback { font-size: clamp(13px, 4cqi, 16px); }

.quiet-bar { margin: 0 2px 10px; padding: 12px 14px; border-radius: 12px; background: linear-gradient(135deg, #22285a, #3b2f6e); color: #e9e6ff; font-size: 14px; }
.quiet-note { background: #2a2c5c; color: #e9e6ff; padding: 10px 12px; border-radius: 10px; }

/* ── 전과목·영어 대회 보기 ── */
.q-tags { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.choices4 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices4.long { grid-template-columns: 1fr; }
.choices4 .btn { min-height: 64px; justify-content: flex-start; text-align: left; gap: 10px; padding: 10px 14px; font-size: 17px; line-height: 1.35; white-space: normal; display: flex; align-items: center; }
.choices4 .btn i { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-style: normal; font-weight: 900; display: grid; place-items: center; font-size: 15px; }
.float .choices4 .btn { min-height: clamp(48px, 14cqi, 64px); font-size: clamp(14px, 4.4cqi, 17px); }
@container (max-width: 360px) { .float .choices4 { grid-template-columns: 1fr; } }

/* ── 직접 쓰기 · 차례 맞추기 · 짝 맞추기 ── */
.textin { display: flex; gap: 8px; }
.textin input { flex: 1; min-width: 0; font-size: 22px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); font-weight: 700; }
.textin input:focus { outline: none; border-color: var(--brand); }
.textin .btn { min-width: 84px; }
.unit { font-size: 22px; font-weight: 800; margin-left: 6px; align-self: center; }
.orderline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin: 6px 0 10px; }
.orderline .oslot { min-width: 44px; min-height: 44px; padding: 6px 10px; border-radius: 12px; background: var(--brand-soft); color: var(--ink); font-weight: 800; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.orderline .oslot.empty { background: transparent; border: 2px dashed var(--line); color: var(--muted); cursor: default; justify-content: center; }
.orderline .oslot i { font-style: normal; font-size: 12px; color: var(--brand); }
.orderline .arr { color: var(--muted); }
.orderline.letters { gap: 4px; }
.orderline.letters .oslot { min-width: 40px; justify-content: center; font-size: 24px; padding: 4px; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tiles .tile { min-height: 52px; padding: 8px 14px; font-size: 17px; white-space: normal; }
.tiles .tile[disabled] { opacity: .25; }
.tiles.letters .tile { min-width: 52px; font-size: 24px; font-weight: 900; }
.tilectl { justify-content: space-between; margin-top: 10px; }
.tilectl .btn.primary { flex: 1; margin-left: 8px; }
.matchrows { display: grid; gap: 6px; margin: 4px 0 10px; }
.mrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; }
.mrow .ml { font-weight: 800; text-align: right; }
.mrow .mr { min-height: 40px; padding: 6px 10px; border-radius: 12px; background: var(--brand-soft); font-weight: 800; cursor: pointer; display: flex; align-items: center; }
.mrow .mr.empty { background: transparent; border: 2px dashed var(--line); color: var(--muted); cursor: default; }
.mrow .mr.now { border-color: var(--brand); }
.float .tiles .tile { min-height: clamp(40px, 12cqi, 52px); font-size: clamp(14px, 4.4cqi, 17px); }

/* ── 푼 문제 · 신고 ── */
.card.hist { padding: 12px 14px; margin-bottom: 10px; }
.hist .htext { font-weight: 700; margin: 8px 0 4px; line-height: 1.45; }
.hist .hopts { margin: 2px 0 6px 18px; padding: 0; font-size: 14px; color: var(--muted); }
.hmark { font-weight: 900; font-size: 18px; width: 22px; text-align: center; }
.hmark.ok { color: var(--ok, #2e7d4f); } .hmark.no { color: var(--bad, #c0392b); } .hmark.mid { color: #d98a1f; }
.hist-link { display: block; color: inherit; text-decoration: none; }
.reasons { display: grid; gap: 6px; margin: 8px 0; }
.reason { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-weight: 600; }
#rnote { width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 12px; padding: 10px; font: inherit; background: var(--card); color: var(--ink); }

/* ── 관리자 ── */
.adm-wrap { max-width: 900px; }
.adm-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; }
.adm-stats div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.adm-stats b { display: block; font-size: 24px; } .adm-stats span { font-size: 12px; color: var(--muted); }
.card.adm { padding: 12px 14px; margin-bottom: 12px; }
.adm .htext { font-weight: 700; margin: 8px 0 4px; }
.adm-reps { margin: 4px 0 8px 16px; padding: 0; font-size: 13px; }
.adm .src { background: var(--brand-soft); border-radius: 10px; padding: 8px 10px; margin: 6px 0; font-size: 14px; }
.adm .src code { font-size: 12px; }
.adm .hopts li.ans { font-weight: 800; color: var(--ink); }
.adm-memo { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; margin: 6px 0; background: var(--card); color: var(--ink); }
.adm-btns { gap: 6px; justify-content: flex-end; }
@media (max-width: 520px) { .adm-stats { grid-template-columns: repeat(2, 1fr); } }

/* ── 지도 화면 가득(게임 화면) ── */
body.fullmap { overflow: hidden; overscroll-behavior: none; }
.game { position: fixed; inset: 0; overflow: hidden; background: var(--t-fog); }
.mapbox.full { position: absolute; inset: 0; height: auto; min-height: 0; border: 0; border-radius: 0; }
.game .mapctl { top: auto; bottom: calc(env(safe-area-inset-bottom) + 50%); right: calc(10px + env(safe-area-inset-right)); transform: translateY(50%); }
.hud-top { position: absolute; left: 0; right: 0; top: 0; padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left)); display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; pointer-events: none; z-index: 4; }
.hud-top > * { pointer-events: auto; }
.hud-me { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: min(60vw, 420px); padding: 6px 12px 6px 6px; border-radius: 16px; border: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); box-shadow: var(--shadow); text-align: left; color: var(--ink); font: inherit; cursor: pointer; }
.hud-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 10px; background: #fff; flex: none; }
.hud-logo.ph { display: grid; place-items: center; font-size: 22px; }
.hud-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.hud-who b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-who .small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-btns { display: flex; gap: 6px; flex: none; }
.hud-btn { position: relative; width: 52px; height: 52px; border-radius: 16px; border: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); box-shadow: var(--shadow); font-size: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; cursor: pointer; color: var(--ink); }
.hud-btn span { font-size: 11px; font-weight: 700; color: var(--muted); }
.hud-btn .dot { position: absolute; top: 6px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad, #d64545); }
.hud-sub { position: absolute; left: calc(12px + env(safe-area-inset-left)); top: calc(76px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; max-width: min(92vw, 460px); pointer-events: none; z-index: 3; }
.hud-sub > * { pointer-events: auto; }
.hud-goal .goal { gap: 8px; padding: 6px 12px 6px 6px; border-radius: 14px; background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line); box-shadow: var(--shadow); }
.hud-goal .ring { width: 40px; height: 40px; }
.hud-goal .ring span { font-size: 11px; }
.goal-txt { display: flex; flex-direction: column; line-height: 1.3; font-size: 14px; }
.goal-txt .small { color: var(--muted); }
.hud-sub #events:empty, .hud-sub .reach-hint:empty { display: none; }
.hud-sub .quiet-bar, .hud-sub .ev-bar { margin: 0; box-shadow: var(--shadow); }
.hud-pill { margin: 0; padding: 6px 10px; border-radius: 12px; background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 13px; }
.hud-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); display: flex; gap: 8px; align-items: flex-end; justify-content: center; flex-wrap: wrap; pointer-events: none; z-index: 3; }
.hud-bottom > * { pointer-events: auto; }
.hud-card { background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 10px 14px; }
.hud-bottom #recommend { flex: 1 1 340px; max-width: 520px; }
.hud-bottom .bag { margin: 0; flex: 0 1 auto; max-width: 520px; }
.hud-bottom .bag .her-powers { margin-bottom: 6px; }
.panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 92vw); z-index: 6; background: var(--paper); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(0,0,0,.18); padding: calc(14px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; animation: panel-in .18s ease-out; }
.panel[hidden] { display: none; }
@keyframes panel-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.panel .x { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 18px; cursor: pointer; color: var(--ink); }
.menu-list { display: grid; gap: 6px; }
.menu-list a, .menu-list button { display: block; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; }
.panel .foot { margin-top: 18px; }
@media (max-width: 600px) {
  .hud-btn { width: 46px; height: 46px; font-size: 18px; }
  .hud-btn span { display: none; }
  .hud-me { max-width: calc(100vw - 190px); }
  .hud-sub { top: calc(70px + env(safe-area-inset-top)); max-width: calc(100vw - 80px); }
  .goal-txt { font-size: 13px; }
  .game .mapctl { bottom: auto; top: calc(70px + env(safe-area-inset-top)); transform: none; }
  .game .mapctl button { width: 40px; height: 40px; }
  .hud-bottom .bag { flex: 1 1 100%; padding: 8px 10px; }
  .hud-bottom .bag-row > .small { display: none; }
  .hud-bottom .bag-row { flex-wrap: nowrap; }
  .hud-bottom #recommend { padding: 8px 12px; }
}

.hud-test { font-style: normal; font-size: 11px; font-weight: 800; color: #9a5b00; background: #ffe9c2; border-radius: 6px; padding: 1px 5px; margin-left: 4px; vertical-align: 2px; }

/* ── 주말 돌아보기 · 유산 도감 ── */
.quiet-bar.week { background: linear-gradient(135deg, #5a3b12, #8a5a1c); color: #fff4e0; }
.week-result { display: grid; gap: 8px; }
.wr-stats { display: flex; gap: 16px; }
.wr-stats span { font-size: 14px; color: var(--muted); } .wr-stats b { font-size: 24px; color: var(--ink); margin-right: 2px; }
.wr-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.her-card { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); margin-bottom: 8px; }
.her-card.mine { border-color: var(--brand); background: var(--brand-soft); }
.her-ic { font-size: 28px; line-height: 1; }
.game.weekend .hud-goal, .game.weekend #bag { display: none; }

/* ── 지금 싸우는 중 ── */
.act-ring { fill: none; stroke-width: 4; stroke-linejoin: round; stroke-dasharray: 7 5; animation: act-spin 1.2s linear infinite, act-pulse 1.2s ease-in-out infinite; }
.act.guard .act-ring { stroke-dasharray: none; stroke-width: 3; animation: act-pulse 1.6s ease-in-out infinite; }
.act.dig .act-ring { stroke-dasharray: 3 4; stroke-width: 3; }
.act.minehit .act-ring { stroke: #e0322d !important; stroke-width: 5; }
.act-badge circle { fill: #fff; stroke: rgba(0,0,0,.25); stroke-width: 1; }
.act.minehit .act-badge circle { fill: #ffe1e0; stroke: #e0322d; stroke-width: 2; }
.act-icon { font-size: 13px; text-anchor: middle; animation: act-bob .7s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.act.guard .act-icon, .act.dig .act-icon { animation: none; }
.act-n { font-size: 10px; font-weight: 900; fill: #fff; stroke: rgba(0,0,0,.55); stroke-width: 2.5px; paint-order: stroke; text-anchor: middle; }
@keyframes act-spin { to { stroke-dashoffset: -24; } }
@keyframes act-pulse { 50% { opacity: .45; } }
@keyframes act-bob { from { transform: translateY(0) scale(1); } to { transform: translateY(-3px) scale(1.15); } }
.fight-pill { pointer-events: auto; border: 0; border-radius: 12px; padding: 7px 12px; font: inherit; font-size: 14px; text-align: left; background: #fff3d6; color: #6a4300; box-shadow: var(--shadow); cursor: pointer; }
.fight-pill.mine { background: #e0322d; color: #fff; animation: act-pulse 1.4s ease-in-out infinite; }
.fight-pill u { margin-left: 4px; }
@media (prefers-reduced-motion: reduce) { .act-ring, .act-icon, .fight-pill.mine { animation: none; } }
.replay-note { margin: 8px 16px; padding: 10px 12px; border-radius: 12px; background: var(--brand-soft); font-size: 14px; }

/* ── 구경 중 · 참여 팝업 ── */
.game.guest .pm-bar { left: auto; right: calc(10px + env(safe-area-inset-right)); top: auto; bottom: calc(110px + env(safe-area-inset-bottom)); }
.join-cta { display: flex; align-items: center; gap: 12px; flex: 1 1 340px; max-width: 560px; }
.join-cta > div { flex: 1; }
.join-modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.join-back { position: absolute; inset: 0; background: rgba(10, 20, 15, .45); backdrop-filter: blur(2px); }
.join-box { position: relative; width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; background: var(--bg); border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35); padding: 18px 16px 20px; animation: panel-in .18s ease-out; }
.join-box .hero { margin: 0 0 8px; }
.join-x { position: sticky; top: 0; float: right; z-index: 2; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 18px; cursor: pointer; color: var(--ink); }
.panel .step-label { font-weight: 800; margin: 4px 0 6px; }
.panel .contests { display: grid; gap: 6px; }
@media (max-width: 600px) { .join-modal { padding: 0; place-items: end stretch; } .join-box { border-radius: 20px 20px 0 0; max-height: 92dvh; } }
.game.guest .pm-bar { transform: none; }
.guest-empty { position: absolute; left: 50%; top: calc(84px + env(safe-area-inset-top)); transform: translateX(-50%); width: min(420px, calc(100vw - 32px)); text-align: center; z-index: 2; }

/* ── 로고 그림 · 홈 화면에 추가 ── */
.logo-img { display: block; width: min(300px, 70vw); height: auto; margin: 0 auto 4px; }
.hero .logo small { display: block; text-align: center; }
.install-ask { position: fixed; z-index: 40; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(520px, calc(100vw - 24px)); display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 18px; background: #1f1d3d; color: #f6efd9; box-shadow: 0 14px 40px rgba(0,0,0,.35); animation: panel-in .2s ease-out; }
.install-ask img { border-radius: 12px; flex: none; }
.install-ask .ia-txt { flex: 1 1 200px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.install-ask .ia-txt b { font-size: 16px; color: #ffd56a; }
.install-ask ol { margin: 4px 0 0 18px; padding: 0; font-size: 14px; line-height: 1.5; }
.install-ask .ia-btns { display: flex; gap: 6px; margin-left: auto; }
.install-ask .btn.ghost { color: #f6efd9; border-color: rgba(255,255,255,.3); background: transparent; }

/* ── 영토 에너지 막대(실시간 전투) ── */
.ebar { flex: 1; display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #d9dcd6; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); min-width: 60px; }
.ebar i { display: block; height: 100%; transition: width .45s ease; }
.ebar i.me { box-shadow: inset 0 0 0 2px rgba(255,255,255,.6); }
.ebar i.neu { background: repeating-linear-gradient(135deg, #c8ccc6 0 4px, #d9dcd6 4px 8px); }
.ebar.big { height: 22px; margin: 6px 0 8px; }
.tilebar .ebar { height: 14px; }
.tb-pct { font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; font-weight: 800; }
.tp-head { display: flex; justify-content: space-between; align-items: center; }
.chip.hot { background: #ffe1d6; color: #b8360d; animation: act-pulse 1.2s ease-in-out infinite; }
.tp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tp-list li { display: grid; grid-template-columns: 12px 1fr auto 62px; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.tp-list li > i { width: 12px; height: 12px; border-radius: 50%; }
.tp-list li.neu > i { background: #c8ccc6; }
.tp-name small { display: block; color: var(--muted); font-size: 11px; }
.tp-pct { color: var(--muted); text-align: right; }
.tp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; text-align: center; }
.tp-stats div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.tp-stats b { display: block; font-size: 17px; } .tp-stats span { font-size: 11px; color: var(--muted); }
.tp-log ul { list-style: none; margin: 4px 0 0; padding: 0; font-size: 13px; display: grid; gap: 2px; }
.tp-log time { color: var(--muted); font-size: 11px; margin-left: 4px; }

/* ── 아이템 1차 6종 ── */
.item-btn img { width: 30px; height: 30px; object-fit: contain; display: block; }
.item-btn { position: relative; padding: 4px; }
.item-btn span { position: absolute; right: -4px; bottom: -4px; }
.use-hint img, .pick-img { width: 28px; height: 28px; object-fit: contain; vertical-align: -8px; }
.pick-img { width: 56px; height: 56px; margin: 0 auto 4px; display: block; }
.pick-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important; }
.recon-box { margin-top: 6px; padding: 8px 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.recon-box ul { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 3px; }
.recon-box li { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.recon-box li i { width: 10px; height: 10px; border-radius: 50%; }
.it-badge circle { fill: #fff; stroke: rgba(0,0,0,.3); stroke-width: 1; }
.it-badge text { font-size: 11px; text-anchor: middle; }
.it-badge.rally.on circle { fill: #ffe082; stroke: #e65100; stroke-width: 2; }
.it-badge .rl-n { font-size: 9px; font-weight: 900; fill: #fff; stroke: rgba(0,0,0,.6); stroke-width: 2.5px; paint-order: stroke; }
.recon-t path { fill: rgba(255, 213, 79, .18); stroke: #ffb300; stroke-width: 2.5; stroke-dasharray: 5 3; }
.recon-t text { font-size: 11px; font-weight: 900; text-anchor: middle; fill: #fff; stroke: rgba(0,0,0,.65); stroke-width: 3px; paint-order: stroke; }
.tp-items { display: grid; gap: 3px; margin: 6px 0; font-size: 13px; }
.hud-bottom .bag-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; }
.hud-bottom .bag-row .item-btn { flex: none; width: 40px; height: 40px; }
.hud-bottom .bag-row .item-btn img { width: 28px; height: 28px; margin: 0 auto; }
.hud-bottom .bag-row #pick { flex: none; white-space: nowrap; }

/* ── 끊김 없이 풀기 ── */
.play-count { flex: 1; display: flex; gap: 10px; align-items: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.play-count .cnt-ok { color: var(--ok, #2e7d4f); }
.play-count .cnt-all { color: var(--muted); font-weight: 600; font-size: 14px; }
.result-card.won h1 { color: #b8360d; }

/* ── 같이 하자 알림 ── */
.call-pop { position: fixed; z-index: 45; left: 50%; top: calc(80px + env(safe-area-inset-top)); transform: translateX(-50%); width: min(460px, calc(100vw - 24px)); display: grid; gap: 4px; padding: 12px 14px; border-radius: 16px; color: #fff; box-shadow: 0 14px 40px rgba(0,0,0,.35); animation: panel-in .2s ease-out; }
.call-pop.def { background: linear-gradient(135deg, #c62828, #8e1b1b); }
.call-pop.atk { background: linear-gradient(135deg, #ef6c00, #b23c00); }
.call-pop b { font-size: 16px; } .call-pop span { font-size: 14px; opacity: .95; }
.call-pop .cp-btns { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.call-pop .btn.ghost { color: #fff; border-color: rgba(255,255,255,.5); background: transparent; }
.call-pop .btn.primary { background: #fff; color: #8e1b1b; }
.call-pop .cp-btns .btn.primary { background: #fff !important; color: #8e1b1b !important; border-color: #fff !important; font-weight: 800; }
.call-pop.atk .cp-btns .btn.primary { color: #b23c00 !important; }

/* ── 번개·주운 아이템·판 표시 ── */
.bolt-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: #ffe066; color: #7a4b00; font-weight: 900; animation: act-bob .5s ease-in-out 2 alternate; }
.horn-chip.bolt-on { background: #ffe066; color: #7a4b00; font-weight: 900; }
.drop-tag { margin-top: 6px; display: flex; gap: 6px; align-items: center; font-size: 14px; color: #6b3d00; background: #fff4cc; border-radius: 10px; padding: 6px 8px; }
.drop-tag img { width: 28px; height: 28px; }
.ver-tag { position: fixed; right: calc(6px + env(safe-area-inset-right)); bottom: calc(2px + env(safe-area-inset-bottom)); z-index: 60; font-size: 10px; color: rgba(255,255,255,.85); text-shadow: 0 1px 2px rgba(0,0,0,.7); pointer-events: none; letter-spacing: .02em; }
body:not(.fullmap) .ver-tag { color: var(--muted); text-shadow: none; }

/* 검색 로봇·화면이 뜨기 전 소개(app.js 가 바로 바꿔 그린다) */
.seo-intro { max-width: 640px; margin: 40px auto; padding: 0 16px; line-height: 1.6; color: var(--ink); }
.seo-intro h1 { font-size: 24px; } .seo-intro h2 { font-size: 18px; margin-top: 18px; }
.warn-note { background: #fff1e6; color: #8a3b00; border-radius: 10px; padding: 8px 10px; line-height: 1.5; }

/* 점검(2026-11-14): 문제 창의 확인 단추는 창 아래에 붙고, 작은 화면에선 숫자판을 줄인다 */
.float .play .enter-btn { position: sticky; bottom: 0; z-index: 2; box-shadow: 0 -6px 12px var(--paper, #fff); }
@media (max-height: 700px) { .float .pad button { min-height: 40px; padding: 6px; font-size: 20px; } .float .answer-row .slot { min-height: 44px; } }
.tlabel { paint-order: stroke; stroke: rgba(255,255,255,.85); stroke-width: 3px; fill: #1d2a22 !important; }

/* 메뉴 판이 열리면 지도를 가린다(누르면 닫힘) */
.panel-back { position: absolute; inset: 0; z-index: 5; background: rgba(10, 20, 15, .28); animation: fade-in .15s ease-out; touch-action: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.panel-head .pback { margin-right: auto; }

/* 손님 체험 모드 */
.trial-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; pointer-events: auto; background: #fff4d6; color: #6b4a00; border: 1px solid #f0c75e; }
.trial-bar .btn { min-height: 30px; padding: 4px 10px; }
.trial-note { background: #fff4d6; color: #6b4a00; border-radius: 10px; padding: 8px 10px; line-height: 1.5; }
.trial-btn[aria-pressed="true"] { border-color: #e0a800; background: #fff4d6; font-weight: 700; }

/* 틀린 문제 벌칙(5초) */
.pen-wait { position: relative; overflow: hidden; text-align: center; padding: 16px 12px; border-radius: 14px; background: #fff1e6; color: #8a3b00; font-weight: 700; }
.pen-wait .cd { position: absolute; left: 0; bottom: 0; height: 4px; background: #e8762b; transform-origin: left; animation: nextcd linear forwards; width: 100%; }
.next-big[disabled] { opacity: 1; cursor: default; background: #b9c4bd; border-color: #b9c4bd; }

/* 관리자 · 풀이 기록 */
.lg-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.lg-filter input, .lg-filter select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); font: inherit; background: var(--card); color: var(--ink); min-width: 0; }
.lg-dev summary { cursor: pointer; line-height: 1.6; }
.lg { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.lg td { border-top: 1px solid var(--line); padding: 6px 4px; vertical-align: top; }
.lg td:first-child { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.lg-b td { background: rgba(47,127,230,.07); }
.lg-no td { background: rgba(230,120,40,.07); }
.lg-dup td { background: rgba(220,40,40,.16); }
@media (max-width: 600px) { .lg { font-size: 12px; } }

/* 대분수 입력: 자연수 칸 + 분수 칸 */
.mixin { display: flex; align-items: center; gap: 8px; justify-content: center; }
.mixin > .slot { min-width: 64px; }

/* 휴대폰 가로(낮은 화면): 아래 가방·추천 땅을 한 줄로 작게, 위 안내도 줄여 지도를 더 보이게(2026-11-14) */
@media (max-height: 500px) and (orientation: landscape) {
  .hud-bottom { flex-wrap: nowrap; align-items: stretch; gap: 6px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); } /* 오른쪽 아래 판·저작권 글자 자리 */
  .hud-bottom .bag { flex: 0 1 auto; padding: 4px 8px; display: flex; align-items: center; }
  .hud-bottom .bag-row { flex-wrap: nowrap; gap: 4px; }
  .hud-bottom .bag-row > b, .hud-bottom .bag-row > .small, .hud-bottom .bag .her-powers { display: none; }
  .hud-bottom .bag .item-btn { width: 36px; height: 36px; }
  .hud-bottom .bag .item-btn img { width: 26px; height: 26px; }
  .hud-bottom #recommend { flex: 1 1 auto; padding: 4px 10px; display: flex; align-items: center; }
  .hud-bottom #recommend > * { width: 100%; }
  .hud-bottom #recommend .small, .hud-bottom #recommend .muted { display: none; }
  .hud-bottom #recommend .btn { min-height: 36px; padding: 6px 12px; }
  .hud-sub { gap: 4px; top: calc(62px + env(safe-area-inset-top)); }
  .hud-sub .reach-hint { display: none; }
  .hud-top { padding-top: calc(6px + env(safe-area-inset-top)); }
  .goal .ring { width: 34px; height: 34px; }
  .game .mapctl { top: calc(62px + env(safe-area-inset-top)); }
  .game .mapctl button { width: 36px; height: 36px; font-size: 18px; }
  .hud-bottom .join-cta { padding: 6px 12px; }
  .hud-bottom .join-cta .small { display: none; }
}

/* 닉네임 신고 */
.nick-rep:not(.btn) { border: 0; background: none; cursor: pointer; font-size: 13px; padding: 0 2px; opacity: .55; }
.nick-rep:not(.btn):hover { opacity: 1; }
.nick-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; }
/* 선생님 화면: 로고 올리기 파일 칸·닉네임 목록이 좁은 폰에서 넘치지 않게 */
#logofile { max-width: 100%; min-width: 0; font-size: 14px; }
.nick-list li { flex-wrap: wrap; }

/* ═════ 일기토 ═════ */
.duel-go { background: linear-gradient(90deg, #ffe1d6, #fff1c9); border-color: #f0a37e; font-weight: 800; }
.duel-invite { position: fixed; z-index: 46; left: 50%; top: calc(8px + env(safe-area-inset-top)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 6px; border-radius: 14px; background: color-mix(in srgb, var(--paper) 96%, transparent); border: 1px solid #f0a37e; box-shadow: 0 6px 18px rgba(0,0,0,.2); max-width: calc(100vw - 24px); animation: panel-in .2s ease-out; }
.duel-invite .di-rider { width: 42px; height: 42px; object-fit: contain; transform: scaleX(-1); margin: 0; }
.di-txt { display: grid; gap: 2px; min-width: 0; font-size: 13px; }
.di-txt b { font-size: 14px; } .di-txt span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.di-x { border: 0; background: none; font-size: 16px; padding: 4px 6px; cursor: pointer; color: var(--muted); }
.di-time { height: 6px; background: #eee; border-radius: 4px; overflow: hidden; }
.di-time i { display: block; height: 100%; background: #e8762b; transform-origin: left; animation: nextcd linear forwards; }
.duel { position: fixed; inset: 0; z-index: 55; display: flex; flex-direction: column; background: #1d2a22; }
.duel-stage { position: relative; flex: 1 1 auto; min-height: 220px; background-size: cover; background-position: center 60%; overflow: hidden; }
.duel-top { position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: start; padding: calc(10px + env(safe-area-inset-top)) 12px 0; }
.duel-side { display: grid; gap: 4px; }
.duel-side.opp { text-align: right; }
.duel-name { color: #fff; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.duel-hp { height: 16px; border-radius: 8px; background: rgba(0,0,0,.45); border: 2px solid #fff; overflow: hidden; }
.duel-hp i { display: block; height: 100%; width: 100%; background: linear-gradient(180deg, #7dff7a, #22b83a); transition: width .4s ease; }
.duel-side.opp .duel-hp i { margin-left: auto; }
.duel-hp i.low { background: linear-gradient(180deg, #ff8f7a, #e0362a); }
.duel-mid { color: #fff; text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,.8); min-width: 90px; }
.duel-timer { height: 6px; margin-top: 4px; border-radius: 4px; background: rgba(0,0,0,.45); overflow: hidden; }
.duel-timer i { display: block; height: 100%; background: #ffd23f; width: 100%; transition: width .2s linear; }
.duel-rider { position: absolute; bottom: 6%; width: min(36vw, 280px); filter: drop-shadow(0 10px 10px rgba(0,0,0,.35)); transition: transform .2s; }
.duel-rider.me { left: 6%; transform: scaleX(-1); }
.duel-rider.opp { right: 6%; }
.duel-rider.me.lunge { animation: lunge-r .55s ease-out; }
.duel-rider.opp.lunge { animation: lunge-l .55s ease-out; }
@keyframes lunge-r { 0% { transform: scaleX(-1) translateX(0); } 45% { transform: scaleX(-1) translateX(-38vw); } 100% { transform: scaleX(-1) translateX(0); } }
@keyframes lunge-l { 0% { transform: translateX(0); } 45% { transform: translateX(-38vw); } 100% { transform: translateX(0); } }
.duel-rider.me.hurt { animation: hurt-r .45s; } .duel-rider.opp.hurt { animation: hurt-l .45s; }
@keyframes hurt-r { 0%,100% { transform: scaleX(-1); filter: none; } 30% { transform: scaleX(-1) translateX(14px) rotate(-6deg); filter: brightness(1.8) saturate(.4); } }
@keyframes hurt-l { 0%,100% { transform: none; filter: none; } 30% { transform: translateX(14px) rotate(6deg); filter: brightness(1.8) saturate(.4); } }
.duel-rider.me.down { transform: scaleX(-1) rotate(-14deg) translateY(10px); opacity: .55; } .duel-rider.opp.down { transform: rotate(14deg) translateY(10px); opacity: .55; }
.duel-hit { position: absolute; bottom: 22%; width: min(26vw, 200px); pointer-events: none; }
.duel-hit.at-opp { right: 12%; } .duel-hit.at-me { left: 12%; }
.duel-hit.pop { animation: hitpop .6s ease-out forwards; }
@keyframes hitpop { 0% { transform: scale(.2) rotate(-20deg); opacity: 0; } 30% { transform: scale(1.15) rotate(8deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 0; } }
.duel-stage.shake { animation: shake .35s; }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translate(-6px, 3px); } 50% { transform: translate(6px, -3px); } 75% { transform: translate(-3px, 2px); } }
.duel-pop { position: absolute; left: 50%; top: 32%; transform: translateX(-50%); font-size: 28px; font-weight: 900; color: #fff; -webkit-text-stroke: 1.5px #3a1d00; animation: panel-in .3s; white-space: nowrap; }
.duel-pop.good { color: #ffe066; } .duel-pop.bad { color: #ff9a8a; }
.duel-panel { flex: 0 0 auto; background: var(--paper); border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); max-height: 55vh; overflow-y: auto; }
.duel-q { font-size: 24px; font-weight: 800; text-align: center; margin: 4px 0 12px; }
.duel-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.duel-opts .btn { min-height: 52px; font-size: 17px; }
.duel-num { display: grid; gap: 8px; max-width: 420px; margin: 0 auto; }
.duel-num .slot { text-align: center; font-size: 26px; font-weight: 800; padding: 8px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); }
.duel-num .pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.duel-num .pad button { min-height: 48px; font-size: 20px; font-weight: 800; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.duel-lock, .duel-wait { text-align: center; color: var(--muted); padding: 12px; }
.duel-end { text-align: center; display: grid; gap: 8px; padding: 6px; }
.duel-end b { font-size: 30px; } .duel-end.win b { color: #d98a00; }
.duel-flee { position: fixed; right: calc(12px + env(safe-area-inset-right)); top: calc(64px + env(safe-area-inset-top)); z-index: 56; }
@media (max-height: 520px) { .duel-rider { width: min(26vw, 200px); } .duel-q { font-size: 19px; margin-bottom: 8px; } .duel-panel { max-height: 50vh; padding-top: 8px; } }
@media (max-height: 520px) { .duel-rider { width: auto; height: 62%; bottom: 4%; } .duel-hit { width: auto; height: 45%; } }
@media (max-width: 520px) and (min-height: 600px) { .duel-rider { width: 46vw; } }

/* 일대일대결: 장수 움직임 — 서 있을 때 말이 들썩, 차례인 장수 빛, 공격(돌진)·공격 실패(돌진했다 튕김)·막기 */
.duel-rider { animation: gallop-l 1.1s ease-in-out infinite; }
.duel-rider.me { animation-name: gallop-r; }
@keyframes gallop-r { 0%,100% { transform: scaleX(-1) translateY(0); } 50% { transform: scaleX(-1) translateY(-6px); } }
@keyframes gallop-l { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.duel-rider.turn { filter: drop-shadow(0 0 10px #ffe066) drop-shadow(0 10px 10px rgba(0,0,0,.35)); }
.duel-rider.me.lunge-fail { animation: lungef-r .6s ease-out; } .duel-rider.opp.lunge-fail { animation: lungef-l .6s ease-out; }
@keyframes lungef-r { 0% { transform: scaleX(-1); } 40% { transform: scaleX(-1) translateX(-30vw); } 55% { transform: scaleX(-1) translateX(-24vw) rotate(4deg); } 100% { transform: scaleX(-1); } }
@keyframes lungef-l { 0% { transform: none; } 40% { transform: translateX(-30vw); } 55% { transform: translateX(-24vw) rotate(-4deg); } 100% { transform: none; } }
.duel-rider.me.block { animation: block-r .5s; } .duel-rider.opp.block { animation: block-l .5s; }
@keyframes block-r { 0%,100% { transform: scaleX(-1); filter: none; } 35% { transform: scaleX(-1) translateX(10px) rotate(-3deg); filter: drop-shadow(0 0 14px #9fd3ff) brightness(1.15); } }
@keyframes block-l { 0%,100% { transform: none; filter: none; } 35% { transform: translateX(10px) rotate(3deg); filter: drop-shadow(0 0 14px #9fd3ff) brightness(1.15); } }
.duel-timer i.mine { background: #ff8a3d; }
.duel-q.watch { color: var(--muted); }
.duel-first { text-align: center; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.duel-waitbar { border-color: #f3c27a; }
.rec-attack { color: #c0392b; font-weight: 700; }

/* 새 버전 알림(저절로 다시 읽지 않음) */
.update-bar { position: fixed; z-index: 47; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-radius: 14px; background: #1f3b2c; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.3); font-size: 14px; max-width: calc(100vw - 24px); }
.update-bar .di-x { color: #cfe; }

/* 본진을 잃음(공격력 −25%) · 되찾기(+50%) */
.horn-chip.hq-lost { background: #fde2e1; color: #a1251b; border-color: #f3b1ab; }
.horn-chip.hq-back { background: #fff1c9; color: #7a4b00; border-color: #f1d27a; }

/* 일대일대결 단추: 늘 보이고, 못 쓸 때는 흐리게(누르면 이유) */
.duel-slot { margin-top: 10px; }
.duel-go.off { opacity: .5; filter: grayscale(.7); cursor: help; }
.duel-help { margin: 6px 2px 0; line-height: 1.45; }
