@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,600&display=swap');

:root {
  --ink: #292521;
  --muted: #756c65;
  --paper: #fffaf3;
  --line: rgba(52, 42, 34, .13);
  --accent: #d96d62;
  --accent-dark: #a9453d;
  --level-color: #f3c1b9;
  --level-color-deep: #d96d62;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  background: var(--level-color);
  transition: background-color 1.2s ease;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background-image: radial-gradient(rgba(61, 46, 38, .22) .7px, transparent .7px);
  background-size: 15px 15px;
  mix-blend-mode: multiply;
}

.ambient { position: fixed; pointer-events: none; border-radius: 50%; filter: blur(2px); opacity: .28; }
.ambient-one { width: 36vw; height: 36vw; right: -13vw; top: -14vw; background: #fff2c6; }
.ambient-two { width: 24vw; height: 24vw; left: -12vw; bottom: -10vw; background: #b9e2a8; }

.app-shell { width: min(100% - 40px, 980px); margin: 0 auto; padding: 32px 0 50px; position: relative; }
.topbar, .level-strip, .question-meta, .quiz-footer { display: flex; align-items: center; justify-content: space-between; }
.topbar { margin-bottom: 48px; }
.brand-mark { display: flex; align-items: center; gap: 13px; }
.brand-icon { display: grid; place-items: center; width: 47px; height: 47px; border: 1px solid rgba(39, 32, 27, .2); border-radius: 14px; background: rgba(255, 250, 243, .55); font-family: serif; font-size: 27px; box-shadow: 3px 3px 0 rgba(48, 35, 28, .08); }
.eyebrow, .level-kicker, .prompt-label { margin: 0; text-transform: uppercase; letter-spacing: .14em; font-family: 'DM Mono', monospace; font-size: 10px; font-weight: 500; }
.brand-mark h1 { margin: 2px 0 0; font-family: Fraunces, serif; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.streak-pill { display: flex; gap: 8px; align-items: center; padding: 8px 13px; border: 1px solid var(--line); border-radius: 99px; background: rgba(255, 250, 243, .53); font-size: 12px; font-weight: 600; }
.spark { color: #b46631; font-size: 16px; }

.level-strip { gap: 28px; margin-bottom: 17px; }
.level-heading { min-width: 125px; }
.level-heading strong { display: block; margin-top: 4px; font-family: Fraunces, serif; font-size: 25px; letter-spacing: -.02em; }
.level-kicker { color: rgba(41, 37, 33, .62); }
.level-dots { display: flex; flex: 1; gap: 8px; }
.level-dot { height: 8px; flex: 1; border-radius: 3px; background: rgba(255, 250, 243, .42); transition: background .5s, transform .3s; }
.level-dot.active { background: var(--level-color-deep); transform: scaleY(1.45); }
.level-dot.complete { background: rgba(41, 37, 33, .65); }
.time-badge { white-space: nowrap; padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 250, 243, .44); font-size: 11px; }
.time-badge strong { font-family: 'DM Mono', monospace; font-size: 15px; }
.clock-icon { margin-right: 4px; font-size: 17px; vertical-align: -1px; }

.quiz-card { padding: 28px 38px 22px; border: 1px solid rgba(59, 42, 31, .16); border-radius: 22px; background: rgba(255, 250, 243, .93); box-shadow: 0 25px 55px rgba(76, 49, 33, .13), 0 2px 0 rgba(255, 255, 255, .65) inset; }
.question-meta { color: var(--muted); font-family: 'DM Mono', monospace; font-size: 11px; }
.question-meta span span { opacity: .5; }
.hint { font-family: 'DM Sans', sans-serif; font-size: 12px; }
.timer-track { height: 7px; margin-top: 17px; overflow: hidden; border-radius: 99px; background: #eee1d5; }
.timer-fill { width: 100%; height: 100%; border-radius: inherit; background: var(--level-color-deep); transform-origin: left; transition: width 1s linear, background .5s; }
.timer-fill.warning { background: #cf5b4b; }
.prompt-wrap { padding: 48px 0 37px; text-align: center; }
.prompt-label { color: var(--muted); }
.character { margin-top: 8px; font-family: serif; font-size: clamp(92px, 16vw, 150px); line-height: 1; letter-spacing: -.06em; }
.answers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.answer-button { display: grid; grid-template-columns: 46px 1fr; align-items: center; min-height: 77px; padding: 12px 15px; border: 1px solid #e8dcd0; border-radius: 13px; color: var(--ink); background: #fffdf9; font-family: inherit; text-align: left; cursor: pointer; transition: transform .2s, border .2s, box-shadow .2s, background .2s; }
.answer-button:hover { transform: translateY(-2px); border-color: var(--level-color-deep); box-shadow: 0 8px 18px rgba(79, 49, 33, .1); }
.answer-button:focus-visible { outline: 3px solid rgba(35, 105, 126, .3); outline-offset: 2px; }
.answer-button.correct { border-color: #64a069; background: #e8f4e5; }
.answer-button.incorrect { border-color: #cb685c; background: #fbe5e0; }
.answer-emoji { font-size: 27px; text-align: center; }
.answer-copy { padding-left: 14px; border-left: 1px solid #e8dcd0; }
.answer-pinyin { display: block; font-family: 'DM Mono', monospace; font-size: 12px; font-weight: 500; }
.answer-meaning { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.quiz-footer { margin-top: 24px; color: var(--muted); font-size: 11px; }
.keyboard-note { font-family: 'DM Mono', monospace; font-size: 10px; }

.modal-backdrop { display: grid; place-items: center; position: fixed; inset: 0; z-index: 10; padding: 20px; background: rgba(53, 42, 36, .42); backdrop-filter: blur(7px); }
.hidden { display: none; }
.modal-card { position: relative; width: min(100%, 470px); padding: 42px 40px 38px; border: 1px solid rgba(59, 42, 31, .14); border-radius: 22px; background: var(--paper); text-align: center; box-shadow: 0 30px 80px rgba(44, 29, 19, .25); animation: rise .4s ease both; }
.modal-icon, .success-icon { display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto 20px; border-radius: 20px; background: #f8d8af; font-size: 32px; }
.modal-card h2 { margin: 8px 0 10px; font-family: Fraunces, serif; font-size: 30px; line-height: 1.08; letter-spacing: -.03em; }
.modal-copy { max-width: 310px; margin: 0 auto; color: var(--muted); font-size: 14px; line-height: 1.55; }
.round-time { margin: 19px 0 0; color: var(--muted); font-family: 'DM Mono', monospace; font-size: 11px; }
.round-time strong { color: var(--ink); font-size: 16px; }
.modal-actions { display: grid; gap: 10px; margin-top: 28px; }
.button { min-height: 46px; border: 0; border-radius: 10px; font: 600 13px 'DM Sans', sans-serif; cursor: pointer; transition: transform .2s, box-shadow .2s; }
.button:hover { transform: translateY(-2px); box-shadow: 0 8px 15px rgba(66, 40, 26, .15); }
.button-primary { color: #fffaf3; background: var(--accent-dark); }
.button-secondary { color: var(--ink); border: 1px solid #dfd1c3; background: #fffdf9; }
.success-card { overflow: hidden; padding-top: 46px; }
.success-icon { color: #fffaf3; background: #6a9d62; font-family: serif; }
.success-card h2 { font-size: 27px; }
.final-time { margin: 22px 0 25px; color: var(--muted); font-family: 'DM Mono', monospace; font-size: 12px; }
.final-time strong { color: var(--ink); font-size: 18px; }
.play-again { width: 100%; }
.play-again span { margin-left: 5px; font-size: 18px; vertical-align: -2px; }
.confetti-wrap { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti { position: absolute; top: -18px; width: 8px; height: 16px; animation: fall 2.8s linear infinite; }

@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fall { to { transform: translateY(560px) rotate(720deg); } }

@media (max-width: 650px) {
  .app-shell { width: min(100% - 26px, 520px); padding-top: 22px; }
  .topbar { margin-bottom: 31px; }
  .level-strip { flex-wrap: wrap; gap: 12px; }
  .level-heading { flex: 1; }
  .level-dots { order: 3; flex-basis: 100%; }
  .time-badge { padding: 7px 10px; }
  .quiz-card { padding: 22px 17px 19px; border-radius: 18px; }
  .prompt-wrap { padding: 38px 0 29px; }
  .answers { gap: 9px; }
  .answer-button { grid-template-columns: 33px 1fr; min-height: 71px; padding: 9px; }
  .answer-copy { padding-left: 9px; }
  .answer-emoji { font-size: 22px; }
  .answer-pinyin, .answer-meaning { font-size: 11px; }
  .hint { display: none; }
  .modal-card { padding: 33px 23px 28px; }
}
