:root {
  --ink: #10283a;
  --muted: #61717b;
  --paper: #f7f0df;
  --paper-2: #fffaf0;
  --navy: #0b1e2d;
  --teal: #1f716f;
  --teal-light: #cfe7df;
  --gold: #df9f3d;
  --gold-light: #f6e2b4;
  --coral: #d9654f;
  --success: #287a61;
  --shadow: 0 18px 50px rgba(7, 28, 42, .16);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--navy); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  background:
    linear-gradient(180deg, rgba(7, 23, 35, .56), rgba(7, 23, 35, .82)),
    url("assets/asterfall-hero.png") center top / cover fixed;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(223,159,61,.55); outline-offset: 3px; }

.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { min-height: 86px; display: flex; align-items: center; justify-content: space-between; color: white; }
.brand { display: flex; align-items: center; gap: 11px; border: 0; color: white; background: transparent; text-align: left; padding: 0; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.45); border-radius: 13px; font-family: Fraunces, serif; font-size: 24px; background: rgba(255,255,255,.1); backdrop-filter: blur(10px); }
.brand strong { font: 700 19px/1 Fraunces, serif; display: block; letter-spacing: .02em; }
.brand small { opacity: .66; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.top-actions { display: flex; gap: 12px; align-items: center; }
.streak, .level-chip, .icon-btn { border: 1px solid rgba(255,255,255,.18); background: rgba(7, 24, 36, .42); color: white; backdrop-filter: blur(12px); }
.streak { padding: 8px 11px; border-radius: 14px; }
.streak span { color: var(--gold); }
.level-chip { min-width: 130px; padding: 8px 12px; border-radius: 14px; font-size: 12px; }
.mini-bar { height: 3px; background: rgba(255,255,255,.18); border-radius: 10px; margin-top: 5px; overflow: hidden; }
.mini-bar i { display: block; width: 8%; height: 100%; background: var(--gold); transition: width .4s; }
.icon-btn { width: 39px; height: 39px; border-radius: 13px; font-size: 18px; }

main { flex: 1; }
main:focus { outline: none; }
.screen { animation: reveal .45s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }

.hero { min-height: calc(100vh - 140px); display: grid; align-items: center; grid-template-columns: 1.1fr .9fr; gap: clamp(24px, 6vw, 80px); padding: 54px 0 80px; color: white; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--gold-light); text-transform: uppercase; letter-spacing: .16em; font-size: 11px; font-weight: 700; }
.eyebrow::before { content: ""; width: 24px; height: 1px; background: currentColor; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; margin-top: 0; }
.hero h1 { font-size: clamp(52px, 7vw, 88px); line-height: .94; margin: 18px 0 22px; max-width: 760px; text-wrap: balance; }
.hero-copy > p { max-width: 610px; font-size: clamp(17px, 2vw, 20px); line-height: 1.65; color: rgba(255,255,255,.8); }
.feature-pills { display: flex; flex-wrap: wrap; gap: 10px; margin: 30px 0; }
.feature-pills span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.19); border-radius: 99px; background: rgba(9,29,43,.26); font-size: 12px; }
.primary-btn, .secondary-btn { border: 0; border-radius: 15px; padding: 14px 20px; font-weight: 700; transition: transform .18s, filter .18s; }
.primary-btn:hover, .secondary-btn:hover { transform: translateY(-2px); filter: brightness(1.04); }
.primary-btn { color: #172230; background: var(--gold-light); box-shadow: 0 8px 24px rgba(223,159,61,.2); }
.primary-btn.dark { background: var(--ink); color: white; }
.primary-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.secondary-btn { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); color: white; }
.hero-card { padding: 32px; border: 1px solid rgba(255,255,255,.22); border-radius: 32px; background: rgba(9, 29, 43, .64); backdrop-filter: blur(18px); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.hero-card::after { content: "✦"; position: absolute; right: 18px; top: 10px; font-size: 90px; opacity: .035; }
.seal { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; color: var(--gold-light); border: 1px solid rgba(246,226,180,.4); font: 700 25px Fraunces, serif; }
.hero-card h2 { font-size: 28px; margin: 20px 0 10px; }
.hero-card p { color: rgba(255,255,255,.68); line-height: 1.6; }
.name-field { display: grid; gap: 8px; margin: 24px 0; }
.name-field label { font-size: 12px; color: rgba(255,255,255,.72); }
.name-field input { width: 100%; padding: 14px 15px; color: white; background: rgba(0,0,0,.18); border: 1px solid rgba(255,255,255,.18); border-radius: 13px; }

.paper-panel { background: rgba(255, 250, 240, .97); border-radius: 30px; min-height: 650px; box-shadow: var(--shadow); overflow: hidden; margin: 20px 0 44px; }
.panel-head { padding: 24px 32px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e6dcc8; }
.panel-head h2 { font-size: 25px; margin: 0 0 3px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 13px; }
.step-track { display: flex; gap: 5px; }
.step-track i { width: 30px; height: 5px; background: #ded5c4; border-radius: 6px; }
.step-track i.done { background: var(--teal); }
.question-wrap { max-width: 790px; margin: 0 auto; padding: clamp(36px, 7vw, 80px) 28px; }
.quest-label { color: var(--teal); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 700; }
.question-wrap h2 { font-size: clamp(29px, 4vw, 42px); margin: 13px 0; line-height: 1.17; }
.question-help { color: var(--muted); margin-bottom: 28px; line-height: 1.55; }
.option-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.option { border: 1px solid #dbd3c5; background: white; padding: 17px; border-radius: 15px; color: var(--ink); text-align: left; font-weight: 600; transition: .18s; }
.option:hover { border-color: var(--teal); transform: translateY(-1px); }
.option.selected { color: white; background: var(--teal); border-color: var(--teal); }
.listen-btn { display: flex; gap: 12px; align-items: center; border: 0; color: white; background: var(--teal); border-radius: 18px; padding: 14px 22px; margin: 24px 0; font-weight: 700; }
.listen-btn span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.15); }
.answer-input, .answer-textarea { width: 100%; border: 1px solid #d8cebd; border-radius: 15px; background: white; padding: 16px; color: var(--ink); }
.answer-textarea { min-height: 130px; resize: vertical; line-height: 1.6; }
.question-actions { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 30px; }
.question-actions small { color: var(--muted); }

.result-layout { display: grid; grid-template-columns: .85fr 1.15fr; gap: 38px; padding: clamp(30px, 6vw, 70px); }
.rank-card { text-align: center; padding: 36px 24px; background: var(--ink); color: white; border-radius: 25px; }
.rank-ring { width: 150px; height: 150px; margin: 0 auto 20px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--gold) var(--score), rgba(255,255,255,.1) 0); position: relative; }
.rank-ring::after { content: ""; position: absolute; inset: 9px; background: var(--ink); border-radius: 50%; }
.rank-ring div { position: relative; z-index: 1; }
.rank-ring strong { display: block; font: 700 37px Fraunces, serif; }
.rank-ring span { font-size: 11px; color: rgba(255,255,255,.6); }
.rank-card h2 { font-size: 28px; margin-bottom: 8px; }
.rank-card p { color: rgba(255,255,255,.65); line-height: 1.55; }
.skills h2 { font-size: 34px; margin-bottom: 8px; }
.skills > p { color: var(--muted); line-height: 1.6; }
.skill-row { display: grid; grid-template-columns: 92px 1fr 44px; gap: 12px; align-items: center; margin: 18px 0; font-size: 13px; }
.bar { height: 9px; border-radius: 10px; background: #e4ddcf; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--teal); border-radius: inherit; }
.recommendation { margin: 28px 0; padding: 18px; border-radius: 16px; background: var(--teal-light); color: #194b4b; line-height: 1.55; }

.dashboard { padding: 25px 0 50px; color: white; }
.dash-greeting { display: flex; justify-content: space-between; align-items: end; gap: 25px; margin: 25px 0 30px; }
.dash-greeting h1 { font-size: clamp(38px, 5vw, 61px); margin: 8px 0; }
.dash-greeting p { color: rgba(255,255,255,.68); margin: 0; }
.xp-card { min-width: 220px; padding: 16px; border: 1px solid rgba(255,255,255,.16); background: rgba(5,20,31,.48); border-radius: 17px; backdrop-filter: blur(12px); }
.xp-card div { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 7px; }
.map-grid { display: grid; grid-template-columns: 1.4fr .6fr; gap: 18px; }
.missions-panel, .side-panel { border: 1px solid rgba(255,255,255,.15); background: rgba(7, 25, 38, .72); backdrop-filter: blur(16px); border-radius: 27px; padding: 24px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.panel-title h2 { margin: 0; font-size: 24px; }
.panel-title span { font-size: 11px; color: rgba(255,255,255,.55); text-transform: uppercase; letter-spacing: .12em; }
.mission-list { display: grid; gap: 12px; }
.mission-card { display: grid; grid-template-columns: 55px 1fr auto; gap: 16px; align-items: center; width: 100%; color: white; text-align: left; padding: 16px; border: 1px solid rgba(255,255,255,.11); border-radius: 18px; background: rgba(255,255,255,.055); transition: .2s; }
.mission-card:hover:not(:disabled) { border-color: rgba(246,226,180,.55); transform: translateX(3px); }
.mission-card:disabled { opacity: .45; cursor: not-allowed; }
.mission-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; background: rgba(223,159,61,.14); font-size: 25px; }
.mission-card h3 { font: 700 17px DM Sans, sans-serif; margin: 0 0 4px; }
.mission-card p { color: rgba(255,255,255,.56); font-size: 12px; margin: 0; }
.mission-status { color: var(--gold-light); font-size: 12px; }
.side-panel { display: grid; gap: 17px; align-content: start; }
.profile-card { padding: 4px; }
.profile-card h3 { margin-bottom: 4px; }
.profile-card p { color: rgba(255,255,255,.55); font-size: 12px; margin-top: 0; }
.stat-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 14px; border-radius: 15px; background: rgba(255,255,255,.06); }
.stat strong { display: block; color: var(--gold-light); font: 700 24px Fraunces, serif; }
.stat span { color: rgba(255,255,255,.55); font-size: 11px; }
.word-card { padding: 18px; color: var(--ink); background: var(--gold-light); border-radius: 17px; }
.word-card small { text-transform: uppercase; letter-spacing: .11em; opacity: .6; }
.word-card strong { font: 700 25px Fraunces, serif; display: block; margin: 7px 0 2px; }
.word-card p { font-size: 12px; margin: 0; opacity: .7; }

.mission-shell { margin: 20px 0 45px; display: grid; grid-template-columns: 260px 1fr; min-height: 680px; border-radius: 29px; overflow: hidden; box-shadow: var(--shadow); }
.mission-nav { background: rgba(8, 27, 40, .95); color: white; padding: 28px 22px; }
.back-link { border: 0; color: rgba(255,255,255,.7); background: transparent; padding: 0; font-size: 12px; }
.mission-nav h2 { font-size: 27px; margin: 32px 0 8px; }
.mission-nav > p { color: rgba(255,255,255,.55); font-size: 13px; line-height: 1.5; }
.mission-steps { margin-top: 35px; display: grid; gap: 18px; }
.mission-step { display: grid; grid-template-columns: 29px 1fr; gap: 10px; align-items: center; color: rgba(255,255,255,.45); font-size: 12px; }
.mission-step i { width: 29px; height: 29px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; display: grid; place-items: center; font-style: normal; }
.mission-step.active { color: white; }
.mission-step.active i { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.mission-step.done { color: var(--teal-light); }
.mission-content { background: var(--paper-2); padding: clamp(30px, 5vw, 68px); }
.story-art { padding: 22px; border-left: 3px solid var(--gold); background: #f2e8d6; border-radius: 0 16px 16px 0; color: #4a4d4b; font: 600 17px/1.65 Fraunces, serif; margin: 22px 0 30px; }
.challenge-box { padding: 24px; background: white; border: 1px solid #e3d9c8; border-radius: 18px; }
.challenge-box h3 { font: 700 20px DM Sans, sans-serif; margin-bottom: 8px; }
.challenge-box > p { color: var(--muted); line-height: 1.55; }
.feedback { margin-top: 18px; padding: 15px 17px; border-radius: 14px; line-height: 1.5; font-size: 13px; }
.feedback.good { background: #d9eee4; color: #1d664e; }
.feedback.try { background: #f7e4cf; color: #805126; }
.hidden { display: none !important; }
.sentence-builder { display: flex; flex-wrap: wrap; gap: 9px; margin: 18px 0; min-height: 50px; }
.word-tile { border: 1px solid #d8cebd; background: white; border-radius: 10px; padding: 9px 12px; }
.word-tile.used { opacity: .3; }
.choice-story { display: grid; gap: 11px; margin-top: 20px; }
.choice-story button { border: 1px solid #ded3c0; border-radius: 13px; padding: 14px; background: #fff; text-align: left; }

.celebration { text-align: center; padding: 55px 20px; }
.celebration .big-seal { width: 110px; height: 110px; display: grid; place-items: center; margin: 0 auto 24px; border-radius: 50%; background: var(--gold-light); font-size: 50px; box-shadow: 0 0 0 10px rgba(223,159,61,.13); }
.celebration h2 { font-size: 42px; margin-bottom: 10px; }
.celebration p { max-width: 540px; margin: 0 auto 25px; color: var(--muted); line-height: 1.65; }

footer { min-height: 50px; color: rgba(255,255,255,.45); display: flex; justify-content: space-between; font-size: 11px; }
.text-button { border: 0; background: transparent; color: inherit; }
.toast { position: fixed; left: 50%; bottom: 25px; z-index: 10; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 12px 17px; border-radius: 12px; color: white; background: #10283a; box-shadow: var(--shadow); transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .hero, .result-layout, .map-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 25px; }
  .hero h1 { font-size: clamp(48px, 14vw, 72px); }
  .hero-card { max-width: 560px; }
  .dash-greeting { align-items: start; flex-direction: column; }
  .xp-card { width: 100%; }
  .mission-shell { grid-template-columns: 1fr; }
  .mission-nav { padding: 20px; }
  .mission-nav h2 { margin: 18px 0 4px; }
  .mission-steps { grid-template-columns: repeat(3, 1fr); margin-top: 18px; }
  .mission-step { grid-template-columns: 25px 1fr; gap: 6px; }
  .mission-step i { width: 25px; height: 25px; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 20px, 1180px); }
  .level-chip { display: none; }
  .option-grid { grid-template-columns: 1fr; }
  .panel-head { padding: 18px; }
  .panel-head p, .step-track i:nth-child(n+7) { display: none; }
  .question-wrap { padding: 40px 20px; }
  .question-actions { align-items: stretch; flex-direction: column; }
  .question-actions .primary-btn { width: 100%; }
  .result-layout { padding: 24px 18px; }
  .mission-card { grid-template-columns: 48px 1fr; }
  .mission-status { grid-column: 2; }
  .side-panel { padding: 18px; }
  .mission-content { padding: 30px 18px; }
  footer span { display: none; }
  footer { justify-content: flex-end; }
}

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