/* Star Runner page styles. One font stack (the localization runtime sets --sbg-font-fallback for scripts the stack cannot show). */
:root {
  --font-ui: "Segoe UI", system-ui, Roboto, "Helvetica Neue", var(--sbg-font-fallback, sans-serif);
  --bg: #050813; --ink: #e8f1ff; --dim: #9db2d4; --cyan: #6fe4ff; --amber: #ffb04a; --red: #ff5a4a; --accent: #ffb04a;
  --panel: rgba(7, 14, 32, 0.86); --deck-h: 214px; --pad: clamp(10px, 2vw, 20px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--font-ui); overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, select, input { font: inherit; color: inherit; }
.shell { position: fixed; inset: 0; overflow: hidden; background: var(--bg); }
.shell[data-view="title"] { background: #050813 url("./art/title.webp") center / cover no-repeat; }
.shell[data-view="menu"] { background: linear-gradient(rgba(5, 8, 19, 0.8), rgba(5, 8, 19, 0.92)), url("./art/vesper-sky.webp") center / cover no-repeat; }
.shell[data-view="title"] .view, .shell[data-view="menu"] .view { visibility: hidden; }
.view { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; }

/* ---- screens ---- */
.ui { position: absolute; inset: 0; display: flex; justify-content: center; align-items: stretch; pointer-events: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.screen { pointer-events: auto; width: min(980px, 100%); height: 100%; display: flex; flex-direction: column; gap: 8px; padding: var(--pad); }
.screen-head, .bar { flex: none; }
.screen-head h2 { margin: 0; font-size: clamp(22px, 4vw, 34px); letter-spacing: 0.06em; text-transform: uppercase; }
.screen-head .sub, .sub { color: var(--dim); margin: 2px 0 0; font-size: 0.9rem; }
.kicker { color: var(--accent); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem; margin: 0; }
.scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 6px 10px 2px; scrollbar-width: thin; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; padding-top: 6px; position: relative; z-index: 2; }
.note { color: var(--dim); font-size: 0.9rem; }
.lead { font-size: 1.1rem; max-width: 62ch; }
.link { color: var(--cyan); }

.btn { appearance: none; cursor: pointer; min-height: 48px; min-width: 120px; padding: 6px 26px; border: 14px solid transparent; border-image: url("./art/ui/button.webp") 44 fill / 14px stretch; background: none; color: var(--ink); font-weight: 600; letter-spacing: 0.04em; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.btn:hover, .btn:focus-visible { border-image-source: url("./art/ui/button-lit.webp"); color: #0b1020; outline: none; }
.btn:active { border-image-source: url("./art/ui/button-pressed.webp"); }
.btn-primary { border-image-source: url("./art/ui/button-lit.webp"); color: #0b1020; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-small { min-height: 40px; min-width: 0; padding: 2px 14px; }
.panel { border: 16px solid transparent; border-image: url("./art/ui/panel-wide.webp") 40 fill / 16px stretch; padding: 4px 8px; }
.ico { display: inline-block; vertical-align: middle; object-fit: contain; }
.ico-blank { width: 56px; height: 56px; }
.pill { display: inline-block; padding: 2px 12px; border-radius: 999px; background: var(--accent); color: #0b1020; font-weight: 700; font-size: 0.85rem; }
.chips, .rules { list-style: none; margin: 4px 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rules { flex-direction: column; gap: 2px; }
.chips li { padding: 2px 10px; border-radius: 999px; background: rgba(120, 160, 220, 0.18); font-size: 0.85rem; display: inline-flex; gap: 6px; align-items: center; }
.chips li.good { background: rgba(80, 220, 140, 0.2); }
.chips li.bad { background: rgba(255, 110, 90, 0.22); }
h3, h4 { margin: 12px 0 4px; }
h4 { color: var(--accent); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; }

/* title */
.screen-title { position: absolute; inset: 0; width: auto; display: block; }
.title-menu { position: absolute; left: clamp(10px, 2.5vw, 40px); bottom: clamp(30px, 7vh, 70px); width: min(250px, calc(100% - 28px)); display: flex; flex-direction: column; gap: 4px; }
.title-menu .btn { width: 100%; min-height: 40px; border-width: 11px; border-image-width: 11px; justify-content: flex-start; padding-left: 18px; }
.notice { position: absolute; left: 0; right: 0; bottom: 8px; margin: 0; text-align: center; font-size: 0.78rem; color: var(--dim); text-shadow: 0 1px 3px #000; }
.notice.warn { bottom: auto; top: 8px; color: var(--amber); }

/* contracts */
.biome { margin: 0 0 14px; }
.biome header h3 { margin: 0; color: var(--accent); letter-spacing: 0.08em; text-transform: uppercase; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 6px; margin-top: 6px; }
.card { appearance: none; cursor: pointer; text-align: left; display: grid; grid-template-columns: 38px 1fr 40px; gap: 8px; align-items: center; min-height: 58px; padding: 6px 12px; border: 12px solid transparent; border-image: url("./art/ui/button.webp") 44 fill / 12px stretch; background: none; }
.card:hover:not([disabled]), .card:focus-visible { border-image-source: url("./art/ui/button-lit.webp"); color: #0b1020; outline: none; }
.card.locked { opacity: 0.45; cursor: not-allowed; }
.card-num { font-weight: 700; color: var(--accent); }
.card-body { display: flex; flex-direction: column; min-width: 0; }
.card-body strong { overflow-wrap: anywhere; }
.card:hover:not([disabled]) .sub, .card:focus-visible .sub { color: #26324a; }
/* A gamepad moves focus without a key press, so the lit state follows plain focus while the pad is in use. */
.shell[data-pad="on"] .btn:focus, .shell[data-pad="on"] .card:focus { border-image-source: url("./art/ui/button-lit.webp"); color: #0b1020; outline: none; }
.shell[data-pad="on"] .card:focus .sub { color: #26324a; }
.shell[data-pad="on"] input:focus, .shell[data-pad="on"] select:focus, .shell[data-pad="on"] a.link:focus { outline: 2px solid #ffd56a; outline-offset: 3px; }
.medal-empty { width: 30px; height: 30px; border-radius: 50%; border: 2px dashed rgba(157, 178, 212, 0.4); }

/* briefing */
.briefing { --accent: #ffb04a; }
.dispatch { margin: 10px 0; padding: 8px 14px; border-left: 3px solid var(--accent); background: rgba(7, 14, 32, 0.6); }
.dispatch p { margin: 4px 0 0; }
.tip { color: var(--dim); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.check input { width: 22px; height: 22px; }

/* result */
.medal-big { display: flex; align-items: center; gap: 16px; margin: 6px 0; }
.medal-big strong { font-size: 1.6rem; letter-spacing: 0.08em; text-transform: uppercase; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 10px 0; }
.facts div { background: rgba(120, 160, 220, 0.12); padding: 8px 12px; border-radius: 6px; }
.facts dt { color: var(--dim); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.facts dd { margin: 0; font-size: 1.4rem; font-weight: 700; }
.credits { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }

/* hangar */
.slot { margin-bottom: 12px; }
.modules { display: grid; gap: 8px; }
.module { display: grid; grid-template-columns: 60px 1fr auto; gap: 12px; align-items: center; padding: 8px 12px; background: rgba(120, 160, 220, 0.1); border-radius: 8px; border: 1px solid transparent; }
.module.fitted { border-color: var(--accent); }
.module p { margin: 2px 0; color: var(--dim); font-size: 0.9rem; }
.credits .ico { margin-right: 4px; }

/* options */
fieldset { border: 1px solid rgba(157, 178, 212, 0.3); border-radius: 8px; margin: 0 0 12px; padding: 8px 14px 12px; }
legend { padding: 0 8px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.85rem; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 44px; }
.field input[type="range"] { width: min(260px, 50%); accent-color: var(--accent); }
.field select { min-height: 40px; background: #0b1428; border: 1px solid var(--dim); border-radius: 6px; padding: 4px 8px; }
.field.check { justify-content: flex-start; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.dialog { margin: auto; width: min(420px, 100%); display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--panel); text-align: center; }
.screen-pause { display: flex; }

/* The link back to the game's page (added by the site) sits top left, where the objective is in flight: it steps aside while a flight runs. */
body:has(.shell[data-view="play"]:not([data-paused])) .exit-link { display: none; }

/* hud */
.hud { position: absolute; inset: 0; pointer-events: none; padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 10px) 0 calc(env(safe-area-inset-left) + 10px); }
.hud-bar { display: flex; gap: 8px; align-items: flex-start; }
.hud-goal { flex: 1; min-width: 0; background: var(--panel); }
.goal { margin: 0; font-size: 0.95rem; font-weight: 600; overflow-wrap: anywhere; }
.hud-stats { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--panel); }
.stat { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; }
.stat-clock { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1rem; }
.meter { width: 84px; height: 12px; border-radius: 6px; background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(157, 178, 212, 0.5); overflow: hidden; }
.fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #35b6ff, #6fe4ff); }
.meter-hull .fill { background: linear-gradient(90deg, #3ddc84, #b8f27a); }
.meter-hull.low .fill, .meter-heat.low .fill { background: linear-gradient(90deg, #ff5a4a, #ff9a4a); }
.meter-heat .fill { background: linear-gradient(90deg, #ffb04a, #ff7a3a); }
.meter-boost .fill { background: linear-gradient(90deg, #ffb04a, #ffe08a); }
.pause { pointer-events: auto; flex: none; }
.pause-bars { width: 12px; height: 14px; border-left: 4px solid currentColor; border-right: 4px solid currentColor; margin-right: 8px; }
.toast { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); margin: 0; max-width: min(520px, 90%); text-align: center; padding: 6px 16px; background: var(--panel); border-radius: 8px; opacity: 0; transition: opacity 0.25s; font-weight: 600; }
.toast.show { opacity: 1; }

/* touch: a stick on the left, hold buttons on the right */
.touch { position: absolute; left: 0; right: 0; bottom: 0; pointer-events: none; padding: 0 calc(env(safe-area-inset-right) + 14px) calc(env(safe-area-inset-bottom) + 12px) calc(env(safe-area-inset-left) + 14px); }
.touch-deck { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.stick { pointer-events: auto; touch-action: none; position: relative; width: 150px; height: 150px; background: url("./art/ui/stick-base.webp") center / contain no-repeat; }
.stick .knob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; background: url("./art/ui/stick-knob.webp") center / contain no-repeat; transform: translate(var(--sx, 0), var(--sy, 0)); }
.touch-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; max-width: 60%; }
.tbtn { pointer-events: auto; touch-action: none; appearance: none; min-width: 74px; min-height: 74px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 4px 8px; border: 12px solid transparent; border-image: url("./art/ui/button.webp") 44 fill / 12px stretch; background: none; font-size: 0.72rem; }
.tbtn.is-down { border-image-source: url("./art/ui/button-pressed.webp"); }
.tbtn .ico { width: 30px; height: 30px; }
.shell[data-touch="off"] .touch { display: none; }
.shell[data-layout="portrait"][data-touch="on"] .touch { background: linear-gradient(0deg, #050813 70%, rgba(5, 8, 19, 0)); padding-top: 8px; height: var(--deck-h); display: flex; align-items: flex-end; }
.shell[data-layout="portrait"][data-touch="on"] .touch-deck { width: 100%; }
.hud .panel { border-width: 10px; border-image-width: 10px; padding: 0 4px; }
.shell[data-layout="portrait"] .hud-bar { flex-wrap: wrap; gap: 4px; }
.shell[data-layout="portrait"] .hud-goal { flex: 1 1 100%; }
.shell[data-layout="portrait"] .hud-stats { flex: 1 1 0; gap: 8px; }
.shell[data-layout="portrait"] .goal { font-size: 0.8rem; }
.shell[data-layout="portrait"][data-view="play"] .view { top: 98px; height: calc(100% - 98px); }
.shell[data-layout="portrait"][data-touch="on"][data-view="play"] .view { height: calc(100% - 98px - var(--deck-h)); }
.shell[data-layout="portrait"] .grid2 { grid-template-columns: 1fr; }
.shell[data-paused] .view { filter: brightness(0.55); }

@media (max-height: 500px) {
  html, body { font-size: 14px; }
  .btn { min-height: 40px; padding: 2px 18px; }
  .stick { width: 120px; height: 120px; }
  .tbtn { min-width: 62px; min-height: 62px; }
  .screen { padding: 8px; gap: 4px; }
  .hud-stats { gap: 8px; }
  .meter { width: 64px; }
  .toast { top: 30%; }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .module { grid-template-columns: 48px 1fr; }
  .module > :last-child { grid-column: 1 / -1; }
  .title-menu { left: 14px; right: 14px; width: auto; bottom: 30px; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
.shell[data-reduce-motion="true"] .toast { transition: none; }
[dir="rtl"] .bar { justify-content: flex-start; }
