:root {
  --bg: #070b10;
  --panel: rgba(9, 15, 21, 0.9);
  --panel2: rgba(18, 28, 37, 0.92);
  --line: rgba(190, 220, 235, 0.14);
  --ink: #e9eef2;
  --muted: #9aaab5;
  --amber: #ffc23d;
  --cyan: #5fd4ff;
  --mint: #6fe6c6;
  --red: #ff4d4d;
  --orange: #ff9a3d;
  --on-amber: #1b1406;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: "Titillium Web", system-ui, -apple-system, Segoe UI, sans-serif; -webkit-text-size-adjust: 100%;
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body.touch { -webkit-user-select: none; user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { display: inline-block; min-width: 20px; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; font: 600 12px/18px "Titillium Web", sans-serif; text-align: center; color: var(--ink); background: rgba(255,255,255,0.06); }

#loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--bg); z-index: 50; }
#loading b { font-size: 34px; letter-spacing: 6px; font-weight: 700; }
#loading span { color: var(--muted); }

/* ------------------------------------------------------------ screens */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.screen { position: absolute; inset: 0; display: none; pointer-events: auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 70% 40%, rgba(7,11,16,0.25), rgba(7,11,16,0.8)); }
.screen.active { display: flex; }
.screen > * { margin: auto; }
#title.screen { background: linear-gradient(90deg, rgba(7,11,16,0.94) 0%, rgba(7,11,16,0.72) 42%, rgba(7,11,16,0.08) 100%); gap: 24px; align-items: center; }
.t-main { max-width: 520px; width: 100%; margin: auto auto auto clamp(0px, 5vw, 80px); }
.logo small { color: var(--amber); letter-spacing: 2px; text-transform: uppercase; font-size: 12px; font-weight: 600; }
.logo h1 { margin: 6px 0 10px; font-size: clamp(44px, 8vw, 82px); line-height: 0.9; letter-spacing: 1px; font-weight: 700; }
.logo h1 span { color: var(--amber); }
.story { color: #c9d5dc; font-size: 15px; line-height: 1.5; margin: 0 0 16px; max-width: 480px; }
.challenge:empty { display: none; }
.challenge { background: rgba(255,194,61,0.12); border: 1px solid rgba(255,194,61,0.4); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu .row { display: flex; gap: 8px; }
.menu .row button { flex: 1; }
.menu button, .e-buttons button, .panel button.primary { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 11px 16px; text-align: left; font-size: 17px; font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.1s; }
.menu button small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.menu button:hover, .e-buttons button:hover { border-color: rgba(255,194,61,0.6); background: rgba(30,42,52,0.95); }
.menu button:active { transform: translateY(1px); }
button.primary { background: var(--amber) !important; color: var(--on-amber) !important; border-color: var(--amber) !important; }
button.primary small { color: rgba(27,20,6,0.75) !important; }
button.primary:hover { filter: brightness(1.06); }
.disclaimer { color: var(--muted); font-size: 12px; margin-top: 14px; line-height: 1.45; }
.disclaimer a { color: var(--muted); }
.rank { margin-top: 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 14px; }
.rank span { color: var(--muted); }
.rank i, .xp i { grid-column: 1 / -1; height: 5px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; display: block; }
.rank u, .xp u { display: block; height: 100%; background: var(--amber); }
.t-side { width: 320px; max-width: 100%; margin: auto clamp(0px, 4vw, 60px) auto auto; display: flex; flex-direction: column; gap: 10px; }
.t-side > div:empty { display: none; }
.hs-board { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.streak { opacity: 0; transform: translateY(-6px); transition: 0.4s; background: rgba(255,154,61,0.15); border: 1px solid rgba(255,154,61,0.45); border-radius: 8px; padding: 8px 12px; }
.streak.show { opacity: 1; transform: none; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px 20px; width: 100%; max-width: 760px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.panel.wide { max-width: 1040px; }
.panel.narrow { max-width: 380px; }
.panel header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.panel h2 { margin: 0; font-size: 24px; }
.panel h2 small { display: block; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: 0.5px; }
.panel h4 { margin: 14px 0 6px; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--amber); }
.panel p { line-height: 1.5; color: #cfd9df; }
.lead { margin-top: 0; color: var(--muted) !important; }
button.ghost { background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; color: var(--muted); }
button.ghost:hover { color: var(--ink); border-color: var(--muted); }
.big { width: 100%; margin-top: 16px; padding: 14px !important; text-align: center !important; font-size: 19px !important; }

.flist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.fcard { text-align: left; background: var(--panel2); border: 1px solid var(--line); border-top: 4px solid var(--fc); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 3px; transition: transform 0.15s, border-color 0.15s; }
.fcard:hover { transform: translateY(-2px); border-color: var(--fc); }
.fcard i { font-style: normal; font-size: 28px; color: var(--fc); }
.fcard h3 { margin: 2px 0 0; font-size: 21px; }
.fcard b { font-size: 14px; } .fcard small { color: var(--muted); }
.fcard p { font-size: 13.5px; margin: 8px 0; flex: 1; }
.fcard em { font-style: normal; color: var(--amber); font-weight: 700; }

.mlist { display: flex; flex-direction: column; gap: 8px; }
.mcard { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.mcard:hover:not(:disabled) { border-color: rgba(255,194,61,0.6); }
.mcard .n { font-size: 26px; font-weight: 700; color: var(--amber); text-align: center; }
.mcard .t b { display: block; font-size: 17px; } .mcard .t small { color: var(--muted); }
.mcard .s { text-align: right; } .mcard .s small { display: block; color: var(--muted); font-size: 12px; }
.mcard.locked { opacity: 0.45; cursor: not-allowed; }
i.on, .stars i.on { color: var(--amber); }
.mcard .s i, .b-stars i { font-style: normal; color: rgba(255,255,255,0.18); font-size: 18px; }

.b-meta { color: var(--muted); font-size: 14px; }
.b-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; }
.b-grid ul { margin: 0; padding-left: 18px; line-height: 1.5; }
.b-obj { list-style: none; padding: 0 !important; }
.b-obj li.bonus { color: var(--amber); }
.tips li { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.b-load { background: rgba(255,194,61,0.06); border: 1px solid rgba(255,194,61,0.25); border-radius: 10px; padding: 2px 12px 12px; }
.b-load:empty { display: none; }
.b-load p { font-size: 13.5px; margin: 0 0 8px; }
.split { display: flex; align-items: center; gap: 10px; }
.split input { flex: 1; accent-color: var(--amber); }
.chk { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 14px; color: var(--muted); }
.fits { display: grid; gap: 6px; }
.fit { text-align: left; background: rgba(255,255,255,0.03); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.fit b { display: block; font-size: 14.5px; } .fit small { color: var(--muted); font-size: 12.5px; }
.fit.on { border-color: var(--amber); background: rgba(255,194,61,0.12); }
.b-stars { margin-top: 14px; color: var(--muted); }

.panel.end { max-width: 820px; text-align: center; }
.end h2 { font-size: 30px; }
.reason { color: var(--red) !important; margin: 4px 0; }
.reason:empty { display: none; }
.stars { font-size: 52px; letter-spacing: 6px; margin: 4px 0; }
.stars:empty { display: none; }
.stars i { font-style: normal; color: rgba(255,255,255,0.14); display: inline-block; transition: transform 0.35s cubic-bezier(.2,1.8,.4,1), color 0.2s; }
.stars i.on { color: var(--amber); transform: scale(1.18); text-shadow: 0 0 22px rgba(255,194,61,0.6); }
.score small { display: block; color: var(--muted); letter-spacing: 2px; font-size: 12px; }
.score b { font-size: 44px; font-variant-numeric: tabular-nums; }
.near { color: var(--orange) !important; margin: 4px 0 10px; }
.near:empty { display: none; }
.e-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; text-align: left; }
.e-obj, .e-break { list-style: none; padding: 0; margin: 0 0 10px; font-size: 14px; }
.e-obj li { padding: 2px 0; } .e-obj li.done { color: var(--mint); } .e-obj li.failed, .e-obj li.active { color: var(--muted); }
.e-break li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 3px 0; color: var(--muted); }
.e-break b { color: var(--ink); font-variant-numeric: tabular-nums; }
.e-reward { display: flex; flex-direction: column; gap: 10px; }
.merit { font-size: 20px; font-weight: 700; color: var(--amber); }
.merit em { font-style: normal; font-size: 12px; background: rgba(255,194,61,0.15); color: var(--amber); border-radius: 4px; padding: 1px 6px; margin-left: 4px; }
.crate { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); animation: pulse 1.4s infinite; }
.crate i { grid-row: span 2; font-style: normal; font-size: 32px; } .crate small { color: var(--muted); }
.crate.rare { border-color: var(--cyan); } .crate.epic { border-color: #c07bff; box-shadow: 0 0 22px rgba(192,123,255,0.35); }
.crate.open { animation: pop 0.45s; } .crate.open b { color: var(--amber); }
@keyframes pulse { 50% { transform: scale(1.03); } }
@keyframes pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.xp { display: grid; grid-template-columns: 1fr auto; gap: 4px; font-weight: 600; }
.xp span { color: var(--mint); }
.xp .up { grid-column: 1 / -1; font-style: normal; color: var(--amber); font-size: 18px; animation: pop 0.6s; }
.intel { border: 1px dashed rgba(111,230,198,0.5); border-radius: 10px; padding: 10px 12px; background: rgba(111,230,198,0.06); animation: pop 0.5s; }
.intel small { color: var(--mint); letter-spacing: 1.5px; font-size: 11px; } .intel p { margin: 4px 0 0; font-size: 13.5px; }
.e-board { color: var(--muted) !important; font-size: 14px; min-height: 1em; }
.e-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.e-buttons button { text-align: center; min-width: 120px; }

.ulist section { margin-bottom: 8px; }
.up { display: grid; grid-template-columns: 1fr auto 80px; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.up b { display: block; } .up small { color: var(--muted); font-size: 13px; }
.up .lv { display: flex; gap: 4px; } .up .lv i { width: 14px; height: 8px; border-radius: 2px; background: rgba(255,255,255,0.12); } .up .lv i.on { background: var(--amber); }
.up button { background: var(--amber); color: var(--on-amber); border: 0; border-radius: 6px; padding: 7px 10px; font-weight: 700; }
.up button:disabled { background: rgba(255,255,255,0.08); color: var(--muted); cursor: default; }
.ilist { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.icard { background: var(--panel2); border: 1px solid rgba(111,230,198,0.35); border-radius: 10px; padding: 12px; }
.icard small { color: var(--mint); letter-spacing: 1.5px; font-size: 11px; } .icard b { display: block; margin: 2px 0 4px; } .icard p { margin: 0; font-size: 13.5px; }
.icard.locked { border-color: var(--line); opacity: 0.55; } .icard.locked small { color: var(--muted); }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.srow div { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.srow button { background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; color: var(--muted); }
.srow button.on { border-color: var(--amber); color: var(--amber); }
.help { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.keys { list-style: none; padding: 0; margin: 0; font-size: 14px; line-height: 1.5; }
.keys li { margin-bottom: 6px; color: #cfd9df; }
.help p { font-size: 14px; margin: 0 0 8px; }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-size: 13px; text-shadow: 0 1px 2px rgba(0,0,0,0.8); }
#hud > div, #hud > canvas { position: absolute; }
.h-tl { top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); width: min(330px, 34vw); }
.h-mission { font-size: 17px; font-weight: 700; }
.h-mission small { display: block; font-size: 11px; color: var(--amber); letter-spacing: 1px; text-transform: uppercase; font-weight: 600; }
.h-obj { list-style: none; padding: 0; margin: 6px 0 0; background: rgba(6,10,14,0.5); border-radius: 8px; padding: 6px 9px; }
.h-obj li { display: grid; grid-template-columns: 16px 1fr; gap: 0 4px; padding: 2px 0; line-height: 1.3; }
.h-obj li i { font-style: normal; color: var(--ink); }
.h-obj li.bonus i { color: var(--amber); }
.h-obj li.done { color: var(--mint); } .h-obj li.done i { color: var(--mint); }
.h-obj li.failed { color: #8a949b; text-decoration: line-through; } .h-obj li.failed i { color: var(--red); }
.h-obj li b { color: var(--amber); font-weight: 600; }
.h-obj li em { grid-column: 2; height: 3px; background: rgba(255,255,255,0.12); border-radius: 2px; overflow: hidden; margin-top: 2px; }
.h-obj li em u { display: block; height: 100%; background: var(--amber); transition: width 0.3s; }
.h-tc { top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); text-align: center; }
.h-compass { width: 420px; max-width: 46vw; height: 40px; border-radius: 6px; }
.h-clock { font-weight: 600; color: var(--muted); } .h-clock b { color: var(--amber); }
.h-tr { top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); width: min(360px, 34vw); }
.h-tension { background: rgba(6,10,14,0.55); border-radius: 8px; padding: 6px 9px; }
.no-tension .h-tension { display: none; }
.h-tl-label { font-weight: 700; letter-spacing: 1.5px; font-size: 11px; display: flex; justify-content: space-between; }
.h-tl-label b { font-size: 14px; }
.h-tbar { position: relative; height: 7px; background: rgba(255,255,255,0.1); border-radius: 4px; margin-top: 3px; overflow: hidden; }
.h-tbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #ffd23f, #ff7a45, #ff3030); transition: width 0.3s; }
.h-tension.hot .h-tl-label { color: var(--orange); }
.h-tension.crit { animation: crit 0.8s infinite; } .h-tension.crit .h-tl-label { color: var(--red); }
@keyframes crit { 50% { background: rgba(120,10,10,0.6); } }
.h-radio { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.rmsg { background: rgba(6,10,14,0.62); border-left: 3px solid #788691; border-radius: 4px; padding: 4px 7px; line-height: 1.35; transition: opacity 1s; animation: rin 0.3s; }
.rmsg.old { opacity: 0.45; }
.rmsg .ch { font-size: 10px; color: var(--muted); margin-right: 5px; letter-spacing: 0.5px; }
.rmsg .from { color: #d3dde3; }
.rmsg .tag { background: #788691; color: #000; border-radius: 3px; padding: 0 4px; margin-right: 5px; font-size: 10.5px; text-shadow: none; }
.rmsg.warn { border-color: var(--orange); } .rmsg.warn .tag { background: var(--orange); }
.rmsg.mayday { border-color: var(--red); background: rgba(60,6,6,0.7); } .rmsg.mayday .tag { background: var(--red); animation: blink 0.6s 6; }
.rmsg.pan { border-color: var(--orange); } .rmsg.pan .tag { background: var(--orange); }
.rmsg.sec { border-color: var(--cyan); } .rmsg.sec .tag { background: var(--cyan); }
.rmsg.navy { border-color: var(--cyan); }
.rmsg.order { border-color: var(--amber); } .rmsg.order .tag { background: var(--amber); }
.rmsg.you { border-color: var(--mint); } .rmsg.you .from { color: var(--mint); }
.rmsg.intel { border-color: var(--mint); background: rgba(6,40,30,0.6); } .rmsg.intel .tag { background: var(--mint); }
@keyframes blink { 50% { opacity: 0.2; } }
@keyframes rin { from { transform: translateX(20px); opacity: 0; } }
.h-bl { bottom: max(12px, env(safe-area-inset-bottom)); left: max(12px, env(safe-area-inset-left)); width: 300px; }
.h-keys { display: grid; gap: 1px; margin-bottom: 6px; padding: 5px 8px; width: fit-content; min-width: 200px; background: rgba(6,10,14,0.5); border-radius: 8px; font-size: 11.5px; color: rgba(220,230,235,0.78); }
.h-keys div { display: flex; align-items: center; gap: 8px; }
.h-keys kbd { min-width: 62px; text-align: center; font-size: 10px; line-height: 14px; padding: 0 4px; }
.h-keys div.hot { color: var(--amber); font-weight: 700; animation: keyglow 1.2s ease-in-out infinite; }
.h-keys div.hot kbd { border-color: var(--amber); color: var(--amber); }
.h-keys.min { display: inline-grid; opacity: 0.7; }
@keyframes keyglow { 50% { opacity: 0.55; } }
body.touch .h-keys { display: none; }
@media (max-height: 640px) { .h-keys { display: none; } }
.h-ship { background: rgba(6,10,14,0.6); border-radius: 10px; padding: 8px 10px; }
.sh-name { font-weight: 700; font-size: 14px; }
.sh-row { display: flex; gap: 10px; align-items: center; margin: 2px 0 4px; }
.sh-speed b { font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; } .sh-speed small { display: block; color: var(--muted); font-weight: 600; }
.sh-tel { list-style: none; margin: 0; padding: 0; font-size: 10px; letter-spacing: 0.5px; flex: 1; }
.sh-tel li { color: rgba(220,230,235,0.32); line-height: 1.25; } .sh-tel li.on { color: var(--amber); font-weight: 700; font-size: 11.5px; }
.sh-bar { position: relative; height: 16px; background: rgba(255,255,255,0.09); border-radius: 4px; overflow: hidden; margin: 3px 0; }
.sh-bar i { position: absolute; inset: 0 auto 0 0; background: var(--mint); opacity: 0.7; transition: width 0.3s; }
.sh-bar span { position: relative; z-index: 1; font-size: 11px; font-weight: 700; padding-left: 6px; line-height: 16px; }
.sh-bar.warn i { background: var(--amber); } .sh-bar.crit i { background: var(--red); }
.sh-bar.board i { background: var(--red); animation: blink 0.8s infinite; }
.sh-rud { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: center; font-size: 10px; color: var(--muted); }
.sh-rud div { position: relative; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; }
.sh-rud div::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: rgba(255,255,255,0.4); }
.sh-rud i { position: absolute; top: -3px; width: 4px; height: 12px; margin-left: -2px; background: var(--amber); border-radius: 2px; }
.sh-flags { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font-size: 11px; color: var(--muted); font-weight: 600; }
.sh-flags .bad { color: var(--red); animation: blink 1s infinite; } .sh-flags .ok, .sh-flags b.ok { color: var(--mint); } .sh-flags b { color: var(--ink); }
.h-bc { bottom: max(12px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); pointer-events: auto; }
.h-weapons { display: flex; gap: 6px; }
.wp { position: relative; width: 64px; padding: 4px 6px 5px; background: rgba(6,10,14,0.66); border: 1px solid var(--line); border-radius: 7px; text-align: center; overflow: hidden; cursor: pointer; }
.wp kbd { position: absolute; top: 3px; left: 3px; min-width: 14px; line-height: 13px; font-size: 10px; padding: 0 2px; }
.wp b { display: block; font-size: 11.5px; margin-top: 8px; letter-spacing: 0.5px; }
.wp span { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.wp em { display: block; font-style: normal; font-size: 9.5px; color: var(--mint); font-weight: 700; }
.wp u { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.14); }
.wp.sel { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber) inset; } .wp.sel b { color: var(--amber); }
.wp.empty { opacity: 0.4; }
.h-br { bottom: max(12px, env(safe-area-inset-bottom)); right: max(12px, env(safe-area-inset-right)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.h-radar { width: 220px; height: 220px; }
.h-target { width: 210px; background: rgba(6,10,14,0.66); border-radius: 8px; padding: 7px 10px; }
.h-target.empty { display: none; }
.h-target header { font-weight: 700; letter-spacing: 1.5px; font-size: 11px; }
.h-target header.hostile { color: var(--red); } .h-target header.friend { color: var(--cyan); } .h-target header.unknown { color: var(--amber); } .h-target header.neutral { color: #e8ecef; }
.h-target b { display: block; font-size: 15px; } .h-target small { color: var(--muted); display: block; }
.h-target div { margin-top: 3px; } .h-target em { font-style: normal; } .h-target .bad { color: var(--red); font-weight: 700; }
.tbar { height: 4px; background: rgba(255,255,255,0.12); border-radius: 2px; overflow: hidden; } .tbar i { display: block; height: 100%; background: var(--red); }
.warnlvl { color: var(--orange); font-weight: 700; font-size: 11px; letter-spacing: 1px; }
.h-labels { inset: 0; }
.lbl { position: absolute; left: 0; top: 0; font-size: 11.5px; font-weight: 600; white-space: nowrap; color: #e8ecef; opacity: 0.92; }
.lbl.hostile { color: var(--red); } .lbl.friend { color: var(--cyan); } .lbl.unknown { color: var(--amber); } .lbl.mine { color: var(--orange); }
.lbl.mk { font-size: 12.5px; font-weight: 700; background: rgba(0,0,0,0.35); padding: 0 5px; border-radius: 3px; }
.h-bracket { left: 0; top: 0; }
.h-bracket i { position: absolute; width: 12px; height: 12px; border: 2px solid currentColor; }
.h-bracket .c1 { left: 0; top: 0; border-right: 0; border-bottom: 0; } .h-bracket .c2 { right: 0; top: 0; border-left: 0; border-bottom: 0; }
.h-bracket .c3 { left: 0; bottom: 0; border-right: 0; border-top: 0; } .h-bracket .c4 { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.h-bracket span { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; margin-top: 2px; white-space: nowrap; }
.h-bracket, .h-arrow { color: #e8ecef; } .h-bracket.hostile, .h-arrow.hostile { color: var(--red); } .h-bracket.friend, .h-arrow.friend { color: var(--cyan); } .h-bracket.unknown, .h-arrow.unknown { color: var(--amber); }
.h-arrow { left: -10px; top: -10px; font-size: 20px; }
.h-alert { top: 26%; left: 50%; transform: translate(-50%, -10px); font-size: clamp(22px, 4vw, 40px); font-weight: 700; letter-spacing: 3px; opacity: 0; transition: opacity 0.25s, transform 0.25s; text-align: center; white-space: nowrap; }
.h-alert.show { opacity: 1; transform: translate(-50%, 0); }
.h-alert.bad { color: var(--red); } .h-alert.good { color: var(--mint); } .h-alert.warn { color: var(--orange); } .h-alert.info { color: var(--amber); }
.h-alert.bad.show { animation: blink 0.5s 4; }
.h-toasts { top: 34%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.toast { background: rgba(6,10,14,0.75); padding: 4px 12px; border-radius: 6px; font-weight: 600; transition: opacity 0.5s; white-space: nowrap; }
.toast.good { color: var(--mint); } .toast.bad { color: var(--red); } .toast.warn { color: var(--orange); }
.toast.out { opacity: 0; }
.h-hint { top: 70px; left: 50%; transform: translateX(-50%); max-width: min(560px, 90vw); background: rgba(255,194,61,0.14); border: 1px solid rgba(255,194,61,0.5); border-radius: 8px; padding: 6px 12px; text-align: center; line-height: 1.4; }
.h-hint b { color: var(--amber); margin-right: 6px; letter-spacing: 1px; }
.h-radiomenu { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(440px, 92vw); background: rgba(8,14,20,0.94); border: 1px solid rgba(95,212,255,0.4); border-radius: 12px; padding: 10px; pointer-events: auto; text-shadow: none; }
.h-radiomenu header { font-weight: 700; letter-spacing: 2px; color: var(--cyan); margin-bottom: 6px; }
.h-radiomenu header small { letter-spacing: 0; color: var(--muted); font-weight: 600; margin-left: 6px; }
.h-radiomenu button { display: grid; grid-template-columns: 26px 1fr; gap: 8px; width: 100%; text-align: left; background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; margin-bottom: 4px; align-items: center; }
.h-radiomenu button:hover { border-color: var(--cyan); }
.h-radiomenu button small { display: block; color: var(--muted); font-size: 12px; }
.h-radiomenu p { color: var(--muted); margin: 4px; } .h-radiomenu footer { color: var(--muted); font-size: 11px; text-align: right; }
.h-hit { inset: 0; box-shadow: inset 0 0 120px rgba(255,30,30,0.0); }
.h-hit.on { animation: hit 0.6s; }
@keyframes hit { 0% { box-shadow: inset 0 0 160px rgba(255,30,30,0.65); } 100% { box-shadow: inset 0 0 160px rgba(255,30,30,0); } }
.h-tac { inset: 0; width: 100%; height: 100%; }
.h-touch { display: none; }
body.in-game #ui { pointer-events: none; }

/* ------------------------------------------------------------ touch and small screens */
/* Phones and tablets (body.touch). Landscape layout, checked at 667x320 (iPhone SE with Safari's
   bars), 844x390 (iPhone 14) and 932x430. Top band: mission and objectives (left), compass and
   target (centre), escalation and radio (right). Bottom band: ship status over the radar and the
   telegraph (left), weapons and rudder (centre), buttons (right). Tips sit just above the centre. */
body.touch .h-touch { display: block; position: absolute; inset: 0; pointer-events: none; }
body.touch .h-touch button, body.touch .h-touch input { pointer-events: auto; touch-action: manipulation; }
.t-left button, .t-right button { width: 54px; height: 44px; border-radius: 10px; background: rgba(8,14,20,0.72); border: 1px solid var(--line); font-weight: 700; font-size: 12px; color: var(--ink); }
.t-left button:active, .t-right button:active { background: rgba(255,194,61,0.3); }
.t-left { position: absolute; left: calc(max(8px, env(safe-area-inset-left)) + 108px); bottom: max(8px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 3px; }
.t-left button { width: 52px; height: 42px; }
.t-tel { font-size: 9px; font-weight: 700; color: var(--amber); width: 64px; text-align: center; line-height: 1.1; }
.t-rudder { position: absolute; left: calc(max(8px, env(safe-area-inset-left)) + 176px); right: calc(max(8px, env(safe-area-inset-right)) + 184px); bottom: max(4px, env(safe-area-inset-bottom)); text-align: center; }
.t-rudder input { width: 100%; max-width: 420px; accent-color: var(--amber); height: 30px; }
.t-rudder small { display: block; color: var(--muted); font-size: 9px; margin-top: -6px; }
.t-right { position: absolute; right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 54px); gap: 5px; }
.t-right .t-fire { grid-column: 1 / -1; grid-row: 3; width: auto; height: 56px; background: rgba(255,77,77,0.38); border-color: var(--red); font-size: 17px; }
body.touch #hud { font-size: 11px; }
body.touch .h-tl { width: min(29vw, 260px); top: max(6px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); }
body.touch .h-mission { font-size: 13px; line-height: 1.15; }
body.touch .h-mission small { font-size: 9.5px; letter-spacing: 0.5px; }
body.touch .h-obj { padding: 3px 6px; margin-top: 4px; font-size: 10.5px; }
body.touch .h-obj li { padding: 1px 0; line-height: 1.25; }
body.touch .h-obj li:nth-child(n+4) { display: none; }
body.touch .h-tc { top: max(4px, env(safe-area-inset-top)); }
body.touch .h-tc .h-compass { width: min(220px, 34vw); height: 26px; }
body.touch .h-clock { font-size: 10px; }
body.touch .h-tr { width: min(29vw, 270px); top: max(6px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
body.touch .h-tension { padding: 4px 7px; }
body.touch .h-radio { margin-top: 5px; }
body.touch .h-radio .rmsg { padding: 3px 6px; font-size: 10.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
body.touch .h-radio .rmsg:nth-last-child(n+3) { display: none; }
body.touch .h-br { left: max(8px, env(safe-area-inset-left)); right: auto; bottom: max(8px, env(safe-area-inset-bottom)); }
body.touch .h-radar { width: 100px; height: 100px; }
body.touch .h-target { position: fixed; top: calc(max(4px, env(safe-area-inset-top)) + 44px); left: 50%; transform: translateX(-50%); width: min(250px, 36vw); padding: 3px 8px; text-align: center; }
body.touch .h-target small, body.touch .h-target .tbar { display: none; }
body.touch .h-target b { font-size: 12px; display: inline; margin-left: 4px; }
body.touch .h-target header { display: inline; }
body.touch .h-bl { left: max(8px, env(safe-area-inset-left)); bottom: calc(max(8px, env(safe-area-inset-bottom)) + 106px); width: 100px; }
body.touch .h-ship { padding: 4px 6px; }
body.touch .sh-tel, body.touch .sh-rud, body.touch .sh-name { display: none; }
body.touch .sh-row { margin: 0 0 2px; }
body.touch .sh-speed b { font-size: 20px; } body.touch .sh-speed small { font-size: 9px; }
body.touch .sh-bar { height: 13px; margin: 2px 0; } body.touch .sh-bar span { font-size: 9.5px; line-height: 13px; }
body.touch .sh-flags { font-size: 9px; gap: 1px 6px; margin-top: 2px; }
body.touch .h-bc { left: calc(max(8px, env(safe-area-inset-left)) + 176px); right: calc(max(8px, env(safe-area-inset-right)) + 184px); transform: none; bottom: calc(max(4px, env(safe-area-inset-bottom)) + 34px); }
body.touch .h-weapons { justify-content: center; overflow-x: auto; scrollbar-width: none; }
body.touch .wp { flex: none; width: 46px; padding: 2px 3px 3px; }
body.touch .wp kbd { display: none; }
body.touch .wp b { margin-top: 1px; font-size: 9.5px; } body.touch .wp span { font-size: 13px; }
body.touch .h-hint { top: auto; bottom: calc(max(4px, env(safe-area-inset-bottom)) + 92px); max-width: min(440px, 40vw); font-size: 11px; padding: 4px 9px; line-height: 1.35; }
body.touch .h-alert { top: 28%; font-size: clamp(18px, 4vw, 30px); }
body.touch .h-toasts { top: 38%; }
body.touch .toast { font-size: 11px; padding: 3px 9px; }
body.touch .h-radiomenu { max-height: calc(100% - 16px); overflow-y: auto; width: min(560px, 74vw); z-index: 3; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; align-content: start; }
body.touch .h-radiomenu.hidden { display: none; }
body.touch .h-radiomenu header, body.touch .h-radiomenu p, body.touch .h-radiomenu .r-close { grid-column: 1 / -1; }
body.touch .h-radiomenu header { margin-bottom: 0; }
body.touch .h-radiomenu button { padding: 7px 8px; margin: 0; font-size: 12.5px; line-height: 1.25; }
body.touch .h-radiomenu button small { font-size: 10.5px; }
body.touch .h-radiomenu kbd { display: none; }
body.touch .h-radiomenu button { grid-template-columns: 1fr; }
body.touch .h-radiomenu .r-close { display: block; text-align: center; font-weight: 700; color: var(--muted); margin-top: 2px; }
/* very short screens (iPhone SE with Safari's bars): only the newest radio line, 2 objectives */
@media (max-height: 360px) {
  body.touch .h-radio .rmsg:nth-last-child(n+2) { display: none; }
  body.touch .h-obj li:nth-child(n+3) { display: none; }
  body.touch .h-bl { bottom: calc(max(8px, env(safe-area-inset-bottom)) + 96px); }
  body.touch .h-radar { width: 90px; height: 90px; }
  .t-left button { height: 38px; }
  .t-right button { height: 40px; } .t-right .t-fire { height: 50px; }
}
/* portrait phones: the game needs landscape */
#rotate { display: none; position: fixed; inset: 0; z-index: 40; background: var(--bg); flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 24px; }
#rotate .rotate-icon { font-size: 60px; color: var(--amber); animation: tilt 1.6s ease-in-out infinite; }
#rotate p { font-size: 19px; font-weight: 700; margin: 0; } #rotate small { color: var(--muted); }
@keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
@media (orientation: portrait) and (pointer: coarse) { body.mission #rotate { display: flex; } } /* during a mission, paused or not */

/* menus on short landscape screens (phones): keep columns, tighten everything */
@media (max-height: 520px) {
  .logo h1 { font-size: 40px; } .logo small { font-size: 10px; }
  .story { font-size: 12.5px; margin-bottom: 8px; line-height: 1.4; }
  .menu { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .menu .primary, .menu .row { grid-column: 1 / -1; }
  #pause .menu { display: flex; }
  .menu button { padding: 6px 11px; font-size: 14.5px; } .menu button small { font-size: 11px; }
  .disclaimer { font-size: 10.5px; margin-top: 8px; }
  .panel { padding: 10px 14px 12px; } .panel h2 { font-size: 19px; } .panel header { margin-bottom: 6px; }
  .panel h4 { margin: 8px 0 4px; }
  .panel p, .b-grid ul, .tips li { font-size: 13px; }
  .lead { font-size: 12.5px; margin-bottom: 8px; }
  .fcard { padding: 9px 11px; } .fcard i { font-size: 22px; } .fcard h3 { font-size: 17px; } .fcard p { font-size: 12px; margin: 4px 0; }
  .mcard { padding: 6px 12px; } .mcard .n { font-size: 21px; } .mcard .t b { font-size: 15px; } .mcard .t small { font-size: 12px; }
  .stars { font-size: 34px; } .score b { font-size: 30px; } .end h2 { font-size: 22px; }
  .e-obj, .e-break { font-size: 12.5px; }
  /* keep the start button on screen while the briefing scrolls */
  #brief .big { position: sticky; bottom: 0; margin-top: 10px; box-shadow: 0 -10px 20px rgba(7,11,16,0.85); }
}
@media (max-height: 520px) and (min-width: 641px) {
  #title.screen { flex-direction: row; gap: 16px; }
  .t-main { max-width: 470px; margin: auto 0 auto clamp(0px, 3vw, 40px); }
  .t-side { width: 260px; margin: auto clamp(0px, 3vw, 40px) auto auto; }
}
/* narrow screens (portrait phones): one column */
@media (max-width: 640px) {
  .flist, .help, .b-grid, .e-grid { grid-template-columns: 1fr; }
  #title.screen { flex-direction: column; background: rgba(7,11,16,0.82); }
  .t-main, .t-side { margin: 0 auto; }
}
@media (max-width: 900px) { .h-radio .rmsg:nth-last-child(n+4) { display: none; } }
@media (max-width: 900px) and (min-width: 641px) {
  .flist { grid-template-columns: repeat(3, 1fr); gap: 8px; } .b-grid { grid-template-columns: 1.1fr 1fr; gap: 14px; }
  .help, .e-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-height: 520px) {
  body:not(.touch) .h-radar { width: 150px; height: 150px; }
  body:not(.touch) .h-obj li:nth-child(n+4) { display: none; }
  body:not(.touch) .h-radio .rmsg:nth-last-child(n+3) { display: none; }
}
.b-diff { font: inherit; color: var(--ink); background: rgba(255,255,255,0.07); border: 1px solid var(--line); border-radius: 5px; padding: 0 8px; cursor: pointer; }
.b-diff b { color: var(--amber); }
