/* Normal Space. Palette matches the art style guide in ART_PROMPTS.md. */
:root {
  --cyan-rgb: 54, 226, 240; --amber-rgb: 255, 179, 71; --magenta-rgb: 255, 79, 154; --violet-rgb: 91, 63, 214;
  --navy-rgb: 11, 16, 38; --white-rgb: 232, 236, 255; --midnight-rgb: 22, 32, 74;
  --modal: #0e1535; /* the background of a popup */
  --round: 1; /* every corner radius is multiplied by this: 0 makes the whole game square */
  --navy: #0b1026;
  --midnight: #16204a;
  --violet: #5b3fd6;
  --cyan: #36e2f0;
  --amber: #ffb347;
  --magenta: #ff4f9a;
  --white: #e8ecff;
  --dim: rgba(var(--white-rgb), .62);
  --faint: rgba(var(--white-rgb), .32);
  --panel: rgba(13, 19, 46, .86);
  --line: rgba(var(--violet-rgb), .55);
  --mono: "Cascadia Mono", "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, "DejaVu Sans Mono", Menlo, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  background: var(--navy);
  color: var(--white);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
button { font: inherit; color: inherit; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }

kbd {
  display: inline-block;
  min-width: 1.55em;
  padding: 0 .38em;
  margin: 0 .1em;
  border: 1px solid rgba(var(--cyan-rgb), .5);
  border-bottom-width: 2px;
  border-radius: calc(5px * var(--round));
  background: rgba(var(--midnight-rgb), .9);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: .86em;
  line-height: 1.45;
  text-align: center;
  white-space: nowrap;
}

/* A capital letter is a different command in Vim, so a lone capital keycap carries a small shift mark. */
kbd.cap::before {
  content: ""; display: inline-block; width: .5em; height: .6em; margin-right: .2em; vertical-align: .02em;
  background: currentColor; opacity: .5; /* the letter's own color, dimmer: a hint, not a highlight */
  clip-path: polygon(50% 0, 100% 48%, 71% 48%, 71% 100%, 29% 100%, 29% 48%, 0 48%); /* a solid up arrow */
}

.btn {
  display: inline-flex; align-items: center; gap: .45em;
  padding: .42em .95em;
  border: 1px solid var(--cyan);
  border-radius: calc(8px * var(--round));
  background: var(--cyan);
  color: var(--navy);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn kbd { background: rgba(var(--navy-rgb), .14); color: inherit; border-color: rgba(var(--navy-rgb), .4); }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: rgba(var(--midnight-rgb), .7); color: var(--white); border-color: var(--line); font-weight: 500; }
.btn.ghost kbd { background: rgba(var(--navy-rgb), .6); color: var(--cyan); border-color: rgba(var(--cyan-rgb), .4); }
.btn.ghost:hover { border-color: var(--cyan); }
.btn.danger { background: transparent; color: var(--magenta); border-color: var(--magenta); }
button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.chip {
  display: inline-flex; align-items: center; gap: .45em;
  padding: .25em .8em;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(var(--midnight-rgb), .7);
  font-size: .93em;
}
.chip img { width: 1.5em; height: 1.5em; object-fit: contain; }
.chip-btn { cursor: pointer; }
.chip-btn:hover { border-color: var(--cyan); }
/* In Classic the readouts in the top bar (stars, credits, level, rank) are plain: no pill around them.
   The themes draw their own chips, so this is for the game with no theme on. */
:root:not([data-theme]) .topbar .chip { padding: .25em .35em; border-color: transparent; background: none; }
:root:not([data-theme]) .topbar .chip-btn:hover { border-color: var(--line); }

.keyhelp { color: var(--dim); font-size: .88em; }
.keyhelp kbd { margin-left: .55em; }
.keyhelp kbd + kbd { margin-left: .1em; }
.keyhelp.bar { padding: .5em 1.2em; background: rgba(var(--navy-rgb), .8); border-top: 1px solid rgba(var(--violet-rgb), .35); }

.stars { display: inline-flex; gap: .12em; vertical-align: middle; }
.stars img { width: 1.2em; height: 1.2em; object-fit: contain; }
.stars img.off { filter: grayscale(1) brightness(.5); opacity: .55; }

/* ---------- no keyboard ---------- */
/* Shown in place of the game on a phone or tablet. The button, or any real key press, lets you in. */
.nokeys {
  position: fixed; inset: 0; z-index: 70;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  padding: 1.5rem; text-align: center;
  background: var(--navy) url(../assets/art-60dfea5d/bg_title.webp) center / cover no-repeat;
}
.nokeys img { width: min(420px, 78vw); height: auto; }
.nokeys h1 { font-size: 1.6rem; line-height: 1.2; text-shadow: 0 2px 12px var(--navy); }
.nokeys p { max-width: 32ch; text-shadow: 0 1px 8px var(--navy); }
.nokeys small { color: var(--dim); text-shadow: 0 1px 6px var(--navy); }

/* ---------- title ---------- */
#screen-title, #screen-rank {
  align-items: center; justify-content: center;
  background: var(--navy) url(../assets/art-60dfea5d/bg_title.webp) center / cover no-repeat;
}
.title-box { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1.5rem; max-width: 100%; }
.logo { width: min(560px, 82vw); height: auto; max-height: 40vh; object-fit: contain; filter: drop-shadow(0 6px 24px rgba(var(--navy-rgb), .8)); }
.tagline { font-size: 1.25rem; color: var(--white); letter-spacing: .04em; text-shadow: 0 2px 10px var(--navy); }
.fine { color: var(--dim); font-size: .85em; text-shadow: 0 1px 6px var(--navy); }

.menu { display: flex; flex-direction: column; gap: .6rem; width: min(360px, 86vw); margin-top: .5rem; }
.menu-item {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: .7em 1.1em;
  border: 1px solid var(--line);
  border-radius: calc(10px * var(--round));
  background: var(--panel);
  cursor: pointer;
  text-align: left;
}
.menu-item b { font-size: 1.1rem; font-weight: 600; }
.menu-item span { color: var(--dim); font-size: .86em; }
.menu-item.sel { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 0 22px rgba(var(--cyan-rgb), .25); }
.menu-item.sel b::before { content: "> "; color: var(--cyan); font-family: var(--mono); }

/* ---------- rank ---------- */
.rank-box { display: flex; flex-direction: column; align-items: center; gap: 1.1rem; padding: 1.5rem; width: min(1040px, 100%); max-height: 100%; overflow: auto; }
.rank-box h1 { font-size: 1.9rem; font-weight: 650; text-shadow: 0 2px 12px var(--navy); }
.rank-box .sub { color: var(--dim); text-align: center; max-width: 56ch; text-shadow: 0 1px 8px var(--navy); }
.rank-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; width: 100%; }
.rank-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: .45rem;
  padding: 1.2rem 1.1rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: calc(14px * var(--round));
  background: var(--panel);
  cursor: pointer;
  text-align: center;
}
.rank-card img { width: 120px; height: 120px; object-fit: contain; }
.rank-card h3 { font-size: 1.35rem; }
.rank-card .tag { color: var(--amber); font-weight: 600; }
.rank-card p { color: var(--dim); font-size: .93em; }
.rank-card .pick { position: absolute; top: .7rem; right: .8rem; }
.rank-card.sel { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 0 28px rgba(var(--cyan-rgb), .28); transform: translateY(-4px); }

/* ---------- map ---------- */
#screen-map { background: var(--navy) url(../assets/art-60dfea5d/bg_map.webp) center / cover no-repeat; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .55rem 1.1rem;
  background: rgba(var(--navy-rgb), .82);
  border-bottom: 1px solid rgba(var(--violet-rgb), .4);
}
.logo-small { height: 44px; width: auto; object-fit: contain; }
.topbar-right { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; justify-content: flex-end; }

.map-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
.galaxy { position: relative; min-height: 0; overflow: hidden; }
.galaxy svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.galaxy svg polyline { fill: none; stroke: rgba(var(--cyan-rgb), .38); stroke-width: 2; stroke-dasharray: 3 9; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.planet {
  position: absolute;
  display: flex; flex-direction: column; align-items: center;
  width: 150px; margin: -62px 0 0 -75px;
  padding: 0; border: 0; background: none; cursor: pointer;
  text-shadow: 0 1px 8px var(--navy), 0 0 3px var(--navy);
}
.planet img { width: clamp(64px, 11vh, 108px); height: clamp(64px, 11vh, 108px); object-fit: contain; transition: transform .18s; }
.planet .p-name { font-weight: 650; margin-top: .15rem; }
.planet .p-skill { color: var(--cyan); font-size: .85em; }
.planet .p-state { color: var(--dim); font-size: .82em; }
.planet.locked img { filter: grayscale(1) brightness(.45); }
.planet.locked .p-name, .planet.locked .p-skill { color: var(--faint); }
.planet.sel img { transform: scale(1.14); filter: drop-shadow(0 0 16px rgba(var(--cyan-rgb), .75)); }
.planet.locked.sel img { filter: grayscale(1) brightness(.6) drop-shadow(0 0 12px rgba(var(--white-rgb), .4)); }
.planet.sel .p-name::before { content: "> "; color: var(--cyan); font-family: var(--mono); }

/* The launch prompt at the foot of the map: the picked mission, the key that starts it, and your ship. */
.launch {
  position: absolute; left: 50%; bottom: 1.1rem; z-index: 2;
  display: flex; align-items: center; gap: .8rem;
  max-width: calc(100% - 2rem);
  padding: .5rem 1.3rem .5rem .8rem;
  border: 1px solid rgba(var(--cyan-rgb), .55); border-radius: calc(16px * var(--round));
  background: rgba(var(--navy-rgb), .84);
  box-shadow: 0 0 22px rgba(var(--cyan-rgb), .22);
  cursor: pointer; text-align: left;
  transform: translateX(-50%);
  animation: launch-bob 1.4s ease-in-out infinite;
}
.launch:hover { border-color: var(--cyan); box-shadow: 0 0 28px rgba(var(--cyan-rgb), .42); }
.launch .shipart { flex: none; width: 48px; height: 48px; margin: 0; }
.launch .l-text { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.launch .l-where { color: var(--dim); font-size: .88em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.launch .l-where b { color: var(--white); font-weight: 650; }
.launch .l-go { font-size: 1.25rem; font-weight: 700; color: var(--cyan); }
.launch .l-go kbd { margin-right: .25em; }
@keyframes launch-bob { 50% { transform: translate(-50%, -9px); } }
@media (max-width: 860px), (max-height: 620px) { .launch { display: none; } }

.sector-panel {
  display: flex; flex-direction: column; gap: .7rem;
  padding: 1.1rem 1.1rem 1.2rem;
  background: var(--panel);
  border-left: 1px solid rgba(var(--violet-rgb), .4);
  overflow: auto;
}
.sector-panel .eyebrow, .eyebrow { color: var(--cyan); font-size: .8em; letter-spacing: .12em; text-transform: uppercase; }
.sector-panel h2 { font-size: 1.45rem; line-height: 1.2; }
.sector-panel .blurb { color: var(--dim); }
.sector-panel .notice { padding: .5em .75em; border-radius: calc(8px * var(--round)); background: rgba(var(--amber-rgb), .12); border: 1px solid rgba(var(--amber-rgb), .4); color: var(--amber); font-size: .92em; }
.mission-list { display: flex; flex-direction: column; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.mission-row {
  display: grid; grid-template-columns: 1.6em 1fr auto; align-items: center; gap: .6em;
  width: 100%; padding: .5em .7em;
  border: 1px solid transparent; border-radius: calc(9px * var(--round));
  background: rgba(var(--midnight-rgb), .55);
  cursor: pointer; text-align: left;
}
.mission-row .m-num { color: var(--faint); font-family: var(--mono); }
.mission-row .m-title { font-weight: 600; }
.mission-row .m-keys { display: block; color: var(--dim); font-family: var(--mono); font-size: .8em; }
.mission-row .m-state { color: var(--faint); font-size: .82em; }
.mission-row.locked { opacity: .5; }
/* The picked mission is marked by a bracket down its left edge, not an outline all the way round. */
.mission-row.sel { border-color: transparent; background: rgba(var(--cyan-rgb), .1); box-shadow: inset 3px 0 0 var(--cyan); }
.mission-row.check .m-title::after { content: " checkride"; color: var(--amber); font-size: .72em; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- mission ---------- */
#screen-mission { background: var(--navy) url(../assets/art-60dfea5d/bg_space.webp) center / cover no-repeat; }
.hud {
  display: flex; align-items: center; gap: 1rem;
  padding: .5rem .9rem;
  background: rgba(var(--navy-rgb), .86);
  border-bottom: 1px solid rgba(var(--violet-rgb), .4);
}
.hud-title { min-width: 0; }
.hud-sector { color: var(--cyan); font-size: .76em; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.hud-name { font-size: 1.15rem; font-weight: 650; line-height: 1.2; white-space: nowrap; }
.hud-meters { flex: 1; display: flex; align-items: center; justify-content: center; gap: 1.3rem; flex-wrap: wrap; row-gap: .2rem; }
.hud-buttons { display: flex; gap: .45rem; }
.hud .btn { padding: .32em .7em; font-size: .9em; }
.meter { display: inline-flex; align-items: center; gap: .5em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.meter-label { color: var(--dim); font-size: .8em; letter-spacing: .08em; text-transform: uppercase; }
.meter-num { font-family: var(--mono); }
.meter b { font-family: var(--mono); font-weight: 600; }
.meter img { width: 1.25em; height: 1.25em; object-fit: contain; }
.meter img.off { filter: grayscale(1) brightness(.5); opacity: .6; }
.meter .good { color: var(--cyan); }
.meter .warn { color: var(--amber); }
.meter .bad { color: var(--magenta); }
.bar-track { display: inline-block; width: 120px; height: 10px; border-radius: calc(6px * var(--round)); background: rgba(var(--white-rgb), .14); overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 100%; border-radius: calc(6px * var(--round)); background: var(--cyan); transition: width .12s, background-color .2s; }
.bar-fill.warn { background: var(--amber); }
.bar-fill.bad { background: var(--magenta); }

.stage { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.stage.has-target { grid-template-columns: 290px minmax(0, 1fr) minmax(260px, 30%); }

.side, .target { background: var(--panel); overflow: auto; padding: .9rem; display: flex; flex-direction: column; gap: .8rem; }
.side { border-right: 1px solid rgba(var(--violet-rgb), .4); }
.target { border-left: 1px solid rgba(var(--violet-rgb), .4); }
.side h3, .target h3 { color: var(--cyan); font-size: .78em; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.copilot-line { display: flex; gap: .7rem; align-items: flex-start; }
.copilot-line img { width: 58px; height: 58px; object-fit: contain; flex: none; }
.copilot-line p { font-size: .95em; }
.cards { display: flex; flex-direction: column; gap: .32rem; }
.card { display: grid; grid-template-columns: auto 1fr; gap: .65em; align-items: baseline; font-size: .92em; }
.card .keys { white-space: nowrap; }
/* Keycaps in a card are drawn as large as the keycaps in a route, so the two can be compared at a glance. */
.card .keys kbd { font-size: .935em; }
.card .desc { color: var(--dim); }
.offline { padding: .5em .7em; border-radius: calc(8px * var(--round)); border: 1px solid rgba(var(--magenta-rgb), .5); background: rgba(var(--magenta-rgb), .1); font-size: .9em; }
.hintbox { display: flex; flex-direction: column; gap: .45rem; }
.hint { padding: .5em .7em; border-radius: calc(8px * var(--round)); border-left: 3px solid var(--amber); background: rgba(var(--amber-rgb), .1); font-size: .92em; }
.hint-note { color: var(--faint); font-size: .84em; }

.viewport { position: relative; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 16px 20px; }
.viewport.flash::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(var(--cyan-rgb), .5), transparent 70%); animation: flash .7s ease-out forwards; pointer-events: none; }
.viewport.hit::after { content: ""; position: absolute; inset: 0; background: rgba(var(--magenta-rgb), .28); animation: flash .4s ease-out forwards; pointer-events: none; }

.grid { position: relative; flex: none; font-family: var(--mono); font-size: var(--fs, 20px); line-height: 1; }
.row { display: flex; align-items: flex-end; height: var(--rh); white-space: pre; }
.ln { flex: none; width: var(--gut); height: var(--gh); line-height: var(--gh); padding-right: 1.1em; text-align: right; color: var(--faint); font-size: .68em; }
.row.cur-row .ln { color: var(--amber); }
.cell { flex: none; width: var(--cw); height: var(--gh); line-height: var(--gh); text-align: center; border-radius: calc(3px * var(--round)); }
.cell.trail { color: var(--faint); }
.cell.sel { background: rgba(var(--violet-rgb), .6); }
.cell.hl { background: rgba(var(--amber-rgb), .26); }
.cell.inc { background: var(--amber); color: var(--navy); }
.cell.mark { box-shadow: inset 0 -3px 0 var(--amber); }
.cell.gatecell { box-shadow: inset 0 -3px 0 rgba(var(--white-rgb), .35); }
.cell.gatecell.open { box-shadow: inset 0 -3px 0 var(--cyan); }
.cell.cur { background: var(--cyan); color: var(--navy); }
.cell.cur-op { box-shadow: inset 0 -.5em 0 var(--cyan); }
.cell.cur-idle { box-shadow: inset 0 0 0 1px var(--cyan); }
.cell.cur-ins { background: rgba(var(--amber-rgb), .14); box-shadow: inset 2px 0 0 var(--amber); }
.cell.cur.sel { background: var(--white); }

.grid.wide .row { align-items: center; }
.grid.wide .ln { font-size: .5em; }
.grid.wide .cell { border-radius: calc(6px * var(--round)); }
.grid.wide .cell.dust { color: rgba(var(--white-rgb), .2); }
.grid.wide .cell.rock { color: transparent; background: url(../assets/art-60dfea5d/asteroid.webp) center / 116% no-repeat; }
.grid.wide .cell.mark, .grid.wide .cell.gatecell { box-shadow: none; }
.grid.wide .cell.cur { background-color: rgba(var(--cyan-rgb), .14); color: transparent; box-shadow: inset 0 0 0 2px rgba(var(--cyan-rgb), .7); }

#sprites { position: absolute; inset: 0; pointer-events: none; }
.sprite { position: absolute; left: 0; top: 0; width: var(--sp); height: var(--sp); margin: calc(var(--sp) / -2) 0 0 calc(var(--sp) / -2); }
.sprite i { display: block; width: 100%; height: 100%; background: center / contain no-repeat; }
.beacon i { background-image: url(../assets/art-60dfea5d/beacon.webp); animation: bob 1.7s ease-in-out infinite; filter: drop-shadow(0 0 6px rgba(var(--amber-rgb), .7)); }
.beacon.got i { animation: pop .4s ease-out forwards; }
.gate i { background-image: url(../assets/art-60dfea5d/gate.webp); opacity: .4; filter: grayscale(.9); transform: scale(1.15); transition: opacity .3s, filter .3s; }
.gate.open i { opacity: 1; filter: drop-shadow(0 0 9px rgba(var(--cyan-rgb), .9)); animation: pulse 1.4s ease-in-out infinite; }
.ship { z-index: 3; transition: transform .1s ease-out; }
.ship i { background-image: var(--ship-img, url(../assets/art-60dfea5d/ship.webp)); filter: drop-shadow(0 0 6px rgba(var(--ship-glow, 54, 226, 240), .75)); transition: transform .14s ease-out; }
.ship.insert i { background-image: var(--ship-ins-img, url(../assets/art-60dfea5d/ship_insert.webp)); filter: drop-shadow(0 0 6px rgba(var(--amber-rgb), .8)); }
.ship.visual i { filter: drop-shadow(0 0 7px rgba(var(--violet-rgb), 1)) hue-rotate(50deg); }
.ship.bump { animation: shake .18s linear; }
.boom { z-index: 4; border-radius: 50%; background: radial-gradient(circle, var(--white) 0%, var(--magenta) 40%, transparent 70%); animation: pop .45s ease-out forwards; }

.target .t-lines { font-family: var(--mono); font-size: 13.5px; line-height: 1.7; overflow-x: auto; padding-bottom: .3rem; }
.t-line { display: flex; gap: .7em; white-space: pre; color: var(--dim); }
.t-line .t-mark { flex: none; width: 1em; color: var(--faint); }
.t-line.ok { color: var(--cyan); }
.t-line.ok .t-mark { color: var(--cyan); }
.t-line.cur { color: var(--white); }
.t-line.cur .t-mark { color: var(--amber); }
.t-line .diff { background: rgba(var(--amber-rgb), .25); border-radius: calc(2px * var(--round)); }
.target .t-note { color: var(--dim); font-size: .88em; }

.statusline {
  display: flex; align-items: center; gap: 1rem;
  min-height: 2.3rem; padding: .25rem .9rem;
  background: rgba(var(--navy-rgb), .92);
  border-top: 1px solid rgba(var(--violet-rgb), .4);
  font-family: var(--mono); font-size: .92em;
}
.st-mode { flex: none; padding: .08em .7em; border-radius: calc(5px * var(--round)); background: var(--cyan); color: var(--navy); font-weight: 700; }
.st-mode.insert { background: var(--amber); }
.st-mode.visual { background: var(--violet); color: var(--white); }
.st-mode.cmd { background: var(--white); }
.st-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: pre; }
.st-msg.note { color: var(--amber); font-family: var(--sans); }
.st-msg.err { color: var(--magenta); }
.st-msg .caret { display: inline-block; width: .55em; height: 1.05em; margin-left: 1px; background: var(--white); vertical-align: text-bottom; animation: blink 1s steps(1) infinite; }
.st-rec { color: var(--magenta); white-space: nowrap; }
.st-cmd { min-width: 3.5em; color: var(--cyan); white-space: pre; }
.st-tape { color: var(--faint); white-space: pre; max-width: 30%; overflow: hidden; direction: rtl; text-align: right; }
.st-tape bdo { direction: ltr; unicode-bidi: bidi-override; }

/* ---------- overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(6, 9, 24, .74); backdrop-filter: blur(3px); }
.modal {
  width: min(680px, 100%); max-height: 100%; overflow: auto;
  padding: 1.4rem 1.5rem;
  border: 1px solid var(--line); border-radius: calc(16px * var(--round));
  background: var(--modal);
  box-shadow: 0 20px 70px rgba(0, 0, 0, .6), 0 0 0 1px rgba(var(--cyan-rgb), .12);
  display: flex; flex-direction: column; gap: .85rem;
}
.modal.wide { width: min(980px, 100%); }

/* Icon pictures, on a button or a tile. Each picture has an empty margin, so the box is a little bigger than the drawing. */
img.ico { flex: none; width: 1.9em; height: 1.9em; object-fit: contain; }
/* "Show me" under the reference route. */
.showme { align-self: flex-start; padding: .25em 1em .25em .55em; gap: .3em; }

/* The big buttons under a briefing or a result. The first is the way forward: wide, with the pilot's ship.
   The rest are squares: an icon, a word or two, and the key in the corner. */
.actions.tiles { align-items: stretch; gap: .55rem; }
.modal .actions.tiles { background: linear-gradient(transparent, var(--modal) .6rem); }
.tile {
  position: relative; flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
  width: 5.1rem; min-height: 5.3rem; padding: 1.05rem .25rem .45rem;
  border: 1px solid var(--line); border-radius: calc(12px * var(--round));
  background: var(--midnight); color: var(--white);
  font-size: .84em; line-height: 1.15; text-align: center; cursor: pointer;
}
.tile img.ico { width: 2.9rem; height: 2.9rem; margin: -.15rem 0 -.35rem; }
.tile:hover { border-color: var(--cyan); }
.tile > kbd { position: absolute; top: .3rem; right: .3rem; margin: 0; font-size: .82em; }

.tile .shipart { flex: none; width: 2rem; height: 2rem; margin: 0; }
.tile.go {
  flex: 1 1 13rem; flex-direction: row; justify-content: flex-start; gap: .85rem;
  padding: .6rem .95rem;
  border-color: var(--cyan); background: var(--cyan); color: var(--navy);
  box-shadow: 0 0 20px rgba(var(--cyan-rgb), .22);
  font-size: 1em; text-align: left;
}
.tile.go:hover { border-color: var(--cyan); box-shadow: 0 0 26px rgba(var(--cyan-rgb), .45); filter: brightness(1.08); }
.tile.go .shipart { width: 2.7rem; height: 2.7rem; }
.tile.go img.ico { width: 3.6rem; height: 3.6rem; margin: -.45rem -.3rem; }
/* An icon on the solid button gets a dark disc behind it, so a cyan drawing does not vanish into a cyan button. */
.tile.go img.ico { background: radial-gradient(closest-side, var(--navy) 80%, transparent 82%); }
.tile.go .shipart { animation: tile-ready 1.4s ease-in-out infinite; }
.tile.go .t-txt { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.tile.go b { color: var(--navy); font-size: 1.2rem; line-height: 1.2; }
.tile.go small { color: var(--navy); font-size: .88em; }
@keyframes tile-ready { 50% { transform: translateY(-4px); } }
/* The ✕ in the top right corner. It stays put while the window scrolls and takes up no room in the column. */
.modal-x {
  position: sticky; top: -.8rem; z-index: 3; align-self: flex-end; flex: none; display: grid; place-items: center;
  width: 2rem; height: 2rem; margin: -.8rem -.7rem -2.05rem 0; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: var(--modal); color: var(--dim); font-size: .95rem; line-height: 1; cursor: pointer;
}
.modal-x:hover { color: var(--white); border-color: var(--cyan); }
.modal-x + * { padding-right: 2rem; }
.modal h2 { font-size: 1.55rem; line-height: 1.2; }
.modal .story { color: var(--dim); font-style: italic; }
.modal .lesson { line-height: 1.75; }
/* The objective is a plain line under the title: the word in cyan, then the goal. */
.modal .goal b { color: var(--cyan); margin-right: .5em; }
.modal .meta { color: var(--dim); font-size: .9em; }
.modal a { color: var(--cyan); }
.modal .actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .3rem; }
.modal-head { display: flex; gap: 1rem; align-items: center; }
.modal-head img { width: 84px; height: 84px; object-fit: contain; flex: none; }
.modal .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .35rem 1.2rem; }
.modal .banner { padding: .55em .8em; border-radius: calc(9px * var(--round)); background: rgba(var(--amber-rgb), .12); border: 1px solid rgba(var(--amber-rgb), .45); color: var(--amber); font-weight: 600; }
.bigstars { display: flex; gap: .5rem; justify-content: center; padding: .3rem 0; }
.bigstars img { width: 64px; height: 64px; object-fit: contain; }
.bigstars img.off { filter: grayscale(1) brightness(.45); opacity: .5; }
.bigstars img.on { animation: starin .45s cubic-bezier(.2, 1.6, .4, 1) backwards; }
.bigstars img.on:nth-child(2) { animation-delay: .15s; }
.bigstars img.on:nth-child(3) { animation-delay: .3s; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: .5rem; }
.stat { padding: .5em .7em; border-radius: calc(9px * var(--round)); background: rgba(var(--midnight-rgb), .7); }
.stat span { display: block; color: var(--dim); font-size: .76em; letter-spacing: .08em; text-transform: uppercase; }
.stat b { font-family: var(--mono); font-size: 1.25rem; font-weight: 600; }
.route { font-family: var(--mono); line-height: 2; }
.route kbd { margin: 0 .08em; }
/* One command of a route: its keys sit together in one soft box, with a gap before the next command. */
.cmd { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 3px 1px; max-width: 100%; margin: 2px .4em 2px 0; padding: 2px 3px; border-radius: calc(8px * var(--round)); background: rgba(140, 160, 255, .09); line-height: 1.5; vertical-align: middle; cursor: help; }
.cmd kbd { margin: 0; }
.cmd.peek, .demo-step.peek { background: rgba(var(--cyan-rgb), .16); box-shadow: 0 0 0 1px rgba(var(--cyan-rgb), .6); }
.demo-step[data-r] { cursor: help; }
kbd.extra { border-color: var(--amber); background: rgba(var(--amber-rgb), .2); color: var(--amber); }
kbd.miss { border-style: dashed; border-bottom-width: 1px; background: transparent; color: var(--dim); }
.route .lbl { display: block; color: var(--dim); font-family: var(--sans); font-size: .82em; letter-spacing: .06em; text-transform: uppercase; }
.sheet { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1rem 1.6rem; }
.sheet h3 { color: var(--amber); font-size: .95rem; margin-bottom: .3rem; }
.sheet .card { font-size: .88em; }
.results { display: flex; flex-direction: column; gap: .35rem; }
.result { display: grid; grid-template-columns: 1fr auto; gap: 1rem; padding: .5em .8em; border-radius: calc(9px * var(--round)); background: rgba(var(--midnight-rgb), .7); }
.result small { display: block; color: var(--dim); }
.result .pass { color: var(--cyan); font-weight: 650; }
.result .miss { color: var(--faint); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .55em 0; border-top: 1px solid rgba(var(--violet-rgb), .3); }
.setting:first-of-type { border-top: 0; }
.setting small { display: block; color: var(--dim); }
.seg { display: inline-flex; gap: .35rem; flex-wrap: wrap; }
.seg .btn.on { background: var(--cyan); color: var(--navy); border-color: var(--cyan); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 3.6rem; z-index: 30; transform: translateX(-50%); padding: .5em 1.1em; border: 1px solid var(--amber); border-radius: 999px; background: var(--modal); color: var(--amber); box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }

/* ---------- motion ---------- */
@keyframes bob { 0%, 100% { transform: translateY(-6%); } 50% { transform: translateY(6%); } }
@keyframes pop { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(2.4); opacity: 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1.12); } 50% { transform: scale(1.28); } }
@keyframes shake { 0%, 100% { margin-left: calc(var(--sp) / -2); } 30% { margin-left: calc(var(--sp) / -2 - 3px); } 70% { margin-left: calc(var(--sp) / -2 + 3px); } }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes starin { 0% { transform: scale(0) rotate(-40deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
}

/* ---------- narrower windows ---------- */
@media (max-width: 1180px) {
  .stage, .stage.has-target { grid-template-columns: 250px minmax(0, 1fr); }
  .stage.has-target { grid-template-rows: minmax(0, 1fr) auto; }
  .stage.has-target .side { grid-row: 1 / span 2; }
  .target { border-left: 0; border-top: 1px solid rgba(var(--violet-rgb), .4); max-height: 34vh; }
  .hud-buttons .btn kbd, #btn-quit kbd { display: none; }
  .bar-track { width: 84px; }
}
@media (max-width: 860px) {
  .rank-cards { grid-template-columns: 1fr; }
  .rank-card { flex-direction: row; text-align: left; flex-wrap: wrap; }
  .rank-card img { width: 64px; height: 64px; }
  .map-body { grid-template-columns: 1fr; grid-template-rows: minmax(200px, 42%) minmax(0, 1fr); }
  .sector-panel { border-left: 0; border-top: 1px solid rgba(var(--violet-rgb), .4); }
  .planet { width: 110px; margin-left: -55px; }
  .planet .p-skill, .planet .p-state { display: none; }
  .stage, .stage.has-target { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .stage.has-target .side { grid-row: auto; }
  .side { border-right: 0; border-bottom: 1px solid rgba(var(--violet-rgb), .4); max-height: 26vh; }
  .side .cards, .side h3 { display: none; }
  .hud { flex-wrap: wrap; row-gap: .3rem; }
  .st-tape { display: none; }
  .topbar .btn { padding: .3em .6em; }
}

/* ---------- scanner: what still needs fixing in an editing mission ---------- */
.row { position: relative; }
.row.ok .ln { color: var(--cyan); }
.row.junkrow { background: linear-gradient(90deg, transparent var(--gut), rgba(var(--magenta-rgb), .1) var(--gut)); }
.cell.junk, .row.junkrow .cell { color: #ffa3c8; background: rgba(var(--magenta-rgb), .2); box-shadow: inset 0 -2px 0 var(--magenta); }
.cell.swap { color: var(--amber); background: rgba(var(--amber-rgb), .2); box-shadow: inset 0 -2px 0 var(--amber); }
.cell.gap { box-shadow: inset 3px 0 0 var(--amber); animation: gapblink 1.1s ease-in-out infinite; }
.grid:not(.wide) .cell.cur.junk, .grid:not(.wide) .cell.cur.swap, .grid:not(.wide) .row.junkrow .cell.cur { background: var(--cyan); color: var(--navy); }
.cell.cur.gap { box-shadow: inset 3px 0 0 var(--amber); }
.row.gap-above::before, .row.gap-below::after {
  position: absolute; left: var(--gut); right: 0;
  padding-top: .15em;
  border-top: 2px dashed rgba(var(--amber-rgb), .65);
  color: var(--amber); font-family: var(--sans); font-size: .55em; line-height: 1.2;
  pointer-events: none;
}
.row.gap-above::before { content: attr(data-above); top: 6%; }
.row.gap-below::after { content: attr(data-below); top: calc(100% + .3em); }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; color: var(--dim); font-size: .8em; }
.legend i { display: inline-block; width: .9em; height: .9em; margin-right: .4em; border-radius: calc(2px * var(--round)); vertical-align: -1px; }
.legend .l-junk { background: rgba(var(--magenta-rgb), .55); }
.legend .l-swap { background: rgba(var(--amber-rgb), .55); }
.legend .l-gap { box-shadow: inset 3px 0 0 var(--amber); }

/* ---------- mines and patrol drones ---------- */
.cell.minecell { color: #ffa3c8; box-shadow: inset 0 -3px 0 var(--magenta); }
.cell.lane { background-color: rgba(var(--magenta-rgb), .08); }
.cell.next { background-color: rgba(var(--magenta-rgb), .3); box-shadow: inset 0 0 0 2px rgba(var(--magenta-rgb), .75); }
.grid.wide .cell.minecell { box-shadow: none; }
.grid.wide .cell.lane { color: rgba(var(--magenta-rgb), .45); }
.mine i { background-image: url(../assets/art-60dfea5d/mine.webp); animation: bob 2.3s ease-in-out infinite; filter: drop-shadow(0 0 5px rgba(var(--magenta-rgb), .7)); }
.drone { z-index: 2; transition: transform .12s linear; }
.drone i { background-image: url(../assets/art-60dfea5d/drone.webp); animation: hover 1.1s ease-in-out infinite; filter: drop-shadow(0 0 6px rgba(var(--magenta-rgb), .85)); }

/* ---------- effects ---------- */
.fx { position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; }
.fx.trail { height: 3px; margin-top: -1.5px; border-radius: calc(2px * var(--round)); transform-origin: 0 50%; background: linear-gradient(90deg, transparent, var(--trail, var(--cyan))); box-shadow: 0 0 8px var(--trail, var(--cyan)); animation: fade .38s ease-out forwards; }
.fx.spark { width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--amber); animation: spark .5s ease-out forwards; }
.fx.spark.hot { background: var(--magenta); }
.fx.popup { color: var(--cyan); font-family: var(--sans); font-size: .62em; font-weight: 650; white-space: nowrap; text-shadow: 0 1px 6px var(--navy), 0 0 2px var(--navy); animation: rise .9s ease-out forwards; }
.grid.shake { animation: gridshake .3s linear; }
.ship.warp i { animation: warp .62s ease-in forwards; }
.stage-banner {
  position: absolute; left: 50%; top: 14%; z-index: 6; transform: translateX(-50%);
  padding: .45em 1.2em; border: 1px solid var(--cyan); border-radius: 999px;
  background: rgba(var(--navy-rgb), .92); color: var(--white); white-space: nowrap;
  box-shadow: 0 0 26px rgba(var(--cyan-rgb), .35);
  animation: bannerin .28s cubic-bezier(.2, 1.5, .4, 1);
}
.stage-banner b { color: var(--cyan); margin-right: .4em; }

/* a slow drift of stars behind the mission, and gently bobbing planets on the map */
#screen-mission::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .55;
  background-image:
    radial-gradient(1.5px 1.5px at 22px 34px, #fff, transparent), radial-gradient(1px 1px at 128px 82px, #cfeaff, transparent),
    radial-gradient(1.5px 1.5px at 204px 166px, #fff, transparent), radial-gradient(1px 1px at 74px 196px, #b9a8ff, transparent),
    radial-gradient(1px 1px at 236px 20px, #fff, transparent);
  background-size: 270px 240px;
  animation: drift 70s linear infinite;
}
#screen-mission > * { position: relative; z-index: 1; }
.planet img { animation: float 6s ease-in-out infinite; }
.planet:nth-child(odd) img { animation-delay: -3s; }
.planet.locked img { animation: none; }

/* ---------- credits, levels, medals, hangar ---------- */
.xp { display: inline-block; width: 64px; height: 6px; border-radius: calc(4px * var(--round)); background: rgba(var(--white-rgb), .16); overflow: hidden; }
.xp i { display: block; height: 100%; border-radius: calc(4px * var(--round)); background: var(--amber); transition: width .5s; }
.chip .streak { color: var(--amber); font-size: .88em; }
.chip.big { font-size: 1.1rem; margin-left: auto; }
.sector-panel .notice.review { background: rgba(var(--cyan-rgb), .08); border-color: rgba(var(--cyan-rgb), .35); color: var(--white); }
.reward { display: flex; align-items: center; gap: .7rem; padding: .5em .8em; border-radius: calc(9px * var(--round)); background: rgba(var(--amber-rgb), .1); border: 1px solid rgba(var(--amber-rgb), .4); }
.reward img { width: 30px; height: 30px; object-fit: contain; flex: none; }
.reward b { color: var(--amber); font-family: var(--mono); font-size: 1.3rem; }
.reward span { color: var(--dim); font-size: .88em; }
.xpline { display: flex; align-items: center; gap: .7rem; color: var(--dim); font-size: .88em; white-space: nowrap; }
.xpline .xp { flex: 1; width: auto; height: 8px; }
.modal .banner.won { display: flex; align-items: center; gap: .7rem; }
.banner.won img { width: 42px; height: 42px; object-fit: contain; flex: none; animation: starin .5s cubic-bezier(.2, 1.6, .4, 1) backwards; }
.banner.won small { display: block; color: var(--dim); font-weight: 400; }
.modal .actions { position: sticky; bottom: -1.4rem; margin-bottom: -.6rem; padding: .6rem 0; background: linear-gradient(transparent, var(--modal) 30%); }
.modal .mastery kbd { margin-left: .3em; }
.modal .recall h3 { color: var(--cyan); font-size: .78em; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; margin-bottom: .35rem; }
.side .cards.recall .card, .modal .recall .card { font-size: .86em; }
.side .cards.recall .desc { color: var(--faint); }
.hint.tip { border-left-color: var(--cyan); background: rgba(var(--cyan-rgb), .1); animation: bannerin .3s ease-out; }
.hint.tip b { color: var(--cyan); margin-right: .4em; }
.side .route { line-height: 1.9; }

.pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.pips i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(var(--amber-rgb), .6); }
.pips i.on { background: var(--amber); }
.upgrades { display: flex; flex-direction: column; gap: .5rem; }
.upgrade { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: .9rem; padding: .55em .8em; border-radius: calc(10px * var(--round)); background: rgba(var(--midnight-rgb), .7); }
.upgrade img { width: 56px; height: 56px; object-fit: contain; }
.upgrade small { display: block; color: var(--dim); }
.upgrade .btn img, .chip.big img { width: 1.3em; height: 1.3em; }
.upgrade .maxed { color: var(--cyan); font-weight: 650; }
.swatch { display: inline-block; width: 1em; height: 1em; border-radius: 50%; }
.medals { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .45rem; }
.medal { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: .7rem; padding: .45em .7em; border-radius: calc(9px * var(--round)); background: rgba(var(--midnight-rgb), .55); }
.medal img { width: 40px; height: 40px; object-fit: contain; filter: grayscale(1) brightness(.45); opacity: .6; }
.medal small { display: block; color: var(--dim); font-size: .85em; }
.medal > span { color: var(--faint); font-size: .82em; white-space: nowrap; }
.medal .prog { display: flex; align-items: center; gap: .6em; margin-top: .35em; }
.medal .prog span { flex: 1; height: 5px; overflow: hidden; border-radius: calc(3px * var(--round)); background: rgba(140, 160, 255, .16); }
.medal .prog i { display: block; height: 100%; border-radius: calc(3px * var(--round)); background: var(--cyan); }
.medal .prog em { color: var(--dim); font: normal .78em var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.medal.got { background: rgba(var(--amber-rgb), .1); box-shadow: inset 0 0 0 1px rgba(var(--amber-rgb), .4); }
.medal.got img { filter: none; opacity: 1; }
.medal.got > span { color: var(--amber); }
.medal:not(.got) b { color: var(--dim); }
.sheet.skills { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }
.skill { display: grid; grid-template-columns: 6.2em 1fr auto 5.2em; align-items: baseline; gap: .6em; padding: .12em 0; font-size: .88em; }
.skill .keys { white-space: nowrap; }
.skill .desc { color: var(--dim); }
.skill .lvl { color: var(--dim); font-size: .9em; text-align: right; }
.skill .lvl.rusty { color: var(--amber); }
.skill.locked { opacity: .45; }

@keyframes gapblink { 50% { box-shadow: inset 3px 0 0 rgba(var(--amber-rgb), .25); } }
@keyframes hover { 0%, 100% { transform: scale(1) rotate(-4deg); } 50% { transform: scale(1.08) rotate(4deg); } }
@keyframes fade { to { opacity: 0; } }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, -60%); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -280%); } }
@keyframes gridshake { 0%, 100% { transform: none; } 20% { transform: translate(-5px, 2px); } 40% { transform: translate(5px, -2px); } 60% { transform: translate(-3px, -1px); } 80% { transform: translate(3px, 1px); } }
@keyframes warp { 0% { opacity: 1; } 35% { transform: scale(1.35, .75); opacity: 1; } 100% { transform: scale(.08, 3.2); opacity: 0; } }
@keyframes bannerin { 0% { opacity: 0; margin-top: 10px; } 100% { opacity: 1; margin-top: 0; } }
@keyframes drift { to { background-position: -270px 240px; } }
@keyframes float { 50% { translate: 0 -5px; } }
@media (prefers-reduced-motion: reduce) {
  #screen-mission::before, .planet img, .cell.gap { animation: none !important; }
}

/* ---------- route demo ("Show me") ---------- */
/* The key being pressed sits just above the text and the buttons just below it, so the eye stays on the ship. */
.viewport { flex-direction: column; gap: 1rem; }
.demo-top, .demo-bottom { position: relative; z-index: 3; flex: none; max-width: 100%; display: flex; flex-direction: column; align-items: center; gap: .45rem; }
.demo-now {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem;
  box-sizing: border-box; height: 6rem; min-width: min(26rem, 100%); max-width: 100%; padding: .4rem 1.3rem;
  border: 1px solid var(--line); border-radius: calc(12px * var(--round)); background: rgba(var(--navy-rgb), .85);
}
.demo-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.demo-keys kbd { font-size: 1.35rem; padding: .1em .5em; }
.demo-keys.long kbd { font-size: .85rem; padding: .1em .35em; }
.demo-text { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.15rem; font-weight: 600; color: var(--white); }
.demo-hint { min-height: 1.3em; color: var(--dim); font-size: .88rem; text-align: center; }
.demo-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .4rem; }
.demo-controls .btn { padding: .3em .7em; font-size: .88em; }
.demo-speedbox { display: inline-flex; align-items: center; gap: .35rem; margin-left: .7rem; }
.demo-speedbox b { min-width: 3.8em; text-align: center; color: var(--amber); font-size: .88em; }
.demo-route { display: flex; flex-wrap: wrap; gap: .2rem .25rem; margin-bottom: .7rem; }
.demo-step { display: inline-flex; gap: 2px; padding: 2px 3px; border: 1px solid transparent; border-radius: calc(6px * var(--round)); }
.demo-step kbd { font-size: .8em; }
.demo-step.done { opacity: .38; }
.demo-step.cur { border-color: var(--cyan); background: rgba(var(--cyan-rgb), .1); }
kbd.hit { opacity: .45; }
kbd.next { background: var(--cyan); color: var(--navy); border-color: var(--cyan); animation: keypulse 1s ease-in-out infinite; }
.btn.mini { padding: .1em .6em; font-size: .8em; margin-left: .6em; vertical-align: middle; font-family: var(--sans); line-height: 1.6; }
.modal .alsouses { color: var(--dim); font-size: .9em; }
@keyframes keypulse { 50% { box-shadow: 0 0 0 4px rgba(var(--cyan-rgb), .3); } }

/* ---------- lesson animations in the briefing ---------- */
.minibox { display: grid; gap: .5rem; padding: .7rem .9rem .8rem; border: 1px solid var(--line); border-radius: calc(12px * var(--round)); background: rgba(var(--navy-rgb), .6); }
.minibox.done { animation: boxdone 1.1s ease-out; }
.mini-head { display: flex; align-items: center; gap: .8rem; }
.mini-head > b { color: var(--cyan); font-size: .76em; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; }
.mini-tabs { display: flex; flex-wrap: wrap; gap: .3rem; }
.mini-tab { padding: .15em .6em; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--dim); font: inherit; font-size: .9em; cursor: pointer; opacity: .6; }
.mini-tab.on { border-color: var(--cyan); background: rgba(var(--cyan-rgb), .12); color: var(--white); opacity: 1; }
.mini-next { margin-left: auto; white-space: nowrap; }
.mini-tab small { margin-left: .3em; color: var(--dim); font-size: .85em; }
.mini-say { min-height: 1.4em; color: var(--white); }
.mini-now { display: flex; align-items: center; gap: .9rem; min-height: 2.7rem; }
.mini-now .demo-keys { justify-content: flex-start; flex: none; max-width: 60%; }
.mini-now .demo-text { color: var(--amber); animation: captionin .35s ease-out; }
.mini-now kbd { opacity: .35; }
.mini-now kbd.lit { opacity: 1; background: var(--cyan); color: var(--navy); border-color: var(--cyan); }
.mini-now kbd.new { animation: keydown .32s ease-out; }
.mini-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; padding: .5rem 0; border-radius: calc(8px * var(--round)); background: rgba(5, 8, 22, .55); }
.mini { position: relative; font-family: var(--mono); font-size: 17px; line-height: 1; }
.mini.rec::after { content: "● recording"; position: absolute; right: 0; top: 0; color: var(--magenta); font: 600 11px var(--sans); letter-spacing: .06em; animation: gapblink 1.1s ease-in-out infinite; }
.mini-fx { position: absolute; inset: 0; pointer-events: none; }
.mrow { display: flex; align-items: flex-end; height: 2.7em; }
.mc { position: relative; flex: none; width: 1ch; padding: .2em 0; border-radius: calc(2px * var(--round)); text-align: center; white-space: pre; transition: background-color .2s; }
.mc::after { position: absolute; left: 50%; bottom: 100%; width: 1.4em; height: 1.4em; transform: translateX(-50%); background: center / contain no-repeat; pointer-events: none; }
.mc.gate::after { content: ""; background-image: url(../assets/art-60dfea5d/gate.webp); opacity: .55; }
.mc.gate.open::after { opacity: 1; }
.mc.beacon::after { content: ""; background-image: url(../assets/art-60dfea5d/beacon.webp); }
.mc.mine::after { content: ""; background-image: url(../assets/art-60dfea5d/mine.webp); }
.mc.drone::after { content: ""; background-image: url(../assets/art-60dfea5d/drone.webp); }
.mc.mine { color: #ffa3c8; box-shadow: inset 0 -2px 0 var(--magenta); }
.mc.cur { background: var(--cyan); color: var(--navy); }
.mc.cur.ins { background: none; color: inherit; box-shadow: inset 2px 0 0 var(--amber); }
/* about to be removed, about to move, just arrived, where the ship is headed, just copied */
.mc.doomed { color: #fff; background: rgba(var(--magenta-rgb), .6); box-shadow: inset 0 -2px 0 var(--magenta); animation: doom .42s ease-in-out infinite alternate; }
.mc.moving { color: var(--navy); background: rgba(var(--amber-rgb), .85); }
.mc.fresh { animation: fresh 1.2s ease-out; }
.mc.land { box-shadow: 0 0 0 2px var(--cyan), 0 0 12px var(--cyan); border-radius: calc(4px * var(--round)); animation: landpulse .5s ease-in-out infinite alternate; }
.mc.copied { color: var(--navy); background: rgba(var(--amber-rgb), .8); }
.mini-ship { position: absolute; left: 0; top: 0; z-index: 4; width: 1.5em; height: 1.5em; margin: -1.5em 0 0 -.75em; pointer-events: none; transition: transform .5s cubic-bezier(.3, 1.25, .5, 1); }
.mini-ship.snap, .mini-ship.snap i { transition: none; }
.mini-ship i { display: block; width: 100%; height: 100%; background: var(--ship-img, url(../assets/art-60dfea5d/ship.webp)) center / contain no-repeat; filter: drop-shadow(0 0 5px rgba(var(--ship-glow, 54, 226, 240), .7)); transition: transform .3s; }
.mini-ship.ins i { background-image: var(--ship-ins-img, url(../assets/art-60dfea5d/ship_insert.webp)); filter: drop-shadow(0 0 5px rgba(var(--amber-rgb), .8)); }
.mini .fx.trail { height: 4px; margin-top: -2px; animation-duration: .6s; }
.mini .fx.ring { width: 12px; height: 12px; margin: -6px 0 0 -6px; border: 2px solid var(--cyan); border-radius: 50%; animation: ring .65s ease-out forwards; }
.mini.wide .mrow { height: 28px; }
.mini.wide .mc { width: 28px; height: 28px; padding: 0; box-sizing: border-box; }
.mini.wide .mc::after { left: 0; bottom: 0; width: 100%; height: 100%; transform: none; }
.mini.wide .mc.dust { background: radial-gradient(circle, rgba(var(--white-rgb), .22) 1.2px, transparent 1.7px); }
.mini.wide .mc.rock { background: url(../assets/art-60dfea5d/asteroid.webp) center / 92% no-repeat; }
.mini.wide .mc.next { box-shadow: inset 0 0 0 2px rgba(var(--magenta-rgb), .7); background-color: rgba(var(--magenta-rgb), .2); }
.mini.wide .mc.land { box-shadow: inset 0 0 0 2px var(--cyan), 0 0 12px var(--cyan); }
.mini.wide .mini-ship { width: 26px; height: 26px; margin: -13px 0 0 -13px; }
@keyframes doom { from { background: rgba(var(--magenta-rgb), .3); } to { background: rgba(var(--magenta-rgb), .75); } }
@keyframes fresh { 0% { background: var(--cyan); color: var(--navy); transform: translateY(-5px) scale(1.3); } 35% { transform: none; } 100% { background: transparent; } }
@keyframes landpulse { from { box-shadow: 0 0 0 2px var(--cyan), 0 0 4px var(--cyan); } to { box-shadow: 0 0 0 2px var(--cyan), 0 0 16px var(--cyan); } }
@keyframes ring { to { transform: scale(4.5); opacity: 0; } }
@keyframes keydown { 0% { transform: translateY(-7px) scale(1.25); } 60% { transform: translateY(2px) scale(.94); } 100% { transform: none; } }
@keyframes captionin { from { opacity: 0; transform: translateX(-6px); } }
@keyframes boxdone { 0% { box-shadow: 0 0 0 0 rgba(var(--cyan-rgb), .7); border-color: var(--cyan); } 100% { box-shadow: 0 0 0 14px rgba(var(--cyan-rgb), 0); } }
@media (prefers-reduced-motion: reduce) {
  kbd.next, .mc.doomed, .mc.land, .mc.fresh, .mini-now kbd.new, .minibox.done { animation: none; }
  .mini-ship { transition: none; }
}

/* ---------- ships ---------- */
/* A ship is an image, a glow color and an idle animation. The sprite carries a class as-<ship>. */
.ship i, .mini-ship i, .shipart i { position: relative; }
/* Only the scout has its own Insert mode art. The others are tinted amber while typing. */
.ship.insert:not(.as-scout) i, .mini-ship.ins:not(.as-scout) i { filter: sepia(1) saturate(2.6) hue-rotate(-14deg) drop-shadow(0 0 6px rgba(var(--amber-rgb), .85)); }

/* The idle animations use translate, rotate and scale, which stack with the transform that turns the ship. */
.as-comet:not(.warp) i { animation: comet-idle .42s ease-in-out infinite; }
/* One flame under each of the comet's two engines, over the small ones painted on the art. */
.as-comet i::before, .as-comet i::after {
  content: ""; position: absolute; left: 44%; top: 81%; width: 9%; height: 20%; translate: -50% 0; transform-origin: 50% 0;
  border-radius: 45% 45% 60% 60%; background: radial-gradient(ellipse at 50% 0, #fff 0 16%, var(--amber) 42%, transparent 72%);
  animation: flame .15s ease-in-out infinite alternate; pointer-events: none;
}
.as-comet i::after { left: 55.9%; animation-delay: .07s; }
.as-manta:not(.warp) i { animation: manta-idle 2.8s ease-in-out infinite; }
/* The saucer is a side view, drawn tipped about 7 degrees. It rocks either side of level and bobs. */
.as-saucer:not(.warp) i { animation: saucer-tip 3.4s ease-in-out infinite, saucer-bob 1.9s ease-in-out infinite; }
/* Its rim lights: four amber spots slide along the front of the rim and thin out at the ends, so the disc
   looks like it is turning. The layer is tilted with the art, about the center of the disc. The keyframes
   follow the ring the first saucer's painted lights sat on (x = 390 cos t, y = -19.5 + 86.5 sin t art pixels
   from the disc's center at 512, 522), one eighth of a turn per loop. */
.as-saucer i::after {
  content: ""; position: absolute; inset: 0; rotate: 6.92deg; transform-origin: 50% 50.98%; pointer-events: none;
  --rim: radial-gradient(ellipse closest-side, #fff3c4 0, #ffc457 45%, #ffb347 72%, rgba(var(--amber-rgb), 0));
  background-image: var(--rim), var(--rim), var(--rim), var(--rim); background-repeat: no-repeat;
  background-position: 13.3% 52.4%, 33.9% 57.2%, 66.1% 57.2%, 86.7% 52.4%; background-size: 4.02% 5.0%, 9.70% 5.0%, 9.70% 5.0%, 4.02% 5.0%;
  animation: saucer-rim .6s linear infinite;
}
.as-saucer.warp i::after { animation-duration: .12s; }
/* Its tractor beam: on while typing, and a quick flash when it picks up a beacon. It hangs straight down behind the ship. */
.ship.as-saucer::before, .mini-ship.as-saucer::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: 58%; width: 95%; height: 125%; translate: -50% 0; transform-origin: 50% 0;
  clip-path: polygon(34% 0, 66% 0, 100% 100%, 0 100%); opacity: 0; pointer-events: none;
  background: linear-gradient(rgba(255, 214, 140, .95), rgba(var(--amber-rgb), .5) 45%, rgba(var(--amber-rgb), 0));
}
.ship.as-saucer.insert::before, .mini-ship.as-saucer.ins::before { opacity: 1; animation: beam-hum .9s ease-in-out infinite; }
.ship.as-saucer.beam::before, .mini-ship.as-saucer.beam::before { animation: beam-grab .5s ease-out; }
.as-hauler:not(.warp) i { animation: hauler-idle .16s steps(2) infinite; }
.as-hauler i::before, .as-hauler i::after {
  content: ""; position: absolute; top: 90%; width: 15%; height: 15%; border-radius: 50%;
  background: rgba(var(--white-rgb), .75); animation: puff 1.1s ease-out infinite; pointer-events: none;
}
.as-hauler i::before { left: 18%; }
.as-hauler i::after { left: 67%; animation-delay: .55s; }
.as-phantom:not(.warp) i { animation: phantom-idle 3.4s ease-in-out infinite; }
@keyframes comet-idle { 50% { scale: 1 1.06; } }
@keyframes flame { from { transform: scaleY(.65); opacity: .7; } to { transform: scaleY(1.55); opacity: 1; } }
@keyframes manta-idle { 0%, 100% { rotate: -8deg; } 50% { rotate: 8deg; } }
@keyframes saucer-tip { 0%, 100% { rotate: -15deg; } 50% { rotate: 1deg; } }
@keyframes saucer-bob { 50% { translate: 0 -3px; } }
@keyframes saucer-rim {
  0% { background-position: 11.9% 49.0%, 20.9% 55.3%, 50.0% 57.9%, 79.1% 55.3%; background-size: 0.00% 5.0%, 7.42% 5.0%, 10.50% 5.0%, 7.42% 5.0%; }
  12.5% { background-position: 11.7% 49.9%, 23.7% 55.9%, 54.2% 57.9%, 81.5% 54.7%; background-size: 1.03% 5.0%, 8.12% 5.0%, 10.45% 5.0%, 6.66% 5.0%; }
  25% { background-position: 11.9% 50.8%, 26.8% 56.4%, 58.3% 57.7%, 83.6% 54.0%; background-size: 2.05% 5.0%, 8.73% 5.0%, 10.30% 5.0%, 5.83% 5.0%; }
  37.5% { background-position: 12.4% 51.6%, 30.2% 56.9%, 62.3% 57.5%, 85.3% 53.2%; background-size: 3.05% 5.0%, 9.26% 5.0%, 10.05% 5.0%, 4.95% 5.0%; }
  50% { background-position: 13.3% 52.4%, 33.9% 57.2%, 66.1% 57.2%, 86.7% 52.4%; background-size: 4.02% 5.0%, 9.70% 5.0%, 9.70% 5.0%, 4.02% 5.0%; }
  62.5% { background-position: 14.7% 53.2%, 37.7% 57.5%, 69.8% 56.9%, 87.6% 51.6%; background-size: 4.95% 5.0%, 10.05% 5.0%, 9.26% 5.0%, 3.05% 5.0%; }
  75% { background-position: 16.4% 54.0%, 41.7% 57.7%, 73.2% 56.4%, 88.1% 50.8%; background-size: 5.83% 5.0%, 10.30% 5.0%, 8.73% 5.0%, 2.05% 5.0%; }
  87.5% { background-position: 18.5% 54.7%, 45.8% 57.9%, 76.3% 55.9%, 88.3% 49.9%; background-size: 6.66% 5.0%, 10.45% 5.0%, 8.12% 5.0%, 1.03% 5.0%; }
  100% { background-position: 20.9% 55.3%, 50.0% 57.9%, 79.1% 55.3%, 88.1% 49.0%; background-size: 7.42% 5.0%, 10.50% 5.0%, 7.42% 5.0%, 0.00% 5.0%; }
}
@keyframes beam-hum { 0%, 100% { opacity: .75; transform: scaleX(.9); } 50% { opacity: 1; transform: scaleX(1.08); } }
@keyframes beam-grab { 0% { opacity: 0; transform: scaleY(.2); } 25% { opacity: 1; transform: scaleY(1); } 100% { opacity: 0; transform: scaleY(.35); } }
@keyframes hauler-idle { 50% { translate: .7px -.5px; } }
@keyframes puff { from { transform: translateY(0) scale(.5); opacity: .8; } to { transform: translateY(90%) scale(1.7); opacity: 0; } }
@keyframes phantom-idle { 0%, 52%, 100% { opacity: 1; translate: 0 0; } 60% { opacity: .3; } 66% { opacity: .9; } 72% { opacity: .25; translate: 2px 0; } 80% { opacity: 1; translate: 0 0; } }

/* the hangar */
.hangar-h { display: flex; align-items: baseline; gap: .7rem; color: var(--cyan); font-size: .8em; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.hangar-h small { color: var(--dim); font-size: 1.05em; font-weight: 400; letter-spacing: 0; text-transform: none; }
.ships { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: .5rem; }
.shipcard { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .7rem .5rem .6rem; border: 1px solid transparent; border-radius: calc(10px * var(--round)); background: rgba(var(--midnight-rgb), .7); text-align: center; }
.shipcard.on { border-color: var(--cyan); background: rgba(var(--cyan-rgb), .1); }
/* A theme's card in the hangar: a sample of its background, type, panel and accent colors. */
.themeart { display: flex; align-items: center; justify-content: center; gap: .3rem; width: 100px; height: 60px; margin-bottom: .35rem; border: 1px solid rgba(var(--white-rgb), .3); border-radius: calc(8px * var(--round)); }
.themeart b { margin-right: .2rem; font-size: 1.6rem; font-weight: 600; line-height: 1; }
.themeart i { width: 13px; height: 26px; border: 1px solid rgba(255, 255, 255, .2); border-radius: calc(3px * var(--round)); }
.shipcard small { flex: 1; color: var(--dim); font-size: .82em; line-height: 1.35; }
.shipcard .btn { padding: .25em .6em; font-size: .88em; }
.shipcard .btn img { width: 1.2em; height: 1.2em; }
.shipcard .maxed { padding: .25em 0; color: var(--cyan); font-weight: 650; }
.shipart { display: block; width: 72px; height: 72px; margin-bottom: .2rem; }
.shipart i { display: block; width: 100%; height: 100%; background: center / contain no-repeat; filter: drop-shadow(0 0 7px rgba(var(--ship-glow, 54, 226, 240), .7)); }
.shipcard.locked .shipart i { filter: drop-shadow(0 0 4px rgba(var(--ship-glow, 54, 226, 240), .35)) saturate(.75) brightness(.85); }
.modal.wide .upgrades { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
@media (prefers-reduced-motion: reduce) {
  .ship.as-saucer::before, .mini-ship.as-saucer::before, .as-saucer i::after, .as-comet i, .as-comet i::before, .as-comet i::after, .as-manta i, .as-saucer i, .as-hauler i, .as-hauler i::before, .as-hauler i::after, .as-phantom i { animation: none !important; }
}

/* ---------- keycap popup ---------- */
/* Hovering a keycap shows that key at work. The window never takes the mouse, so it cannot get in the way. */
.keypop {
  position: fixed; z-index: 40; width: min(600px, calc(100vw - 16px)); display: grid; gap: .5rem; padding: .7rem .9rem .8rem;
  border: 1px solid var(--cyan); border-radius: calc(12px * var(--round)); background: var(--modal);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .6), 0 0 22px rgba(var(--cyan-rgb), .18);
  pointer-events: none; animation: popin .16s ease-out;
}
.keypop.done { animation: boxdone 1.1s ease-out; }
.keypop-head { display: flex; align-items: baseline; gap: .7rem; color: var(--white); }
.keypop-head .keys { white-space: nowrap; }
kbd.peek { box-shadow: 0 0 0 2px rgba(var(--cyan-rgb), .45); }
@keyframes popin { from { opacity: 0; transform: translateY(4px); } }

/* ---------- guided tour ---------- */
/* The layer sits over everything except the key popup, and takes every click. The "hole" is a box over
   the thing being shown: its huge shadow is what dims the rest of the screen. */
.tour { position: fixed; inset: 0; z-index: 35; }
.tour.blank { background: rgba(6, 9, 24, .8); }
.tour-hole {
  position: fixed; border-radius: calc(10px * var(--round)); pointer-events: none;
  box-shadow: 0 0 0 2px var(--cyan), 0 0 22px 4px rgba(var(--cyan-rgb), .45), 0 0 0 200vmax rgba(6, 9, 24, .8);
  transition: left .25s ease-out, top .25s ease-out, width .25s ease-out, height .25s ease-out;
}
.tour-box {
  position: fixed; width: min(350px, calc(100vw - 24px)); display: grid; grid-template-columns: 44px 1fr; gap: .2rem .7rem;
  padding: .8rem .9rem .7rem; border: 1px solid var(--cyan); border-radius: calc(12px * var(--round)); background: var(--modal);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .6), 0 0 22px rgba(var(--cyan-rgb), .18);
}
.tour-box img { width: 44px; height: 44px; object-fit: contain; }
.tour-box p { align-self: center; font-size: 1.02rem; line-height: 1.4; }
.tour-foot { grid-column: 1 / -1; display: flex; align-items: center; gap: .5rem; margin-top: .4rem; }
.tour-foot span { flex: 1; color: var(--faint); font-size: .8em; }
.tour-foot .btn { padding: .25em .7em; font-size: .88em; }
/* The pointer a tour slides onto a key to show hovering. Its tip is the top left corner of the box. */
.tour-mouse {
  position: fixed; z-index: 45; width: 26px; height: 26px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 2l15 11.5-6.6.9 3.9 7.3-2.7 1.4-3.8-7.3L5 20.5z' fill='white' stroke='%230b1026' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .7));
  animation: mouse-in .7s ease-out, mouse-rest 1.6s ease-in-out .7s infinite;
}
@keyframes mouse-in { from { transform: translate(70px, 54px); opacity: 0; } }
@keyframes mouse-rest { 50% { transform: translate(2px, 2px); } }
@media (prefers-reduced-motion: reduce) { .tour-hole { transition: none; } .tour-mouse { animation: none; } }
/* Scenes in the popup are drawn smaller than in the briefing, so a tall one still fits beside the keycap. */
.keypop { width: min(480px, calc(100vw - 16px)); --mini-row: 30; --mini-cell: 22; }
.keypop .mini { font-size: 13px; }
.keypop .mrow { height: 30px; }
.keypop .mini-now { min-height: 2.3rem; }
.keypop .mini-now .demo-keys kbd { font-size: 1.1rem; }
.keypop .mini.wide .mrow { height: 22px; }
.keypop .mini.wide .mc { width: 22px; height: 22px; }
.keypop .mini.wide .mini-ship { width: 20px; height: 20px; margin: -10px 0 0 -10px; }
/* A command from a route, played in its own level: wider, so a whole line of the level fits. */
.keypop.ctx { width: min(560px, calc(100vw - 16px)); }
.keypop.ctx .keypop-head { flex-wrap: wrap; row-gap: .3rem; }
.keypop.ctx .keypop-head .keys { display: inline-flex; flex-wrap: wrap; gap: 2px; white-space: normal; }
.keypop.ctx.one .mini-now .demo-text { display: none; }
.keypop.dense { --mini-row: 24; }
.keypop.dense .mini { font-size: 12px; }
.keypop.dense .mrow { height: 24px; }
