/* 모바일 우선, 시스템 폰트, 외부 리소스 없음. 다크모드는 OS 설정을 따른다. */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #14181f;
  --muted: #566070;
  --line: #dde1e8;
  --accent: #0b5fd6;
  --accent-text: #ffffff;
  --good: #0a7a3d;
  --warn-bg: #fff4d6;
  --warn-text: #5c4200;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --card: #181d26;
    --text: #eef1f6;
    --muted: #a3adbd;
    --line: #2b3342;
    --accent: #6aa5ff;
    --accent-text: #0a1220;
    --good: #5fd48c;
    --warn-bg: #3a2f10;
    --warn-text: #ffe29a;
  }
}
* { box-sizing: border-box; }
html { font-size: 112.5%; } /* 기본 18px: 저시력·작은 폰 배려 */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}
.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }
header.site { padding: 12px 0 4px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
header.site a { color: var(--text); font-weight: 700; font-size: 1.2rem; text-decoration: none; }
header.site span { color: var(--muted); font-size: .85rem; }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 12px 0 6px; }
p.lead { color: var(--muted); margin: 0 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 6px; }
input[type="text"] {
  width: 100%; font-size: 1.3rem; padding: 12px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--bg); color: var(--text);
}
input[type="text"]:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.primary {
  width: 100%; margin-top: 12px; font-size: 1.1rem; font-weight: 700; padding: 14px;
  border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-text); cursor: pointer;
}
.secondary { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
canvas { width: 100%; height: auto; border-radius: 10px; display: block; }
.net { text-align: center; }
.net .label { color: var(--muted); font-size: .9rem; }
.net .amount { font-size: 2.1rem; font-weight: 800; color: var(--good); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; }
td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
tr.total th, tr.total td { font-weight: 700; border-bottom: 0; }
.notice { background: var(--warn-bg); color: var(--warn-text); border-radius: 10px; padding: 10px 12px; font-size: .85rem; margin-bottom: 16px; }
.error { color: #c0272d; margin-top: 8px; font-size: .9rem; }
@media (prefers-color-scheme: dark) { .error { color: #ff8a8f; } }
footer.note { color: var(--muted); font-size: .8rem; padding-bottom: 32px; }
footer.note a { color: var(--accent); }
footer.note ul { padding-left: 18px; margin: 6px 0; }
.prose h2 { font-size: 1.15rem; margin: 22px 0 6px; }
.prose p, .prose li { margin: 8px 0; }
.prose ul { padding-left: 20px; }
.prose a, ul.list a { color: var(--accent); }
ul.list { list-style: none; padding: 0; margin: 0 0 12px; }
[hidden] { display: none !important; }
blockquote { margin: 12px 0; padding: 8px 14px; border-left: 4px solid var(--accent); background: var(--card); border-radius: 0 8px 8px 0; }
.tablewrap { overflow-x: auto; }
.prose th { font-weight: 700; }
.prose code { background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: .9em; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--accent); }
figure { margin: 16px 0; }
figure img { display: block; width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); }
figcaption { color: var(--muted); font-size: .85rem; margin-top: 6px; }
.choices { display: grid; gap: 10px; margin-top: 12px; }
button.choice { text-align: left; font: inherit; line-height: 1.35; padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
button.choice:hover, button.choice:focus-visible { border-color: var(--accent); }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.result-name { font-size: 1.6rem; margin: 6px 0 0; color: var(--good); }
h2.more { font-size: 1.1rem; margin: 24px 0 8px; }
#q-text { font-size: 1.3rem; line-height: 1.3; outline: none; }
canvas.strip { display: block; width: 100%; max-width: 560px; height: auto; margin: 4px auto 8px; }
canvas.mascot { display: block; width: 220px; max-width: 70%; height: auto; margin: 0 auto 4px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { canvas.mascot { animation: none; } }

.hud { display: flex; justify-content: space-between; font-size: 1.1rem; margin-bottom: 8px; }
.gamecv { display: block; width: 100%; max-width: 420px; margin: 0 auto; border-radius: 16px; border: 2px solid var(--line); touch-action: none; user-select: none; background: #fff; }
.mgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 420px; margin: 0 auto; }
.mcard { position: relative; aspect-ratio: 1; padding: 0; border-radius: 14px; border: 2px solid var(--line); background: linear-gradient(135deg, var(--accent), #8ab6ff); cursor: pointer; overflow: hidden; }
.mcard canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .15s; }
.mcard .back { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; font-weight: 800; color: #fff; }
.mcard.open canvas, .mcard.done canvas { opacity: 1; }
.mcard.open .back, .mcard.done .back { display: none; }
.mcard.done { border-color: var(--good); }

a.linkbtn { display: block; line-height: 1.2; text-align: center; text-decoration: none; box-sizing: border-box; }

.pads { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 360px; margin: 0 auto; }
button.pad { position: relative; aspect-ratio: 1; padding: 0; border-radius: 20px; border: 3px solid var(--line); overflow: hidden; cursor: pointer; background: var(--card); transition: transform .08s, box-shadow .08s, border-color .08s; }
button.pad canvas { width: 100%; height: 100%; display: block; }
button.pad:disabled { cursor: default; }
button.pad.lit { transform: scale(1.06); border-color: var(--accent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 35%, transparent); filter: brightness(1.12) saturate(1.3); }
.soundbtn { font-size: 1.2rem; line-height: 1; padding: 6px 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }

/* ===== 콘텐츠 테마 (심리테스트·게임 페이지만 body[data-theme], body[data-layout] 사용) =====
   테마 = 색·글꼴·모서리·배경 분위기, 레이아웃 = 선택지 배치. JSON 의 "theme"/"layout" 으로 고른다. */
body { background-image: var(--bg-img, none); background-attachment: fixed; font-family: var(--font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif); }
.card, button.choice, .primary, .mcard, button.pad { border-radius: var(--radius, 12px); box-shadow: var(--shadow, none); }
h1, h2, .result-name { font-family: var(--font-head, inherit); }

body[data-theme="sunset"] { --bg: #fff1e6; --card: #fffaf5; --text: #3b1f1a; --muted: #7a4f45; --line: #f3c9b0; --accent: #e8590c; --accent-text: #fff; --good: #c2255c; --radius: 20px; --bg-img: linear-gradient(160deg, #ffe3d0 0%, #ffd6e7 100%); --font-head: Georgia, "Times New Roman", serif; }
body[data-theme="palengke"] { --bg: #fff6c9; --card: #ffffff; --text: #111; --muted: #444; --line: #111; --accent: #ff4d6d; --accent-text: #111; --good: #0b7a3b; --radius: 4px; --shadow: 4px 4px 0 #111; --font: "Trebuchet MS", Verdana, sans-serif; --font-head: Impact, "Arial Black", sans-serif; }
body[data-theme="ulan"] { --bg: #e6f2f7; --card: rgba(255,255,255,.72); --text: #0f2a3a; --muted: #3f6073; --line: #b7d6e4; --accent: #0a7ea4; --accent-text: #fff; --good: #0a7ea4; --radius: 18px; --shadow: 0 6px 20px rgba(10,126,164,.15); --bg-img: linear-gradient(180deg, #cfe9f3 0%, #eaf6fa 60%); }
body[data-theme="kape"] { --bg: #f1e7da; --card: #fbf5ec; --text: #2e1d12; --muted: #6b5240; --line: #d8c3ab; --accent: #6f4018; --accent-text: #fff; --good: #6f4018; --radius: 6px; --font: Georgia, "Times New Roman", serif; --font-head: Georgia, "Times New Roman", serif; }
body[data-theme="neon"] { --bg: #120b24; --card: #1d1238; --text: #f4eeff; --muted: #b9a9e6; --line: #3d2a73; --accent: #39ffb6; --accent-text: #120b24; --good: #ff5fd2; --radius: 10px; --shadow: 0 0 14px rgba(57,255,182,.25); --font: "Courier New", ui-monospace, monospace; color-scheme: dark; }
body[data-theme="pastel"] { --bg: #f4efff; --card: #ffffff; --text: #2a2340; --muted: #6a6288; --line: #dcd2ff; --accent: #7c5cff; --accent-text: #fff; --good: #1fa37a; --radius: 28px; --bg-img: radial-gradient(circle at 15% 10%, #e2f8ee 0, transparent 40%), radial-gradient(circle at 90% 30%, #ffe3f1 0, transparent 40%); }
body[data-theme="fiesta"] { --bg: #fff8e1; --card: #ffffff; --text: #1d2b1a; --muted: #55603f; --line: #f2c94c; --accent: #d62828; --accent-text: #fff; --good: #1b7f3b; --radius: 14px; --bg-img: repeating-linear-gradient(90deg, #d62828 0 28px, #f2c94c 28px 56px, #1b7f3b 56px 84px, #1e63c4 84px 112px); background-size: 100% 10px; background-repeat: no-repeat; background-attachment: scroll; }
body[data-theme="papel"] { --bg: #fdfcf3; --card: #fffef8; --text: #1b2a4a; --muted: #5a6788; --line: #c9d3ea; --accent: #2748b8; --accent-text: #fff; --good: #2748b8; --radius: 3px; --font: "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive, sans-serif; --bg-img: repeating-linear-gradient(transparent 0 27px, #dbe3f5 27px 28px); }
@media (prefers-color-scheme: dark) {
  body[data-theme="sunset"] { --bg: #2a1512; --card: #3a1d19; --text: #ffe9dc; --muted: #e0b4a2; --line: #6b3a30; --accent: #ff8a4c; --accent-text: #2a1512; --good: #ff7aa8; --bg-img: linear-gradient(160deg, #2a1512 0%, #35142a 100%); }
  body[data-theme="palengke"] { --bg: #1b1a10; --card: #26241a; --text: #fff6c9; --muted: #d6cf9f; --line: #fff6c9; --accent: #ff6b86; --accent-text: #111; --good: #6be28f; --shadow: 4px 4px 0 #fff6c9; }
  body[data-theme="ulan"] { --bg: #0d1e28; --card: rgba(25,50,66,.8); --text: #e4f4fb; --muted: #9bc0d2; --line: #28506a; --accent: #4cc3ea; --accent-text: #08202c; --good: #4cc3ea; --bg-img: linear-gradient(180deg, #0a1a24 0%, #0d1e28 60%); }
  body[data-theme="kape"] { --bg: #1c130c; --card: #271b12; --text: #f3e6d6; --muted: #c3a98f; --line: #4a3626; --accent: #d9a066; --accent-text: #1c130c; --good: #d9a066; }
  body[data-theme="pastel"] { --bg: #1c1830; --card: #272142; --text: #f0ecff; --muted: #b8b0dc; --line: #3d3566; --accent: #a592ff; --accent-text: #1c1830; --good: #5fd9ad; --bg-img: none; }
  body[data-theme="fiesta"] { --bg: #1c1a0e; --card: #26240f; --text: #fff4cc; --muted: #d6cd95; --line: #5f5420; --accent: #ff6b6b; --accent-text: #1c1a0e; --good: #6be28f; }
  body[data-theme="papel"] { --bg: #121a2e; --card: #18223a; --text: #e6ecff; --muted: #a2b0d6; --line: #2c3a62; --accent: #8fa8ff; --accent-text: #121a2e; --good: #8fa8ff; --bg-img: repeating-linear-gradient(transparent 0 27px, #1d2947 27px 28px); }
}

/* 선택지 레이아웃 */
body[data-layout="tiles"] .choices { grid-template-columns: 1fr 1fr; }
body[data-layout="tiles"] button.choice { text-align: center; min-height: 112px; display: grid; place-items: center; }
body[data-layout="bubbles"] .choices { gap: 12px; }
body[data-layout="bubbles"] button.choice { border-radius: 999px; padding: 14px 22px; text-align: center; }
body[data-layout="lettered"] .choices { counter-reset: opt; }
body[data-layout="lettered"] button.choice { position: relative; padding-left: 52px; counter-increment: opt; }
body[data-layout="lettered"] button.choice::before { content: counter(opt, upper-alpha); position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: .9rem; }
body[data-layout="stripe"] button.choice { border-width: 0 0 0 8px; border-left-color: var(--accent); border-radius: 4px; }
body[data-layout="centered"] .wrap { text-align: center; }
body[data-layout="centered"] button.choice { text-align: center; }
@media (max-width: 380px) { body[data-layout="tiles"] .choices { grid-template-columns: 1fr; } }
