:root {
  --ink: #f7f1e4;
  --muted: #c9c0ad;
  --night: #081522;
  --panel: rgba(8, 21, 34, 0.84);
  --panel-soft: rgba(21, 40, 53, 0.9);
  --gold: #efc76e;
  --gold-deep: #b8872e;
  --rose: #d9787a;
  --teal: #64c4bd;
  --green: #72d19b;
  --red: #ef7c7c;
  --line: rgba(239, 199, 110, 0.24);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--night);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button { font: inherit; }

button:focus-visible,
a:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  padding: 0.65rem 1rem;
  color: var(--night);
  background: #fff;
  border-radius: 0.5rem;
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.app {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  overflow: hidden;
}

.scene-art,
.scene-shade {
  position: fixed;
  inset: 0;
  z-index: -2;
}

.scene-art {
  background-position: center;
  background-size: cover;
  filter: saturate(1.08) brightness(1.08);
  transition: opacity 300ms ease, filter 300ms ease;
}

.app[data-scene="orchard"] .scene-art { background-image: url("assets/orchard-stage-v2.webp"); }
.app[data-scene="balcony"] .scene-art { background-image: url("assets/balcony-stage-v2.webp"); }
.app[data-scene="friar"] .scene-art { background-image: url("assets/friar-cell-stage-v2.webp"); }
.app[data-scene="tomb"] .scene-art { background-image: url("assets/capulet-tomb-stage-v1.webp"); }

.scene-shade {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(5, 13, 23, 0.38), rgba(5, 13, 23, 0.08) 50%, rgba(5, 13, 23, 0.34)),
    linear-gradient(0deg, rgba(5, 13, 23, 0.48), transparent 48%, rgba(5, 13, 23, 0.16));
}

.topbar {
  width: min(1100px, calc(100% - 2rem));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  border: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.crest {
  display: grid;
  width: 34px;
  height: 38px;
  place-items: center;
  color: var(--night);
  background: var(--gold);
  clip-path: polygon(50% 0, 100% 14%, 92% 74%, 50% 100%, 8% 74%, 0 14%);
  font-family: Georgia, serif;
  font-weight: 900;
}

.top-stats { display: flex; gap: 0.55rem; }

.stat {
  padding: 0.42rem 0.68rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(5, 13, 23, 0.72);
  font-size: 0.9rem;
}

.stat span { color: var(--gold); }
.stat strong { color: var(--ink); }

.game-shell {
  width: min(820px, calc(100% - 2rem));
  min-height: 600px;
  margin: clamp(1rem, 4vh, 3.5rem) auto 2rem;
  padding: clamp(1.4rem, 4vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.08);
}

.screen { display: none; }
.screen.active { display: block; animation: fade-in 280ms ease both; }

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

.eyebrow,
.card-kicker,
.scene-label,
.passage-card > span {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1,
h2,
h3 {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.04;
}

h1 {
  max-width: 690px;
  margin: 1rem 0;
  font-size: clamp(2.6rem, 8vw, 5.3rem);
  letter-spacing: -0.045em;
}

h2 { margin: 0.55rem 0 0.9rem; font-size: clamp(2.1rem, 5vw, 3.4rem); }
h3 { font-size: 1.55rem; }

.lead {
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: 1.2rem;
}

.route {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto 1fr auto;
  align-items: center;
  gap: 0.7rem;
  max-width: 600px;
  margin: 2.2rem 0;
}

.route i { height: 1px; background: var(--line); }

.route-stop {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
}

.route-stop span,
.chapter-medallion {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  background: rgba(239, 199, 110, 0.08);
  font-family: Georgia, serif;
  font-weight: 800;
}

.route-stop small { color: var(--muted); }

.home-actions,
.result-actions,
.question-actions,
.study-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  min-height: 48px;
  padding: 0.72rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }

.btn-primary { color: #17202a; background: var(--gold); }
.btn-primary:hover { background: #f8d98e; }
.btn-quiet { color: var(--ink); background: transparent; border-color: var(--line); }
.btn-quiet:hover { background: rgba(255, 255, 255, 0.06); }

.microcopy { margin: 1.1rem 0 0; color: var(--muted); font-size: 0.85rem; }

.mission-note {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  max-width: 610px;
  margin: 1.3rem 0;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--rose);
  background: rgba(217, 120, 122, 0.08);
}

.mission-note > span { color: var(--rose); font-size: 1.4rem; }
.mission-note p { margin: 0; color: var(--muted); }
.mission-note strong { color: var(--ink); }

.screen-heading,
.question-topline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.counter {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 750;
}

.study-card {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 1.4rem;
  min-height: 330px;
  margin: 1.3rem 0;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel-soft);
}

.device-icon {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border-radius: 20px;
  color: var(--night);
  background: var(--gold);
  font-family: Georgia, serif;
  font-size: 2rem;
  font-weight: 900;
}

.study-card h3 { margin: 0.25rem 0 0.7rem; font-size: clamp(2rem, 5vw, 3rem); }
.definition { max-width: 560px; color: var(--ink); font-size: 1.08rem; }

.example-box {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--rose);
  background: rgba(217, 120, 122, 0.08);
}

.example-box span { color: var(--rose); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; }
.example-box p { margin: 0.35rem 0 0; }

.study-nav { justify-content: space-between; }
.study-dots { display: flex; gap: 0.35rem; }
.study-dots span { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.22); }
.study-dots span.active { background: var(--gold); transform: scale(1.3); }

#chapter-screen { max-width: 620px; margin: 4vh auto 0; text-align: center; }
.chapter-medallion { width: 62px; height: 62px; margin: 0 auto 1.2rem; font-size: 1.25rem; }
.chapter-copy { max-width: 520px; margin: 0 auto 1.25rem; color: var(--muted); font-size: 1.08rem; }

.chapter-goal {
  max-width: 520px;
  margin: 0 auto 1.6rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--gold);
  background: rgba(239, 199, 110, 0.07);
  font-weight: 750;
}

.focus-chips { display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.8rem; }
.focus-chips span { padding: 0.4rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.85rem; }

.progress-track { height: 6px; margin: 0.7rem 0 1.5rem; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--rose), var(--gold)); transition: width 250ms ease; }

.dialogue-row {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 0.8rem;
  align-items: start;
  margin-bottom: 1.1rem;
}

.speaker-mark {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--night);
  background: var(--gold);
  font-family: Georgia, serif;
  font-size: 1.2rem;
  font-weight: 900;
}

.speech {
  position: relative;
  padding: 0.78rem 0.95rem;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 5px 14px 14px 14px;
  background: rgba(255,255,255,.055);
}

.speech strong { color: var(--gold); }
.speech p { margin: 0.2rem 0 0; color: var(--muted); }
.story-heading { margin-bottom: 0.8rem; font-family: inherit; font-size: clamp(1.15rem, 2.5vw, 1.4rem); }

.dual-quote {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-bottom: 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--line);
}

.dual-quote > div {
  min-width: 0;
  padding: 1rem 1.1rem;
  background: var(--panel-soft);
}

.dual-quote > div:last-child { background: rgba(100,196,189,.075); }

.dual-quote span {
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.dual-quote blockquote {
  margin: 0.45rem 0 0;
  font-family: Georgia, serif;
  font-size: clamp(1.2rem, 2.7vw, 1.55rem);
  font-style: italic;
  line-height: 1.35;
}

.dual-quote p { margin: 0.45rem 0 0; color: var(--muted); }
.dual-quote.compact blockquote { font-size: clamp(1.08rem, 2.4vw, 1.35rem); }
.dual-quote.compact p { font-size: 0.95rem; }

.story-guess {
  margin-top: 1.1rem;
  padding: 1rem;
  border: 1px solid rgba(239,199,110,.32);
  border-radius: 18px;
  background: rgba(5,13,23,.5);
}

.guess-kicker {
  margin: 0 0 .2rem;
  color: var(--teal);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.story-guess h3 { margin: 0 0 .8rem; font-family: inherit; font-size: 1.15rem; }
.story-options .answer-btn { min-height: 52px; }

.lesson-reveal {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 1rem;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid rgba(114,209,155,.35);
  border-radius: 18px;
  background: rgba(114,209,155,.08);
}

.lesson-reveal.is-wrong { border-color: rgba(239,199,110,.45); background: rgba(239,199,110,.09); }
.lesson-feedback { display: block; margin-bottom: .25rem; color: var(--green); }
.lesson-reveal.is-wrong .lesson-feedback { color: var(--gold); }

.lesson-reveal .device-icon { width: 62px; height: 62px; border-radius: 16px; font-size: 1.5rem; }
.lesson-reveal h3 { margin: 0.15rem 0 0.45rem; font-size: 1.8rem; }
.lesson-reveal .definition { margin-bottom: 0.45rem; font-size: 1rem; }
.lesson-effect { margin: 0; color: var(--muted); }

#check-intro-screen { max-width: 620px; margin: 3vh auto 0; text-align: center; }

.passage-card {
  margin-bottom: 1.5rem;
  padding: 1.2rem 1.35rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
}

.passage-card blockquote {
  margin: 0.45rem 0 0.7rem;
  font-family: Georgia, serif;
  font-size: clamp(1.3rem, 3vw, 1.75rem);
  line-height: 1.35;
}

.text-btn {
  padding: 0;
  border: 0;
  color: var(--teal);
  background: transparent;
  cursor: pointer;
  font-weight: 750;
}

.original-text {
  margin: 0.75rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255,255,255,.1);
  color: var(--muted);
  font-family: Georgia, serif;
  font-style: italic;
}

.question-prompt { font-family: inherit; font-size: clamp(1.2rem, 3vw, 1.55rem); line-height: 1.35; }

.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }

.answer-btn {
  min-height: 64px;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 13px;
  color: var(--ink);
  background: rgba(255,255,255,.055);
  cursor: pointer;
  text-align: left;
  font-weight: 700;
}

.answer-btn:hover { border-color: var(--gold); background: rgba(239,199,110,.08); }
.answer-btn.correct { border-color: var(--green); background: rgba(114,209,155,.12); }
.answer-btn.wrong { border-color: var(--red); background: rgba(239,124,124,.12); }
.answer-btn:disabled { cursor: default; }

.feedback {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 0.75rem;
  align-items: start;
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  background: rgba(114,209,155,.1);
}

.feedback.is-wrong { background: rgba(239,124,124,.1); }
.feedback-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: var(--night); background: var(--green); font-weight: 900; }
.feedback.is-wrong .feedback-mark { background: var(--red); }
.feedback strong { color: var(--green); }
.feedback.is-wrong strong { color: var(--red); }
.feedback p { margin: 0.2rem 0 0; color: var(--muted); }

.question-actions { margin-top: 1rem; justify-content: space-between; }
.hint-text { margin: 0.9rem 0 0; padding: 0.7rem 0.85rem; border-left: 3px solid var(--teal); color: var(--muted); background: rgba(100,196,189,.08); }

#result-screen { text-align: center; }
.result-seal { display: grid; width: 78px; height: 78px; margin: 0 auto 1rem; place-items: center; border: 2px solid var(--gold); border-radius: 50%; color: var(--gold); font-size: 2rem; font-weight: 900; }
.result-message { max-width: 560px; margin: 0 auto 1.5rem; color: var(--muted); font-size: 1.05rem; }

.score-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; margin-bottom: 1.3rem; }
.score-row div { padding: 1rem 0.5rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.04); }
.score-row strong { display: block; color: var(--gold); font-family: Georgia, serif; font-size: 1.8rem; }
.score-row span { color: var(--muted); font-size: 0.8rem; }

.mastery-panel { padding: 1rem; border-radius: 16px; background: var(--panel-soft); text-align: left; }
.mastery-panel h3 { margin: 0 0 0.8rem; font-family: inherit; font-size: 1rem; }
.skill-list { display: grid; gap: 0.6rem; }
.skill-item { display: grid; grid-template-columns: 1fr auto; gap: 0.8rem; align-items: center; }
.skill-bar { height: 7px; margin-top: 0.25rem; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.skill-bar span { display: block; height: 100%; background: var(--teal); }
.skill-item small { color: var(--muted); }
.result-actions { justify-content: center; margin-top: 1.2rem; }

.footer-note { width: min(820px, calc(100% - 2rem)); margin: 0 auto 1.5rem; color: rgba(255,255,255,.55); font-size: 0.78rem; text-align: center; }

@media (max-width: 650px) {
  .topbar { min-height: 62px; }
  .brand > span:last-child { display: none; }
  .game-shell { min-height: calc(100svh - 100px); margin-top: 0.5rem; border-radius: 20px; }
  .study-card { grid-template-columns: 1fr; min-height: 390px; }
  .device-icon { width: 58px; height: 58px; border-radius: 15px; }
  .answer-grid { grid-template-columns: 1fr; }
  .dual-quote { grid-template-columns: 1fr; }
  .lesson-reveal { grid-template-columns: 54px 1fr; }
  .lesson-reveal .device-icon { width: 48px; height: 48px; border-radius: 13px; }
  .score-row strong { font-size: 1.45rem; }
  .route-stop small { font-size: 0.72rem; }
}

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