:root {
  --green-900: #124a38;
  --green-700: #176b4d;
  --green-500: #27a56f;
  --green-100: #e4f5ed;
  --green-50: #f3fbf7;
  --purple-700: #5e54a4;
  --purple-100: #eceafa;
  --ink: #1c2924;
  --muted: #66756f;
  --line: #dfe8e3;
  --surface: #ffffff;
  --background: #f0f5f2;
  --danger: #c45858;
  --shadow: 0 22px 60px rgba(27, 72, 54, 0.12);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 8%, rgba(116, 197, 152, 0.2), transparent 25rem),
    radial-gradient(circle at 90% 92%, rgba(94, 84, 164, 0.09), transparent 24rem),
    var(--background);
}

button { font: inherit; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.76);
  border-inline: 1px solid rgba(23, 107, 77, 0.08);
  box-shadow: var(--shadow);
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(28px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
}

.screen.is-active { animation: fade-in 0.28s ease both; }

.start-screen,
.result-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.campaign-mark {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  margin-bottom: 20px;
  border-radius: 24px 24px 24px 8px;
  color: #fff;
  background: linear-gradient(145deg, var(--green-500), var(--green-700));
  box-shadow: 0 12px 28px rgba(23, 107, 77, 0.23);
  transform: rotate(-4deg);
}

.campaign-mark span { font-size: 26px; font-weight: 900; transform: rotate(4deg); }

.eyebrow {
  margin: 0 0 10px;
  color: var(--green-700);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1 { margin: 0; color: var(--green-900); font-size: clamp(34px, 9vw, 46px); line-height: 1.15; letter-spacing: -0.05em; }
h1 span { color: var(--green-500); }

.start-message { margin: 20px 0 24px; font-size: 19px; font-weight: 700; line-height: 1.55; letter-spacing: -0.025em; }

.quiz-summary {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(27, 72, 54, 0.06);
}

.quiz-summary div { display: flex; min-width: 110px; flex-direction: column; }
.quiz-summary strong { color: var(--green-700); font-size: 29px; line-height: 1; }
.quiz-summary span { margin-top: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.quiz-summary .summary-plus { margin: 0; color: #a3afa9; font-size: 22px; }

.time-guide { margin: 14px 0 4px; color: var(--muted); font-size: 14px; font-weight: 700; }
.random-guide { margin: 9px 0 22px; color: var(--green-700); font-size: 14px; font-weight: 800; }
.preview-note { margin: -8px 0 16px; padding: 10px 12px; border-radius: 12px; color: #735b28; background: #fff5db; font-size: 12px; font-weight: 800; }

.start-form { width: 100%; }
.participant-fields { margin: 0 0 20px; padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); text-align: left; }
.participant-label { margin: 0 0 10px; color: var(--green-900); font-size: 14px; font-weight: 850; }
.student-code-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 800; }
.student-code-input { display: block; width: 100%; height: 50px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff; font: inherit; font-size: 20px; font-weight: 850; letter-spacing: 0.15em; }
.student-code-input:focus { border-color: var(--green-500); }
.participant-help { margin: 11px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.start-status { min-height: 18px; margin: 10px 0 0; color: var(--green-900); font-size: 13px; font-weight: 750; }

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 17px;
  cursor: pointer;
  font-weight: 850;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button { color: #fff; background: var(--green-700); box-shadow: 0 12px 25px rgba(23, 107, 77, 0.2); }
.primary-button:hover { background: var(--green-900); transform: translateY(-1px); }
.primary-button:active { transform: scale(0.985); }
.primary-button span { margin-left: 8px; }
.secondary-button { margin-top: 22px; color: var(--green-700); background: var(--green-100); }
.secondary-button:hover { background: #d5eee2; }

.start-note { margin: 22px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }

.quiz-screen { padding-top: max(22px, env(safe-area-inset-top)); }
.quiz-header { margin-bottom: 22px; }
.progress-meta { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 700; }
.progress-meta span:first-child { color: var(--green-900); font-size: 15px; font-weight: 900; }

.progress-dots { display: flex; gap: 7px; margin: 12px 0 9px; }
.progress-dots span { width: 9px; height: 9px; border-radius: 99px; background: #d7e0db; transition: 0.25s ease; }
.progress-dots .is-complete { background: var(--green-500); }
.progress-dots .is-current { width: 25px; background: var(--green-700); }
.is-spelling .progress-dots .is-complete { background: #8d83c5; }
.is-spelling .progress-dots .is-current { background: var(--purple-700); }

.progress-track { height: 4px; overflow: hidden; border-radius: 99px; background: #dfe7e3; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--green-500); transition: width 0.25s ease; }
.is-spelling .progress-track span { background: var(--purple-700); }

.question-card {
  min-height: calc(100dvh - 116px);
  padding: 25px 20px 22px;
  border: 1px solid rgba(23, 107, 77, 0.1);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(27, 72, 54, 0.09);
}

.question-enter { animation: slide-in 0.25s ease both; }

.type-badge { display: inline-flex; align-items: center; padding: 8px 12px; border-radius: 999px; color: var(--green-700); background: var(--green-100); font-size: 13px; font-weight: 850; }
.is-spelling .type-badge { color: var(--purple-700); background: var(--purple-100); }
.category-label { margin: 18px 0 8px; color: var(--green-700); font-size: 13px; font-weight: 850; }
.is-spelling .category-label { color: var(--purple-700); }
.question-context { min-height: 48px; margin: 0; color: var(--muted); font-size: 16px; font-weight: 650; line-height: 1.55; white-space: pre-line; }
.question-title { margin: 11px 0 22px; outline: 0; color: var(--ink); font-size: clamp(21px, 5.8vw, 27px); line-height: 1.42; letter-spacing: -0.035em; }

.choices { display: grid; gap: 10px; }
.choice-button {
  display: flex;
  width: 100%;
  min-height: 62px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.choice-button:hover:not(:disabled) { border-color: var(--green-500); background: var(--green-50); transform: translateY(-1px); }
.is-spelling .choice-button:hover:not(:disabled) { border-color: var(--purple-700); background: #f8f7ff; }
.choice-button:disabled { cursor: default; }
.choice-number { display: grid; flex: 0 0 32px; height: 32px; place-items: center; border-radius: 10px; color: var(--green-700); background: var(--green-100); font-size: 13px; font-weight: 900; }
.is-spelling .choice-number { color: var(--purple-700); background: var(--purple-100); }
.choice-button.is-correct { border-color: var(--green-500); background: var(--green-50); }
.choice-button.is-selected-wrong { border-color: #df8f8f; background: #fff6f6; }
.choice-button.is-selected-wrong .choice-number { color: #fff; background: var(--danger); }
.choice-button.is-selected-correct { animation: correct-pop 0.24s ease; }

.feedback { margin-top: 16px; padding: 17px; border-radius: 16px; animation: fade-in 0.22s ease both; }
.feedback.is-success { background: var(--green-100); }
.feedback.is-help { background: #fff5db; }
.feedback-title { margin: 0 0 8px; color: var(--green-900); font-size: 17px; font-weight: 900; }
.feedback-answer { margin: 0 0 6px; font-size: 14px; font-weight: 850; }
.feedback-answer:empty { display: none; }
.feedback-text { margin: 0; color: #44534d; font-size: 14px; line-height: 1.55; }
.next-button { min-height: 54px; margin-top: 15px; }

.celebration { margin-bottom: 10px; font-size: 52px; animation: correct-pop 0.5s ease both; }
.result-screen h1 { font-size: clamp(32px, 8.5vw, 44px); }
.completion-copy { margin: 15px 0 20px; color: var(--muted); font-weight: 700; }
.score-card { width: 100%; padding: 19px; border-radius: 22px; color: #fff; background: linear-gradient(145deg, var(--green-700), var(--green-900)); box-shadow: 0 14px 30px rgba(23, 107, 77, 0.2); }
.score-card > span { font-size: 13px; font-weight: 750; opacity: 0.82; }
.score-card strong { display: block; margin: 3px 0; font-size: 45px; line-height: 1.1; }
.score-card small { font-size: 20px; opacity: 0.72; }
.score-card p { margin: 5px 0 0; font-size: 13px; }
.today-message { width: 100%; margin: 15px 0; padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: #fff; }
.today-message > span { color: var(--green-700); font-size: 12px; font-weight: 900; letter-spacing: 0.05em; }
.today-message blockquote { margin: 8px 0 0; font-size: 19px; font-weight: 850; letter-spacing: -0.03em; }
.completion-badge { display: flex; align-items: center; gap: 9px; margin-top: 7px; color: var(--green-900); font-size: 25px; font-weight: 950; }
.completion-badge span { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: #fff; background: var(--green-500); font-size: 18px; }
.staff-guide { margin: 11px 0 0; color: var(--muted); font-size: 14px; font-weight: 700; }
.record-status { min-height: 20px; margin: 10px 0 0; color: var(--green-700); font-size: 13px; font-weight: 750; }
.retry-button { margin-top: 14px; }

:focus-visible { outline: 3px solid rgba(94, 84, 164, 0.45); outline-offset: 3px; }
[hidden] { display: none !important; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes correct-pop { 50% { transform: scale(1.025); } }

@media (max-width: 380px) {
  .screen { padding-inline: 16px; }
  .question-card { padding: 21px 15px 18px; border-radius: 23px; }
  .choice-button { min-height: 57px; padding: 10px 12px; font-size: 14px; }
  .quiz-summary { gap: 8px; }
  .quiz-summary div { min-width: 102px; }
}

@media (min-width: 521px) {
  body { padding-block: 22px; }
  .app-shell, .screen { min-height: calc(100vh - 44px); min-height: calc(100dvh - 44px); }
  .app-shell { overflow: hidden; border-radius: 30px; }
  .question-card { min-height: calc(100dvh - 160px); }
}

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