:root {
  --cream: #fff9ed;
  --paper: #fffdf7;
  --ink: #37291f;
  --muted: #7e6f63;
  --orange: #ff8248;
  --orange-dark: #e95f2b;
  --yellow: #ffd65a;
  --green: #58a66b;
  --green-dark: #2f7c4a;
  --pink: #ff9fba;
  --blue: #78b7e8;
  --line: #eadbca;
  --shadow: 0 16px 40px rgba(85, 56, 33, 0.12);
  --pencil: #6f472f;
  --paper-warm: #fffaf0;
  --challenge-bg-image: url("./assets/illustrations/quiz-kitchen-bg-v3.png");
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--cream); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 214, 90, .34), transparent 28%),
    radial-gradient(circle at 92% 22%, rgba(255, 159, 186, .25), transparent 24%),
    linear-gradient(180deg, #fff9ed 0%, #fff4df 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.background-doodles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .36;
  background-image: var(--challenge-bg-image);
  background-position: center top;
  background-repeat: repeat-y;
  background-size: min(100vw, 1180px) auto;
}

.app-shell {
  position: relative;
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
}

.app-shell.quiz-mode,
.app-shell.review-mode,
.app-shell.result-mode {
  background-image: linear-gradient(rgba(255,249,237,.78),rgba(255,249,237,.78)), var(--challenge-bg-image);
  background-position: center top;
  background-size: 100% auto;
  border-radius: 30px;
}

.app-shell.reading-mode { width: min(100%, 900px); }

.card {
  background:
    radial-gradient(circle at 18% 12%, rgba(255,255,255,.92), transparent 34%),
    rgba(255, 253, 247, .97);
  border: 2px solid rgba(111, 71, 47, .18);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  color: var(--green-dark);
  background: #eaf7e9;
  border: 1px solid #c9e5c9;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.subject-icon,
.eyebrow-icon {
  display: inline-block;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  object-fit: contain;
  vertical-align: middle;
}
.eyebrow-icon { width: 29px; height: 29px; margin: -5px 0; }

.hero {
  overflow: hidden;
  padding: 24px 20px 20px;
  text-align: center;
  background:
    radial-gradient(circle at 18% 18%, rgba(255,216,90,.2) 0 4px, transparent 5px),
    linear-gradient(145deg, rgba(255,255,255,.98), rgba(255,247,224,.96));
  background-size: 44px 44px, auto;
}

.hero h1 {
  margin: 12px 0 8px;
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1.15;
  letter-spacing: -1.4px;
}

.hero p { margin: 0; color: var(--muted); line-height: 1.6; }

.hero-art-wrap {
  position: relative;
  display: grid;
  place-items: center;
  height: 245px;
  margin: 4px -12px -18px;
}

.hero-art {
  position: relative;
  z-index: 1;
  display: block;
  width: min(100%, 285px);
  max-height: 250px;
  object-fit: contain;
  filter: drop-shadow(0 13px 14px rgba(93, 56, 30, .13));
}

.pencil-spark { position: absolute; z-index: 2; color: #f4b825; font-size: 26px; transform: rotate(-8deg); }
.spark-one { left: 12%; top: 30%; }
.spark-two { right: 13%; top: 18%; font-size: 18px; }

.chef-stage {
  position: relative;
  height: 156px;
  margin: 10px -20px -4px;
}

.chef-bear {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 132px;
  height: 132px;
  transform: translateX(-50%);
}

.chef-face {
  position: absolute;
  inset: 24px 15px 6px;
  display: grid;
  place-items: center;
  background: #c9874c;
  border: 5px solid #8a552f;
  border-radius: 48% 48% 44% 44%;
  font-size: 48px;
}

.chef-hat {
  position: absolute;
  left: 28px;
  top: 0;
  width: 78px;
  height: 48px;
  background: white;
  border: 4px solid #d8c9b9;
  border-radius: 40px 40px 14px 14px;
  z-index: 2;
}

.chef-hat::before, .chef-hat::after {
  content: "";
  position: absolute;
  top: -13px;
  width: 34px;
  height: 34px;
  background: white;
  border: 4px solid #d8c9b9;
  border-radius: 50%;
}
.chef-hat::before { left: 3px; }
.chef-hat::after { right: 3px; }

.plate {
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 220px;
  height: 30px;
  transform: translateX(-50%);
  background: #d9ebf7;
  border: 4px solid #91b8d0;
  border-radius: 50%;
}

.mini-rolls { position: absolute; left: 50%; bottom: 17px; display: flex; gap: 5px; transform: translateX(-50%); }
.mini-roll {
  width: 42px; height: 42px; position: relative; border: 5px solid #273f31; border-radius: 50%; background: #fff0c5;
}
.mini-roll::after {
  content: ""; position: absolute; inset: 8px; border-radius: 50%; background: conic-gradient(#f2cf38 0 25%, #ef7658 0 50%, #68a657 0 75%, #de985f 0);
}

.section-title { margin: 24px 4px 10px; font-size: 19px; letter-spacing: -.4px; }

.goal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.goal-card {
  position: relative;
  padding: 16px 8px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 18px;
  text-align: center;
  cursor: pointer;
  transition: .18s ease;
}
.goal-card strong { display: block; font-size: 23px; }
.goal-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.goal-card.selected { border-color: var(--orange); background: #fff1e8; transform: translateY(-2px); box-shadow: 0 8px 18px rgba(255,130,72,.18); }

.course-list { display: grid; gap: 12px; }
.course-card { display: grid; grid-template-columns: 68px 1fr auto; gap: 12px; align-items: center; min-height: 92px; padding: 10px 14px 10px 8px; border-radius: 22px 18px 24px 17px; background: rgba(255,255,255,.78); border: 2px solid rgba(111,71,47,.14); box-shadow: 0 8px 20px rgba(91,57,34,.06); }
.course-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; font-size: 25px; }
.course-card:nth-child(1) .course-icon { background: #eaf7e9; }
.course-card:nth-child(2) .course-icon { background: #fff0d2; }
.course-card:nth-child(3) .course-icon { background: #e8f3fd; }
.course-card strong { display: block; font-size: 15px; }
.course-card small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.4; }
.course-count { color: var(--green-dark); font-weight: 900; font-size: 13px; }
.course-art { display: block; width: 72px; height: 72px; object-fit: contain; filter: drop-shadow(0 6px 6px rgba(86,52,29,.12)); }
.course-art-focus { transform: scale(1.08); }
.course-step { display: block; margin-bottom: 2px; color: var(--orange-dark); font-size: 10px; font-weight: 900; letter-spacing: .04em; }

.reward-banner {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px dashed #e9b846;
  border-radius: 18px;
  background: #fff8d9;
  color: #73551b;
  font-size: 13px;
  line-height: 1.55;
}

.primary-btn, .secondary-btn, .ghost-btn {
  min-height: 52px;
  border-radius: 17px;
  border: 0;
  font-weight: 900;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.primary-btn:active, .secondary-btn:active, .ghost-btn:active { transform: scale(.98); }
.primary-btn { width: 100%; margin-top: 18px; color: white; background: linear-gradient(135deg, var(--orange), #ff6a3a); box-shadow: 0 11px 22px rgba(233,95,43,.26); }
.secondary-btn { padding: 0 20px; color: white; background: var(--green); }
.ghost-btn { padding: 0 16px; color: var(--muted); background: transparent; border: 1px solid var(--line); }
.danger-link { margin: 12px auto 0; display: block; color: #a16d61; background: none; border: 0; text-decoration: underline; cursor: pointer; font-size: 12px; }

.topbar { display: flex; align-items: center; gap: 10px; margin: 2px 0 12px; }
.topbar-copy { flex: 1; min-width: 0; }
.topbar-copy strong { display: block; font-size: 14px; }
.topbar-copy small { color: var(--muted); font-size: 12px; }
.progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: #eadfce; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), #8ecf83); transition: width .3s ease; }

.question-card {
  padding: 20px 18px 18px;
  min-height: 520px;
  background: rgba(255,253,247,.965);
  box-shadow: 0 18px 42px rgba(85,56,33,.14), inset 0 0 0 1px rgba(255,255,255,.75);
}
.question-card::before {
  content: "";
  display: block;
  width: 42px;
  height: 5px;
  margin: -7px auto 14px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, var(--yellow) 0 7px, transparent 7px 10px);
  opacity: .8;
}
.question-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.subject-pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px 5px 6px; border-radius: 999px; color: var(--green-dark); background: #edf8ec; font-size: 12px; font-weight: 900; }
.subject-pill .subject-icon { width: 29px; height: 29px; margin: -4px 0; }
.question-number { color: var(--muted); font-size: 13px; font-weight: 800; }
.question-card h2 { margin: 0 0 16px; font-size: 22px; line-height: 1.45; letter-spacing: -.5px; }
.question-context { margin: 12px 0 18px; padding: 14px; color: #57473b; background: #fff7e5; border-left: 5px solid var(--yellow); border-radius: 12px; line-height: 1.65; white-space: pre-line; }
.poem { text-align: center; line-height: 1.9; background: linear-gradient(180deg, #f4f8ff, #fff); border: 1px solid #d6e4f0; border-left: 1px solid #d6e4f0; }
.reference-btn { display:flex; align-items:center; justify-content:center; gap:7px; width: 100%; margin: -4px 0 16px; padding: 10px 14px; color: var(--green-dark); background: #edf8ec; border: 1px solid #bcdcbc; border-radius: 14px; font-weight: 900; cursor: pointer; }

.options { display: grid; gap: 10px; }
.option-btn {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 11px;
  align-items: center;
  width: 100%;
  padding: 13px 14px;
  color: var(--ink);
  background: white;
  border: 2px solid var(--line);
  border-radius: 16px;
  text-align: left;
  line-height: 1.45;
  cursor: pointer;
  transition: .14s ease;
}
.option-btn:hover { border-color: #d7b995; }
.option-btn.selected { border-color: var(--orange); background: #fff0e7; box-shadow: 0 7px 14px rgba(255,130,72,.13); }
.option-index { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; color: #796657; background: #f6eee4; font-weight: 900; }
.option-btn.selected .option-index { color: white; background: var(--orange); }

.answer-input {
  width: 100%;
  height: 62px;
  padding: 0 18px;
  border: 2px solid #ddc8b3;
  border-radius: 16px;
  background: white;
  color: var(--ink);
  font-size: 21px;
  font-weight: 800;
  outline: none;
}
.answer-input:focus { border-color: var(--orange); box-shadow: 0 0 0 5px rgba(255,130,72,.12); }
.input-help { margin: 8px 3px 0; color: var(--muted); font-size: 12px; }

.illustration { overflow:hidden; margin: 8px auto 16px; padding: 8px; max-width: 390px; background: #fffaf0; border: 2px solid rgba(111,71,47,.13); border-radius: 22px 17px 24px 18px; }
.question-illustration-image { display: block; width: 100%; height: 190px; object-fit: contain; border-radius: 15px; }

.question-nav { position: sticky; bottom: 10px; display: grid; grid-template-columns: 1fr 1.5fr; gap: 10px; margin-top: 14px; padding: 10px; background: rgba(255,249,237,.92); border: 1px solid rgba(234,219,202,.9); border-radius: 20px; backdrop-filter: blur(12px); }
.question-nav button { margin: 0; }

.kitchen-status { display: flex; gap: 7px; justify-content: center; margin: 12px 0; }
.ingredient-dot { width: 10px; height: 10px; border-radius: 50%; background: #dfd4c8; }
.ingredient-dot.done:nth-child(3n+1) { background: var(--green); }
.ingredient-dot.done:nth-child(3n+2) { background: var(--yellow); }
.ingredient-dot.done:nth-child(3n) { background: var(--pink); }

.reading-workspace { display:grid; grid-template-rows:minmax(270px,42vh) auto; gap:14px; }
.reading-panel { display:grid; grid-template-rows:auto minmax(0,1fr) auto; overflow:hidden; min-height:0; padding:14px 14px 10px; background:rgba(255,253,247,.975); }
.reading-header { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:2px 3px 10px; }
.reading-header h2 { margin:2px 0 2px; font-size:20px; letter-spacing:-.5px; }
.reading-header small { color:var(--muted); font-size:11px; }
.reading-kicker { color:var(--orange-dark); font-size:11px; font-weight:900; }
.reading-page-badge { flex:0 0 auto; padding:6px 9px; color:var(--green-dark); background:#edf8ec; border-radius:999px; font-size:12px; font-weight:900; }
.reading-viewport { overflow:hidden; min-height:0; background:#fffaf0; border:1px solid #ead7c3; border-radius:17px; outline:none; }
.reading-viewport:focus-visible { box-shadow:0 0 0 4px rgba(255,130,72,.16); border-color:var(--orange); }
.reading-track { display:flex; height:100%; transition:transform .28s ease; }
.reading-page { flex:0 0 100%; height:100%; overflow:auto; padding:16px 17px 22px; overscroll-behavior:contain; scrollbar-width:thin; }
.reading-page p { margin:0; white-space:pre-line; color:#4c3b30; font-family:"Nanum Myeongjo","AppleMyungjo",serif; font-size:14px; line-height:1.82; }
.reading-controls { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:10px; padding-top:9px; }
.reading-arrow { padding:7px 9px; color:var(--green-dark); background:#edf8ec; border:1px solid #c8dfc6; border-radius:11px; font-size:12px; font-weight:900; cursor:pointer; }
.reading-arrow:disabled { opacity:.38; cursor:default; }
.reading-dots { display:flex; justify-content:center; gap:5px; }
.reading-dots i { width:6px; height:6px; border-radius:50%; background:#d9cbbb; }
.reading-dots i.active { width:17px; border-radius:999px; background:var(--orange); }
.reading-questions .question-card { min-height:0; }

.review-card, .result-card {
  padding: 22px 18px;
  background: linear-gradient(155deg, rgba(255,255,255,.97), rgba(255,247,222,.96));
  border-color: rgba(111,71,47,.22);
}
.story-card { text-align: center; overflow: hidden; }
.review-art { display: block; width: min(78%, 285px); max-height: 235px; margin: 4px auto -8px; object-fit: contain; filter: drop-shadow(0 10px 12px rgba(86,52,29,.12)); }
.story-card .review-summary, .story-card .review-grid, .story-card .reward-banner, .story-card .score-list, .story-card .reward-list { text-align: left; }
.review-card h1, .result-card h1 { margin: 8px 0; font-size: 29px; }
.review-card > p, .result-card > p { color: var(--muted); line-height: 1.6; }
.review-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin: 18px 0; }
.review-number { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--muted); font-weight: 800; cursor: pointer; }
.review-number.answered { color: white; background: var(--green); border-color: var(--green); }
.review-summary { display: flex; justify-content: space-between; margin: 14px 0; padding: 13px 15px; border-radius: 14px; background: #f5efe7; font-weight: 800; }

.result-plate { position: relative; height: 170px; margin: 8px 0 2px; }
.result-hero { position: relative; height: 300px; margin: -8px -12px -10px; background: radial-gradient(circle at 50% 54%, rgba(255,214,90,.38), transparent 48%); }
.result-art { display: block; width: min(100%, 330px); height: 295px; margin: 0 auto; object-fit: contain; filter: drop-shadow(0 14px 15px rgba(86,52,29,.14)); }
.result-hero .score-ring { left:auto; right:13px; top:28px; transform:rotate(5deg); z-index:2; }
.result-spark { position:absolute; z-index:2; color:#efb522; font-size:28px; transform:rotate(-9deg); }
.result-spark-one { left:8%; top:28%; }
.result-spark-two { right:12%; bottom:22%; font-size:20px; }
.result-plate .plate { bottom: 12px; width: 260px; height: 42px; }
.result-rolls { position: absolute; left: 50%; bottom: 31px; display: flex; gap: 6px; transform: translateX(-50%); }
.result-rolls .mini-roll { width: 52px; height: 52px; animation: pop .45s both; }
.result-rolls .mini-roll:nth-child(2) { animation-delay: .12s; }
.result-rolls .mini-roll:nth-child(3) { animation-delay: .24s; }
.result-rolls .mini-roll:nth-child(4) { animation-delay: .36s; }
@keyframes pop { from { opacity: 0; transform: translateY(-20px) scale(.6) rotate(-10deg); } to { opacity: 1; transform: none; } }
.score-ring { position:absolute; display:block; width:auto; height:auto; padding:0; border:0; background:transparent; box-shadow:none; }
.score-ring strong { position:relative; display:block; color:#e4542d; font-family:"Gaegu","Apple SD Gothic Neo",sans-serif; font-size:45px; font-weight:700; line-height:1; letter-spacing:-2px; transform:rotate(-4deg); text-shadow:0 2px 0 rgba(255,255,255,.95), 2px 0 0 rgba(255,255,255,.8), -2px 0 0 rgba(255,255,255,.8), 1px 3px 3px rgba(106,55,31,.15); }
.score-ring strong::after { content:""; position:absolute; left:8%; right:2%; bottom:-4px; height:3px; border-radius:50%; background:#e4542d; opacity:.7; transform:rotate(-3deg); }

.score-list { display: grid; gap: 8px; margin: 18px 0; }
.score-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 9px 13px 9px 9px; background: #f8f4ee; border-radius: 13px; }
.score-row > span { display:flex; align-items:center; gap:7px; }
.score-row .subject-icon { width:34px; height:34px; }
.score-row strong { color: var(--green-dark); }
.reward-list { margin: 14px 0; padding: 14px; border-radius: 16px; background: #fff5cf; }
.reward-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed #e8ce78; }
.reward-row:last-child { border-bottom: 0; font-weight: 900; }
.result-card.story-card > .reward-banner { text-align:center; }
.share-help { margin:16px 0 -10px; color:var(--muted); font-size:12px; text-align:center; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: end center; padding: 18px; background: rgba(48,35,25,.56); backdrop-filter: blur(6px); }
.modal { width: min(100%, 560px); max-height: 90vh; overflow: auto; padding: 20px; background: var(--paper); border-radius: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-header h2 { margin: 0; font-size: 22px; }
.close-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: #f1e8df; color: var(--ink); font-size: 20px; cursor: pointer; }
.passage-pages { display: grid; gap: 12px; }
.passage-pages img { display: block; width: 100%; border-radius: 16px; border: 1px solid var(--line); cursor: zoom-in; }
.passage-pages img.zoomed { width: 180%; max-width: none; cursor: zoom-out; }
.passage-note { color: var(--muted); font-size: 12px; line-height: 1.5; }
.transition-copy { text-align: center; }
.transition-copy p { color: var(--muted); line-height: 1.6; }
.story-modal {
  position:relative;
  overflow: hidden;
  background: linear-gradient(rgba(255,253,248,.91),rgba(255,244,217,.92)), var(--challenge-bg-image) center/cover;
  border: 3px solid rgba(111,71,47,.18);
  border-radius: 32px 24px 34px 25px;
}
.story-modal::before { content:""; position:absolute; top:10px; left:50%; width:70px; height:15px; transform:translateX(-50%) rotate(-2deg); background:rgba(255,214,90,.42); border-radius:2px; }
.transition-art { display: block; width: min(80%, 310px); max-height: 300px; margin: -4px auto -12px; object-fit: contain; filter: drop-shadow(0 12px 13px rgba(86,52,29,.13)); }
.story-modal h2 { margin: 0 0 8px; font-size: 27px; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translate(-50%, 20px); padding: 12px 18px; color: white; background: #382b22; border-radius: 999px; opacity: 0; pointer-events: none; transition: .2s ease; font-weight: 800; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.closed-card { padding: 30px 22px; text-align: center; }
.closed-art { display:block; width:130px; height:130px; margin:0 auto 4px; object-fit:contain; }
.closed-card h1 { font-size: 28px; }
.closed-card p { color: var(--muted); line-height: 1.6; }

@media (min-width: 720px) {
  .app-shell { padding-top: 34px; padding-bottom: 50px; }
  .question-card { padding: 26px 24px; }
  .modal-backdrop { place-items: center; }
  .reading-workspace { grid-template-rows:minmax(320px,46vh) auto; }
  .reading-panel { padding:18px 18px 12px; }
  .reading-page { padding:19px 24px 26px; }
  .reading-page p { font-size:15px; }
}

@media (max-width: 390px) {
  .hero-art-wrap { height: 220px; }
  .course-card { grid-template-columns: 60px 1fr; }
  .course-art { width: 62px; height: 62px; }
  .course-count { grid-column: 2; justify-self: start; margin-top: -8px; }
  .result-hero { height: 270px; }
  .result-art { height: 265px; }
  .reading-workspace { grid-template-rows:minmax(250px,40vh) auto; }
  .reading-header small { display:block; max-width:220px; }
  .reading-page { padding:14px 14px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
