:root { color-scheme: light; --ink: #243b35; --muted: #73827b; --green: #287b58; --border: #e1e9df; }
* { box-sizing: border-box; }
body { margin: 0; background: #f4f7ed; color: var(--ink); font-family: "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif; }
button { font: inherit; }
.app { max-width: 1540px; margin: auto; padding: 38px 32px 20px; }
.header { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: 2px; }
h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: -1.3px; }
h1 span { margin-left: 8px; }
.subtitle { color: var(--muted); margin: 9px 0 0; font-size: 14px; }
.stage-badge, .small-tag { border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; background: white; font-size: 12px; color: var(--muted); white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { border: 1px solid var(--border); background: white; padding: 17px 22px; border-radius: 14px; }
.stat > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.stat strong { font-size: 26px; } small { font-size: 12px; color: var(--muted); font-weight: 500; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.panel { padding: 22px; background: white; border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 4px 16px #233c2910; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
h2 { font-size: 18px; margin: 0; letter-spacing: -.5px; }
.live-badge { background: #edf6e9; color: var(--green); border-radius: 20px; font-size: 12px; padding: 7px 12px; }
.canvas-wrap { overflow: auto; max-height: 760px; border-radius: 12px; background: #deedc9; border: 1px solid #d4e4bf; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 20 / 13; touch-action: manipulation; }
.map-tools { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: 12px; margin-bottom: 12px; color: var(--muted); }
.map-tools select { padding: 6px; border: 1px solid var(--border); border-radius: 6px; background: white; }
.shop-grid { grid-auto-rows: 1fr; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.shop-item { display: flex; flex-direction: column; position: relative; border: 2px solid var(--border); border-radius: 12px; background: #f6f8ef; padding: 12px 6px; color: var(--ink); text-align: center; }
.shop-item .shop-icon { display: block; font-size: 32px; margin-bottom: 6px; }
.shop-item strong { display: block; font-size: 12px; }.shop-item small { display: block; margin-top: 5px; color: #a47a24; }
.shop-item .shop-description { margin: 8px 0 0; font-size: 11px; min-height: 0; }
.shop-item .shop-buy { margin-top: auto; }
.shop-item .shop-description { padding-bottom: 10px; }
.shop-buy { min-height: 52px; padding: 10px 4px; font-size: 12px; }
.shop-item:disabled { opacity: .5; cursor: not-allowed; }
.shop-item[data-state="wave-locked"] { background: #eceeed; border-color: #c4cac7; color: #727a75; }
.shop-item[data-state="wave-locked"] small { color: #626d67; }
.shop-item[data-state="unaffordable"] { opacity: .85; background: #fff5df; border-color: #dfc28c; }
.shop-item[data-state="unaffordable"] small { color: #945600; font-weight: 700; }
.shop-description { font-size: 12px; color: var(--muted); line-height: 1.8; min-height: 42px; }
.tower-detail { margin-top: 14px; background: #edf4e8; border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.tower-detail p { font-size: 12px; color: var(--muted); line-height: 1.7; margin-bottom: 0; }
.wave-preview { padding: 12px; background: #f8eed4; color: #866329; border-radius: 8px; font-size: 12px; line-height: 1.7; }
.map-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-top: 18px; font-size: 11px; color: var(--muted); }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }.path-dot { background: #d9bc8c; }.tower-dot { background: #74a263; }
.text-button { margin-left: auto; border: 0; color: var(--green); background: transparent; cursor: pointer; padding: 6px; font-size: 12px; }
.map-message { margin: 12px 0 0; padding: 12px; border-radius: 8px; background: #f5f8f1; color: #59704f; font-size: 12px; }
.sidebar { display: grid; gap: 18px; }.quiz-panel { text-align: center; }.quiz-panel > .eyebrow { margin-bottom: 12px; }
.quiz-meta { display: flex; justify-content: center; gap: 8px; margin: 17px 0; }.quiz-meta span { background: #edf4eb; color: #5b8055; padding: 5px 9px; border-radius: 6px; font-size: 11px; }
.placeholder-icon { display: grid; place-items: center; width: 58px; height: 58px; background: #f9ecca; color: #b38b37; border-radius: 18px; margin: 24px auto 18px; font-size: 32px; font-weight: 800; transform: rotate(-7deg); }
h3 { margin: 0; font-size: 14px; }.muted { color: var(--muted); font-size: 13px; line-height: 1.8; }
.primary-button, .secondary-button { width: 100%; padding: 12px; border: 0; border-radius: 9px; margin-top: 10px; font-weight: 700; font-size: 13px; }.primary-button { background: #e3ebdf; color: #7c9176; }.secondary-button { background: #f0f3ec; color: #8b9783; }button:disabled { cursor: not-allowed; }
.development-note { font-size: 10px; color: var(--muted); margin: 10px 0 0; }.small-tag { padding: 4px 7px; font-size: 10px; }
.tower-card { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }.tower-icon { background: #f6f0df; padding: 8px; border-radius: 8px; font-size: 23px; }.tower-card p { font-size: 10px; color: var(--muted); margin: 5px 0 0; }.tower-card strong { margin-left: auto; font-size: 12px; color: #a67b26; white-space: nowrap; }
.tip { display: flex; gap: 12px; padding: 0 8px; color: #788568; }.tip > span { font-size: 24px; }.tip p { margin: 0; font-size: 12px; line-height: 1.8; }.tip strong { color: #5a714a; }
.footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; color: #97a28e; font-size: 11px; }
button:focus-visible { outline: 3px solid #327e61; outline-offset: 3px; }
.primary-button:not(:disabled) { background: var(--green); color: white; cursor: pointer; }
.secondary-button:not(:disabled) { color: var(--green); cursor: pointer; }
.stage-label { display: block; text-align: left; font-size: 12px; margin: 16px 0 6px; color: var(--muted); }
#quiz-stage, #quiz-grade, #quiz-subject { width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: 8px; background: white; color: var(--ink); font: inherit; font-size: 13px; }
.difficulty-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-panel { margin-bottom: 22px; }
.mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.mode-card { padding: 18px; border: 2px solid var(--border); border-radius: 12px; background: #f8faf4; color: var(--ink); text-align: left; cursor: pointer; }
.mode-card strong, .mode-card span { display: block; }.mode-card span { margin-top: 8px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.mode-card[aria-pressed="true"] { background: #edf6e9; border-color: var(--green); }
.game-result { padding: 16px; border-radius: 10px; background: #f9ecca; color: #735a22; font-weight: 700; line-height: 1.7; }
select:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.quiz-choices { display: grid; gap: 8px; margin-top: 16px; }
.quiz-choice { padding: 10px; text-align: left; border: 1px solid var(--border); border-radius: 8px; background: #f5f8f1; color: var(--ink); cursor: pointer; }
.quiz-choice[data-result="correct"] { background: #deedc9; border-color: var(--green); }
.quiz-choice[data-result="wrong"] { background: #fbe4df; border-color: #a54935; }
.quiz-choice:disabled { cursor: default; }
.quiz-choice[data-choice="0"] { background: #ffe5e8; border-color: #d77789; color: #6e2032; }
.quiz-choice[data-choice="1"] { background: #e3eeff; border-color: #6e98d8; color: #224b83; }
.quiz-choice[data-choice="2"] { background: #fff1cd; border-color: #c9a23b; color: #694d09; }
.quiz-choice[data-choice="3"] { background: #eee4ff; border-color: #a08acc; color: #503273; }
.quiz-choice[data-result="correct"] { background: #d6f4d9; border: 3px solid #267b3b; color: #164923; }
.quiz-choice[data-result="wrong"] { background: #ffe2de; border: 3px dashed #ad3427; color: #71291e; }
[hidden] { display: none !important; }
.session-controls { margin-bottom: 14px; }
.phase-guide { color: var(--green); text-align: center; font-weight: 700; }
.game-layout[data-screen="quiz"] { display: block; }
.game-layout[data-screen="quiz"] .sidebar { display: block; max-width: 800px; margin: 0 auto; }
.game-layout[data-screen="quiz"] .quiz-panel { padding: 32px; }
.game-layout[data-screen="quiz"] .quiz-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.game-layout[data-screen="quiz"] .quiz-choice { min-height: 90px; font-size: 17px; font-weight: 700; }
.game-layout[data-screen="quiz"] #quiz-question { font-size: 22px; line-height: 1.6; }
.battlefield-stage { position: relative; }
.wave-result { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 20px; text-align: center; background: #e8f4dff2; border: 2px solid var(--green); border-radius: 12px; overflow: auto; }
.wave-result p { margin: 0; max-width: 480px; line-height: 1.8; }
.countdown-overlay { position: fixed; inset: 0; z-index: 100; background: #173929dd; display: grid; place-items: center; text-align: center; color: white; pointer-events: none; }
.countdown-overlay strong { display: block; font-size: clamp(100px, 20vw, 180px); animation: countdown-pulse 1s ease-out infinite; }
@keyframes countdown-pulse { from { transform: scale(1.2); opacity: .5; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .countdown-overlay strong { animation: none; } }
@media (max-width: 580px) { .game-layout[data-screen="quiz"] .quiz-panel { padding: 20px 14px; } .game-layout[data-screen="quiz"] .quiz-choices { grid-template-columns: 1fr; } }
#quiz-question { line-height: 1.7; }
[hidden] { display: none !important; }
canvas.placing { cursor: crosshair; }
.game-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.control-button { padding: 10px 16px; border: 0; border-radius: 8px; background: var(--green); color: white; font-weight: 700; cursor: pointer; }
.secondary-control { background: #eaf1e5; color: var(--green); }
.control-button:disabled { opacity: .45; cursor: not-allowed; }
.slot-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.slot-button { background: #f5f8f1; color: #59704f; border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-size: 11px; cursor: pointer; }
.slot-button[aria-pressed="true"] { background: #deedc9; border-color: var(--green); color: var(--green); }
.live-badge[data-state="gameOver"] { background: #fbe4df; color: #a54935; }
@media (max-width: 980px) { .stats { grid-template-columns: repeat(3, 1fr); }.game-layout { grid-template-columns: 1fr; }.sidebar { grid-template-columns: 1fr 1fr; }.tip { grid-column: 1 / -1; }.app { padding: 24px; } }
@media (max-width: 580px) { .app { padding: 20px 12px; }.header { align-items: start; flex-direction: column; gap: 12px; }.stats { grid-template-columns: 1fr 1fr; gap: 10px; }.stat { padding: 14px; }.stat strong { font-size: 23px; }.sidebar { grid-template-columns: 1fr; }.panel { padding: 16px; }.map-footer { gap: 10px; }.footer { flex-direction: column; } }
@media (max-width: 580px) { .mode-options { grid-template-columns: 1fr; }.stats .stat:last-child { grid-column: 1 / -1; } }

.question-clock { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-top: 16px; padding: 10px; background: #edf4e8; border-radius: 8px; font-size: 12px; }
.question-clock strong { font-size: 20px; color: var(--green); }.question-clock progress { width: 100%; height: 8px; margin-top: 8px; accent-color: var(--green); }.question-clock[data-urgent="true"] strong { color: #bd3434; }.question-clock[data-urgent="true"] progress { accent-color: #bd3434; }
#ranking-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
#ranking-name { border: 1px solid var(--border); border-radius: 6px; padding: 10px; max-width: 180px; }
#ranking-list { padding-left: 26px; font-size: 13px; line-height: 2; }
.quit-button { background: #a55843; }
.quiz-meta { flex-wrap: wrap; }

.ranking-hall { margin-top: 28px; border: 2px solid #d9ad43; background: linear-gradient(135deg, #fff9e5, #fff); }
.ranking-hall h2 { font-size: 26px; color: #795618; }
.ranking-hall .development-note { font-size: 12px; line-height: 1.9; }
#ranking-list { list-style: none; padding: 0; display: grid; gap: 12px; }
#ranking-list li { padding: 16px; background: #f0f5eb; border: 1px solid var(--border); border-radius: 12px; }
#ranking-list li strong { font-size: 18px; }
#ranking-list li p { margin: 6px 0 0; font-size: 12px; line-height: 1.8; }
#ranking-list li[data-rank="1"] { background: #fff0bb; border: 2px solid #d4a532; }
#ranking-list li[data-rank="1"] strong { font-size: 25px; }
#ranking-list li[data-rank="2"] { background: #eef1fb; border-color: #a5b2d6; }
#ranking-list li[data-rank="3"] { background: #fae8d6; border-color: #ce9a64; }
#ranking-entry { border: 2px solid #d9ad43; background: #fff8df; }

.tower-manager { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 16px; padding: 16px; border: 2px solid #b8d4a9; border-radius: 12px; background: #f3f8ed; }
.tower-manager-info { flex: 1 1 220px; min-width: 0; }
.tower-manager h3 { margin-bottom: 8px; color: var(--green); font-size: 16px; }
.tower-manager-info > strong { font-size: 13px; }
.tower-manager-info > p, .tower-selection-hint { margin: 6px 0 0; font-size: 12px; line-height: 1.6; color: #52664c; }
.tower-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tower-actions .control-button { min-height: 48px; }
.sell-control { background: #f8e7bd; color: #795618; }
.tower-selection-hint { flex-basis: 100%; margin: 0; }
.tower-manager[data-selected="true"] { border-color: var(--green); background: #edf6e9; }
@media (max-width: 580px) { .tower-actions { width: 100%; }.tower-actions .control-button { flex: 1; padding: 10px; font-size: 12px; } }

.upgrade-legend { padding: 5px 9px; border: 1px solid #bb9032; border-radius: 6px; background: #ffe17a; color: #543b00; font-weight: 700; }

.pause-overlay { width: min(360px, calc(100% - 32px)); padding: 32px 24px; border: 2px solid #b8d4a9; border-radius: 20px; background: #f8fcf3; color: var(--ink); text-align: center; box-shadow: 0 16px 64px #17392940; }
.pause-overlay::backdrop { background: #173929b8; }
.pause-icon { display: block; margin-bottom: 12px; font-size: 42px; color: var(--green); }
.pause-overlay h2 { font-size: 26px; }
.pause-overlay p { margin: 16px 0 24px; color: #52664c; font-size: 14px; line-height: 1.8; }
.pause-overlay .control-button { width: 100%; min-height: 50px; font-size: 16px; }

/* 이야기와 묻는 말을 나누어 읽도록 문제은행의 줄바꿈을 보존합니다. */
#quiz-question { white-space: pre-line; word-break: keep-all; overflow-wrap: anywhere; }
.quiz-choice { word-break: keep-all; overflow-wrap: anywhere; line-height: 1.6; }
/* 접속 공유와 두 단계 카테고리 */
.header-actions { display:flex; flex-wrap:wrap; gap:10px; justify-content:flex-end; }
#quiz-domain { width:100%; padding:11px; border:1px solid var(--green); border-radius:8px; background:#edf6e9; color:var(--ink); font:inherit; font-weight:700; }
.qr-dialog { box-sizing:border-box; position:fixed; inset:0; width:100vw; max-width:none; height:100dvh; max-height:none; margin:0; border:0; padding:24px clamp(16px,5vw,72px); background:white; color:#15251d; text-align:center; overflow:auto; }
.qr-dialog[open] { display:flex; flex-direction:column; align-items:center; gap:12px; }
.qr-top { display:flex; justify-content:space-between; align-items:center; gap:24px; width:100%; text-align:left; }
.qr-top .eyebrow { margin:0 0 5px; }.qr-top h2 { font-size:clamp(18px,3vw,30px); }
.qr-image { flex:1; min-height:120px; width:100%; display:flex; align-items:center; justify-content:center; }
.qr-image svg { display:block; width:min(72vw,55dvh); max-width:100%; height:auto; max-height:55dvh; background:white; }
.qr-url { margin:0; overflow-wrap:anywhere; max-width:100%; font-size:clamp(12px,1.7vw,18px); }
.qr-actions { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; }.qr-dialog #qr-message { font-size:13px; margin:0; }
.qr-settings { width:min(720px,100%); font-size:12px; }.qr-settings summary { cursor:pointer; padding:5px; }.qr-settings form { text-align:left; margin-top:8px; }
.inline-form { display:flex; gap:8px; margin-top:6px; }.inline-form input { flex:1; min-width:0; }
.library-dialog { width:min(780px,calc(100vw - 24px)); max-height:90dvh; padding:clamp(16px,3vw,30px); border:1px solid var(--border); border-radius:18px; color:var(--ink); }
.library-dialog::backdrop { background:#152c21aa; }.library-dialog p { font-size:13px; line-height:1.8; }
.library-dialog input:not([type=file]), .library-dialog textarea, .qr-settings input { box-sizing:border-box; width:100%; border:1px solid var(--border); border-radius:8px; padding:10px; font:inherit; color:var(--ink); }
.library-dialog textarea { font-family:monospace; font-size:12px; resize:vertical; }
.library-help { background:#f0f6ec; border-radius:10px; padding:16px; font-size:13px; }
.library-dialog hr { border:0; border-top:1px solid var(--border); margin:24px 0; }
.upload-preview { max-height:300px; overflow:auto; padding:12px; border:1px solid var(--border); border-radius:10px; margin:12px 0; }
.upload-preview ol { padding-left:24px; margin:0; }.upload-preview li { font-size:13px; line-height:1.7; padding:10px 0; border-bottom:1px solid var(--border); white-space:pre-wrap; }.upload-preview p { margin:4px 0; }.upload-preview .correct-answer { color:#246338; font-weight:700; }
.public-library-list { display:grid; gap:10px; }.public-pack { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:12px; border:1px solid var(--border); border-radius:10px; }.public-pack strong { flex:1; min-width:140px; font-size:13px; }.public-pack small { width:100%; color:var(--muted); }
#upload-message[data-error="true"] { color:#a52929; }.control-button:disabled { opacity:.55; }
@media(max-width:640px) { .header { align-items:flex-start; flex-direction:column; }.header-actions { justify-content:flex-start; }.qr-dialog { padding:14px; gap:8px; }.qr-top { gap:12px; }.qr-image svg { width:min(90vw,53dvh); }.qr-actions .control-button { font-size:12px; padding:10px; }.inline-form { flex-wrap:wrap; }.inline-form input { flex-basis:100%; }.library-dialog .panel-heading { gap:12px; align-items:flex-start; } }
.authoring-method { display:flex; flex-wrap:wrap; gap:8px; margin:18px 0 12px; }
.authoring-method [aria-pressed="true"] { background:var(--green); color:white; }
.file-authoring { margin:0; padding:0; border:0; min-width:0; }
.visually-hidden { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.direct-question { min-width:0; margin:16px 0; border:1px solid var(--border); border-radius:12px; padding:16px; background:#f8faf5; }
.direct-question legend { padding:0 8px; font-size:15px; font-weight:700; color:var(--green); }
.direct-question label { display:block; margin:12px 0 5px; font-size:12px; }
.direct-question select { width:100%; padding:10px; border:1px solid var(--border); border-radius:8px; background:white; color:var(--ink); font:inherit; }
.direct-question .remove-question { display:block; margin:10px 0 0 auto; color:#9c3930; }
#direct-count { color:var(--green); font-weight:700; }
