:root {
  color-scheme: dark;
  --bg: #03050e;
  --panel: rgba(14, 22, 48, 0.9);
  --panel-solid: #0e1630;
  --line: rgba(130, 170, 255, 0.25);
  --text: #eaf2ff;
  --muted: #9fb0d6;
  --kin: #4fd8ff;
  --nuk: #ffc23d;
  --good: #6dffb0;
  --warn: #ffd84d;
  --warn2: #ff9b3d;
  --bad: #ff4d5e;
  --accent: #8a7dff;
  --radius: 14px;
  --font: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation; /* no double-tap zoom */
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
#app { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; display: block; touch-action: none; }
.hidden { display: none !important; }
.grow { flex: 1; }
button { font-family: inherit; color: inherit; cursor: pointer; }
b { font-weight: 600; }

/* ---------- Top bar ---------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(to bottom, rgba(3, 6, 18, 0.92), rgba(3, 6, 18, 0));
  pointer-events: none;
  z-index: 5;
}
#topbar > * { pointer-events: auto; }
#mission-title { display: flex; align-items: baseline; gap: 8px; font-size: 20px; font-weight: 600; white-space: nowrap; }
#mission-num { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
#asteroid-chip { display: flex; gap: 6px; flex-wrap: wrap; }
#asteroid-chip span {
  font-size: 13px; padding: 3px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap;
}
#run-stats { display: flex; gap: 6px; font-size: 15px; font-weight: 600; }
#run-stats span { padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); }
#run-stats .warn { border-color: var(--warn); }
#run-stats .warn2 { border-color: var(--warn2); color: var(--warn2); }
#run-stats .bad { border-color: var(--bad); color: var(--bad); background: rgba(255, 77, 94, 0.15); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(20, 30, 64, 0.85); border: 1px solid var(--line);
  font-size: 17px; font-weight: 700; display: grid; place-items: center; position: relative;
}
.icon-btn:hover { background: rgba(40, 56, 110, 0.95); }
#btn-book[data-count]::after {
  content: attr(data-count);
  position: absolute; top: -4px; right: -4px;
  font-size: 10px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--accent); color: #fff; display: grid; place-items: center;
}

/* ---------- Bottom bars ---------- */
.bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 10px max(14px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px));
  background: linear-gradient(to top, rgba(3, 6, 18, 0.95), rgba(3, 6, 18, 0.6) 70%, rgba(3, 6, 18, 0));
  z-index: 5;
}
.pen-btn {
  touch-action: none; /* lets a finger drag it into the zone */
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 10px; border-radius: var(--radius);
  background: var(--panel); border: 2px solid var(--line);
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.pen-btn:hover { transform: translateY(-2px); }
.pen-btn .pb-ico { font-size: 26px; }
.pen-btn .pb-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.pen-btn .pb-txt b { font-size: 15px; }
.pen-btn .count { font-size: 13px; color: var(--muted); }
.pen-btn.kin.armed { border-color: var(--kin); box-shadow: 0 0 18px rgba(79, 216, 255, 0.5); }
.pen-btn.nuk.armed { border-color: var(--nuk); box-shadow: 0 0 18px rgba(255, 194, 61, 0.5); }
.pen-btn.kin b { color: var(--kin); }
.pen-btn.nuk b { color: var(--nuk); }
.pen-btn.empty { opacity: 0.45; }
.launch {
  white-space: nowrap; flex: none;
  font-size: 20px; font-weight: 700; letter-spacing: 0.04em;
  padding: 12px 26px; border-radius: 999px; border: none;
  background: linear-gradient(135deg, #ff7a3d, #ff3d6e); color: #fff;
  box-shadow: 0 4px 22px rgba(255, 80, 90, 0.35);
  opacity: 0.55; transition: transform 0.12s, opacity 0.2s;
}
.launch.ready { opacity: 1; animation: glow 1.6s ease-in-out infinite; }
.launch:hover { transform: scale(1.05); }
@keyframes glow { 50% { box-shadow: 0 4px 34px rgba(255, 110, 80, 0.75); } }

#speed-btns { display: flex; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
#speed-btns button { background: var(--panel); border: none; padding: 8px 12px; font-size: 14px; font-weight: 600; color: var(--muted); }
#speed-btns button.on { background: #2c3e7a; color: #fff; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
#damage-meter { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
#damage-meter b { min-width: 58px; color: var(--text); }
.bar-out, .dmg-bar { width: 160px; height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.fill { height: 100%; width: 0; border-radius: 6px; transition: width 0.3s; }
.fill.ok { background: var(--good); }
.fill.warn { background: var(--warn); }
.fill.warn2 { background: var(--warn2); }
.fill.bad { background: var(--bad); }

/* ---------- Mission computer: a small pill above the bottom bar ---------- */
#timeline {
  position: absolute; right: max(14px, env(safe-area-inset-right, 0px)); bottom: 76px;
  display: flex; align-items: center; gap: 6px;
  padding: 3px 4px 3px 10px; border-radius: 999px; z-index: 5;
  background: var(--panel); border: 1px solid rgba(110, 215, 255, 0.45);
  box-shadow: 0 0 14px rgba(80, 190, 255, 0.15); font-size: 13px; white-space: nowrap;
}
.tl-ico { font-size: 16px; }
#tl-play, #tl-close { width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.08); font-size: 12px; }
#tl-close { background: transparent; color: var(--muted); font-size: 14px; }
#tl-slider { width: min(220px, 22vw); accent-color: #6fd6ff; }
#tl-time { min-width: 52px; font-weight: 600; color: #cfefff; font-variant-numeric: tabular-nums; }
#tl-status { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); }
#tl-status.ready { background: var(--good); }
#tl-status.busy { background: var(--warn); animation: blink 0.6s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: 0.3; } }

/* ---------- Detonate button ---------- */
#btn-detonate {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 14px 28px; border-radius: 999px; border: 3px solid #ffd0d0;
  background: radial-gradient(circle at 30% 30%, #ff6b5d, #c0141f);
  color: #fff; font-size: 22px; font-weight: 700; letter-spacing: 0.05em;
  box-shadow: 0 6px 26px rgba(255, 40, 40, 0.5);
  z-index: 6;
}
#btn-detonate small { font-size: 11px; opacity: 0.8; border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 5px; padding: 1px 5px; }
#btn-detonate.pulse { animation: pulse 0.55s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: translateX(-50%) scale(1.12); box-shadow: 0 6px 40px rgba(255, 60, 60, 0.9); } }

/* ---------- Docked controls for the selected penetrator ---------- */
.pb-n { display: none; font-weight: 700; font-size: 16px; min-width: 14px; text-align: center; }
.pen-btn.kin .pb-n { color: var(--kin); }
.pen-btn.nuk .pb-n { color: var(--nuk); }
/* while a penetrator is selected, the add buttons shrink to icon + number */
#palette.inspecting .pen-btn { padding: 6px 10px; gap: 6px; }
#palette.inspecting .pen-btn .pb-txt { display: none; }
#palette.inspecting .pen-btn .pb-n { display: block; }
#palette.inspecting #btn-clear { display: none; }
#palette.inspecting .launch { padding: 12px 20px; font-size: 18px; }
@media (max-width: 1150px) {
  .insp-info > span:first-child { display: none; }
}
@media (max-width: 1060px) {
  .fuse-cur small { display: none; }
  #palette.inspecting .pen-btn { padding: 6px 8px; }
}
#dock { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.dock-idle { color: var(--muted); font-size: 14px; white-space: nowrap; }
.dock-idle b { color: var(--text); }
.insp-id {
  font-weight: 700; font-size: 17px; padding: 6px 10px; border-radius: 10px; white-space: nowrap;
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line);
}
.insp-id.kin { color: var(--kin); }
.insp-id.nuk { color: var(--nuk); }
.insp-info { display: flex; flex-direction: column; line-height: 1.25; font-size: 13px; color: var(--muted); white-space: nowrap; }
.insp-info .ok { color: var(--good); }
.insp-info .bad { color: var(--bad); font-weight: 600; }
.insp-meters { display: grid; grid-template-columns: auto 52px; gap: 3px 5px; align-items: center; font-size: 11px; }
.insp-meters .m { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.insp-meters i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #6dffb0, #ffd84d, #ff6b5d); }
.insp-group {
  display: flex; align-items: center; gap: 2px; padding: 2px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
}
.insp-group button {
  min-width: 36px; height: 36px; padding: 0 6px; border-radius: 9px; border: 1px solid transparent; white-space: nowrap;
  background: transparent; font-size: 16px; line-height: 1;
}
.insp-group button:hover { background: rgba(255, 255, 255, 0.12); }
.insp-group button.on { background: rgba(255, 194, 61, 0.2); border-color: var(--nuk); }
.insp-group button.done { color: var(--good); font-weight: 700; font-size: 18px; }
.insp-group b { min-width: 58px; text-align: center; color: #ffe9a8; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fuse-cur { display: flex; align-items: center; gap: 5px; color: var(--nuk); }
.fuse-cur small { font-size: 13px; font-weight: 600; }
#fuse-pop {
  position: absolute; z-index: 9; width: min(320px, calc(100vw - 16px));
  display: flex; flex-direction: column; gap: 4px; padding: 6px;
  background: var(--panel-solid); border: 1px solid var(--nuk); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}
#fuse-pop button {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 8px 10px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; font-size: 13px; color: var(--muted); line-height: 1.3;
}
#fuse-pop button b { color: var(--text); font-size: 15px; }
#fuse-pop button:hover { background: rgba(255, 255, 255, 0.08); }
#fuse-pop button.on { border-color: var(--nuk); background: rgba(255, 194, 61, 0.12); }
#fuse-pop .fi { font-size: 24px; width: 30px; text-align: center; flex: none; }
.touch #fuse-pop button { padding: 11px 12px; }
.dock-btn {
  width: 44px; height: 44px; flex: none; border-radius: 12px; font-size: 20px;
  background: var(--panel); border: 1px solid var(--line);
}
.dock-btn.on { border-color: #6fd6ff; box-shadow: 0 0 12px rgba(111, 214, 255, 0.45); }
.dock-btn.busy { animation: busy 0.9s ease-in-out infinite alternate; }
@keyframes busy { to { box-shadow: 0 0 14px rgba(255, 216, 77, 0.6); } }

/* ---------- Hints & toasts ---------- */
#hint {
  position: absolute; left: 50%; top: 58px; transform: translateX(-50%);
  max-width: min(640px, 92vw);
  background: rgba(20, 32, 80, 0.94); border: 1px solid rgba(140, 170, 255, 0.5);
  border-radius: var(--radius); padding: 10px 18px; font-size: 16px; text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); z-index: 7; pointer-events: none;
  animation: drop 0.35s ease-out;
}
@keyframes drop { from { opacity: 0; transform: translate(-50%, -10px); } }
.tut-glow { animation: tutglow 1s ease-in-out infinite alternate !important; }
@keyframes tutglow { to { box-shadow: 0 0 0 4px rgba(110, 255, 180, 0.9), 0 0 30px rgba(110, 255, 180, 0.8); } }
#toasts { position: absolute; left: calc(14px + env(safe-area-inset-left, 0px)); bottom: 90px; display: flex; flex-direction: column; gap: 8px; z-index: 8; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 340px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 14px; font-size: 14px;
  opacity: 0; transform: translateX(-20px); transition: opacity 0.3s, transform 0.3s;
}
.toast.show { opacity: 1; transform: none; }
.toast.fact { border-color: var(--accent); cursor: pointer; }
.toast .t-ico { font-size: 26px; }

/* ---------- Modals ---------- */
#overlay {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(2, 4, 12, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 24px 12px;
  touch-action: pan-y;
}
.modal {
  width: min(880px, 100%); margin: auto;
  background: linear-gradient(160deg, rgba(20, 30, 66, 0.97), rgba(10, 15, 36, 0.97));
  border: 1px solid var(--line); border-radius: 22px;
  padding: 22px 26px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: pop 0.25s ease-out;
  user-select: text; -webkit-user-select: text;
}
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
.modal h2 { margin: 0 0 6px; font-size: 28px; }
.modal h3 { margin: 16px 0 6px; font-size: 18px; color: #c9d6ff; }
.modal p { line-height: 1.45; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--muted); opacity: 0.8; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.row.wrap { flex-wrap: wrap; }
.btn {
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 18px; font-size: 16px; font-weight: 500;
  transition: background 0.12s, transform 0.12s;
}
.btn:hover { background: rgba(255, 255, 255, 0.16); transform: translateY(-1px); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.primary { background: linear-gradient(135deg, #5b6cff, #8a4dff); border-color: transparent; font-weight: 600; }
.btn.go { background: linear-gradient(135deg, #23c483, #1aa0b8); border-color: transparent; font-weight: 600; }
.btn.big { font-size: 19px; padding: 12px 24px; }
.btn small { opacity: 0.75; font-size: 12px; }
.link { background: none; border: none; color: var(--muted); text-decoration: underline; font-size: 14px; }
.badge { font-size: 13px; background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.kin { color: var(--kin); }
.nuk { color: var(--nuk); }

/* title */
.modal.title {
  width: min(560px, 100%); text-align: center; margin-left: 4vw; margin-right: auto;
  background: linear-gradient(160deg, rgba(20, 30, 66, 0.86), rgba(10, 15, 36, 0.86));
  backdrop-filter: blur(4px);
}
#overlay:has(.modal.title) { background: transparent; align-items: center; }
.logo { display: flex; flex-direction: column; line-height: 0.95; margin: 6px 0 8px; }
.logo .l1 { font-size: 30px; letter-spacing: 0.5em; color: #9fd8ff; padding-left: 0.5em; }
.logo .l2 {
  font-size: 64px; font-weight: 700; letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff 20%, #ffb35c 60%, #ff5d3d);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255, 120, 60, 0.4));
}
.subtitle { color: var(--muted); font-size: 16px; margin-bottom: 8px; }
.lead { font-size: 16.5px; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; margin: 18px auto 6px; max-width: 340px; }

/* levels */
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.level-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 8px 10px; transition: transform 0.12s, background 0.12s;
}
.level-card:hover:not(.locked) { transform: translateY(-3px); background: rgba(255, 255, 255, 0.12); }
.level-card.locked { opacity: 0.45; cursor: not-allowed; }
.lv-num { position: absolute; top: 8px; left: 11px; font-weight: 700; color: var(--muted); }
.lv-icon { font-size: 34px; }
.lv-name { font-weight: 600; font-size: 15.5px; text-align: center; }
.lv-inv { font-size: 12.5px; color: var(--muted); }
.stars i { font-style: normal; color: rgba(255, 255, 255, 0.18); font-size: 18px; }
.stars i.on { color: #ffd84d; text-shadow: 0 0 8px rgba(255, 216, 77, 0.6); }

/* briefing */
.brief-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brief-head h2 { margin: 0; }
.pill.goal { background: rgba(110, 255, 180, 0.16); color: #9dffd0; }
.pill { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: rgba(138, 125, 255, 0.25); color: #cfc8ff; text-transform: uppercase; letter-spacing: 0.06em; }
.brief-text { font-size: 17px; }
.brief-cols { display: grid; grid-template-columns: 250px 1fr; gap: 22px; }
.ast-cards { display: flex; flex-direction: column; gap: 12px; }
.ast-card { background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.ast-preview { width: 100%; aspect-ratio: 1; display: block; }
.ast-name { font-weight: 600; font-size: 17px; margin-top: 4px; }
.layers { list-style: none; padding: 0; margin: 6px 0; font-size: 13.5px; color: var(--muted); }
.layers li { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; border: 1px solid rgba(255, 255, 255, 0.3); }
.ast-stats { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.ast-stats b { color: var(--text); }
.brief-info h3:first-child { margin-top: 0; }
.brief-info p { margin: 4px 0; }
.real { color: var(--muted); font-size: 14.5px; }
.swarm { display: flex; flex-direction: column; gap: 3px; font-weight: 600; }
.tip { margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: rgba(255, 216, 77, 0.1); border: 1px solid rgba(255, 216, 77, 0.35); }
.factline { margin-top: 12px; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { background: rgba(138, 125, 255, 0.15); border: 1px solid rgba(138, 125, 255, 0.4); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.chip em { color: var(--good); font-style: normal; font-weight: 600; }

/* results */
.results { text-align: center; }
.big-stars { font-size: 64px; margin: 4px 0 10px; }
.big-stars i { font-style: normal; color: rgba(255, 255, 255, 0.15); display: inline-block; }
.big-stars i.on { color: #ffd84d; text-shadow: 0 0 20px rgba(255, 216, 77, 0.8); animation: starpop 0.5s cubic-bezier(0.3, 1.8, 0.5, 1) both; }
@keyframes starpop { from { transform: scale(0) rotate(-90deg); opacity: 0; } }
.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; text-align: left; }
.res-row { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.res-row.bad { border-color: rgba(255, 77, 94, 0.6); background: rgba(255, 77, 94, 0.08); }
.res-ico { font-size: 26px; }
.res-n { font-size: 26px; font-weight: 700; min-width: 40px; text-align: center; }
.res-txt { font-size: 13.5px; color: var(--muted); }
.res-txt b { color: var(--text); font-size: 15px; }
.dmg { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 0 4px; color: var(--muted); }
.dmg-bar { width: 260px; height: 14px; }
.advice { margin: 12px auto 0; max-width: 620px; padding: 10px 14px; border-radius: 12px; background: rgba(110, 255, 180, 0.08); border: 1px solid rgba(110, 255, 180, 0.3); text-align: left; }

/* help */
.steps { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 9px 12px; }
.s-ico { font-size: 24px; width: 32px; text-align: center; flex: none; }
.outcomes { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.outcomes td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.outcomes td:first-child { font-size: 22px; width: 36px; }
.outcomes td:nth-child(2) { white-space: nowrap; }

/* logbook */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 12px; }
.fact { display: flex; gap: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.fact.focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(138, 125, 255, 0.5); }
.fact.locked { opacity: 0.45; }
.f-ico { font-size: 30px; flex: none; }
.fact h4 { margin: 0 0 4px; font-size: 16px; }
.fact p { margin: 0; font-size: 14px; color: #c8d3f0; }

/* sandbox */
.sb-group h3 { margin-top: 14px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 15px; }
.opt.on { border-color: var(--accent); background: rgba(138, 125, 255, 0.25); }
.steppers { display: flex; gap: 16px; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; background: rgba(255, 255, 255, 0.05); padding: 6px 10px; border-radius: 12px; }
.stepper button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.1); font-size: 18px; }
.stepper b { min-width: 22px; text-align: center; color: var(--text); }

/* ---------- Portrait phones ---------- */
#rotate-hint {
  display: none; position: absolute; left: 50%; top: calc(56px + env(safe-area-inset-top, 0px)); transform: translateX(-50%);
  z-index: 30; padding: 8px 14px; border-radius: 999px; font-size: 14px; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line); color: var(--text); pointer-events: none;
}
@media (orientation: portrait) and (max-width: 1100px) {
  #rotate-hint { display: block; }
}

/* ---------- Touch screens (iPad): finger-sized controls ---------- */
.touch .icon-btn { width: 46px; height: 46px; font-size: 20px; }
.touch .pen-btn { min-height: 58px; padding: 8px 18px 8px 12px; }
.touch .pen-btn .pb-ico { font-size: 30px; }
.touch .launch { padding: 15px 30px; }
.touch #palette.inspecting .launch { padding: 13px 20px; }
.touch #speed-btns button { padding: 11px 15px; font-size: 15px; }
.touch .toggle input { width: 22px; height: 22px; }
.touch #run-stats span { padding: 6px 10px; }
.touch .insp-group button { min-width: 44px; height: 44px; font-size: 19px; }
.touch #tl-play, .touch #tl-close { width: 40px; height: 40px; }
.touch #tl-slider { -webkit-appearance: none; appearance: none; height: 40px; background: transparent; }
.touch #tl-slider::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: rgba(110, 215, 255, 0.35); }
.touch #tl-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%; background: #6fd6ff; border: 3px solid #0e1630; }
.touch #btn-detonate { padding: 18px 34px; font-size: 24px; }
.touch #btn-detonate small { display: none; }
.touch .opt { padding: 12px 16px; }
.touch .stepper button { width: 46px; height: 46px; font-size: 22px; }
.touch .btn { min-height: 46px; }
.touch .toast { padding: 12px 16px; }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .brief-cols { grid-template-columns: 1fr; }
  .ast-cards { flex-direction: row; flex-wrap: wrap; }
  .ast-card { flex: 1 1 200px; }
  .modal { padding: 16px; }
  .logo .l2 { font-size: 48px; }
  #asteroid-chip { display: none; }
  .pen-btn .pb-txt b { font-size: 13px; }
}
@media (max-width: 640px) {
  #mission-num, #btn-clear, .pen-btn .pb-txt, .tl-ico, .insp-meters, .dock-idle, #damage-meter > span, .toggle { display: none !important; }
  .pen-btn .pb-n { display: block; }
  #palette.inspecting .pen-btn, #palette.inspecting .dock-btn { display: none; }
  .bar, #topbar { gap: 6px; }
  .pen-btn { padding: 4px 10px 4px 6px; }
  .launch { font-size: 15px; padding: 8px 14px; }
  #speed-btns button { padding: 6px 8px; font-size: 12px; }
  .bar-out { width: 80px; }
  #run-stats { gap: 3px; font-size: 12px; flex-wrap: wrap; }
  #run-stats span { padding: 2px 6px; }
  #tl-slider { width: 30vw; }
}
@media (max-height: 560px) {
  #topbar { padding: 4px 8px; }
  .icon-btn { width: 32px; height: 32px; font-size: 15px; }
  #mission-title { font-size: 16px; }
  .bar { padding: 5px 8px; }
  .pen-btn { padding: 4px 10px 4px 6px; }
  .pen-btn .pb-ico { font-size: 20px; }
  .launch { font-size: 16px; padding: 8px 18px; }
  #btn-detonate { bottom: 56px; font-size: 18px; padding: 10px 20px; }
  #hint { top: 44px; font-size: 14px; }
  #run-stats { font-size: 13px; }
}
