/* Owner: Set C. Everything drawn on top of the 3D view, plus the landing page and menus.
   Brand: "Field Archive / دفتر الرحلة" (public/brand). Ivory paper, ink, restrained copper.
   Soft rounded shapes, no arrows, no glass blur. Logical properties (inline-start/end) so Arabic mirrors. */

@font-face { font-family: RelicaInter; src: url(public/brand/fonts/inter-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: RelicaInter; src: url(public/brand/fonts/inter-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: RelicaArabic; src: url(public/brand/fonts/NotoSansArabic.ttf) format('truetype'); font-weight: 100 900; font-display: swap; }

:root {
  --archive: #F2EBDD;
  --paper: #FFFAF0;
  --ink: #101820;
  --ink-2: #1A2530;
  --ink-3: #26333F;
  --copper: #96522F;
  --copper-light: #D08A5C;
  --clay: #B87552;
  --line: #CDC6B7;
  --line-dark: #34414D;
  --muted: #59615C;
  --muted-light: #AEB5B0;
  --success: #42634D;
  --success-light: #7FB08C;
  --danger: #A3382E;
  --font: RelicaInter, RelicaArabic, system-ui, sans-serif;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;
  --shadow: 0 18px 50px rgba(5, 9, 14, 0.35);
  --shadow-soft: 0 8px 24px rgba(5, 9, 14, 0.22);
  --fast: 140ms;
  --panel: 220ms;
}
html[lang="ar"] { --font: RelicaArabic, RelicaInter, system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--ink); overflow: hidden; }
body { font-family: var(--font); color: var(--paper); -webkit-font-smoothing: antialiased; }
html[lang="ar"] body { letter-spacing: 0; }
button, input { font: inherit; }
.hidden { display: none !important; }
bdi.ltr, .ltr { unicode-bidi: isolate; direction: ltr; }
.icon { width: 1.15em; height: 1.15em; flex: 0 0 auto; display: inline-block; vertical-align: middle; }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; font-family: var(--font); }
#shell { position: fixed; inset: 0; pointer-events: none; z-index: 30; }
#shell > * { pointer-events: auto; }
#shell > .hidden { pointer-events: none; }
body.on-landing #view, body.on-landing #ui, body.loading #view { visibility: hidden; }
body.menu-open #ui { visibility: hidden; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 10px 22px; border-radius: var(--r-pill);
  border: 1.5px solid transparent; cursor: pointer; text-decoration: none;
  font-weight: 600; font-size: 16px; line-height: 1.2;
  transition: background var(--fast), color var(--fast), border-color var(--fast), transform var(--fast), box-shadow var(--fast);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .seg:focus-visible, .icon-btn:focus-visible, .choice:focus-visible, .switch:focus-visible, .chapter-card:focus-visible, .next-btn:focus-visible {
  outline: 3px solid var(--copper-light); outline-offset: 3px;
}
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-words { display: flex; flex-direction: column; align-items: flex-start; text-align: start; }
.btn-sub { font-weight: 400; font-size: 12.5px; opacity: 0.75; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--copper); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-secondary:hover { background: var(--ink); color: var(--paper); }
.btn-tile {
  flex-direction: column; gap: 8px; min-height: 92px; border-radius: var(--r-md);
  background: var(--archive); color: var(--ink); border-color: var(--line); font-size: 15px;
}
.btn-tile .icon { width: 26px; height: 26px; color: var(--copper); transition: transform var(--fast); }
.btn-tile .btn-words { align-items: center; }
.btn-tile:hover { background: var(--paper); border-color: var(--copper); }
.btn-tile:hover .icon { transform: translateY(-2px); }
.btn-hero { width: 100%; min-height: 64px; justify-content: flex-start; padding-inline: 22px; font-size: 18px; box-shadow: var(--shadow-soft); }
.btn-hero .icon { width: 22px; height: 22px; padding: 7px; box-sizing: content-box; background: var(--copper); border-radius: var(--r-pill); color: var(--paper); }
html[dir="rtl"] .btn-hero .icon[viewBox] { transform: scaleX(-1); }
.btn-hero:hover .icon { background: var(--paper); color: var(--copper); }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-pill);
  border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer;
  transition: background var(--fast), color var(--fast), border-color var(--fast), transform var(--fast);
}
.icon-btn .icon { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.icon-btn:active { transform: translateY(1px); }

/* Segmented control (language) */
.segmented { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: rgba(16, 24, 32, 0.08); border: 1px solid var(--line); }
.seg-icon { width: 18px; height: 18px; margin-inline: 8px 2px; color: var(--copper); }
.seg {
  min-height: 38px; min-width: 84px; padding: 6px 16px; border-radius: var(--r-pill); border: 0; cursor: pointer;
  background: transparent; color: var(--ink); font-weight: 600; font-size: 14px; transition: background var(--fast), color var(--fast);
}
.seg[lang="ar"] { font-family: RelicaArabic, sans-serif; }
.seg[lang="en"] { font-family: RelicaInter, sans-serif; }
.seg:hover { background: rgba(16, 24, 32, 0.08); }
.seg[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- Keycaps ---------- */
kbd.keycap {
  display: inline-grid; place-items: center; min-width: 1.9em; height: 1.9em; padding: 0 0.45em; margin: 0 0.18em;
  border-radius: 8px; vertical-align: middle; position: relative; top: -0.12em; direction: ltr;
  font: 600 0.82em/1 RelicaInter, sans-serif; letter-spacing: 0;
  color: var(--ink); background: linear-gradient(#FFFDF7, #EDE5D5);
  border: 1px solid #BFB7A6; box-shadow: 0 3px 0 #A79F8E, 0 4px 8px rgba(0, 0, 0, 0.18);
}
kbd.keycap.wide { padding: 0 0.7em; }
kbd.keycap.big { min-width: 52px; height: 52px; font-size: 20px; border-radius: 12px; box-shadow: 0 5px 0 #A79F8E, 0 7px 14px rgba(0, 0, 0, 0.22); vertical-align: middle; }
kbd.keycap.big.wide { font-size: 16px; padding: 0 16px; }
kbd.keycap.space { min-width: 190px; }
/* Keys the game is asking for show themselves being pressed: a tap for a press, a long press for a hold. */
@keyframes key-tap { 0%, 62%, 100% { transform: translateY(0); box-shadow: 0 3px 0 #A79F8E, 0 4px 8px rgba(0, 0, 0, 0.18); } 70%, 80% { transform: translateY(3px); box-shadow: 0 0 0 #A79F8E, 0 1px 2px rgba(0, 0, 0, 0.2); filter: brightness(0.94); } }
@keyframes key-hold { 0%, 30%, 100% { transform: translateY(0); box-shadow: 0 5px 0 #A79F8E, 0 7px 14px rgba(0, 0, 0, 0.22); } 38%, 88% { transform: translateY(4px); box-shadow: 0 1px 0 #A79F8E, 0 2px 4px rgba(0, 0, 0, 0.2); filter: brightness(0.94); } }
.objective kbd.keycap, .mission .tasks li:not(.done) kbd.keycap, .howto-key kbd.keycap { animation: key-tap 1.8s ease-in-out infinite; }
.objective kbd.keycap + kbd.keycap, .mission .tasks li kbd.keycap + kbd.keycap { animation-delay: 0.9s; }
.objective:not(.pressing) .hold-key kbd.keycap.big { animation: key-hold 2.4s ease-in-out infinite; }
.objective.pressing .hold-key kbd.keycap.big { animation: none; }
@media (prefers-reduced-motion: reduce) { kbd.keycap { animation: none !important; } }

/* ================= LANDING PAGE ================= */
#sky {
  position: fixed; inset: 0; z-index: 0; background-color: var(--ink); background-size: cover;
  background-image: radial-gradient(ellipse at 50% 40%, #182633 0%, var(--ink) 70%);
}
body:not(.on-landing):not(.loading) #sky { display: none; }
#landing-3d { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; opacity: 0; transition: opacity 1.2s ease; pointer-events: none; }
body.machines-ready #landing-3d { opacity: 1; }
body:not(.on-landing):not(.loading) #landing-3d { display: none; }

.landing { position: fixed; inset: 0; z-index: 2; display: flex; flex-direction: column; overflow-y: auto; color: var(--paper); transition: opacity 0.5s ease, transform 0.5s ease; }
.landing.leaving { opacity: 0; transform: translateY(-12px); pointer-events: none; }
.landing-top { display: flex; justify-content: flex-end; padding: 20px 24px 0; }
.landing .segmented { background: rgba(255, 250, 240, 0.08); border-color: rgba(255, 250, 240, 0.18); }
.landing .seg { color: var(--paper); }
.landing .seg:hover { background: rgba(255, 250, 240, 0.12); }
.landing .seg[aria-pressed="true"] { background: var(--paper); color: var(--ink); }

.landing-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 20px 48px; gap: 18px; }
.lockup { display: flex; align-items: center; justify-content: center; gap: clamp(16px, 3vw, 34px); flex-wrap: wrap; }
.lockup-relica { height: clamp(52px, 8vw, 92px); width: auto; }
.lockup-spaceapps { height: clamp(56px, 8.4vw, 96px); width: auto; }
.lockup-x { font: 400 clamp(22px, 3vw, 34px)/1 RelicaInter, sans-serif; color: var(--copper-light); opacity: 0.9; }
.landing-challenge { margin: 6px 0 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; font-size: 14px; letter-spacing: 0.02em; color: var(--copper-light); font-weight: 600; }
html[lang="ar"] .landing-challenge { letter-spacing: 0; font-size: 15px; }
.landing-challenge .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--clay); }
.landing-title { margin: 0; font-weight: 600; font-size: clamp(38px, 6.4vw, 76px); line-height: 1.15; color: var(--paper); text-wrap: balance; }
.landing-line { margin: 0; max-width: 680px; font-size: clamp(16px, 1.6vw, 19px); line-height: 1.75; color: #D8D2C5; text-wrap: balance; }
.landing-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px; margin-top: 10px; }
.btn-ghost-light { color: var(--paper); border-color: rgba(255, 250, 240, 0.35); background: rgba(255, 250, 240, 0.04); min-height: 56px; padding-inline: 20px 24px; }
.btn-ghost-light .icon { width: 28px; height: 28px; }
.btn-ghost-light:hover { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn-start { background: var(--copper); color: var(--paper); min-height: 56px; padding-inline: 28px 10px; font-size: 18px; box-shadow: 0 10px 30px rgba(150, 82, 47, 0.35); }
.btn-start:hover { background: #A85C36; box-shadow: 0 12px 34px rgba(150, 82, 47, 0.5); }
.start-dot { display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r-pill); background: var(--paper); color: var(--copper); transition: transform var(--fast); }
.start-dot .icon { width: 18px; height: 18px; }
html[dir="rtl"] .start-dot .icon { transform: scaleX(-1); }
.btn-start:hover .start-dot { transform: scale(1.06); }
#load-retry { padding-inline: 28px; }
.landing-note { margin: 4px 0 0; font-size: 13px; color: var(--muted-light); }

/* ================= LOADER ================= */
.loader { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; transition: opacity 0.6s ease; }
.loader.fade-out { opacity: 0; pointer-events: none; }
.loader-symbol { width: 72px; height: 72px; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.06); opacity: 1; } }
.loader h2 { margin: 6px 0 4px; font-size: 24px; font-weight: 600; }
.load-bar { width: min(460px, 86vw); height: 12px; border-radius: var(--r-pill); background: rgba(255, 250, 240, 0.12); overflow: hidden; }
.load-fill { display: block; height: 100%; width: 0; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--clay), var(--copper-light)); transition: width 0.2s ease; }
html[dir="rtl"] .load-bar { transform: scaleX(-1); }
.load-row { width: min(460px, 86vw); display: flex; justify-content: space-between; gap: 12px; font-size: 15px; color: var(--paper); }
#load-pct { font-weight: 600; font-variant-numeric: tabular-nums; }
.load-sub { display: flex; gap: 14px; font-size: 13px; color: var(--muted-light); font-variant-numeric: tabular-nums; }
.load-error p { color: #F0B9AE; max-width: 420px; }

/* ================= MAIN MENU ================= */
.main-menu { position: absolute; inset: 0; display: flex; align-items: center; padding: 32px clamp(20px, 5vw, 72px); }
.main-menu::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(16, 24, 32, 0.55), rgba(16, 24, 32, 0) 55%); }
html[dir="rtl"] .main-menu::before { background: linear-gradient(270deg, rgba(16, 24, 32, 0.55), rgba(16, 24, 32, 0) 55%); }
.menu-card {
  position: relative; width: min(440px, 100%); max-height: 100%; overflow-y: auto;
  background: var(--paper); color: var(--ink); border-radius: var(--r-lg); padding: 30px 28px 26px;
  box-shadow: var(--shadow); animation: rise var(--panel) ease-out both;
}
/* The brand's detached corner: one copper fold in the corner of the card. */
.menu-card::after { content: ""; position: absolute; top: 0; inset-inline-end: 0; width: 46px; height: 46px; border-start-end-radius: var(--r-lg); background: linear-gradient(225deg, var(--copper) 50%, transparent 50%); }
html[dir="rtl"] .menu-card::after { background: linear-gradient(135deg, var(--copper) 50%, transparent 50%); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.menu-logo { height: 40px; width: auto; display: block; }
.menu-eyebrow { margin-top: 20px; font-size: 13px; font-weight: 600; color: var(--copper); }
.menu-title { margin: 4px 0 6px; font-size: 32px; line-height: 1.3; font-weight: 600; }
.menu-line { margin: 0 0 22px; color: var(--muted); font-size: 15px; line-height: 1.7; }
.menu-actions { display: grid; gap: 10px; }
.menu-actions .btn-secondary { width: 100%; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.menu-lang { position: absolute; top: 20px; inset-inline-end: 24px; }
.menu-lang .segmented { background: var(--paper); box-shadow: var(--shadow-soft); }
.menu-partner { position: absolute; bottom: 22px; inset-inline-end: 26px; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: var(--r-pill); background: rgba(16, 24, 32, 0.78); }
.menu-partner img { height: 30px; width: auto; }
.menu-partner .space-apps { height: 36px; }
.times { font: 400 18px/1 RelicaInter, sans-serif; color: var(--copper-light); }

/* ================= SHEETS (Settings, How to play, Credits, Pause) ================= */
.sheet-layer { position: absolute; inset: 0; z-index: 2; }
.sheet-back { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(8, 12, 18, 0.62); animation: fade var(--panel) ease-out both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: min(620px, 100%); max-height: min(88vh, 100%); display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden;
  animation: rise var(--panel) ease-out both;
}
.sheet.small { width: min(420px, 100%); }
.sheet.wide { width: min(860px, 100%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 14px 26px; border-bottom: 1px solid var(--line); }
html[dir="rtl"] .sheet-head { padding: 20px 26px 14px 22px; }
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 20px 26px 26px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.pause-actions { display: grid; gap: 10px; }
.pause-actions .btn { width: 100%; justify-content: flex-start; }
.pause-actions .btn-primary .icon { color: var(--copper-light); }
html[dir="rtl"] .pause-actions .btn-primary .icon { transform: scaleX(-1); }
.confirm p { margin: 0 0 8px; font-size: 16px; line-height: 1.7; }

/* Settings */
.settings h3 { margin: 0; font-size: 16px; font-weight: 600; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 4px 0 18px; }
.set-block { border-top: 1px solid var(--line); padding: 18px 0; }
.set-block > h3 { margin-bottom: 12px; }
.set-block .set-row { padding-bottom: 8px; }
.set-info { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.set-status { min-height: 1.4em; margin: 8px 0 0; font-size: 14px; color: var(--copper); }
.set-note { margin: 4px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.choice-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: start; min-height: 104px;
  padding: 14px; border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--archive); color: var(--ink); cursor: pointer;
  transition: border-color var(--fast), background var(--fast), transform var(--fast);
}
.choice:hover { border-color: var(--copper); }
.choice:active { transform: translateY(1px); }
.choice strong { font-size: 16px; }
.choice span:not(.choice-bars) { font-size: 13px; color: var(--muted); line-height: 1.5; }
.choice[aria-checked="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.choice[aria-checked="true"] span:not(.choice-bars) { color: var(--muted-light); }
.choice[disabled] { cursor: progress; opacity: 0.7; }
.choice-bars { display: flex; align-items: flex-end; gap: 3px; height: 18px; margin-bottom: 4px; }
.choice-bars i { width: 6px; border-radius: 3px; background: var(--line); }
.choice-bars i:nth-child(1) { height: 7px; } .choice-bars i:nth-child(2) { height: 12px; } .choice-bars i:nth-child(3) { height: 18px; }
.choice-bars i.on { background: var(--copper); }
.choice[aria-checked="true"] .choice-bars i.on { background: var(--copper-light); }
.slider-row { display: grid; grid-template-columns: 150px 1fr 52px; align-items: center; gap: 14px; min-height: 44px; }
.slider-name { font-size: 15px; }
.slider-value { font-size: 14px; font-weight: 600; text-align: end; font-variant-numeric: tabular-nums; direction: ltr; }
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: var(--r-pill); background: linear-gradient(to right, var(--copper) var(--fill, 50%), var(--line) var(--fill, 50%)); cursor: pointer; }
html[dir="rtl"] .slider { background: linear-gradient(to left, var(--copper) var(--fill, 50%), var(--line) var(--fill, 50%)); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--paper); border: 2px solid var(--copper); box-shadow: var(--shadow-soft); }
.slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--paper); border: 2px solid var(--copper); }
.slider:focus-visible { outline: 3px solid var(--copper-light); outline-offset: 6px; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px; border: 0; background: none; color: var(--ink); cursor: pointer; font-weight: 600; font-size: 14px; }
.switch-track { position: relative; width: 50px; height: 28px; border-radius: var(--r-pill); background: var(--line); transition: background var(--fast); }
.switch-knob { position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); transition: inset-inline-start var(--fast); }
.switch[aria-checked="true"] .switch-track { background: var(--success); }
.switch[aria-checked="true"] .switch-knob { inset-inline-start: 25px; }

/* How to play */
.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.how-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 18px; border-radius: var(--r-md); background: var(--archive); border: 1px solid var(--line); }
.how-tile strong { margin-top: 10px; font-size: 16px; }
.how-tile > span { font-size: 14px; color: var(--muted); line-height: 1.6; }
.keys-wasd { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: 52px 52px; gap: 8px 6px; direction: ltr; }
.keys-wasd kbd { margin: 0; }
.keys-wasd kbd:nth-child(1) { grid-column: 2; grid-row: 1; }
.keys-wasd kbd:nth-child(2) { grid-column: 1; grid-row: 2; }
.keys-wasd kbd:nth-child(3) { grid-column: 2; grid-row: 2; }
.keys-wasd kbd:nth-child(4) { grid-column: 3; grid-row: 2; }
.keys-row { display: flex; align-items: center; gap: 14px; min-height: 112px; direction: ltr; }
.hold-demo { width: 110px; height: 12px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.hold-demo-fill { display: block; height: 100%; width: 0; border-radius: inherit; animation: hold-demo 2.6s ease-in-out infinite; }
@keyframes hold-demo { 0% { width: 0; background: hsl(130 62% 46%); } 70% { width: 100%; background: hsl(5 62% 46%); } 100% { width: 100%; background: hsl(5 62% 46%); } }
.how-small { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 26px; padding: 14px 4px 0; }
.how-mini { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.compass.demo { position: relative; }

/* Chapters */
.chapter-list { display: grid; gap: 10px; }
.chapter-card { display: flex; align-items: center; gap: 16px; min-height: 60px; padding: 10px 16px; border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--archive); color: var(--ink); cursor: pointer; text-align: start; font-size: 16px; font-weight: 600; transition: border-color var(--fast), background var(--fast); }
.chapter-card:hover { border-color: var(--copper); background: var(--paper); }
.chapter-num { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--ink); color: var(--paper); font: 600 15px RelicaInter, sans-serif; }

/* Credits sheet */
.credits-sheet h3 { margin: 22px 0 8px; font-size: 13px; font-weight: 600; color: var(--copper); }
.credits-sheet h3:first-child { margin-top: 0; }
.credits-sheet p { margin: 4px 0; font-size: 15px; line-height: 1.6; }
.team { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.team li { padding: 14px 16px; border-radius: var(--r-md); background: var(--archive); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.team strong { font-size: 17px; }
.team span { font-size: 13px; color: var(--muted); }
.credit-partners { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.credit-partners img { height: 34px; width: auto; }
.credit-partners .space-apps { height: 46px; }

/* ================= IN-GAME HUD ================= */
/* Corner layout: environment on the start side, buttons and mission on the end side, objective centre. */
.hud, .mission, .objective, .navigation, .discovery { font-family: var(--font); color: var(--paper); }
.hud-buttons { position: absolute; top: 16px; inset-inline-end: 16px; display: flex; gap: 8px; }
.hud-buttons .icon-btn { width: 48px; height: 48px; background: var(--ink); color: var(--paper); border-color: var(--line-dark); box-shadow: var(--shadow-soft); }
.hud-buttons .icon-btn:hover { background: var(--copper); border-color: var(--copper); }

.hud {
  position: absolute; top: 16px; inset-inline-start: 16px; width: 270px;
  background: rgba(16, 24, 32, 0.94); border: 1px solid var(--line-dark); border-radius: var(--r-md);
  padding: 14px 16px 12px; font-size: 13.5px; line-height: 1.5; box-shadow: var(--shadow-soft);
}
.hud h2 { margin: 0; font-size: 17px; font-weight: 600; }
.hud .place { color: var(--muted-light); margin-bottom: 8px; font-size: 13px; }
.hud .row { display: flex; justify-content: space-between; align-items: center; gap: 14px; border-top: 1px solid var(--line-dark); padding: 6px 0; }
.hud .row-label { color: var(--muted-light); font-size: 12.5px; }
html[lang="en"] .hud .row-label::first-letter { text-transform: uppercase; }
.hud .row-value { text-align: end; font-weight: 600; }
.hud .unverified::after { content: "?"; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-inline-start: 6px; border-radius: 50%; background: var(--clay); color: var(--ink); font-size: 11px; }
.hud .legend { color: var(--clay); font-size: 12px; margin-top: 6px; }
/* World conditions: icon, words and a bar compared with Earth (no raw numbers). */
.hud .gauge { justify-content: flex-start; align-items: center; gap: 12px; padding: 9px 0; }
.gauge-icon { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--ink-3); color: var(--paper); }
.gauge-icon svg { width: 20px; height: 20px; }
.gauge-gravity .gauge-icon { color: #C9B8F2; }
.gauge-temperature .gauge-icon { color: #F2A27E; }
.gauge-pressure .gauge-icon { color: #9FD0F0; }
.gauge-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.gauge-head { display: flex; flex-direction: column; gap: 1px; }
.gauge-label { font-size: 11.5px; color: var(--muted-light); }
.gauge-word { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.gauge-word.unverified::after { width: 14px; height: 14px; font-size: 10px; vertical-align: 1px; }
.gauge-track { position: relative; height: 8px; border-radius: var(--r-pill); background: var(--ink-3); }
.gauge-fill { position: absolute; inset-block: 0; inset-inline-start: 0; min-width: 6px; border-radius: inherit; background: #9C8BD6; }
.gauge-pressure .gauge-fill { background: #7DB6DA; }
.gauge-earth { position: absolute; inset-inline-end: -2px; top: -4px; width: 4px; height: 16px; border-radius: 2px; background: #6FB07F; }
.gauge-temperature .gauge-track { background: linear-gradient(to right, #4C7BD1, #8FC1E8 45%, #E9DFC8 68%, #E39A5E 84%, #C8553D); }
html[dir="rtl"] .gauge-temperature .gauge-track { background: linear-gradient(to left, #4C7BD1, #8FC1E8 45%, #E9DFC8 68%, #E39A5E 84%, #C8553D); }
.gauge-range { position: absolute; top: 2px; bottom: 2px; background: rgba(16, 24, 32, 0.35); border-radius: var(--r-pill); }
.gauge-dot { position: absolute; top: 50%; width: 14px; height: 14px; margin-inline-start: -7px; transform: translateY(-50%); border-radius: 50%; background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.hud .battery .row-value { display: flex; align-items: center; gap: 8px; }
.hud .bar { display: inline-block; width: 100px; height: 9px; border-radius: var(--r-pill); background: var(--ink-3); overflow: hidden; }
html[dir="rtl"] .hud .bar { transform: scaleX(-1); }
.hud .bar .fill { display: block; height: 100%; border-radius: inherit; background: var(--success-light); transition: width 0.3s, background 0.3s; }
.hud .battery.low .fill { background: #D9604B; }
.hud .battery.low .pct { color: #F09A85; }
.hud .pct { min-width: 36px; text-align: end; font-variant-numeric: tabular-nums; }
.hud .counter .num { font-variant-numeric: tabular-nums; }
.hud .counter .planned { margin-inline-start: 8px; font-size: 11.5px; font-weight: 400; color: var(--muted-light); transition: color 1s; }
.hud .counter.passed .planned { color: var(--copper-light); }

.objective {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 2 * 330px)); min-height: 48px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--paper); color: var(--ink); border-radius: var(--r-pill);
  padding: 10px 24px; font-size: 16px; font-weight: 600; line-height: 1.5; box-shadow: var(--shadow-soft);
  animation: drop 0.3s ease-out;
}
@keyframes drop { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.objective-text { display: inline; }
/* Hold prompt inside the objective box */
.objective.holding { border-radius: var(--r-lg); padding: 12px 22px 16px; flex-direction: column; min-width: min(420px, 90vw); }
.hold { width: 100%; }
.hold-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 6px; font-size: 16px; }
.hold-verb { color: var(--muted); font-weight: 600; }
.hold-colon { display: none; }
.hold-text { flex-basis: 100%; margin-top: 4px; }
.hold-key kbd.keycap.big { width: 52px; transition: transform 80ms, box-shadow 80ms; }
.objective.pressing .hold-key kbd.keycap.big { transform: translateY(4px); box-shadow: 0 1px 0 #A79F8E, 0 2px 4px rgba(0, 0, 0, 0.2); }
.hold-track { margin-top: 12px; height: 14px; border-radius: var(--r-pill); background: #E2DACA; overflow: hidden; }
html[dir="rtl"] .hold-track { transform: scaleX(-1); }
.hold-fill { height: 100%; width: 0; border-radius: inherit; background: hsl(130 62% 46%); }
.objective.confirmed .hold-track { box-shadow: 0 0 0 3px rgba(200, 85, 61, 0.25); }

.mission {
  position: absolute; top: 76px; inset-inline-end: 16px; width: min(300px, 34vw);
  background: rgba(16, 24, 32, 0.94); border: 1px solid var(--line-dark); border-radius: var(--r-md);
  padding: 12px 16px 10px; box-shadow: var(--shadow-soft);
}
.mission-label { font-size: 12px; font-weight: 600; color: var(--copper-light); }
.mission h2 { margin: 2px 0 8px; font-size: 17px; font-weight: 600; }
.mission .tasks { list-style: none; margin: 0; padding: 0; }
.mission .tasks li { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; font-size: 14px; line-height: 1.5; border-top: 1px solid var(--line-dark); transition: color 0.4s; }
.mission .check { flex: 0 0 18px; height: 18px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--muted-light); position: relative; transition: background 0.2s, border-color 0.2s; }
.mission .tasks li.done { color: var(--muted-light); }
.mission .tasks li.done .check { background: var(--success-light); border-color: var(--success-light); animation: tick 0.35s ease-out; }
.mission .tasks li.done .check::after { content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 4px; height: 8px; border: solid var(--ink); border-width: 0 2px 2px 0; border-radius: 1px; transform: rotate(45deg); }
.mission .tasks li.done .task-text { text-decoration: line-through; text-decoration-color: rgba(174, 181, 176, 0.6); }
.mission kbd.keycap { font-size: 0.75em; }
@keyframes tick { 0% { transform: scale(0.5); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.mission .bonus { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--ink-3); font-size: 13px; color: var(--muted-light); }
.mission .bonus .ltr { color: var(--paper); font-weight: 600; }

/* Navigation compass: the top of the dial is ahead. */
.navigation { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; max-width: min(440px, 92vw); padding: 10px 20px 10px 12px; background: rgba(16, 24, 32, 0.94); border: 1px solid var(--line-dark); border-radius: var(--r-pill); box-shadow: var(--shadow-soft); }
html[dir="rtl"] .navigation { padding: 10px 12px 10px 20px; }
.compass { position: relative; flex: 0 0 52px; width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--line-dark); background: radial-gradient(circle, var(--ink-3) 0 3px, transparent 4px), var(--ink-2); }
.compass-ahead { position: absolute; top: 3px; left: 50%; width: 12px; height: 4px; margin-left: -6px; border-radius: 2px; background: var(--muted-light); }
.compass-dot { position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--copper-light); box-shadow: 0 0 0 3px rgba(208, 138, 92, 0.3); transition: transform 0.12s linear; }
.navigation.arrived .compass-dot { background: var(--success-light); box-shadow: 0 0 0 6px rgba(127, 176, 140, 0.3); }
.compass.demo .compass-dot { animation: orbit 5s linear infinite; }
@keyframes orbit { from { transform: rotate(0deg) translateY(-17px); } to { transform: rotate(360deg) translateY(-17px); } }
.navigation-words { min-width: 0; }
.navigation-name { font-size: 14.5px; font-weight: 600; line-height: 1.4; }
.navigation-detail { font-size: 13px; color: var(--copper-light); font-variant-numeric: tabular-nums; }

/* Discovery card: a short toast under the objective, the game keeps going. */
.discovery {
  position: absolute; top: 78px; transition: top 0.2s, opacity 0.4s; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(620px, calc(100vw - 2 * 330px)); text-align: center;
  padding: 10px 22px 12px; background: var(--ink); border: 1.5px solid var(--copper); border-radius: var(--r-md);
  box-shadow: var(--shadow); animation: drop 0.4s ease-out; transition: opacity 0.4s;
}
.discovery-label { font-size: 12px; font-weight: 600; color: var(--copper-light); }
.discovery-text { font-size: 15.5px; line-height: 1.6; }
.discovery-second { font-size: 13.5px; color: var(--muted-light); }
.discovery-second:empty { display: none; }
.discovery.out { opacity: 0; }
.cinema .discovery { display: none; }

/* Dialogue: a paper card at the bottom */
.dialogue {
  position: absolute; left: 0; right: 0; margin: 0 auto; bottom: 14px;
  width: min(680px, 94vw); background: rgba(255, 250, 240, 0.96); color: var(--ink);
  border-radius: var(--r-lg); padding: 10px 18px 10px; box-shadow: var(--shadow);
  border-inline-start: 8px solid var(--speaker, var(--copper));
}
.dialogue .who { display: flex; }
.dialogue .who-name { display: inline-block; padding: 3px 12px; border-radius: var(--r-pill); background: var(--speaker, var(--copper)); color: var(--paper); font-size: 13px; font-weight: 600; }
.dialogue[data-who="lrv"]         { --speaker: #96522F; }
.dialogue[data-who="opportunity"] { --speaker: #B5653A; }
.dialogue[data-who="viking"]      { --speaker: #6B6A4E; }
.dialogue[data-who="ingenuity"]   { --speaker: #3F6C86; }
.dialogue[data-who="pioneer"]     { --speaker: #5B4E86; }
.dialogue .line-main { margin: 4px 0 0; min-height: 1.5em; font-size: 19px; line-height: 1.55; font-weight: 600; unicode-bidi: plaintext; text-align: start; }
.dialogue .line-main:lang(ar) { font-size: 20px; }
.dialogue .line-second { font-size: 15px; color: var(--muted); min-height: 1.4em; unicode-bidi: plaintext; text-align: start; }
.dialogue-foot { position: absolute; inset-inline-end: 14px; bottom: 10px; display: flex; }
.dialogue .line-main, .dialogue .line-second { padding-inline-end: 132px; }
.dialogue .line-second:empty { display: none; }
@media (max-width: 560px) { .dialogue-foot { position: static; justify-content: flex-end; margin-top: 4px; } .dialogue .line-main, .dialogue .line-second { padding-inline-end: 0; } }
.next-btn {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 14px 4px 6px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--archive); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: background var(--fast), border-color var(--fast);
}
html[dir="rtl"] .next-btn { padding: 4px 6px 4px 14px; }
.next-btn:hover { border-color: var(--copper); background: var(--paper); }
.next-btn kbd.keycap { font-size: 12px; }

/* Chapter cards and the title screen: a paper sheet in the middle of a dimmed scene */
.card { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(8, 12, 18, 0.55); }
.card-sheet {
  position: relative; width: min(720px, 94vw); padding: 40px 44px 30px; text-align: center;
  background: var(--paper); color: var(--ink); border-radius: var(--r-lg); box-shadow: var(--shadow);
  animation: rise 0.35s ease-out both;
}
.card-sheet::after { content: ""; position: absolute; top: 0; inset-inline-end: 0; width: 52px; height: 52px; border-start-end-radius: var(--r-lg); background: linear-gradient(225deg, var(--copper) 50%, transparent 50%); }
html[dir="rtl"] .card-sheet::after { background: linear-gradient(135deg, var(--copper) 50%, transparent 50%); }
.card .mission-name { font-size: 14px; font-weight: 600; color: var(--copper); margin-bottom: 10px; }
.card h1 { margin: 0; font-size: clamp(32px, 5.6vw, 60px); line-height: 1.25; font-weight: 600; text-wrap: balance; }
.card .card-sub { margin: 12px auto 0; max-width: 560px; font-size: 17px; line-height: 1.7; color: var(--muted); }
.card .card-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.card .card-facts span { padding: 4px 14px; border-radius: var(--r-pill); background: var(--archive); border: 1px solid var(--line); font-size: 14px; }
.card .next-btn { margin-top: 24px; }
.card.title-screen { background: radial-gradient(ellipse at 50% 60%, rgba(24, 38, 51, 0.6), rgba(8, 12, 18, 0.9)); }
.card.title-screen .card-sheet { background: var(--ink); color: var(--paper); border: 1px solid var(--line-dark); }
.card.title-screen .card-sub { color: var(--copper-light); font-weight: 600; }
.card.title-screen .next-btn { background: var(--ink-2); color: var(--paper); border-color: var(--line-dark); }
.card.ending .card-sub { color: var(--ink); }

/* Keys bar: what each key does right now (bottom centre). */
.controls-hint { position: absolute; bottom: 22px; left: 0; right: 0; margin: 0 auto; width: fit-content; display: flex; gap: 8px; flex-wrap: nowrap; white-space: nowrap; justify-content: center; max-width: calc(100vw - 32px); padding: 8px 10px; border-radius: var(--r-pill); background: rgba(16, 24, 32, 0.78); border: 1px solid var(--line-dark); color: var(--paper); font-size: 13.5px; backdrop-filter: blur(6px); animation: rise 0.35s ease-out both; }
.controls-hint.hidden { display: none; }
.controls-item { display: flex; align-items: center; gap: 8px; padding: 2px 10px; }
.controls-item + .controls-item { border-inline-start: 1px solid var(--line-dark); }
.controls-keys { display: inline-flex; gap: 2px; }
.controls-keys kbd.keycap { top: 0; font-size: 12px; animation: key-tap 1.8s ease-in-out infinite; }
.controls-keys kbd.keycap + kbd.keycap { animation-delay: 0.9s; }
.controls-item.hold kbd.keycap { animation: key-hold-small 2.4s ease-in-out infinite; }
@keyframes key-hold-small { 0%, 30%, 100% { transform: translateY(0); box-shadow: 0 3px 0 #A79F8E, 0 4px 8px rgba(0, 0, 0, 0.18); } 38%, 88% { transform: translateY(3px); box-shadow: 0 0 0 #A79F8E, 0 1px 2px rgba(0, 0, 0, 0.2); filter: brightness(0.94); } }
body:has(.dialogue:not(.hidden)) .controls-hint, body:has(.card:not(.hidden)) .controls-hint, body:has(.memory:not(.hidden)) .controls-hint { display: none; }
@media (max-width: 760px) { .controls-hint { flex-wrap: wrap; white-space: normal; border-radius: var(--r-md); font-size: 12px; } }

/* End screen: the team and sources. Above everything; only its two buttons close it. */
.endscreen { position: fixed; inset: 0; z-index: 60; background: radial-gradient(ellipse 80% 60% at 50% 0%, #1B2A38 0%, var(--ink) 60%, #0A1017 100%); color: var(--paper); pointer-events: auto; font-family: var(--font); animation: fade-in 0.8s ease both; }
.endscreen.hidden { display: none; }
body.end-open #ui, body.end-open #shell .hud-buttons { visibility: hidden; }
.end-stars { position: absolute; inset: 0; pointer-events: none; opacity: 0.55;
  background-image: radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 78% 12%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 32% 72%, #F2EBDD 50%, transparent 51%), radial-gradient(1px 1px at 88% 64%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 55% 38%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 6% 88%, #D08A5C 50%, transparent 51%), radial-gradient(1px 1px at 66% 90%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 42% 8%, #fff 50%, transparent 51%);
  background-size: 420px 420px; }
.end-scroll { position: absolute; inset: 0; overflow-y: auto; scrollbar-width: none; padding: 14vh 24px 160px;
  -webkit-mask-image: linear-gradient(transparent 0, #000 12%, #000 80%, transparent 100%); mask-image: linear-gradient(transparent 0, #000 12%, #000 80%, transparent 100%); }
.end-scroll::-webkit-scrollbar { display: none; }
.endscreen .roll { width: min(860px, 100%); margin: 0 auto; text-align: center; }
.end-head { display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 62vh; justify-content: center; }
.end-logo { width: min(340px, 70vw); height: auto; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.45)); }
.end-name { margin: 6px 0 0; font: 600 14px/1 RelicaInter, sans-serif; letter-spacing: 0.32em; text-transform: uppercase; color: var(--copper-light); }
.end-thanks { margin: 26px 0 0; font-size: clamp(32px, 5vw, 52px); font-weight: 600; line-height: 1.2; }
.end-lede { margin: 6px 0 0; max-width: 560px; font-size: 17px; line-height: 1.8; color: #CFC8BA; }
.end-section { margin-top: 72px; }
.end-eyebrow { display: inline-flex; align-items: center; gap: 12px; margin: 0 0 22px; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; color: var(--copper-light); }
.end-eyebrow::before, .end-eyebrow::after { content: ""; width: 34px; height: 1px; background: var(--copper); opacity: 0.7; }
.end-team { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.end-team > li { flex: 0 1 270px; }
.end-member { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 22px 20px; border-radius: var(--r-lg); background: rgba(255, 250, 240, 0.04); border: 1px solid var(--line-dark); }
.end-member::after { content: ""; position: absolute; inset-inline-end: 14px; top: 14px; width: 12px; height: 12px; border-top: 2px solid var(--copper); border-inline-end: 2px solid var(--copper); border-start-end-radius: 6px; }
.end-member strong { font-size: 24px; font-weight: 600; color: var(--paper); }
.end-member span { font-size: 14px; line-height: 1.6; color: var(--muted-light); }
.end-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; text-align: start; }
.end-grid > * { flex: 0 1 270px; }
.end-block { padding: 18px 20px; border-radius: var(--r-md); background: rgba(255, 250, 240, 0.03); border: 1px solid var(--line-dark); }
.end-block h3 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--copper-light); }
.end-block p { margin: 3px 0; font-size: 14.5px; line-height: 1.7; color: #D8D2C5; overflow-wrap: anywhere; }
.end-photos { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; text-align: start; }
.end-photos > li { flex: 0 1 280px; }
.end-photos li { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: var(--r-sm); background: rgba(255, 250, 240, 0.03); }
.end-photos li span { font-size: 14px; color: #D8D2C5; }
.end-photos li bdi { font-size: 12px; color: var(--muted-light); }
.endscreen .credit-partners { margin-top: 80px; border-color: var(--line-dark); }
.end-fin { margin: 60px 0 0; font-size: 22px; font-weight: 600; color: var(--copper-light); }
.end-bar { position: absolute; inset-inline: 0; bottom: 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; padding: 22px 16px 26px; background: linear-gradient(transparent, rgba(10, 16, 23, 0.92) 40%); }
.end-bar .btn { gap: 10px; min-width: 220px; justify-content: center; }
.end-bar .btn svg { width: 20px; height: 20px; }
.btn-end-primary { background: var(--paper); color: var(--ink); }
.btn-end-primary:hover { background: var(--copper-light); color: var(--ink); }
.btn-end-secondary { background: transparent; color: var(--paper); border-color: var(--line-dark); }
.btn-end-secondary:hover { border-color: var(--paper); background: rgba(255, 250, 240, 0.08); }
@media (max-width: 560px) { .end-team > li, .end-grid > *, .end-photos > li { flex-basis: 100%; } .end-bar .btn { min-width: 0; flex: 1 1 100%; } .end-scroll { padding-bottom: 220px; } .end-member strong { font-size: 21px; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Memory photo: a real NASA photo on paper */
.memory { position: absolute; inset: 0; background: rgba(8, 12, 18, 0.8); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.memory .frame { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0; width: min(920px, 94vw); background: var(--paper); color: var(--ink); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); animation: rise 0.4s ease-out both; }
.memory .photo { aspect-ratio: 4 / 3; overflow: hidden; background: var(--ink); }
.memory .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.memory .frame-words { padding: 26px 26px 22px; display: flex; flex-direction: column; gap: 6px; }
.memory .real-tag { align-self: flex-start; padding: 3px 12px; border-radius: var(--r-pill); background: var(--archive); border: 1px solid var(--line); color: var(--copper); font-size: 12.5px; font-weight: 600; }
.memory h3 { margin: 6px 0 0; font-size: 22px; line-height: 1.4; font-weight: 600; }
.memory .meta { display: block; font: 400 12.5px RelicaInter, sans-serif; color: var(--muted); }
.memory .desc { font-size: 15.5px; line-height: 1.75; margin-top: 6px; }
.memory .desc.second { font-size: 14px; color: var(--muted); margin-top: 0; }
.memory .frame-words .next-btn { margin-top: auto; align-self: flex-end; }
.memory .hint { color: var(--muted-light); }
.memory.memory-wall { justify-content: flex-start; pointer-events: auto; background: rgba(8, 12, 18, 0.94); }
.memory.memory-wall > * { flex-shrink: 0; }
.memory .wall { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); gap: 14px; width: min(980px, 100%); }
.memory .wall figure { margin: 0; background: var(--paper); color: var(--ink); border-radius: var(--r-md); overflow: hidden; }
.memory .wall .thumb { aspect-ratio: 4 / 3; overflow: hidden; background: var(--ink); }
.memory .wall img { width: 100%; height: 100%; object-fit: cover; display: block; }
.memory .wall figcaption { padding: 12px 14px 14px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.memory .wall figcaption strong { font-size: 15px; }
.memory .wall .desc { font-size: 13.5px; margin-top: 2px; line-height: 1.6; }
.memory .wall .service { font-weight: 600; border-top: 1px solid var(--line); padding-top: 8px; }
.memory .wall .sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.memory .wall .sources a { padding: 3px 10px; border-radius: var(--r-pill); background: var(--archive); color: var(--copper); text-decoration: none; font-weight: 600; font-size: 12px; }
.memory .wall-heading { width: min(980px, 100%); color: var(--paper); }
.memory .wall-heading h2 { margin: 6px 0 14px; font-size: 26px; font-weight: 600; }
h3.wall-heading { margin: 22px 0 12px; font-size: 18px; font-weight: 600; }
.memory .discovered { width: min(980px, 100%); margin-top: 22px; color: var(--paper); }
.memory .discovered h3 { margin: 0 0 8px; font-size: 16px; color: var(--copper-light); }
.memory .discovered ol { margin: 0; padding-inline-start: 22px; font-size: 14.5px; line-height: 1.8; }
.memory .wall-continue { margin: 22px 0 12px; }
.memory.photo-reveal { animation: photo-reveal 0.7s ease-in both; }
@keyframes photo-reveal { from { opacity: 0; } to { opacity: 1; } }

/* Photo tasks built by chapter code: restyled to the brand */
.photo-mode .hud, .photo-mode .mission, .photo-mode .discovery { visibility: hidden; }
.historic-viewfinder { position: absolute; inset: 0; display: grid; place-items: center; }
.historic-frame { width: min(86vw, 1000px); aspect-ratio: var(--photo-aspect, 1.3); max-height: 64vh; border: 3px solid var(--paper); border-radius: var(--r-lg); box-shadow: 0 0 0 100vmax rgba(8, 12, 18, 0.55); position: relative; transition: border-color 0.2s; }
.historic-frame.aligned { border-color: var(--success-light); }
.historic-reticle { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; transform: translate(-50%, -50%); font-size: 0; border-radius: 50%; border: 2px solid var(--paper); }
.historic-reticle::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--copper-light); }
.historic-label { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--paper); color: var(--ink); border-radius: var(--r-md); padding: 12px 20px; width: min(720px, 94vw); text-align: center; font-size: 14.5px; line-height: 1.6; box-shadow: var(--shadow-soft); }
.historic-label > div:first-child { font-weight: 600; font-size: 16px; }
.historic-label .ar { display: none; }
.pioneer-viewfinder { position: absolute; inset: 0; pointer-events: none; }
.pioneer-reticle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(280px, 48vw); aspect-ratio: 1; border: 3px solid rgba(255, 250, 240, 0.7); border-radius: 50%; }
.pioneer-reticle.aligned { border-color: var(--success-light); }
.pioneer-target { position: absolute; bottom: 100%; padding-bottom: 10px; width: 100%; text-align: center; font-size: 15px; font-weight: 600; color: var(--paper); }
.pioneer-preview { position: absolute; inset-inline-start: 24px; bottom: 110px; width: min(200px, 28vw); border-radius: var(--r-md); border: 3px solid var(--paper); }
.pioneer-image-note { position: absolute; inset-inline-start: 24px; bottom: 82px; padding: 3px 12px; border-radius: var(--r-pill); background: var(--paper); color: var(--ink); font-size: 12.5px; font-weight: 600; }
.fiction-label { position: absolute; bottom: 16px; inset-inline-end: 16px; display: grid; gap: 2px; padding: 6px 14px; border-radius: var(--r-pill); color: var(--paper); background: rgba(16, 24, 32, 0.9); border: 1px solid var(--copper); font-size: 13px; font-weight: 600; pointer-events: none; }

/* Cutscene dressing */
.cinema .hud, .cinema .objective, .cinema .mission, .cinema .navigation { display: none; }
.cinema ~ #shell .hud-buttons { opacity: 0.35; }
.bars::before, .bars::after { content: ""; position: absolute; left: 0; right: 0; height: 11vh; background: #000; }
.bars::before { top: 0; }
.bars::after { bottom: 0; }
.bars { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
/* The cutscene bars stay behind what is said: dialogue and findings are drawn on top of them. */
.dialogue, .finding { z-index: 3; }
.years { position: absolute; left: 50%; bottom: 14vh; transform: translateX(-50%); font: 600 46px RelicaInter, sans-serif; letter-spacing: 0.08em; color: var(--paper); text-shadow: 0 2px 16px #000; direction: ltr; }
.launch-eyes { position: absolute; left: 50%; top: 50%; display: flex; gap: 34px; transform: translate(-50%, -50%); }
.launch-eyes span { display: block; width: 62px; height: 9px; border-radius: 50%; background: var(--paper); box-shadow: 0 0 18px #e3bb7766; transition: height 0.6s; }
.launch-eyes.weightless span { height: 50px; }

/* ================= Responsive ================= */
@media (max-width: 1180px) {
  .hud { width: 230px; font-size: 13px; }
  .objective, .discovery { max-width: min(520px, calc(100vw - 2 * 270px)); }
}
@media (max-width: 960px) {
  .objective { top: auto; bottom: 104px; max-width: 92vw; }
  .objective.holding { bottom: 104px; }
  @keyframes drop { from { opacity: 0; } to { opacity: 1; } }
  .discovery { top: auto; bottom: 170px; max-width: 92vw; }
  .mission { width: min(280px, 44vw); }
  .hud { width: min(230px, 44vw); }
}
@media (max-width: 820px) {
  .main-menu { align-items: flex-end; padding: 80px 16px 16px; }
  .main-menu::before { background: linear-gradient(0deg, rgba(16, 24, 32, 0.7), rgba(16, 24, 32, 0) 70%); }
  .menu-card { width: 100%; padding: 24px 20px 20px; }
  .menu-partner { display: none; }
  .memory .frame { grid-template-columns: 1fr; }
  .choice-row { grid-template-columns: 1fr; }
  .choice { min-height: 0; }
  .slider-row { grid-template-columns: 1fr 52px; }
  .slider-name { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .landing-top { padding: 14px 14px 0; }
  .lockup { flex-direction: column; gap: 8px; }
  .lockup-relica { height: 50px; }
  .lockup-spaceapps { height: 58px; }
  .landing-center { justify-content: flex-start; padding-top: 70px; gap: 14px; }
  .seg { min-width: 70px; padding: 6px 12px; }
  .menu-title { font-size: 26px; }
  .card-sheet { padding: 30px 22px 22px; }
  .sheet-body { padding: 16px 18px 22px; }
  .hud { display: none; }
  .mission { top: 72px; width: min(260px, 70vw); }
  .dialogue .line-main { font-size: 19px; }
  .keys-row { min-height: 0; }
  kbd.keycap.space { min-width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.mission .tasks li.done kbd.keycap { opacity: 0.5; box-shadow: none; }
body:has(.navigation:not(.hidden)) .controls-hint { bottom: 96px; }

/* A finding: one clear card near the bottom while the player keeps driving (hud.note) */
.finding {
  position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%);
  width: min(780px, 92vw); text-align: center;
  background: var(--paper); color: var(--ink); border-radius: var(--r-lg); box-shadow: var(--shadow);
  border-top: 6px solid var(--success-light); padding: 14px 24px;
  animation: finding-in 0.4s ease-out; transition: opacity 0.6s;
}
.finding .en { font-family: var(--font); font-size: 21px; font-weight: 600; line-height: 1.5; }
.finding .ar { font-family: var(--font); font-size: 16px; font-weight: 600; line-height: 1.5; margin-top: 2px; color: var(--muted); }
.finding.leaving { opacity: 0; }
.dialogue:not(.hidden) ~ .finding { bottom: 210px; } /* a conversation has the bottom of the screen: move up */
@keyframes finding-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Viking's flashback: the 3D view like an old photograph, dark at the edges */
body.flashback #view { filter: sepia(0.75) contrast(1.12) brightness(1.04); }
.flashback-veil { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 45%, #1a0f05cc 100%); animation: flashback-flicker 0.35s steps(2) infinite; }
.flashback-label { position: absolute; top: 88px; left: 50%; transform: translateX(-50%); padding: 3px 12px; font: 500 12px var(--font); letter-spacing: 0.12em; text-transform: uppercase; color: #f1e3c4; background: #1a0f05aa; border: 1px solid #f1e3c455; white-space: nowrap; }
.flashback-label [lang="ar"] { font: 600 14px RelicaArabic, system-ui, sans-serif; letter-spacing: 0; }
@keyframes flashback-flicker { from { opacity: 1; } to { opacity: 0.93; } }
@media (prefers-reduced-motion: reduce) { .flashback-veil { animation: none; } }

/* Time skip: a counter racing in the middle of the screen (_timeJump.js) */
/* The launch from inside the folded rover (cinematic.js, shot.eyes): engine glow from below, a slit of
   light through the closed panel, shaking while the rocket climbs; cool and still once weightless. */
.launch-light { position: absolute; inset: 0; pointer-events: none; --burn: 0; }
.launch-light ~ .launch-eyes, .launch-eyes { z-index: 1; }
.launch-glow { position: absolute; inset: -20px; background: radial-gradient(ellipse 95% 75% at 50% 112%, rgba(255, 150, 70, 0.85), rgba(255, 110, 40, 0.32) 45%, transparent 80%); opacity: var(--burn); }
.launch-slit { position: absolute; left: 18%; right: 18%; top: 22%; height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, rgba(255, 214, 160, 0.8), transparent); box-shadow: 0 0 18px 4px rgba(255, 170, 90, 0.35); opacity: calc(0.25 + var(--burn) * 0.6); }
.launch-label { position: absolute; left: 50%; bottom: 16vh; transform: translateX(-50%); font: 600 13px var(--font); letter-spacing: 0.08em; color: rgba(242, 235, 221, 0.7); }
.launch-light.weightless .launch-glow { opacity: 0.35; background: radial-gradient(ellipse 60% 50% at 50% 110%, rgba(120, 160, 220, 0.35), transparent 70%); transition: opacity 1.5s, background 1.5s; }
.launch-light.weightless .launch-slit { opacity: 0.2; background: linear-gradient(90deg, transparent, rgba(170, 200, 255, 0.6), transparent); box-shadow: none; }
@media (prefers-reduced-motion: reduce) { .launch-light { transform: none !important; } }

.time-jump { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 60; text-align: center; pointer-events: none; text-shadow: 0 2px 16px #000; }
.time-jump .label { font: 500 14px var(--font); letter-spacing: 0.3em; text-transform: uppercase; color: var(--copper-light); }
.time-jump .label [lang="ar"] { font: 600 16px RelicaArabic, system-ui, sans-serif; letter-spacing: 0; }
.time-jump .number { font: 500 clamp(64px, 13vw, 150px)/1.05 var(--font); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; color: #f1ede4; filter: blur(1.2px); transition: filter 0.25s, color 0.25s, transform 0.25s; }
.time-jump.landed .number { filter: none; color: var(--copper-light); transform: scale(1.06); }

/* A machine's service record under its real photo (memory.show with tribute) */
.memory .service-label { margin-top: 10px; padding-top: 8px; border-top: 1px solid #ccc7b9; font: 500 11px var(--font); letter-spacing: 0.1em; text-transform: uppercase; color: #5b5b5b; }
.memory .outside-pack { margin-top: 2px; font-style: italic; }
/* A new deploy is on the site: a small card in the corner with an Update button (boot.js). */
.update-toast { position: fixed; z-index: 80; bottom: 16px; inset-inline-start: 16px; display: flex; align-items: center; gap: 12px; max-width: min(460px, calc(100vw - 32px)); padding: 10px 10px 10px 16px; border-radius: var(--r-lg); background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 14px; font-weight: 600; box-shadow: var(--shadow); animation: rise 0.35s ease-out both; }
.update-toast .btn { min-height: 40px; padding: 6px 16px; flex: 0 0 auto; }

/* World panel, compact (playtest: it must stay a small corner card, about a quarter of the screen at most). */
.hud { width: 216px; padding: 10px 12px 6px; font-size: 12px; line-height: 1.4; }
.hud h2 { font-size: 15px; }
.hud .place { font-size: 11.5px; margin-bottom: 2px; }
.hud .row { padding: 4px 0; gap: 10px; }
.hud .row-label { font-size: 11.5px; }
.hud .row-value { font-size: 12.5px; }
.hud .bar { width: 64px; height: 7px; }
.hud .counter .planned { font-size: 10.5px; margin-inline-start: 6px; }
.hud .row[data-label="mission"], .hud .row[data-label="phase"] { display: none; } /* the mission card already says it */
.hud .gauge { padding: 5px 0; gap: 8px; }
.gauge-icon { flex: 0 0 24px; height: 24px; }
.gauge-icon svg { width: 15px; height: 15px; }
.gauge-label { display: none; } /* the icon and the words say it; the full name is in the tooltip */
.gauge-body { gap: 4px; }
.gauge-word { font-size: 12px; line-height: 1.3; }
.gauge-track { height: 5px; }
.gauge-earth { top: -3px; height: 11px; width: 3px; }
.gauge-dot { width: 10px; height: 10px; margin-inline-start: -5px; border-width: 2px; }
@media (max-height: 720px) { .hud { width: 200px; } .hud .row-label, .hud .row-value, .gauge-word { font-size: 11.5px; } }

/* Screen layout (playtest): pause + settings top start corner, world card under them; mission card top end corner. */
.hud-buttons { inset-inline-end: auto; inset-inline-start: 16px; }
.hud { top: 72px; inset-inline-start: 16px; }
.mission { top: 16px; inset-inline-end: 16px; width: 248px; padding: 10px 12px 6px; }
.mission-label { font-size: 11px; }
.mission h2 { margin: 1px 0 6px; font-size: 14.5px; line-height: 1.35; }
.mission .tasks li { gap: 8px; padding: 5px 0; font-size: 12.5px; line-height: 1.4; }
.mission .check { flex-basis: 15px; height: 15px; margin-top: 1px; }
.mission .tasks li.done .check::after { left: 3.5px; top: 0.5px; width: 3.5px; height: 7px; }
.mission .bonus { font-size: 12px; padding: 6px 10px; }
@media (max-width: 960px) { .mission { width: min(230px, 40vw); } .hud { width: min(210px, 40vw); } }
@media (max-width: 560px) { .mission { top: 16px; width: min(220px, 56vw); } }

/* Dialogue: words in one column, the Skip / Continue button in its own column, so they never overlap. */
.dialogue { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; align-items: end; }
.dialogue .who, .dialogue .line-main, .dialogue .line-second { grid-column: 1; }
.dialogue .line-main, .dialogue .line-second { padding-inline-end: 0; }
.dialogue-foot { position: static; grid-column: 2; grid-row: 1 / span 3; align-self: end; margin: 0; }
@media (max-width: 560px) { .dialogue { grid-template-columns: minmax(0, 1fr); } .dialogue-foot { grid-column: 1; grid-row: auto; justify-content: flex-end; margin-top: 4px; } }

/* Chapter card as a game card: dark sheet, the planet and its name on one side, the machine's real NASA photo on the other. */
.card.stage-card { background: radial-gradient(ellipse at 50% 50%, rgba(16, 24, 32, 0.55), rgba(8, 12, 18, 0.85)); }
.card.stage-card .card-sheet { position: relative; width: min(820px, 94vw); padding: 30px 30px 24px; background: linear-gradient(160deg, #1A2733, var(--ink) 55%, #0B1117); color: var(--paper); border: 1px solid var(--line-dark); text-align: start; }
.card.stage-card .next-btn { margin-top: 22px; background: var(--paper); border-color: var(--paper); color: var(--ink); }
.stage { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 28px; align-items: center; }
.stage-when { position: absolute; top: 18px; inset-inline-start: 22px; padding: 4px 12px; border-radius: var(--r-pill); background: rgba(255, 250, 240, 0.08); border: 1px solid var(--line-dark); font-size: 13px; font-weight: 600; color: var(--copper-light); }
.stage-world { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 18px; }
.stage-title { margin: 18px 0 0; font-size: clamp(30px, 4.4vw, 46px); line-height: 1.15; font-weight: 600; }
.stage-place { margin: 6px 0 0; font-size: 15px; color: var(--muted-light); }
.planet { width: clamp(130px, 17vw, 180px); aspect-ratio: 1; border-radius: 50%; box-shadow: inset -18px -14px 36px rgba(0, 0, 0, 0.55), 0 0 60px rgba(255, 255, 255, 0.06); animation: planet-turn 40s linear infinite; background-size: 200% 100%; }
.planet-moon { background-image: radial-gradient(circle at 30% 35%, #8E8C88 0 7%, transparent 8%), radial-gradient(circle at 62% 58%, #7C7A76 0 10%, transparent 11%), radial-gradient(circle at 45% 78%, #87857F 0 5%, transparent 6%), radial-gradient(circle at 72% 28%, #8A8884 0 4%, transparent 5%), linear-gradient(90deg, #C9C7C1, #B3B1AB, #C9C7C1); }
.planet-mars { background-image: radial-gradient(circle at 40% 20%, rgba(255, 245, 235, 0.5) 0 6%, transparent 9%), radial-gradient(ellipse at 55% 55%, #8E3B22 0 16%, transparent 30%), radial-gradient(ellipse at 25% 70%, #9C4628 0 10%, transparent 22%), linear-gradient(90deg, #C1673D, #B25A33, #C9714A, #C1673D); }
.planet-jupiter { background-image: radial-gradient(ellipse at 66% 62%, #B5583C 0 6%, transparent 9%), linear-gradient(180deg, #E7D3B4 0 14%, #C79A6E 14% 24%, #EAD9BD 24% 36%, #B88559 36% 46%, #E4CFAE 46% 58%, #C69A70 58% 70%, #EDDDC3 70% 84%, #C9A27A 84%); background-size: 100% 100%; }
@keyframes planet-turn { from { background-position: 0 0; } to { background-position: 200% 0; } }
.planet-jupiter { animation: none; }
.stage-machine { position: relative; margin: 0; }
.stage-machine img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--line-dark); filter: saturate(0.95) contrast(1.03); }
.stage-credit { position: absolute; top: 8px; inset-inline-end: 8px; padding: 2px 8px; border-radius: var(--r-pill); background: rgba(8, 12, 18, 0.7); color: var(--muted-light); font-size: 10.5px; direction: ltr; }
.stage-machine figcaption { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.stage-machine figcaption strong { font-size: 20px; font-weight: 600; }
.stage-machine figcaption span { font-size: 13.5px; color: var(--copper-light); }
.stage-fact { margin: 10px 0 0; padding: 8px 12px; border-radius: var(--r-sm); background: rgba(255, 250, 240, 0.06); font-size: 13.5px; line-height: 1.55; color: #D8D2C5; }
@media (max-width: 700px) { .stage { grid-template-columns: 1fr; gap: 16px; } .card.stage-card .card-sheet { padding: 24px 18px 18px; max-height: 92vh; overflow-y: auto; } .stage-machine img { aspect-ratio: 16 / 9; } }
@media (prefers-reduced-motion: reduce) { .planet { animation: none; } }
/* Letterbox shots: the subtitle sits above the bottom bar, never under it */
.dialogue { z-index: 3; }
#ui:has(.bars:not(.hidden)) .dialogue { bottom: calc(11vh + 12px); }
#ui:has(.bars:not(.hidden)) .finding { bottom: calc(11vh + 120px); }
