:root {
  color-scheme: dark;
  --night: #0b2024;
  --night-soft: #15383d;
  --stone: #c99b5b;
  --stone-light: #f1d59a;
  --sand: #e5bd6b;
  --papyrus: #fff2cf;
  --papyrus-deep: #ebd197;
  --lapis: #126d78;
  --lapis-bright: #1f98a1;
  --gold: #e4ad3e;
  --gold-light: #ffe08a;
  --coral: #d8613c;
  --ink: #172d2e;
  --muted: #6f6045;
  --success: #23745f;
  --error: #a33d2d;
  --line: rgba(255, 226, 158, .26);
  --shadow: rgba(3, 12, 14, .42);
  font-family: "Trebuchet MS", "Avenir Next", Avenir, sans-serif;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }

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

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--papyrus);
  background:
    radial-gradient(circle at 50% -10%, rgba(229, 173, 62, .19), transparent 39%),
    linear-gradient(115deg, rgba(255, 255, 255, .018) 25%, transparent 25%) 0 0 / 54px 54px,
    var(--night);
}

body.modal-open { overflow: hidden; }
button { color: inherit; font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 4px solid var(--gold-light);
  outline-offset: 3px;
}

button:disabled { cursor: not-allowed; }

.atmosphere {
  position: fixed;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.dust {
  position: absolute;
  width: 5px;
  height: 5px;
  background: var(--gold-light);
  border-radius: 50%;
  box-shadow: 38px 70px 0 1px rgba(255,224,138,.3), 112px 12px 0 rgba(255,224,138,.45), 176px 93px 0 rgba(255,224,138,.24), 240px 42px 0 1px rgba(255,224,138,.2);
  opacity: .48;
  animation: drift-dust 9s linear infinite;
}

.dust-one { top: 18%; left: 6%; }
.dust-two { top: 54%; left: 54%; animation-delay: -3s; animation-duration: 11s; }
.dust-three { top: 81%; left: 18%; animation-delay: -6s; animation-duration: 13s; }

.topbar {
  min-height: 78px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(24px, calc(24px + env(safe-area-inset-right, 0px))) 10px max(24px, calc(24px + env(safe-area-inset-left, 0px)));
  background: rgba(8, 27, 30, .92);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 7px 28px rgba(0, 0, 0, .22);
  backdrop-filter: blur(12px);
}

.back-link {
  justify-self: start;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  color: var(--gold-light);
  border-radius: 12px;
  font-weight: 900;
  text-decoration: none;
}

.back-link:hover { background: rgba(255,255,255,.07); }
.back-link > span:first-child { font-size: 25px; line-height: 1; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand > div:last-child { display: block; }
.brand small, .brand h1 { margin: 0; }
.brand small { display: block; margin-bottom: 2px; color: var(--sand); font-size: 9px; font-weight: 900; letter-spacing: .19em; text-transform: uppercase; }
.brand h1 { font-family: Copperplate, "Palatino Linotype", "Book Antiqua", serif; font-size: clamp(20px, 2vw, 27px); letter-spacing: -.025em; line-height: 1; }

.brand-mark {
  width: 49px;
  height: 49px;
  display: grid;
  place-items: center;
  background: var(--gold);
  border: 2px solid var(--gold-light);
  border-radius: 50% 50% 46% 46%;
  box-shadow: 0 0 0 3px rgba(228,173,62,.15), 0 5px 12px rgba(0,0,0,.25);
}

.brand-mark svg { width: 37px; fill: var(--night); stroke: var(--papyrus); stroke-width: 2.2; stroke-linejoin: round; }

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

.icon-button {
  min-width: 44px;
  height: 44px;
  padding: 0 13px;
  color: var(--gold-light);
  background: rgba(255, 242, 207, .07);
  border: 1px solid rgba(255, 224, 138, .33);
  border-radius: 8px 8px 14px 14px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .25);
  font-weight: 900;
  cursor: pointer;
}

.icon-button:hover { background: rgba(255,224,138,.14); border-color: var(--gold); }
.icon-button:active { transform: translateY(2px); box-shadow: none; }
.icon-button[aria-pressed="false"] { color: #829292; background: rgba(255,255,255,.035); box-shadow: none; }

main {
  width: min(1420px, 100%);
  margin: 0 auto;
  padding: 18px max(20px, env(safe-area-inset-right, 0px)) max(34px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
}

.mission-banner {
  position: relative;
  min-height: 113px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 75px 136px;
  align-items: center;
  gap: 22px;
  padding: 18px 24px;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(92deg, rgba(255,255,255,.34), transparent 34%),
    repeating-linear-gradient(3deg, rgba(80,55,24,.035) 0 1px, transparent 1px 6px),
    var(--papyrus-deep);
  border: 2px solid #8b6531;
  border-radius: 8px 8px 24px 8px;
  box-shadow: 0 10px 28px var(--shadow), inset 0 0 0 3px rgba(255,255,255,.24);
}

.mission-banner::before,
.mission-banner::after {
  content: "";
  position: absolute;
  width: 19px;
  height: 19px;
  border: 2px solid rgba(91,60,25,.32);
  transform: rotate(45deg);
}
.mission-banner::before { left: 9px; top: 9px; }
.mission-banner::after { right: 9px; bottom: 9px; }

.mission-copy { min-width: 0; }
.mission-copy h2, .mission-copy p { margin: 0; }
.mission-copy h2 { font-family: Copperplate, "Palatino Linotype", Georgia, serif; font-size: clamp(21px, 2.5vw, 31px); letter-spacing: -.035em; line-height: 1.05; }
.mission-copy > p:last-child { max-width: 760px; margin-top: 7px; color: #5f543f; font-size: 13px; font-weight: 750; line-height: 1.4; }

.eyebrow { margin: 0; color: var(--coral); font-size: 9px; font-weight: 1000; letter-spacing: .17em; text-transform: uppercase; }

.torch { position: relative; width: 55px; height: 82px; justify-self: center; }
.torch i { position: absolute; left: 23px; top: 38px; width: 10px; height: 44px; background: #6e4625; border: 2px solid #382715; border-radius: 5px; transform: rotate(5deg); }
.torch span { position: absolute; left: 9px; top: 0; width: 38px; height: 51px; background: var(--coral); border: 2px solid #7e3824; border-radius: 54% 46% 57% 43% / 68% 66% 34% 32%; box-shadow: 0 0 25px rgba(216,97,60,.48); transform-origin: 50% 90%; animation: torch-flicker .9s ease-in-out infinite alternate; }
.torch span::after { content: ""; position: absolute; left: 12px; top: 18px; width: 12px; height: 24px; background: var(--gold-light); border-radius: 50% 48% 55% 45%; }

.mission-stamp { width: 124px; height: 79px; display: grid; grid-template-columns: 1fr 38px; grid-template-rows: 1fr 20px; align-items: center; padding: 9px; color: #765128; border: 3px double #9d7137; border-radius: 50%; text-align: center; transform: rotate(-4deg); }
.mission-stamp span { font-family: Copperplate, Georgia, serif; font-size: 13px; font-weight: 900; letter-spacing: .12em; }
.mission-stamp b { font-size: 31px; line-height: 1; }
.mission-stamp small { grid-column: 1 / -1; border-top: 1px solid #9d7137; font-size: 7px; font-weight: 900; letter-spacing: .22em; }

.room-track {
  max-width: 790px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 18px auto 16px;
  padding: 0;
  list-style: none;
}

.room-track li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #789195; font-size: 10px; }
.room-track li::before { content: ""; position: absolute; z-index: -1; top: 16px; right: 50%; width: 100%; height: 2px; background: #315157; }
.room-track li:first-child::before { display: none; }
.room-track span { width: 34px; height: 34px; display: grid; place-items: center; color: #819296; background: #18383d; border: 2px solid #3b5b60; border-radius: 50% 50% 43% 48%; font-weight: 1000; }
.room-track b { font-weight: 900; letter-spacing: .04em; }
.room-track li.current, .room-track li.done { color: var(--papyrus); }
.room-track li.current span { color: var(--night); background: var(--gold); border-color: var(--gold-light); box-shadow: 0 0 0 4px rgba(228,173,62,.12), 0 4px 0 #7e5722; transform: rotate(-5deg) scale(1.07); }
.room-track li.done span { color: var(--papyrus); background: var(--lapis); border-color: #41a6aa; }
.room-track li.done span::after { content: "✓"; }
.room-track li.done span { font-size: 0; }
.room-track li.done span::after { font-size: 15px; }
.room-track li.current::before, .room-track li.done::before { background: var(--gold); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(360px, .82fr); gap: 18px; align-items: start; }
.chamber-card, .puzzle-card { border: 1px solid rgba(255,224,138,.28); box-shadow: 0 15px 36px var(--shadow); }
.chamber-card { overflow: hidden; background: #31261e; border-radius: 7px 7px 19px 7px; }
.puzzle-card { min-height: 650px; display: flex; flex-direction: column; padding: 21px; color: var(--ink); background: var(--papyrus); border-radius: 7px 7px 23px 7px; box-shadow: 0 15px 36px var(--shadow), inset 0 0 0 3px rgba(139,101,49,.12); }

.chamber-head { min-height: 78px; display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 14px 18px; background: linear-gradient(90deg, #122f34, #1b4447); border-bottom: 1px solid rgba(255,224,138,.24); }
.chamber-head h2, .puzzle-head h2 { margin: 2px 0 0; font-family: Copperplate, "Palatino Linotype", Georgia, serif; letter-spacing: -.025em; line-height: 1.08; }
.chamber-head h2 { font-size: clamp(20px, 2vw, 27px); }

.seal-pouch { display: flex; align-items: center; gap: 10px; }
.seal-pouch > span { color: #aac0bd; font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
#seal-pouch-icons { display: flex; gap: 6px; }
#seal-pouch-icons i { width: 31px; height: 31px; display: grid; place-items: center; color: var(--night); background: rgba(255,255,255,.04); border: 1px dashed #587176; border-radius: 50%; font-size: 16px; font-style: normal; transition: transform .3s ease, background .3s ease; }
#seal-pouch-icons i.found { background: var(--gold); border: 2px solid var(--gold-light); box-shadow: 0 3px 0 rgba(0,0,0,.24); animation: seal-arrive .55s cubic-bezier(.2,1.5,.4,1) both; }

.chamber-stage { position: relative; min-height: 570px; overflow: hidden; background: #6c4b2c; }
.chamber-svg { display: block; width: 100%; height: auto; min-height: 510px; max-height: 570px; }
.floor { fill: #2b211c; }
.ceiling-border { fill: none; stroke: #e3b85d; stroke-width: 3; opacity: .68; }
.border-marks { fill: #e8bd61; opacity: .46; }
.wall-torch .flame-outer { fill: #df6437; animation: svg-flame .8s ease-in-out infinite alternate; transform-origin: center bottom; }
.wall-torch .flame-inner { fill: #ffe277; }
.wall-torch .torch-stick { fill: none; stroke: #291b12; stroke-width: 9; stroke-linecap: round; }
.room-art { display: none; }
.room-art.active { display: inline; animation: room-reveal .48s ease both; }
.stone-door { fill: #8b653c; stroke: #d6aa61; stroke-width: 8; }
.door-inset { fill: rgba(35,27,21,.28); stroke: #39291d; stroke-width: 4; }
.carved-line { fill: none; stroke: #d2a45a; stroke-width: 3; }
.door-glyphs { fill: none; stroke: #f2ca70; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.door-glyphs .glyph-sun { fill: #c45c32; stroke: #f2ca70; }
.door-glyphs .glyph-fill { fill: #16737a; }
.sand-line { fill: none; stroke: #e1b65e; stroke-width: 5; opacity: .55; }
.alcove { fill: #2b2922; stroke: #c3914b; stroke-width: 8; }
.scale-art { fill: none; stroke: #e6b651; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.scale-pin, .weight-art { fill: #17838a; }
.feather-art { fill: rgba(255,242,207,.18); }
.sun-shaft { fill: rgba(255,222,119,.22); }
.ceiling-sun { fill: var(--gold); stroke: #ffdf83; stroke-width: 5; }
.mirror-pedestals { fill: #735033; stroke: #c8964e; stroke-width: 5; }
.mirror-pedestals circle { fill: #193f44; stroke: #e4b75f; }
.mirror-shine { fill: none; stroke: #fff2c5; stroke-width: 8; }
.sealed-disc { fill: #12474d; stroke: #d6a446; stroke-width: 8; }
.disc-eye { fill: none; stroke: #f2ca70; stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.final-door { fill: #7f5a35; stroke: #e1b65e; stroke-width: 8; }
.final-inset { fill: #103a40; stroke: #d6a446; stroke-width: 5; }
.wing-left, .wing-right { fill: none; stroke: #e7bf67; stroke-width: 6; stroke-linecap: round; }
.final-sun { fill: #cf6139; stroke: #f1c65d; stroke-width: 5; }
.sarcophagus { fill: #d4a544; stroke: #f4d985; stroke-width: 5; }
.sarcophagus-detail { fill: none; stroke: #126d78; stroke-width: 5; stroke-linecap: round; }
.foreground-stones { fill: #181714; opacity: .9; }

.scene-caption { position: absolute; right: 18px; bottom: 17px; left: 18px; min-height: 67px; display: flex; align-items: center; gap: 13px; padding: 12px 16px; background: rgba(8, 27, 30, .9); border: 1px solid rgba(255,224,138,.34); border-radius: 5px 5px 14px 5px; box-shadow: 0 8px 20px rgba(0,0,0,.28); backdrop-filter: blur(8px); }
.scene-caption p { margin: 0; color: #f6e8c4; font-size: 13px; font-weight: 750; line-height: 1.45; }
.caption-symbol { width: 39px; height: 39px; flex: 0 0 auto; display: grid; place-items: center; color: var(--gold-light); background: rgba(228,173,62,.13); border: 1px solid var(--gold); border-radius: 50%; font-size: 22px; }

.puzzle-head { display: flex; align-items: center; gap: 13px; padding-bottom: 15px; border-bottom: 1px solid #ddc798; }
.puzzle-head h2 { font-size: clamp(22px, 2.2vw, 29px); }
.chamber-number { width: 53px; height: 53px; flex: 0 0 auto; display: grid; place-items: center; color: var(--gold-light); background: var(--night-soft); border: 3px double var(--gold); border-radius: 50% 50% 43% 47%; font-family: Copperplate, Georgia, serif; font-size: 17px; font-weight: 900; box-shadow: 0 4px 0 #9a7335; transform: rotate(-3deg); }
.puzzle-prompt { margin: 17px 0 11px; color: #3b4037; font-size: 15px; font-weight: 800; line-height: 1.42; }
.clue-box { display: flex; gap: 10px; padding: 11px 13px; background: #f2dfac; border-left: 5px solid var(--gold); border-radius: 3px 11px 11px 3px; }
.clue-box > span { color: #a16a21; font-size: 18px; }
.clue-box p { margin: 0; color: #594a32; font-family: Georgia, "Palatino Linotype", serif; font-size: 13px; font-weight: 700; line-height: 1.45; }

.game-area { min-height: 245px; display: grid; align-content: center; padding: 17px 0 12px; }
.math-puzzle { display: grid; gap: 13px; animation: room-reveal .35s ease both; }
.problem-progress { display: flex; justify-content: space-between; align-items: center; color: #796640; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.problem-marks { display: flex; gap: 6px; }
.problem-marks i { width: 31px; height: 6px; background: #ddcfaa; border-radius: 99px; }
.problem-marks i.current { background: var(--gold); box-shadow: 0 0 0 2px rgba(228,173,62,.17); }
.problem-marks i.done { background: var(--success); }
.equation-tablet { position: relative; min-height: 78px; display: grid; place-items: center; overflow: hidden; color: #fff2c9; background: linear-gradient(145deg, #204d50, #102f35); border: 4px double #c89948; border-radius: 5px 5px 18px 5px; box-shadow: inset 0 0 22px rgba(0,0,0,.28), 0 5px 0 #8a642f; font-family: Copperplate, "Palatino Linotype", Georgia, serif; font-size: clamp(29px, 4vw, 40px); font-weight: 900; letter-spacing: .03em; }
.equation-tablet::before, .equation-tablet::after { content: ""; position: absolute; width: 13px; height: 13px; border: 2px solid rgba(255,224,138,.38); transform: rotate(45deg); }
.equation-tablet::before { top: 8px; left: 10px; }
.equation-tablet::after { right: 10px; bottom: 8px; }
.number-choice-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.number-choice, .number-path-choice { min-width: 0; min-height: 62px; padding: 8px; color: var(--ink); background: #dfc58f; border: 2px solid #aa8144; border-radius: 5px 5px 14px 5px; box-shadow: 0 4px 0 #89642f; font-family: Copperplate, Georgia, serif; font-size: 24px; font-weight: 900; cursor: pointer; transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.number-choice:hover, .number-path-choice:hover { background: #f4dcaa; transform: translateY(-2px); }
.number-choice:active, .number-path-choice:active { transform: translateY(2px); box-shadow: 0 1px 0 #89642f; }
.number-choice.selected, .number-path-choice.selected { color: #fff8dc; background: var(--lapis); border-color: #074c56; box-shadow: 0 4px 0 #07363c, 0 0 0 3px rgba(31,152,161,.16); }
.number-choice:disabled, .number-path-choice:disabled { opacity: .72; cursor: not-allowed; transform: none; }
.answer-entry { min-height: 103px; display: grid; grid-template-columns: 1fr minmax(100px, 150px); grid-template-rows: auto auto; align-items: center; gap: 4px 14px; padding: 14px 18px; background: #ead8ad; border: 2px solid #c6a260; border-radius: 5px 17px 5px 17px; }
.answer-label { color: #58482e; font-family: Georgia, serif; font-size: 16px; font-weight: 800; }
.math-answer { grid-column: 2; grid-row: 1 / 3; width: 100%; min-height: 70px; padding: 7px 10px; color: var(--night-soft); background: #fff9e8; border: 3px solid #a87934; border-radius: 5px 5px 15px 5px; box-shadow: inset 0 3px 8px rgba(75,49,18,.12); font-family: Copperplate, Georgia, serif; font-size: 32px; font-weight: 900; text-align: center; }
.math-answer[aria-invalid="true"] { border-color: var(--error); background: #fff0e8; }
.range-note { align-self: start; color: #766541; font-size: 10px; font-weight: 800; }
.code-entry { background: linear-gradient(135deg, #ead8ad, #e5c77f); border-style: double; border-width: 4px; }
.number-path-board { display: grid; gap: 9px; padding: 11px; background: #e9d6a6; border: 2px solid #bd9550; border-radius: 5px 16px 5px 16px; }
.path-journey { position: relative; display: grid; grid-template-columns: 55px 1fr 55px; align-items: center; gap: 7px; }
.path-journey::before { content: ""; position: absolute; z-index: 0; left: 45px; right: 45px; top: 50%; height: 5px; background: repeating-linear-gradient(90deg, var(--gold) 0 12px, transparent 12px 18px); transform: translateY(-50%); }
.path-node { position: relative; z-index: 1; width: 55px; height: 55px; display: grid; place-items: center; color: #fff4d3; background: var(--night-soft); border: 3px double var(--gold); border-radius: 50%; font-family: Copperplate, Georgia, serif; font-size: 19px; font-weight: 900; }
.path-node.target { color: var(--night); background: var(--gold-light); }
.path-step { position: relative; z-index: 1; justify-self: center; padding: 5px 9px; color: #fff5d8; background: var(--coral); border-radius: 99px; font-size: 10px; font-weight: 900; }
.path-instruction { margin: 0; color: #685535; font-size: 10px; font-weight: 900; text-align: center; }
.number-path-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.number-path-choice { min-height: 48px; font-size: 17px; }

.feedback, .hint-box { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; padding: 10px 12px; border-radius: 5px 12px 12px 5px; }
.feedback { color: #6b3028; background: #f3c9b7; border-left: 5px solid var(--error); }
.feedback.correct { color: #174c42; background: #cce7d8; border-left-color: var(--success); }
.feedback > span, .hint-box > span { width: 29px; height: 29px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; font-weight: 1000; }
.feedback > span { color: #fff; background: var(--error); }
.feedback.correct > span { background: var(--success); }
.feedback strong, .feedback p, .hint-box b, .hint-box p { margin: 0; }
.feedback strong, .hint-box b { display: block; font-size: 12px; }
.feedback p, .hint-box p { margin-top: 2px; font-size: 11px; font-weight: 700; line-height: 1.38; }
.hint-box { color: #4d4838; background: #d8e7df; border-left: 5px solid var(--lapis); }
.hint-box > span { color: #fff; background: var(--lapis); font-size: 17px; }

.puzzle-actions { display: flex; gap: 9px; margin-top: auto; }
.primary-button, .secondary-button { min-height: 48px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 5px 5px 13px 5px; font-weight: 1000; cursor: pointer; }
.primary-button { flex: 1; color: #fff7dc; background: var(--lapis); border: 2px solid #074d55; box-shadow: 0 5px 0 #07383e; }
.primary-button:hover { background: #18828b; transform: translateY(-1px); }
.primary-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #07383e; }
.primary-button:disabled { color: #a19a84; background: #d6cfb9; border-color: #bcb39b; box-shadow: none; }
.secondary-button { color: #6b552e; background: transparent; border: 2px solid #c7a66a; box-shadow: 0 3px 0 #c4a568; }
.secondary-button:hover { background: #f4e4bd; }
.secondary-button small { padding: 2px 5px; color: #fff; background: #98713b; border-radius: 8px; font-size: 8px; }
.next-button { background: var(--success); border-color: #165646; box-shadow: 0 5px 0 #12473b; }

.fact-strip { display: flex; align-items: flex-start; gap: 8px; margin-top: 14px; padding-top: 11px; color: #7d6a47; border-top: 1px dashed #ccb078; }
.fact-strip > span { width: 21px; height: 21px; flex: 0 0 auto; display: grid; place-items: center; color: var(--papyrus); background: var(--coral); border-radius: 50%; font-family: Georgia, serif; font-weight: 900; }
.fact-strip p { margin: 1px 0 0; font-size: 10px; line-height: 1.4; }

.completion-card { position: relative; min-height: 520px; display: grid; grid-template-columns: minmax(260px, .7fr) minmax(390px, 1fr); align-items: center; gap: 30px; padding: clamp(30px, 5vw, 70px); overflow: hidden; color: var(--ink); background: radial-gradient(circle at 26% 46%, rgba(255,230,132,.83), transparent 24%), linear-gradient(135deg, #f1d792, #bd8339); border: 4px double #6d481f; border-radius: 8px 8px 28px 8px; box-shadow: 0 18px 45px rgba(0,0,0,.4), inset 0 0 0 7px rgba(255,243,195,.24); animation: completion-in .65s ease both; }
.completion-card::before { content: ""; position: absolute; inset: 18px; border: 2px solid rgba(105,65,26,.28); pointer-events: none; }
.completion-rays { position: absolute; left: 24%; top: 48%; width: 480px; height: 480px; background: repeating-conic-gradient(from 0deg, rgba(255,246,191,.33) 0 7deg, transparent 7deg 18deg); border-radius: 50%; transform: translate(-50%,-50%); animation: rays-turn 22s linear infinite; }
.completion-scarab { position: relative; z-index: 1; width: clamp(210px, 27vw, 340px); aspect-ratio: 1; display: grid; place-items: center; justify-self: center; }
.completion-scarab i { position: absolute; inset: 10%; background: var(--night-soft); border: 8px double var(--gold-light); border-radius: 50%; box-shadow: 0 15px 35px rgba(51,31,12,.33), inset 0 0 30px rgba(255,218,108,.13); }
.completion-scarab span { position: relative; color: var(--gold-light); font-family: Georgia, serif; font-size: clamp(90px, 14vw, 160px); filter: drop-shadow(0 7px 0 rgba(0,0,0,.25)); }
.completion-copy { position: relative; z-index: 1; max-width: 640px; }
.completion-copy h2 { margin: 4px 0 12px; font-family: Copperplate, "Palatino Linotype", Georgia, serif; font-size: clamp(35px, 5vw, 66px); letter-spacing: -.05em; line-height: .94; }
.completion-copy > p:not(.eyebrow) { margin: 0; color: #52452e; font-size: 15px; font-weight: 750; line-height: 1.55; }
.completion-stats { display: flex; flex-wrap: wrap; gap: 9px; margin: 22px 0; }
.completion-stats span { min-width: 105px; padding: 9px 13px; color: #fff1c8; background: var(--night-soft); border: 2px solid #276b70; border-radius: 4px 12px 4px 12px; font-size: 10px; font-weight: 900; text-align: center; }
.completion-stats b { display: block; color: var(--gold-light); font-size: 24px; }
.completion-note { padding-left: 12px; border-left: 4px solid var(--coral); font-family: Georgia, serif; font-style: italic; }
.restart-button { position: relative; z-index: 2; grid-column: 2; width: min(320px, 100%); justify-self: start; background: var(--night-soft); }

.celebration { position: fixed; z-index: 80; inset: 0; overflow: hidden; pointer-events: none; }
.confetti { position: absolute; top: -25px; width: 12px; height: 20px; background: var(--confetti-color); clip-path: polygon(50% 0, 64% 34%, 100% 50%, 64% 64%, 50% 100%, 36% 64%, 0 50%, 36% 34%); animation: confetti-fall var(--fall-time) cubic-bezier(.3,.6,.5,1) forwards; }

.modal { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: calc(18px + env(safe-area-inset-top, 0px)) calc(18px + env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) calc(18px + env(safe-area-inset-left, 0px)); background: rgba(2, 13, 15, .84); backdrop-filter: blur(7px); }
.modal-card { position: relative; width: min(580px, 100%); max-height: 90vh; overflow-y: auto; padding: 31px; color: var(--ink); background: repeating-linear-gradient(2deg, rgba(97,68,29,.03) 0 1px, transparent 1px 7px), var(--papyrus); border: 4px double #b88338; border-radius: 7px 7px 24px 7px; box-shadow: 0 24px 70px rgba(0,0,0,.58), inset 0 0 0 5px rgba(182,133,56,.1); }
.modal-card h2 { margin: 4px 0 12px; font-family: Copperplate, "Palatino Linotype", Georgia, serif; font-size: clamp(30px, 6vw, 48px); letter-spacing: -.045em; line-height: .98; }
.modal-card > p:not(.eyebrow):not(.modal-note):not(.history-note) { color: #5c513e; font-weight: 700; line-height: 1.55; }
.modal-card ul { padding-left: 21px; color: #5c513e; font-size: 13px; font-weight: 700; line-height: 1.55; }
.modal-cartouche { float: right; width: 94px; height: 125px; display: grid; place-items: center; margin: -10px 0 10px 20px; border: 5px double var(--gold); border-radius: 47%; background: var(--night-soft); box-shadow: 0 6px 0 #8f632d; }
.modal-cartouche span { color: var(--gold-light); font-family: Georgia, serif; font-size: 54px; }
.modal-cartouche.small { width: 75px; height: 96px; }
.modal-cartouche.small span { font-size: 42px; }
.intro-steps { clear: both; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 22px 0 14px; padding: 0; list-style: none; }
.intro-steps li { display: flex; align-items: center; gap: 7px; padding: 10px; color: #594c36; background: #f2dfae; border-radius: 5px 12px 5px 12px; font-size: 10px; font-weight: 900; }
.intro-steps span { width: 24px; height: 24px; flex: 0 0 auto; display: grid; place-items: center; color: #fff; background: var(--lapis); border-radius: 50%; }
.modal-note, .history-note { clear: both; margin: 13px 0; padding: 10px 12px; color: #66583e; background: #e3eadb; border-left: 4px solid var(--lapis); font-size: 11px; font-weight: 750; line-height: 1.45; }
.history-note { background: #f0dfb8; border-left-color: var(--coral); }
.modal-start { width: min(330px, 100%); margin-top: 8px; }
.modal-close { position: absolute; z-index: 2; top: 10px; right: 11px; width: 41px; height: 41px; display: grid; place-items: center; color: var(--ink); background: #f4dda9; border: 2px solid #a77a3a; border-radius: 50%; font-size: 23px; font-weight: 900; cursor: pointer; }
.modal-close:hover { background: #ffe8b1; transform: rotate(4deg); }

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

@keyframes drift-dust { from { transform: translate(-30px, 40px); } to { transform: translate(90px, -130px); } }
@keyframes torch-flicker { from { transform: rotate(-4deg) scale(.94,1); } to { transform: rotate(5deg) scale(1.06,.96); } }
@keyframes svg-flame { from { transform: rotate(-2deg) scale(.96,1.03); } to { transform: rotate(3deg) scale(1.04,.95); } }
@keyframes room-reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes seal-arrive { from { opacity: 0; transform: translateY(-18px) rotate(-20deg) scale(.4); } to { opacity: 1; transform: none; } }
@keyframes place-stone { from { opacity: .3; transform: scale(.75) rotate(-8deg); } to { opacity: 1; transform: none; } }
@keyframes completion-in { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes rays-turn { to { transform: translate(-50%,-50%) rotate(360deg); } }
@keyframes confetti-fall { to { transform: translate(var(--drift), 110vh) rotate(720deg); } }

@media (max-width: 1020px) {
  .workspace { grid-template-columns: minmax(0, 1.1fr) minmax(345px, .9fr); }
  .chamber-stage { min-height: 520px; }
  .chamber-svg { min-height: 460px; }
  .puzzle-card { min-height: 610px; }
}

@media (max-width: 820px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .brand { justify-self: center; }
  .workspace { grid-template-columns: 1fr; }
  .chamber-stage { min-height: auto; }
  .chamber-svg { min-height: 0; max-height: none; }
  .puzzle-card { min-height: 0; }
  .game-area { min-height: 225px; }
  .completion-card { grid-template-columns: minmax(190px,.6fr) 1fr; padding: 38px; }
}

@media (max-width: 640px) {
  .topbar { gap: 9px; padding-inline: 12px; }
  .back-label, .action-label { display: none; }
  .brand-mark { width: 42px; height: 42px; }
  .brand h1 { font-size: 18px; }
  .brand small { font-size: 7px; }
  main { padding: 12px 12px max(24px, env(safe-area-inset-bottom)); }
  .mission-banner { grid-template-columns: 1fr 47px; min-height: 105px; padding: 15px 17px; }
  .mission-stamp { display: none; }
  .mission-copy h2 { font-size: 20px; }
  .mission-copy > p:last-child { font-size: 11px; }
  .torch { transform: scale(.77); }
  .room-track { margin-top: 14px; }
  .room-track b { font-size: 9px; }
  .chamber-head { min-height: 70px; padding: 11px 13px; }
  .chamber-head h2 { font-size: 18px; }
  .seal-pouch { gap: 5px; }
  .seal-pouch > span { display: none; }
  #seal-pouch-icons i { width: 27px; height: 27px; }
  .scene-caption { right: 10px; bottom: 10px; left: 10px; min-height: 58px; padding: 9px 11px; }
  .scene-caption p { font-size: 11px; }
  .caption-symbol { width: 32px; height: 32px; font-size: 18px; }
  .puzzle-card { padding: 16px; }
  .puzzle-head h2 { font-size: 22px; }
  .chamber-number { width: 46px; height: 46px; }
  .number-choice-grid { grid-template-columns: repeat(2, 1fr); }
  .number-choice { min-height: 58px; }
  .game-area { min-height: 285px; }
  .puzzle-actions { flex-wrap: wrap; }
  .secondary-button { flex: 0 0 auto; }
  .primary-button { min-width: 180px; }
  .completion-card { grid-template-columns: 1fr; gap: 8px; padding: 35px 27px; text-align: center; }
  .completion-scarab { width: 190px; }
  .completion-copy h2 { font-size: 38px; }
  .completion-stats { justify-content: center; }
  .completion-note { padding-left: 0; border-left: 0; }
  .restart-button { grid-column: 1; justify-self: center; }
  .intro-steps { grid-template-columns: 1fr; }
  .modal-card { padding: 27px 21px 23px; }
  .modal-cartouche { float: none; width: 68px; height: 86px; margin: 0 0 16px; }
  .modal-cartouche span { font-size: 38px; }
}

@media (max-width: 400px) {
  .brand-mark { display: none; }
  .brand h1 { font-size: 16px; }
  .top-actions { gap: 5px; }
  .icon-button { min-width: 40px; height: 40px; padding: 0 10px; }
  .mission-copy h2 { font-size: 18px; }
  .mission-copy > p:last-child { display: none; }
  .room-track span { width: 30px; height: 30px; }
  .room-track li::before { top: 14px; }
  .puzzle-prompt { font-size: 14px; }
  .answer-entry { grid-template-columns: 1fr 105px; padding-inline: 12px; }
  .math-answer { min-height: 62px; font-size: 28px; }
  .number-path-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .number-path-choice { min-height: 45px; padding-inline: 2px; font-size: 15px; }
  .secondary-button, .primary-button { width: 100%; flex: 1 1 100%; }
}

@media (hover: none) {
  .number-choice:hover, .number-path-choice:hover, .primary-button:hover { transform: none; }
}

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