/* 복음의 길 — 복습 퀴즈(quiz.html)
   대상: 샘물청소년부 중심, 40대 이하. 휴대폰 한 손 조작(단추는 아래쪽, 48px), 높은 대비, 쉬운 말.
   색·글꼴·지도 색은 css/atlas.css·css/timeline.css의 토큰과 같은 값(밝은 화면 하나).
   지도 위 정답·고른 곳 표시는 지도 화면의 번호 원(.pin .dot, .pin.current)과 같은 모양이다.
   [크게 보기](data-big): 화면 띄우기(프로젝터)로 다 같이 풀 때 글씨·단추를 키운다. */
:root {
  color-scheme: light;
  --bg: #F8F6F2;
  --surface: #FFFFFF;
  --tint: #F0FAF6;
  --ink: #171719;
  --ink-2: #2E2F33;
  --ink-3: #5A5C63;
  --line: #D8D2C6;
  --line-soft: #ECE7DE;
  --line-strong: #8F8879;
  --primary: #1A6B5A;
  --primary-strong: #15594B;
  --primary-heavy: #10453A;
  --gold: #C99A3C;
  --focus: #1A6B5A;
  --old: #7A5718;
  --ok: #1B6B3A;            /* 맞음(흰 바탕 6.5:1) */
  --ok-bg: #EAF6EE;
  --no: #A3271F;            /* 틀림(흰 바탕 6.6:1) */
  --no-bg: #FCEDEB;
  /* 지도(css/atlas.css와 같은 값) */
  --sea: #CFE1E4;
  --land: #F4EFE6;
  --coast: #A9A08F;
  --now-map: #4A6676;
  --sea-label: #46666D;
  --shadow: 0 1px 2px rgba(20,38,74,.05), 0 10px 30px -12px rgba(20,38,74,.14);
  --hover: rgba(23, 23, 25, .06);
  --press: rgba(23, 23, 25, .14);
  --font-ui: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --t-body: 1.0625rem;
  --t-label: 1rem;
  --t-caption: .875rem;
  --tap: 48px;
  --radius: 16px;
  --radius-btn: 11px;
  --story: var(--primary);
}
/* 크게 보기: rem을 키워 글씨·단추·간격을 한꺼번에 키운다 */
:root[data-big] { font-size: 125%; }
@media (min-width: 1200px) { :root[data-big] { font-size: 150%; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: var(--t-body); line-height: 1.6;
  -webkit-text-size-adjust: 100%; word-break: keep-all; overflow-wrap: anywhere; overflow-x: hidden;
}
button, select { font: inherit; color: inherit; }
a { color: var(--primary-strong); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }
.ic { width: 1.15em; height: 1.15em; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 10; background: var(--surface); padding: 10px 16px; border-radius: var(--radius-btn); box-shadow: var(--shadow); font-weight: 700; }
.skip:focus { top: 12px; }

/* ── 머리(흐름 화면과 같은 모양) ── */
.masthead {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 12px 16px 10px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.kicker { margin: 0; font-size: var(--t-caption); color: var(--ink-3); font-weight: 600; }
.kicker a { color: var(--ink-3); }
.masthead h1 { margin: 0; font-size: 1.5rem; font-weight: 800; line-height: 1.3; letter-spacing: -.01em; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tool, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-btn);
  background: var(--surface); color: var(--ink);
  font-size: var(--t-label); font-weight: 700; text-decoration: none; cursor: pointer;
}
.tool:hover, .btn:hover { background-image: linear-gradient(var(--hover), var(--hover)); }
.tool:active, .btn:active { background-image: linear-gradient(var(--press), var(--press)); }
.tool-map, .btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.tool[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn:disabled { cursor: default; background: var(--line-soft); border-color: var(--line); color: var(--ink-3); background-image: none; }

main { max-width: 1240px; margin: 0 auto; padding: 0 16px 24px; }

/* ── 1. 고르기 ── */
.setup { max-width: 720px; margin: 0 auto; padding: 18px 0 8px; }
.setup-h { margin: 0 0 6px; font-size: 1.3125rem; line-height: 1.4; }
.setup-h:focus { outline: none; }
.setup-lead { margin: 0 0 14px; color: var(--ink-2); }
.pick { margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
.pick legend { padding: 0; margin: 0 0 8px; font-weight: 800; font-size: var(--t-label); }
.opts { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .opts-mode { grid-template-columns: repeat(2, minmax(0, 1fr)); } .opts-scope { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.opts-scope { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opt {
  position: relative; display: flex; flex-direction: column; justify-content: center;
  min-height: 56px; padding: 10px 14px 10px 46px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer;
}
.opt:hover { background-image: linear-gradient(var(--hover), var(--hover)); }
.opt input { position: absolute; left: 14px; top: 50%; width: 22px; height: 22px; margin: -11px 0 0; accent-color: var(--primary); }
.opt-t { font-weight: 700; line-height: 1.35; }
.opt-d { font-size: var(--t-caption); color: var(--ink-3); line-height: 1.4; }
.opt:has(input:checked) { border-color: var(--primary); box-shadow: inset 0 0 0 1.5px var(--primary); background: var(--tint); }
.opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.story-pick { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.story-pick label { font-weight: 700; font-size: var(--t-label); }
.story-pick select {
  min-height: var(--tap); width: 100%; padding: 0 12px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-btn);
  background: var(--surface);
}
.scope-note { margin: 0 0 10px; font-size: var(--t-caption); color: var(--ink-2); min-height: 0; }
.scope-note:empty { display: none; }
.btn-start { width: 100%; min-height: 56px; font-size: 1.125rem; }
.privacy { margin: 10px 0 0; font-size: var(--t-caption); color: var(--ink-3); }

/* ── 2. 문제: 휴대폰은 문제(위) · 지도 · 단추 줄(아래에 붙음), 넓은 화면은 왼쪽 문제 + 오른쪽 지도 ── */
.quiz {
  display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "q" "map" "act"; gap: 0; padding-top: 10px;
}
.qpanel { grid-area: q; min-width: 0; }
.qmap { grid-area: map; position: relative; min-width: 0; }
.act { grid-area: act; }
.qtop { display: flex; align-items: center; gap: 10px; }
.qcount { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qbar { flex: 1 1 auto; height: 8px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.qbar i { display: block; height: 100%; width: 0; background: var(--story); transition: width .3s; }
.qscore { margin: 0; font-size: var(--t-caption); color: var(--ink-2); white-space: nowrap; }
.qscore b { font-size: 1rem; color: var(--ink); }
.qstory { margin: 6px 0 2px; display: flex; align-items: center; gap: 8px; font-size: var(--t-caption); font-weight: 700; color: var(--ink-2); }
.sdot { width: 14px; height: 14px; border-radius: 50%; background: var(--story); flex: 0 0 auto; }
.qh { margin: 0 0 6px; font-size: 1.375rem; line-height: 1.4; font-weight: 800; }
.qh:focus { outline: none; }
.qname { color: var(--story); background: color-mix(in srgb, var(--story) 9%, #fff); padding: 0 4px; border-radius: 6px; }
.qhint { margin: 0 0 8px; font-size: var(--t-caption); color: var(--ink-2); }

.scene { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--story); border-radius: 12px; padding: 12px 14px; margin: 0 0 12px; }
.scene-ref { margin: 0; font-size: var(--t-caption); color: var(--ink-3); font-weight: 700; }
.scene-title { margin: 2px 0 4px; font-weight: 800; font-size: 1.125rem; line-height: 1.45; }
.scene-text { margin: 0; color: var(--ink-2); }
.mask { display: inline-block; padding: 0 4px; border-radius: 5px; background: var(--line-soft); color: var(--ink-3); font-weight: 800; letter-spacing: .05em; }
.mask.shown { background: color-mix(in srgb, var(--story) 12%, #fff); color: var(--ink); letter-spacing: 0; }

.choices { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) and (max-width: 959px) { #q-body > .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 14px; text-align: left;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 12px; cursor: pointer; font-weight: 700; font-size: 1.0625rem;
}
.choice:hover:not(:disabled) { background-image: linear-gradient(var(--hover), var(--hover)); }
.choice:active:not(:disabled) { background-image: linear-gradient(var(--press), var(--press)); }
.choice:disabled { cursor: default; color: var(--ink-2); }
.ck {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: 0 0 auto; border-radius: 50%;
  border: 2.5px solid var(--story); color: var(--story); background: #fff; font-size: .875rem; font-weight: 800;
}
.ct { display: flex; flex-direction: column; line-height: 1.35; }
.ct small { font-weight: 600; color: var(--ink-3); font-size: var(--t-caption); }
.choice.is-ans { border-color: var(--ok); background: var(--ok-bg); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ok); }
.choice.is-ans .ck { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.is-mine { border-color: var(--no); background: var(--no-bg); color: var(--ink); }
.choice.is-mine .ck { background: var(--no); border-color: var(--no); color: #fff; }
.alt { margin: 4px 0 8px; }
.alt-h { margin: 0 0 6px; font-size: var(--t-caption); color: var(--ink-2); }

.order { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.ord {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 14px; text-align: left;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 12px; cursor: pointer;
}
.ord:hover:not(:disabled) { background-image: linear-gradient(var(--hover), var(--hover)); }
.ord .on {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%;
  border: 2.5px dashed var(--line-strong); font-weight: 800; font-variant-numeric: tabular-nums;
}
.ord[aria-pressed="true"] { border-color: var(--story); }
.ord[aria-pressed="true"] .on { border: 3px solid #fff; background: var(--story); color: #fff; box-shadow: 0 0 0 2.5px var(--story); }
.ot { display: flex; flex-direction: column; line-height: 1.4; }
.ot b { font-weight: 800; }
.ot small { color: var(--ink-3); font-size: var(--t-caption); font-weight: 600; }
.ord:disabled { cursor: default; color: var(--ink); }
.ord.is-ans { border-color: var(--ok); background: var(--ok-bg); }
.ord.is-ans .on { border: 3px solid #fff; background: var(--ok); color: #fff; box-shadow: 0 0 0 2.5px var(--ok); }
.ord.is-mine { border-color: var(--no); background: var(--no-bg); }
.ord.is-mine .on { border: 3px solid #fff; background: var(--no); color: #fff; box-shadow: 0 0 0 2.5px var(--no); }

.feedback { margin: 10px 0 8px; padding: 12px 14px; border-radius: 12px; border: 1.5px solid; background: var(--surface); }
.feedback p { margin: 0 0 4px; }
.feedback.ok { border-color: var(--ok); background: var(--ok-bg); }
.feedback.no { border-color: var(--no); background: var(--no-bg); }
.fh { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.1875rem; }
.feedback.ok .fh { color: var(--ok); }
.feedback.no .fh { color: var(--no); }
.tag { display: inline-block; padding: 0 8px; border-radius: 999px; background: #FBF3E2; color: var(--old); border: 1px solid #E6D3A8; font-size: var(--t-caption); font-weight: 700; }
.go { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 700; }

/* 지도: 휴대폰은 화면 높이의 절반쯤. 장면·순서 문제는 답을 고른 뒤에만 보인다 */
.map { height: 52svh; min-height: 260px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--sea); }
.quiz:not([data-map]) .qmap { display: none; }
.quiz[data-kind="map"]:not([data-done]) .map { height: 58svh; }
.map-cover, .map-status {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0;
  padding: 8px 14px; border-radius: 10px; background: rgba(255,255,255,.94); box-shadow: var(--shadow);
  font-weight: 700; color: var(--ink-2); text-align: center; pointer-events: none;
}
.map-status:empty { display: none; }
.map .maplibregl-ctrl-group button { width: 44px; height: 44px; }
.map .maplibregl-canvas { cursor: pointer; }

/* 아래 단추 줄: 한 손 엄지가 닿는 곳에 붙인다 */
.act {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap;
  margin: 10px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 94%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.act:empty { display: none; }
.act .btn { flex: 1 1 0; min-height: 52px; }
.act .btn-next { font-size: 1.125rem; }
.act-hint { margin: 0; font-size: var(--t-caption); color: var(--ink-3); flex: 1 1 auto; text-align: center; }
@media (pointer: coarse) { .act-hint { display: none; } }

@media (min-width: 960px) {
  .quiz {
    grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "q map" "act map"; column-gap: 20px; align-items: start;
  }
  .quiz:not([data-map]) .qmap { display: block; }   /* 넓은 화면은 지도 자리를 늘 둔다(답을 고르면 정답을 보여 줌) */
  .quiz:not([data-map]) .map { filter: saturate(.6); opacity: .55; }
  .qmap { position: sticky; top: 12px; }
  .map, .quiz[data-kind="map"]:not([data-done]) .map { height: calc(100vh - 140px); min-height: 460px; }
  .act { position: static; margin: 8px 0 0; padding: 0; background: none; border: 0; backdrop-filter: none; justify-content: flex-start; }
  .act .btn { flex: 0 1 auto; min-width: 140px; }
  :root[data-big] .map { height: calc(100vh - 170px); }
}

/* 지도 위 이름(css/atlas.css와 같은 모양) */
.landmark { font-family: var(--font-ui); font-weight: 600; font-size: .8125rem; letter-spacing: .08em; color: #3D6A73; pointer-events: none; white-space: nowrap; text-shadow: 0 0 3px var(--sea), 0 0 6px var(--sea); }
.landmark.sea { font-size: 1rem; letter-spacing: .5em; color: var(--sea-label); text-shadow: none; }
.landmark.river { text-shadow: 0 0 3px var(--land), 0 0 6px var(--land); }
.landmark.mountain { color: #6E655A; text-shadow: 0 0 3px var(--land), 0 0 6px var(--land); }
.landmark.mountain::before { content: "▲ "; font-size: .7em; color: #8A8073; }
.country {
  font-family: var(--font-ui); font-weight: 700; font-size: .75rem; letter-spacing: .06em; color: var(--now-map);
  pointer-events: none; white-space: nowrap; padding: 1px 6px;
  border: 1.5px solid color-mix(in srgb, var(--now-map) 55%, transparent); border-radius: 4px;
  background: color-mix(in srgb, var(--land) 80%, transparent);
}

/* 정답·고른 곳·후보·순서 번호: 지도 화면 번호 원(.pin.current .dot)과 같은 모양 */
.qpin { width: 30px; height: 30px; display: grid; place-items: center; pointer-events: none; z-index: 2; }
.qpin .dot {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--story); color: #fff; border: 3px solid #fff;
  box-shadow: 0 0 0 3px var(--story), 0 2px 8px rgba(0,0,0,.25);
  font-weight: 800; font-size: .875rem; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.qpin .dot .ic { width: 16px; height: 16px; stroke-width: 3.2; }
.qpin .name {
  position: absolute; left: 38px; top: 50%; transform: translateY(-50%); white-space: nowrap;
  font-weight: 800; font-size: 1.0625rem; color: var(--ink);
  paint-order: stroke fill; -webkit-text-stroke: 5px #fff; text-shadow: 0 0 3px #fff, 0 0 8px #fff;
}
.qpin.ans { z-index: 3; }
.qpin.mine .dot { background: #4A4B50; box-shadow: 0 0 0 3px #4A4B50, 0 2px 8px rgba(0,0,0,.25); }
.qpin.mine .name { color: var(--ink-2); font-size: .9375rem; }
.qpin.name-l .name { left: auto; right: 38px; }
.qpin.cand .dot { background: #fff; color: var(--story); border: 2.5px solid var(--story); box-shadow: 0 0 0 2px #fff, 0 1px 6px rgba(0,0,0,.25); width: 28px; height: 28px; }
.qpin.ordn .dot { width: auto; min-width: 30px; padding: 0 6px; border-radius: 999px; }
@media (prefers-reduced-motion: no-preference) {
  .qpin.ans .dot { animation: pulse 2.4s ease-out infinite; }
  @keyframes pulse {
    0% { box-shadow: 0 0 0 3px var(--story), 0 0 0 3px color-mix(in srgb, var(--story) 45%, transparent); }
    70%, 100% { box-shadow: 0 0 0 3px var(--story), 0 0 0 18px transparent; }
  }
}

/* ── 3. 결과 ── */
.result { max-width: 760px; margin: 0 auto; padding: 22px 0 8px; }
.rh { margin: 0 0 4px; font-size: 1.75rem; line-height: 1.35; }
.rh:focus { outline: none; }
.rmsg { margin: 0 0 14px; color: var(--ink-2); }
.ract { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.ract .btn { flex: 1 1 180px; }
.rlist-h { margin: 0 0 8px; font-size: 1.125rem; }
.rlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rlist > li { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--no); border-radius: 12px; padding: 10px 14px; }
.rk { display: inline-block; font-size: var(--t-caption); font-weight: 700; color: var(--ink-3); }
.rq { margin: 0; font-weight: 800; }
.ra { margin: 0; color: var(--no); font-weight: 600; }
.rr { margin: 0; }
.rord { margin: 4px 0 0; padding-left: 1.4em; }
.rord li { margin: 2px 0; }
.rord li span { margin-right: 8px; }
.rord small { color: var(--ink-3); }

.foot { max-width: 1240px; margin: 0 auto; padding: 8px 16px 28px; font-size: var(--t-caption); color: var(--ink-3); }
.foot a { color: var(--ink-3); }
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 700; box-shadow: var(--shadow);
}
