:root {
  --bg: #f3f7fa;
  --surface: #ffffff;
  --ink: #12263a;
  --muted: #5f7185;
  --line: #dbe5ee;
  --accent: #0f766e;
  --accent-strong: #0b5d57;
  --accent-soft: #e6f4f1;
  --accent-ink: #064e49;
  --shadow: 0 18px 40px rgba(18, 38, 58, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(15, 118, 110, 0.12), transparent 34rem),
    radial-gradient(circle at 88% 18%, rgba(37, 99, 235, 0.07), transparent 28rem),
    var(--bg);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app {
  width: min(100% - 40px, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 32px;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 40px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--ink);
  color: #ffffff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject-badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

#app-main {
  flex: 1;
}

.screen {
  animation: screen-in 0.25s ease-out;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  margin: 8px 0 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

h1 {
  margin: 0;
  font-size: clamp(2.15rem, 6vw, 3.35rem);
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.lead {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.75;
}

.setup-card {
  display: grid;
  gap: 24px;
  padding: 26px;
  border: 1px solid rgba(219, 229, 238, 0.9);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.fieldset legend {
  margin-bottom: 10px;
  padding: 0;
  font-size: 0.88rem;
  font-weight: 800;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  position: relative;
  display: inline-flex;
}

.chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.chip:hover span {
  border-color: #b9c9d8;
  background: #ffffff;
}

.chip input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(15, 118, 110, 0.2);
}

.chip input:focus-visible + span {
  outline: 3px solid rgba(245, 158, 11, 0.75);
  outline-offset: 2px;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 0.94rem;
  font-weight: 800;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #c7d4dc;
  color: #ffffff;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.btn-secondary:hover {
  border-color: #b9c9d8;
  background: #f8fafc;
}

.btn-block {
  width: 100%;
}

.btn:focus-visible,
.btn-quiet:focus-visible,
.choice:focus-visible {
  outline: 3px solid rgba(245, 158, 11, 0.75);
  outline-offset: 3px;
}

.source-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.notice {
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 0.86rem;
  line-height: 1.7;
  white-space: pre-line;
}

.notice-error {
  margin: 0 0 16px;
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: #9f1239;
}

/* 문제 화면 */
.quiz-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.btn-quiet {
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.btn-quiet:hover {
  color: var(--ink);
}

.progress-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5edf3;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #2dd4bf);
  transition: width 0.25s ease-out;
}

.quiz-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.74rem;
  font-weight: 800;
}

.meta-text {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.question-text {
  max-width: 62ch;
  margin: 6px 0 24px;
  font-size: clamp(1.35rem, 3.6vw, 1.8rem);
  line-height: 1.45;
  letter-spacing: -0.025em;
  overflow-wrap: break-word;
  word-break: keep-all;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 60px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.choice:hover {
  border-color: #9fb6c8;
  box-shadow: 0 6px 16px rgba(18, 38, 58, 0.06);
  transform: translateY(-1px);
}

.choice-number {
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.choice-text {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: keep-all;
}

.choice.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.choice.is-selected .choice-number {
  background: var(--accent);
  color: #ffffff;
}

.choice.is-dimmed {
  opacity: 0.55;
}

.choice-list.is-locked .choice {
  cursor: default;
}

.choice-list.is-locked .choice:hover {
  transform: none;
  border-color: var(--line);
  box-shadow: none;
}

.choice-list.is-locked .choice.is-selected:hover {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.quiz-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

.quiz-actions .hint {
  margin: 0;
}

.quiz-actions .btn {
  flex: 0 0 auto;
  min-width: 150px;
}

/* 결과 화면 */
.result-title {
  margin-bottom: 24px;
  font-size: clamp(2rem, 5vw, 2.8rem);
}

.result-card {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.result-score {
  margin: 4px 0 0;
  font-size: clamp(3.5rem, 12vw, 5rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}

.result-score strong {
  color: var(--accent);
}

.result-score > span {
  color: var(--muted);
  font-size: 0.36em;
  font-weight: 700;
  letter-spacing: 0;
}

.result-percent {
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 800;
}

.result-message {
  max-width: 32rem;
  margin: 16px auto 0;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.7;
}

.result-card .hint {
  margin-top: 18px;
}

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.app-footer {
  margin-top: auto;
  padding-top: 40px;
  color: #8a9aac;
  font-size: 0.72rem;
  text-align: center;
}

.app-footer p {
  margin: 0;
}

@media (max-width: 600px) {
  .app {
    width: min(100% - 28px, 760px);
    padding-top: 20px;
  }

  .app-header {
    margin-bottom: 28px;
  }

  .hero {
    margin-bottom: 22px;
  }

  .setup-card {
    padding: 20px;
    border-radius: 20px;
  }

  .quiz-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .quiz-actions .btn {
    width: 100%;
  }

  .result-card {
    padding: 26px 20px;
  }
}

@media (max-width: 380px) {
  .brand-name {
    display: none;
  }
}

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