:root {
  --navy: #102a43;
  --navy-2: #173f63;
  --ink: #132536;
  --muted: #667b8e;
  --paper: #ffffff;
  --bg: #eef5f9;
  --line: #d8e4ec;
  --blue: #2f80ed;
  --teal: #159d91;
  --coral: #f0645a;
  --gold: #f2b744;
  --green: #249568;
  --red: #c84444;
  --shadow: 0 22px 65px rgba(16, 42, 67, .14);
  --soft-shadow: 0 11px 28px rgba(16, 42, 67, .10);
}

* { box-sizing: border-box; }

html { min-height: 100%; scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 8% 12%, rgba(47, 128, 237, .13), transparent 26rem),
    radial-gradient(circle at 92% 84%, rgba(21, 157, 145, .12), transparent 28rem),
    var(--bg);
  overflow-x: hidden;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(47, 128, 237, .32);
  outline-offset: 3px;
}

.hidden { display: none !important; }

.background-shape {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}

.shape-one {
  width: 340px;
  height: 340px;
  top: -180px;
  right: -100px;
  background: rgba(240, 100, 90, .08);
}

.shape-two {
  width: 430px;
  height: 430px;
  bottom: -250px;
  left: -170px;
  background: rgba(242, 183, 68, .09);
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 22px auto 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 5px;
  color: var(--navy);
  border: 0;
  background: transparent;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  color: #fff;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--navy-2), var(--teal));
  box-shadow: 0 8px 18px rgba(16, 42, 67, .18);
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 13px; letter-spacing: .035em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .11em; }

.top-actions { display: flex; gap: 8px; }

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--navy);
  border: 1px solid rgba(16, 42, 67, .12);
  border-radius: 13px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 6px 16px rgba(16, 42, 67, .07);
  transition: transform .18s ease, background .18s ease;
}

.icon-button:hover { transform: translateY(-2px); background: #fff; }

.screen { display: none; }
.screen.active { display: block; animation: screen-in .34s ease both; }

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

.welcome-card {
  position: relative;
  display: grid;
  min-height: 650px;
  overflow: hidden;
  grid-template-columns: 1.03fr .97fr;
  border: 1px solid rgba(16, 42, 67, .08);
  border-radius: 32px;
  background: #fff;
  box-shadow: var(--shadow);
}

.welcome-copy {
  position: relative;
  z-index: 2;
  padding: clamp(42px, 6vw, 76px);
}

.eyebrow {
  display: inline-block;
  margin-bottom: 14px;
  color: #93e0d7;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.eyebrow.dark { color: var(--teal); }

h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(52px, 7vw, 86px);
  line-height: .88;
  letter-spacing: -.065em;
}

h1 span { color: var(--teal); }

.lead {
  max-width: 580px;
  margin: 23px 0 26px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.5;
}

.mission-stats {
  display: grid;
  max-width: 520px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f9fcfe;
}

.mission-stats div { padding: 14px 15px; text-align: center; }
.mission-stats div + div { border-left: 1px solid var(--line); }
.mission-stats strong { display: block; color: var(--navy); font-size: 24px; }
.mission-stats span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }

.name-field { display: block; max-width: 520px; }
.name-field span { display: block; margin: 0 0 7px 3px; color: var(--navy); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.name-field input {
  width: 100%;
  padding: 16px 17px;
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: 15px;
  background: #fff;
  transition: border .18s ease, box-shadow .18s ease;
}
.name-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(47, 128, 237, .10); outline: 0; }

.primary-button, .secondary-button, .next-button {
  min-height: 52px;
  padding: 14px 22px;
  border-radius: 15px;
  font-weight: 820;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.primary-button {
  color: #fff;
  border: 0;
  background: linear-gradient(135deg, var(--coral), #ef7b4f);
  box-shadow: 0 12px 25px rgba(240, 100, 90, .25);
}

.welcome-copy > .primary-button { width: 100%; max-width: 520px; margin-top: 12px; }
.primary-button:hover, .next-button:hover { transform: translateY(-2px); box-shadow: 0 15px 28px rgba(240, 100, 90, .28); }
.primary-button:active, .next-button:active { transform: translateY(0); }

.save-note { max-width: 520px; margin: 11px 0 0; color: #8495a4; font-size: 11px; text-align: center; }

.route-illustration {
  position: relative;
  overflow: hidden;
  min-height: 100%;
  background:
    linear-gradient(155deg, rgba(16, 42, 67, .96), rgba(23, 63, 99, .96) 56%, rgba(21, 157, 145, .91)),
    #102a43;
}

.route-illustration::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.23) 1px, transparent 1px);
  background-size: 25px 25px;
  mask-image: linear-gradient(to bottom, #000, transparent 94%);
}

.orbit {
  position: absolute;
  border: 2px dashed rgba(255, 255, 255, .19);
  border-radius: 50%;
}
.orbit-a { width: 470px; height: 470px; top: 86px; left: 65px; transform: rotate(-12deg); }
.orbit-b { width: 670px; height: 310px; top: 180px; left: -38px; transform: rotate(28deg); }

.compass {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 190px;
  height: 190px;
  place-items: center;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .26);
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  box-shadow: inset 0 0 0 15px rgba(255,255,255,.035), 0 22px 55px rgba(0,0,0,.18);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(5px);
}
.compass-n { font-family: Georgia, serif; font-size: 42px; font-weight: 800; }
.compass-arrow { position: absolute; top: 14px; color: var(--gold); font-size: 29px; transform: rotate(-58deg); }

.route-dot {
  position: absolute;
  display: grid;
  width: 49px;
  height: 49px;
  place-items: center;
  color: var(--navy);
  border: 4px solid rgba(255,255,255,.32);
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
  font-weight: 900;
}
.dot-1 { top: 15%; left: 18%; }
.dot-2 { top: 23%; right: 16%; }
.dot-3 { top: 47%; right: 8%; }
.dot-4 { bottom: 20%; right: 25%; }
.dot-5 { bottom: 12%; left: 24%; }
.dot-6 { top: 40%; left: 9%; }

.map-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 30px;
  align-items: end;
  margin: 34px 4px 25px;
}
.map-heading h2 { margin: 2px 0 8px; color: var(--navy); font-size: clamp(34px, 5vw, 58px); line-height: 1; letter-spacing: -.045em; }
.map-heading p { max-width: 690px; margin: 0; color: var(--muted); line-height: 1.5; }

.profile-card {
  display: grid;
  min-width: 290px;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}
.profile-card div { padding: 17px 20px; }
.profile-card div + div { border-left: 1px solid var(--line); }
.profile-card span, .profile-card strong { display: block; }
.profile-card span { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.profile-card strong { margin-top: 4px; color: var(--navy); font-size: 20px; }

.round-map { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }

.round-card {
  --accent: var(--blue);
  position: relative;
  display: grid;
  min-height: 244px;
  grid-template-columns: 100px 1fr;
  gap: 22px;
  overflow: hidden;
  padding: 26px;
  border: 1px solid rgba(16, 42, 67, .08);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--soft-shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.round-card:not(.locked):hover { transform: translateY(-4px); box-shadow: 0 18px 38px rgba(16, 42, 67, .14); }
.round-card::after {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  right: -75px;
  bottom: -80px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.round-card.locked { opacity: .63; filter: saturate(.55); }
.round-icon {
  display: grid;
  width: 88px;
  height: 88px;
  place-items: center;
  color: #fff;
  border-radius: 25px;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--navy)));
  box-shadow: 0 12px 24px color-mix(in srgb, var(--accent) 25%, transparent);
  font-size: 40px;
}
.round-icon .lock-icon { font-size: 29px; }
.round-card-body { min-width: 0; }
.round-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.round-meta span:first-child { color: var(--accent); font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .1em; }
.round-stars { color: var(--gold); font-size: 20px; letter-spacing: 2px; white-space: nowrap; }
.round-card h3 { margin: 9px 0 7px; color: var(--navy); font-size: 24px; letter-spacing: -.025em; }
.round-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.round-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 19px; }
.round-best { color: #7a8d9e; font-size: 12px; }
.round-play {
  padding: 10px 15px;
  color: #fff;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  font-weight: 800;
}
.round-play:disabled { color: #7d8b97; background: #dde5eb; cursor: not-allowed; }

.map-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 18px 4px 0; color: #8192a0; font-size: 11px; }
.text-button { padding: 7px 4px; color: var(--blue); border: 0; background: transparent; font-weight: 780; }
.text-button:hover { text-decoration: underline; }
.text-button.danger { color: var(--red); }

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 26px 0 15px;
  padding: 21px 24px;
  color: #fff;
  border-radius: 23px;
  background: linear-gradient(135deg, var(--navy), var(--navy-2) 66%, #176c76);
  box-shadow: var(--soft-shadow);
}

.round-identity { display: flex; align-items: center; gap: 15px; }
.round-number { display: grid; width: 55px; height: 55px; place-items: center; border: 1px solid rgba(255,255,255,.2); border-radius: 17px; background: rgba(255,255,255,.09); color: var(--gold); font-size: 20px; font-weight: 900; }
.round-identity small, .round-identity strong { display: block; }
.round-identity small { color: #9fe5df; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.round-identity strong { margin-top: 3px; font-size: 20px; }

.game-stats { display: flex; gap: 8px; }
.stat { min-width: 84px; padding: 9px 13px; border-radius: 13px; background: rgba(255,255,255,.08); text-align: center; }
.stat span, .stat strong { display: block; }
.stat span { color: #bdd2df; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.stat strong { margin-top: 3px; font-size: 18px; }
.stat.hearts { min-width: 110px; }
.stat.hearts strong { color: #ff8e84; font-size: 15px; letter-spacing: 2px; }

.progress-row { display: grid; grid-template-columns: auto 1fr auto; gap: 13px; align-items: center; margin: 0 6px 15px; color: var(--muted); font-size: 11px; font-weight: 750; }
.progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: #dbe6ed; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--teal)); transition: width .3s ease; }

.game-layout { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }

.rule-card {
  position: sticky;
  top: 18px;
  padding: 22px;
  border: 1px solid #d7e6ee;
  border-radius: 22px;
  background: linear-gradient(155deg, #f5fbff, #f4fbf9);
  box-shadow: var(--soft-shadow);
}
.rule-label { color: var(--teal); font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .11em; }
.rule-card h3 { margin: 8px 0 15px; color: var(--navy); font-size: 21px; }
.rule-content { display: grid; gap: 9px; }
.rule-line { padding: 11px 12px; border: 1px solid #dbe8ee; border-radius: 12px; background: rgba(255,255,255,.72); color: #425b6f; font-size: 13px; line-height: 1.38; }
.rule-line strong { display: block; margin-bottom: 3px; color: var(--navy); }
.rule-card.collapsed .rule-content, .rule-card.collapsed h3 { display: none; }

.question-panel {
  min-height: 530px;
  padding: clamp(23px, 4vw, 42px);
  border: 1px solid rgba(16, 42, 67, .08);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}
.question-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.skill-tag, .combo-badge { display: inline-flex; align-items: center; min-height: 30px; padding: 6px 11px; border-radius: 999px; font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.skill-tag { color: var(--blue); background: #eaf4ff; }
.combo-badge { color: #8a5d00; background: #fff0c6; animation: badge-pop .3s ease; }
@keyframes badge-pop { 50% { transform: scale(1.08); } }
.instruction { margin: 24px 0 8px; color: var(--muted); font-size: 13px; font-weight: 680; }
.prompt { min-height: 83px; margin: 0 0 24px; color: var(--navy); font-size: clamp(29px, 4.5vw, 47px); line-height: 1.17; letter-spacing: -.035em; }

.answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.answer-button {
  position: relative;
  display: flex;
  min-height: 66px;
  align-items: center;
  gap: 13px;
  padding: 13px 15px;
  color: var(--ink);
  border: 2px solid #dce6ed;
  border-radius: 16px;
  background: #fbfdfe;
  text-align: left;
  font-weight: 720;
  line-height: 1.25;
  transition: transform .16s ease, border .16s ease, background .16s ease;
}
.answer-button:hover:not(:disabled) { transform: translateY(-2px); border-color: #95b9db; background: #f6fbff; }
.answer-index { display: grid; width: 31px; height: 31px; flex: 0 0 auto; place-items: center; color: var(--navy); border-radius: 10px; background: #e8f0f5; font-size: 12px; font-weight: 900; }
.answer-button.correct { color: #17613f; border-color: #5fbe91; background: #eaf8f1; }
.answer-button.correct .answer-index { color: #fff; background: var(--green); }
.answer-button.wrong { color: #8d3131; border-color: #e5a1a1; background: #fff0f0; animation: shake .28s ease; }
.answer-button.wrong .answer-index { color: #fff; background: var(--red); }
.answer-button:disabled { cursor: default; }
@keyframes shake { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }

.feedback { display: none; margin-top: 16px; padding: 15px 17px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.feedback.show { display: block; animation: screen-in .25s ease; }
.feedback strong { display: block; margin-bottom: 3px; }
.feedback.good { color: #1f6848; border: 1px solid #bbe1cd; background: #edf9f3; }
.feedback.try { color: #8a4740; border: 1px solid #f0c1bc; background: #fff4f2; }

.question-footer { display: flex; min-height: 61px; align-items: flex-end; justify-content: space-between; gap: 15px; margin-top: 8px; }
.keyboard-hint { color: #93a1ad; font-size: 10px; }
.next-button { min-width: 145px; color: #fff; border: 0; background: linear-gradient(135deg, var(--coral), #ef7b4f); box-shadow: 0 11px 22px rgba(240, 100, 90, .22); }

.result-card {
  max-width: 820px;
  margin: 34px auto 0;
  padding: clamp(35px, 6vw, 64px);
  border: 1px solid rgba(16, 42, 67, .08);
  border-radius: 30px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}
.result-burst { display: grid; width: 88px; height: 88px; margin: 0 auto 20px; place-items: center; color: #fff; border-radius: 28px; background: linear-gradient(145deg, var(--gold), #ef8f3a); box-shadow: 0 16px 28px rgba(242, 183, 68, .3); font-size: 45px; transform: rotate(-6deg); }
.result-card h2 { margin: 4px 0 8px; color: var(--navy); font-size: clamp(37px, 6vw, 58px); line-height: 1; letter-spacing: -.045em; }
.result-card > p { margin: 0; color: var(--muted); font-size: 16px; }
.earned-stars { margin: 25px 0; color: var(--gold); font-size: 47px; letter-spacing: 7px; text-shadow: 0 4px 12px rgba(242,183,68,.25); }
.result-metrics { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: #f9fcfe; }
.result-metrics div { padding: 16px 12px; }
.result-metrics div + div { border-left: 1px solid var(--line); }
.result-metrics span, .result-metrics strong { display: block; }
.result-metrics span { min-height: 26px; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
.result-metrics strong { margin-top: 5px; color: var(--navy); font-size: 23px; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 24px; }
.result-actions .text-button { grid-column: 1 / -1; justify-self: center; }
.secondary-button { color: var(--navy); border: 2px solid #cfdee8; background: #fff; }
.secondary-button:hover { border-color: #9fb9cb; background: #f9fcfe; }

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 24px;
  max-width: min(430px, calc(100% - 28px));
  padding: 13px 18px;
  color: #fff;
  border-radius: 13px;
  background: var(--navy);
  box-shadow: 0 15px 36px rgba(16,42,67,.28);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 15px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.confetti-layer { position: fixed; z-index: 60; inset: 0; overflow: hidden; pointer-events: none; }
.confetti-piece { position: absolute; top: -24px; width: 11px; height: 17px; border-radius: 3px; animation: confetti-fall var(--fall-time) linear forwards; }
@keyframes confetti-fall {
  to { transform: translate3d(var(--drift), 110vh, 0) rotate(740deg); opacity: .7; }
}

@media (max-width: 930px) {
  .welcome-card { grid-template-columns: 1fr; }
  .route-illustration { min-height: 330px; }
  .orbit-a { top: -80px; left: 50%; transform: translateX(-50%); }
  .orbit-b { top: 5px; left: 50%; transform: translateX(-50%) rotate(20deg); }
  .game-layout { grid-template-columns: 1fr; }
  .rule-card { position: static; }
  .round-map { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .app-shell { width: min(100% - 16px, 650px); margin: 8px auto 25px; }
  .brand small { display: none; }
  .welcome-card, .result-card { border-radius: 23px; }
  .welcome-copy { padding: 34px 22px 30px; }
  h1 { font-size: 58px; }
  .route-illustration { min-height: 260px; }
  .compass { width: 145px; height: 145px; }
  .map-heading { grid-template-columns: 1fr; margin-top: 24px; }
  .profile-card { min-width: 0; width: 100%; }
  .round-card { grid-template-columns: 75px 1fr; gap: 15px; padding: 20px; }
  .round-icon { width: 69px; height: 69px; border-radius: 20px; font-size: 32px; }
  .game-header { align-items: flex-start; flex-direction: column; padding: 18px; }
  .game-stats { width: 100%; }
  .stat { flex: 1; min-width: 0; padding-inline: 8px; }
  .progress-row { grid-template-columns: 1fr auto; }
  .progress-track { grid-column: 1 / -1; grid-row: 2; }
  .question-panel { min-height: 0; padding: 24px 17px; }
  .answer-grid { grid-template-columns: 1fr; }
  .prompt { min-height: 0; font-size: 31px; }
  .result-metrics { grid-template-columns: repeat(2, 1fr); }
  .result-metrics div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .result-metrics div:nth-child(4) { border-top: 1px solid var(--line); }
  .result-actions { grid-template-columns: 1fr; }
  .result-actions .text-button { grid-column: auto; }
}

@media (max-width: 470px) {
  .brand strong { font-size: 11px; }
  .welcome-card { min-height: 0; }
  .mission-stats strong { font-size: 20px; }
  .mission-stats span { font-size: 9px; }
  .route-illustration { min-height: 225px; }
  .round-card { grid-template-columns: 1fr; }
  .round-icon { width: 58px; height: 58px; }
  .round-card h3 { font-size: 22px; }
  .game-stats { gap: 5px; }
  .stat span { font-size: 8px; }
  .stat strong { font-size: 15px; }
  .stat.hearts { min-width: 0; }
  .question-footer { align-items: stretch; flex-direction: column-reverse; }
  .next-button { width: 100%; }
  .keyboard-hint { text-align: center; }
}

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