/* Voyager — grimdark pixel UI. Muted rust, bone and soot, with sharp accents for danger and rarity. */
:root {
  --soot: #0c0b0a;
  --coal: #141210;
  --panel: #1a1714;
  --edge: #3a3028;
  --edge-hi: #5a4a3a;
  --bone: #d8c8a0;
  --ash: #8a8070;
  --rust: #b0592e;
  --gold: #d0a020;
  --blood: #a02a2a;
  --toxic: #7fbf3f;
  --void: #a35ad9;
  --font-head: 'Silkscreen', 'Courier New', monospace;
  --font-body: 'VT323', 'Courier New', monospace;
}
* { box-sizing: border-box; }
/* Layout rule: the whole game uses at most 95 % of the screen height. */
html { height: 100%; background: var(--soot); }
body { height: 95vh; height: 95dvh; }
html, body { margin: 0; background: var(--soot); color: var(--bone); font-family: var(--font-body); font-size: 19px; line-height: 1.15; }
body { display: flex; flex-direction: column; overflow: hidden;
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px); }
img.px, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
h2, h3, h4, .logo, .btn, #cycle, .nav-btn em, .card-kind, .tag { font-family: var(--font-head); font-weight: normal; letter-spacing: 1px; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--rust); text-transform: uppercase; }
h3 { font-size: 15px; margin: 0 0 4px; }
h4 { font-size: 12px; margin: 12px 0 6px; color: var(--ash); text-transform: uppercase; }
small, .small { font-size: 16px; }
.muted { color: var(--ash); }
.bad { color: #d05050; }
.flavor { color: #b8a888; font-style: italic; }

/* top bar */
#top { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--coal);
  border-bottom: 2px solid var(--edge); box-shadow: 0 2px 0 #000; flex-wrap: nowrap; }
.logo { font-size: 18px; color: var(--bone); text-shadow: 2px 2px 0 var(--blood); letter-spacing: 3px; }
#top-res { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 0; min-width: 0; }
#top .spacer { display: none; }
#top > .btn, #cycle, .logo, #btn-menu { flex-shrink: 0; }
.res { display: flex; align-items: baseline; gap: 3px; padding: 2px 5px; background: var(--soot); border: 1px solid var(--edge); }
.res .ico { font-size: 16px; }
.res b { font-size: 19px; font-weight: normal; }
.res small { color: #8aa070; font-size: 14px; }
.res small.neg { color: #d05050; }
.res-metal { color: #b8b8c4; } .res-rare { color: #60d0a8; } .res-organics { color: #9ac050; } .res-electronics { color: #d89a60; } .res-chemicals { color: #d8c860; }
.res-research { color: #80c8e0; } .res-shards { color: #c080f0; }
.res-power { color: #f0d060; } .res-infra { color: #d0a878; } .res-compute { color: #70c0c8; }
.res.cap { border-style: dashed; }
.res-sep { width: 1px; align-self: stretch; background: var(--edge); margin: 0 2px; }
.bar.cap-power i { background: repeating-linear-gradient(90deg, #c0a840 0 6px, #907c2c 6px 8px); }
.bar.cap-infra i { background: repeating-linear-gradient(90deg, #b08a58 0 6px, #86683e 6px 8px); }
.bar.cap-compute i { background: repeating-linear-gradient(90deg, #4a9aa0 0 6px, #3a7a80 6px 8px); }
.bar.over i { background: repeating-linear-gradient(90deg, #c04040 0 6px, #902828 6px 8px) !important; }
.res.over { border-color: var(--blood); background: #2a1010; }
.bar.infra i { background: repeating-linear-gradient(90deg, #b8a050 0 6px, #8a7838 6px 8px); }
.bar.infra.over i { background: repeating-linear-gradient(90deg, #c04040 0 6px, #902828 6px 8px); }
.spacer { flex: 1; }
#cycle { font-size: 13px; color: var(--ash); }
#cycle.tester { color: #e05050; }

/* buttons */
.btn { background: #2a221c; color: var(--bone); border: 2px solid var(--edge-hi); padding: 5px 10px; font-size: 11px;
  cursor: pointer; box-shadow: inset -2px -2px 0 #120e0c, inset 2px 2px 0 #4a3e32; text-transform: uppercase; }
.btn:hover:not([disabled]) { background: #3a2e24; color: #fff; }
.btn:active:not([disabled]) { box-shadow: inset 2px 2px 0 #120e0c; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn.gold { border-color: var(--gold); color: #f0d070; background: #2e2410; }
.btn.danger { border-color: var(--blood); color: #f08080; background: #2a1010; }
.btn.on { border-color: var(--bone); background: #4a3a28; }
.btn.small { font-size: 9px; padding: 3px 6px; }
.btn small { font-family: var(--font-body); font-size: 15px; text-transform: none; display: block; color: var(--ash); }
.icon-btn { background: none; border: none; color: var(--ash); font-size: 22px; cursor: pointer; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.btnrow.col { flex-direction: column; }
.btnrow.big .btn { font-size: 13px; padding: 10px 16px; }

/* layout */
#body { flex: 1; display: flex; min-height: 0; }
#nav { width: 170px; background: var(--coal); border-right: 2px solid var(--edge); padding: 8px 6px; display: flex; flex-direction: column; gap: 3px; transition: width .15s; overflow: hidden; }
.nav-collapsed #nav { width: 48px; }
.nav-collapsed .nav-btn em { display: none; }
.nav-btn { display: flex; gap: 10px; align-items: center; background: none; border: 1px solid transparent; color: var(--ash); padding: 7px 8px; cursor: pointer; text-align: left; white-space: nowrap; }
.nav-btn span { width: 20px; text-align: center; font-size: 18px; }
.nav-btn em { font-style: normal; font-size: 11px; text-transform: uppercase; }
.nav-btn:hover { color: var(--bone); background: #1e1a16; }
.nav-btn.active { color: var(--bone); border-color: var(--edge-hi); background: #241e18; box-shadow: inset 3px 0 0 var(--rust); }
#center { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#main { flex: 1; overflow: auto; padding: 12px; }
.log { padding: 1px 0; color: #a89a80; }
.log i { font-style: normal; color: #5a5048; margin-right: 6px; }
.log.good { color: #9ac070; } .log.bad { color: #e06060; } .log.story { color: #c8b890; font-style: italic; } .log.mythic { color: var(--gold); }

/* panels */
.panel { background: var(--panel); border: 2px solid var(--edge); box-shadow: inset 0 0 0 2px #0e0c0a, 4px 4px 0 #000; padding: 12px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 12px; }
.grid2 .panel { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.stats div { background: var(--soot); border: 1px solid var(--edge); padding: 6px 8px; }
.stats small { display: block; color: var(--ash); font-size: 15px; }
.stats b { font-size: 24px; font-weight: normal; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px dashed #2a2420; }
.kv b { font-weight: normal; }
.row { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.dot { width: 10px; height: 10px; display: inline-block; }
.report { border-left: 3px solid var(--edge-hi); padding: 4px 8px; margin-bottom: 6px; background: var(--soot); }
.report.good { border-color: #6a9040; } .report.bad { border-color: var(--blood); }
.bar { height: 14px; background: var(--soot); border: 1px solid var(--edge); margin: 6px 0; }
.bar i { display: block; height: 100%; background: repeating-linear-gradient(90deg, #4a9aa0 0 6px, #3a7a80 6px 8px); }
.lvl { color: var(--gold); font-size: 16px; }
.right { text-align: right; white-space: nowrap; }

/* map */
.mapbox { position: relative; }
/* Star Map and Solar System: fill the screen height, the system panel beside the map */
.fitscreen { display: flex; gap: 12px; height: 100%; min-height: 0; }
.fitscreen .mapcol { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.fitscreen .mapbox, .fitscreen .sysbox { flex: 1; min-height: 0; position: relative; }
.fitscreen .side { height: 100%; overflow: auto; }
.side-top { margin-bottom: 8px; }
.side-top .btn { width: 100%; }
#mapcanvas, #syscanvas { display: block; width: 100%; height: 100%; border: 2px solid var(--edge); box-shadow: 4px 4px 0 #000; cursor: crosshair; background: #070606; box-sizing: border-box; }
#mapcanvas { cursor: grab; image-rendering: pixelated; }
#syscanvas { object-fit: contain; }
.sysmap-title { display: flex; align-items: center; gap: 12px; margin: 0 0 6px; }
.sysmap-title h3 { margin: 0; }
.sysmap-title .btn { margin-left: auto; }
.mapctl { position: absolute; top: 8px; right: 8px; z-index: 3; display: flex; flex-direction: column; gap: 4px; }
.mapctl button { width: 34px; height: 34px; padding: 0; font-size: 20px; line-height: 1; background: rgba(20, 18, 16, .9); }
.maphover { position: absolute; z-index: 4; display: none; pointer-events: none; min-width: 200px; max-width: 320px; background: rgba(20, 18, 16, .96); border: 2px solid var(--edge-hi); box-shadow: 4px 4px 0 #000; padding: 8px 10px; }
.maphover.show { display: block; }
.maphover h4 { margin: 0; }
.maphover .sys-head { margin-bottom: 4px; gap: 8px; }
.hp-row { display: flex; align-items: center; gap: 6px; font-size: 16px; line-height: 1.1; }
.hp-row .hab-pips { margin-left: auto; font-size: 11px; letter-spacing: -1px; }
.maphint { color: var(--ash); padding: 6px 2px; font-size: 17px; }
.side { width: 320px; flex-shrink: 0; overflow: auto; }
.sys-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.fleet { border: 1px solid var(--edge); border-left-width: 3px; padding: 6px 8px; margin-bottom: 6px; background: var(--soot); }
.ships { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.ship { display: inline-flex; align-items: center; gap: 2px; }

/* lists */
.bld, .tech { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px; border: 1px solid #2a2420; margin-bottom: 6px; background: #141210; }
.bld.locked { opacity: .55; }
.tech.cur { border-color: #4a9aa0; box-shadow: inset 3px 0 0 #4a9aa0; }
.tech.done { opacity: .45; }
.shiprow { display: flex; gap: 10px; align-items: center; }
.colony .sys-head { border-bottom: 1px dashed var(--edge); padding-bottom: 8px; }

/* empire-wide building list */
.brow { border: 1px solid #2a2420; background: #141210; padding: 4px 6px; margin-bottom: 3px; }
.brow.open { border-color: var(--edge-hi); box-shadow: inset 3px 0 0 var(--rust); }
.bhead { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.grow { flex: 1 1 auto; min-width: 0; }
.bsub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.1; }
.bauto { flex-shrink: 0; white-space: nowrap; }
.bicon { flex-shrink: 0; display: inline-block; vertical-align: middle; background: #3a3229; border: 1px solid #4a4036; }
.bsum-item { display: flex; align-items: center; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.bchip { display: inline-flex; align-items: center; gap: 2px; background: var(--soot); border: 1px solid #2a2420; padding: 1px 4px 1px 1px; }
.bchip .bicon { border: 0; }
.bhead .bicon { width: 30px; height: 30px; }
.bchip b { color: var(--gold); font-size: 15px; }
.crow { border: 1px solid #2a2420; background: #141210; padding: 4px 6px; margin-bottom: 3px; }
.crow.open { border-color: var(--edge-hi); box-shadow: inset 3px 0 0 var(--rust); }
.crow.unsettled { opacity: .75; border-style: dashed; }
.chead { display: flex; align-items: center; gap: 8px; }
.chead[data-act] { cursor: pointer; }
.chead[data-act]:hover b { color: #fff; }
.cdetail { margin-top: 6px; border-top: 1px dashed var(--edge); padding-top: 6px; }
.csys .star-line { flex-wrap: wrap; }
.csys .star-line h3 { margin: 0; }
.bhead:hover b { color: #fff; }
.bdetail { margin-top: 8px; border-top: 1px dashed var(--edge); padding-top: 4px; }
.bdetail .kv { align-items: center; flex-wrap: wrap; }
.bdetail .spot.best { background: rgba(208, 160, 32, .06); }
.bsum { display: flex; flex-wrap: wrap; gap: 6px; }
.bsum-item { background: var(--soot); border: 1px solid var(--edge); color: var(--bone); padding: 5px 8px; cursor: pointer; text-align: left; font-family: var(--font-body); font-size: 17px; }
.bsum-txt > span { display: block; color: var(--ash); font-size: 15px; }
.bsum-item:hover { border-color: var(--edge-hi); background: #1e1a16; }

/* planets */
.star-line { display: flex; align-items: center; gap: 8px; margin: 4px 0 2px; }
.star-dot { width: 10px; height: 10px; display: inline-block; }
.planet-frame { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.planet-row { display: flex; gap: 8px; align-items: flex-start; padding: 6px; border: 1px solid #2a2420; margin-bottom: 4px; background: #141210; }
.planet-row.settled { border-color: var(--edge-hi); }
.planet-row.sel { border-color: var(--bone); box-shadow: inset 3px 0 0 var(--bone); }
.planet-panel.unsettled { opacity: .75; }
.layers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 12px; margin-top: 10px; }
.layer { background: var(--soot); border: 1px solid var(--edge); padding: 8px; }
.layer h4 { margin-top: 0; display: flex; justify-content: space-between; }
.bld.new { opacity: .85; border-style: dashed; }
details summary { cursor: pointer; color: var(--ash); font-family: var(--font-head); font-size: 10px; text-transform: uppercase; padding: 6px 0; }
details summary:hover { color: var(--bone); }

/* gacha cards */
.tag { font-size: 8px; background: #2a221c; padding: 2px 4px; border: 1px solid var(--edge-hi); }

/* music */
.btn.icon { font-family: var(--font-body); font-size: 18px; padding: 1px 10px; text-transform: none; }
.btn.icon.off { opacity: .45; text-decoration: line-through; }
.slider { accent-color: var(--rust); width: 140px; vertical-align: middle; }
.tracks { margin: 6px 0 12px; }
.track { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid #2a2420; background: #141210; margin-bottom: 4px; }
.voice-files { margin: -4px 0 10px; } .voice-files .good { color: #9ac070; }
.track.now { border-color: var(--edge-hi); box-shadow: inset 3px 0 0 var(--rust); }

/* ship AI transmissions */
#comms { position: fixed; left: 50%; bottom: calc(5vh + 140px); transform: translateX(-50%); z-index: 20; max-width: min(640px, 90vw);
  background: rgba(10, 14, 16, .92); border: 1px solid #3a6a70; box-shadow: 0 0 0 1px #000, 0 0 18px rgba(90, 200, 210, .25), 4px 4px 0 #000;
  padding: 8px 14px; color: #a8e8f0; font-size: 22px; letter-spacing: 1px; pointer-events: none;
  opacity: 0; transition: opacity .6s; text-shadow: 1px 0 rgba(255, 60, 60, .55), -1px 0 rgba(60, 200, 255, .55);
  background-image: repeating-linear-gradient(0deg, rgba(120, 220, 230, .05) 0 1px, transparent 1px 3px); }
#comms.show { opacity: 1; animation: comms-flicker 2.2s steps(1) infinite; }
#comms.jolt { transform: translateX(calc(-50% + 3px)) skewX(-4deg); }
#comms .comms-src { display: block; font-family: var(--font-head); font-size: 9px; letter-spacing: 2px; color: #5aa0a8; margin-bottom: 2px; }
/* danger: combat alerts in red */
#comms.danger { border-color: #8a2a2a; color: #ffb0a0; box-shadow: 0 0 0 1px #000, 0 0 22px rgba(230, 60, 50, .45), 4px 4px 0 #000;
  background: rgba(22, 8, 8, .94); background-image: repeating-linear-gradient(0deg, rgba(255, 80, 60, .07) 0 1px, transparent 1px 3px);
  text-shadow: 1px 0 rgba(255, 40, 40, .7), -1px 0 rgba(255, 160, 60, .45); }
#comms.danger .comms-src { color: #e05a4a; }
#comms.danger.show { animation: comms-flicker 2.2s steps(1) infinite, comms-alarm 1s steps(2) infinite; }
@keyframes comms-alarm { 50% { border-color: #e04040; } }
@keyframes comms-flicker { 0%, 100% { opacity: 1; } 47% { opacity: .82; } 48% { opacity: 1; } 83% { opacity: .9; } }
@media (prefers-reduced-motion: reduce) { #comms.show { animation: none; } }

/* fleet colour pickers */
.colors { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.colorpick { display: flex; align-items: center; gap: 4px; font-size: 16px; color: var(--ash); cursor: pointer; }
.colorpick input { width: 34px; height: 24px; border: 1px solid var(--edge-hi); background: none; padding: 0; cursor: pointer; }
.color-preview { display: flex; gap: 14px; align-items: flex-end; margin: 8px 0 12px; }

/* version tag, bottom right */
#version { position: fixed; right: 8px; bottom: calc(5vh + 6px); z-index: 5; font-family: var(--font-head); font-size: 10px; letter-spacing: 1px; color: #8a8070; background: rgba(12, 11, 10, .85); border: 1px solid var(--edge); padding: 2px 6px; pointer-events: none; }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: none; align-items: center; justify-content: center; z-index: 10; }
#modal.show { display: flex; }
.modal-box { background: var(--panel); border: 2px solid var(--edge-hi); box-shadow: inset 0 0 0 2px #0e0c0a, 6px 6px 0 #000; padding: 18px; width: min(480px, 92vw); max-height: 90vh; overflow: auto; text-align: center; }
.modal-box .btnrow { justify-content: center; }
.modal-box .kv { text-align: left; }
.event-img { display: block; margin: 10px auto; border: 2px solid var(--edge); }
textarea { width: 100%; height: 70px; background: var(--soot); color: var(--bone); border: 1px solid var(--edge); font-family: var(--font-body); font-size: 15px; margin-top: 8px; }


/* ---------- ship cards ---------- */
.cardrow { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; }
.cardrow.wrap { flex-wrap: wrap; overflow: visible; }
.scard { --rc: #9a9080; flex: 0 0 150px; width: 150px; background: linear-gradient(#1c1915, #100e0c); border: 2px solid var(--rc); box-shadow: 0 0 0 2px #000, 3px 3px 0 #000; padding: 5px 6px 6px; display: flex; flex-direction: column; gap: 2px; position: relative; cursor: default; }
.scard[data-act] { cursor: pointer; }
.scard[data-act]:hover { filter: brightness(1.15); }
.scard.small { flex-basis: 118px; width: 118px; }
.scard.big { width: 100%; max-width: 220px; flex-basis: auto; }
.scard.sel { outline: 2px solid var(--bone); outline-offset: 2px; }
.scard.busy { opacity: .6; }
.scard.empty { border: 2px dashed var(--edge); background: transparent; box-shadow: none; align-items: center; justify-content: center; color: var(--ash); min-height: 120px; font-size: 16px; }
.scard.empty[data-act] { border-color: var(--edge-hi); color: var(--bone); }
.scard.empty[data-act]:hover { background: #1e1a16; }
.sc-top { display: flex; justify-content: space-between; align-items: center; }
.sc-size { font-family: var(--font-head); font-size: 10px; background: #2a2420; border: 1px solid var(--edge-hi); padding: 0 4px; color: var(--bone); }
.sc-rar { font-family: var(--font-head); font-size: 8px; color: var(--rc); text-transform: uppercase; letter-spacing: 1px; }
.sc-img { height: 108px; display: flex; align-items: center; justify-content: center; }
.sc-img img { max-width: 100%; max-height: 100%; }
.scard.small .sc-img { height: 64px; }
.scard.big .sc-img { height: 124px; }
.tile-ships img { height: 44px; width: auto; }
.sc-name { font-size: 18px; font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1; }
.sc-type { color: var(--ash); font-size: 14px; line-height: 1; }
.sbar { position: relative; height: 10px; background: #0a0908; border: 1px solid #2a2420; }
.sbar i { display: block; height: 100%; }
.sbar.sh i { background: repeating-linear-gradient(90deg, #4a9ad0 0 4px, #3a7ab0 4px 5px); }
.sbar.hu i { background: repeating-linear-gradient(90deg, #c07038 0 4px, #a05828 4px 5px); }
.sbar span { position: absolute; right: 2px; top: -4px; font-size: 13px; color: #fff; text-shadow: 1px 1px 0 #000; }
.sc-stats { display: flex; flex-wrap: wrap; gap: 0 6px; font-size: 13px; color: var(--ash); }
.sc-weps { display: flex; flex-direction: column; gap: 2px; }
.sc-stats .q { margin-left: auto; color: var(--bone); }
.sc-stats .q.hi { color: #9ac070; } .sc-stats .q.lo { color: #c07060; }
.wchip { --wc: #aaa; --rc: #9a9080; display: inline-flex; align-items: center; gap: 3px; font-size: 14px; line-height: 1.1; padding: 1px 4px; background: #0e0c0b; border: 1px solid #2a2420; border-left: 3px solid var(--rc); white-space: nowrap; }
.wchip i { font-style: normal; color: var(--wc); }
.wchip em { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.scard .wchip { width: 100%; font-size: 13px; }
.wchip b { color: var(--bone); margin-left: auto; padding-left: 4px; }
.wchip small { font-size: 12px; color: var(--ash); }
.wchip.empty { color: #5a5048; border-left-color: #2a2420; }
.wlist { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.r-strong { box-shadow: 0 0 0 2px #000, 0 0 8px #4a9ad055, 3px 3px 0 #000; }
.r-epic { box-shadow: 0 0 0 2px #000, 0 0 10px #a060d077, 3px 3px 0 #000; }
.r-legendary { box-shadow: 0 0 0 2px #000, 0 0 14px #d0a020aa, 3px 3px 0 #000; }
.r-omega { box-shadow: 0 0 0 2px #000, 0 0 18px #e04040; animation: omega 1.2s steps(3) infinite; }
@keyframes omega { 50% { box-shadow: 0 0 0 2px #000, 0 0 26px #ff6060, 0 0 4px #fff inset; } }

/* shipyard */
.buildtiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 10px; margin: 8px 0; }
.buildtile { background: var(--soot); border: 1px solid var(--edge); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.buildtile.locked { opacity: .55; }
.buildtile h3 { margin: 0; display: flex; justify-content: space-between; }
.tile-ships { display: flex; gap: 10px; flex-wrap: wrap; font-size: 15px; color: var(--ash); }
.tile-ships span { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.reveal { display: flex; gap: 14px; align-items: flex-start; padding: 10px; border: 1px solid var(--edge-hi); background: #120f0c; animation: reveal .45s steps(5); flex-wrap: wrap; }
.reveal.r-legendary, .reveal.r-omega, .reveal.r-epic { background: radial-gradient(circle at 20% 40%, #2a1f10, #120f0c 70%); }
@keyframes reveal { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.forged { margin-top: 8px; }

/* fleets */
.fleetscreen { display: grid; grid-template-columns: 1fr 330px; gap: 12px; align-items: start; }
.fleetscreen .side { width: auto; position: sticky; top: 0; }
.lanewrap { display: flex; flex-direction: column; gap: 2px; flex: 0 0 auto; }
.lanelbl { font-family: var(--font-head); font-size: 8px; color: var(--ash); letter-spacing: 1px; text-align: center; }
.fleetrow { border-top: 1px dashed var(--edge); padding: 8px 0 4px; }
.fleethead { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.icon-btn.small { font-size: 15px; padding: 0 2px; }
.wslot { border: 1px solid #2a2420; padding: 4px; margin-bottom: 4px; }
.wslot .kv { align-items: center; }
.nav-btn.alert { color: #ff7060; animation: alert 1s steps(2) infinite; }
@keyframes alert { 50% { background: #3a1210; } }

/* battle board */
.board { display: flex; flex-direction: column; gap: 8px; position: relative; }
.barrow { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; overflow: visible; }
.arrow-bob { animation: arrowbob 1.1s ease-in-out infinite; }
.arrow-flow { animation: arrowflow .6s linear infinite; }
@keyframes arrowbob { 50% { transform: translateY(-4px); } }
@keyframes arrowflow { to { stroke-dashoffset: -17; } }
.bpower { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; border-left: 3px solid var(--fc); color: var(--fc); }
.bpower span { color: var(--ash); font-size: 16px; } .bpower span b { color: var(--bone); font-size: 20px; }
.pbar { height: 8px; background: #6a2a24; border: 1px solid var(--edge); margin: 14px 0; }
.pbar i { display: block; height: 100%; background: #c8b890; transition: width .4s; }
.swapnav { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 3px; font-size: 13px; color: var(--ash); }
.swapnav .btn { padding: 1px 7px; }
.scard.swap-dest, .lane-empty.swap-dest { outline: 2px dashed var(--gold); outline-offset: 2px; }
.lane-empty.swap-dest { display: flex; align-items: center; justify-content: center; color: var(--gold); opacity: 1; }
.dragover { outline: 2px solid var(--gold) !important; background: #2a2410 !important; }
.scard[data-drag] { cursor: grab; }
.border { position: sticky; bottom: 0; z-index: 4; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; justify-content: center; padding: 6px 8px;
  background: rgba(14, 12, 10, .96); border-top: 2px solid var(--edge-hi); box-shadow: 0 -6px 12px rgba(0, 0, 0, .6); margin: 0 -12px -12px; }
.ord-lbl { font-family: var(--font-head); font-size: 9px; color: var(--ash); letter-spacing: 1px; margin-right: 6px; }
.ord small { font-size: 12px; opacity: .7; }
.ord.done { opacity: .45; }
.bhead2 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bhead2 h3 { margin: 0; }
.bhead2 .btnrow { margin: 0 0 0 auto; }
.bside { --lanes: 5; display: grid; grid-template-columns: repeat(var(--lanes), minmax(0, 150px)); gap: 10px; justify-content: center; min-height: 150px; padding: 8px; background: #0e0c0a; border: 1px solid var(--edge); }
.bside .scard { width: auto; flex-basis: auto; }
.lane-empty { border: 1px dashed #2a2420; opacity: .5; min-height: 120px; }
.bside.enemy { background: linear-gradient(#1a0c0c, #0e0c0a); }
.bside.player { background: linear-gradient(#0e0c0a, #0c1214); }
.scard.dead { opacity: .25; filter: grayscale(1); }
.scard.acting { outline: 2px solid #f0e0a0; outline-offset: 3px; transform: translateY(-3px); }
.bside.enemy .scard.acting { transform: translateY(3px); }
.scard.target { outline: 2px dashed #e06050; outline-offset: 2px; }
.scard.hit { animation: hit .5s steps(3); }
@keyframes hit { 0% { transform: translateX(-4px); filter: brightness(2) sepia(1) hue-rotate(-30deg); } 50% { transform: translateX(4px); } 100% { transform: none; } }
.preview { font-size: 14px; color: #f0c080; text-align: center; border-top: 1px solid #3a2a20; margin-top: 2px; }
.preview i { font-style: normal; font-size: 11px; color: var(--ash); margin-left: 1px; }
.ord { padding: 0 5px; border: 1px solid var(--edge); color: var(--ash); font-size: 15px; }
.ord.player { border-color: #5a6a5a; } .ord.enemy { border-color: #6a3a3a; }
.ord.now { background: #f0e0a0; color: #000; }
.ord.dead { text-decoration: line-through; opacity: .4; }
.bcontrols { min-height: 64px; text-align: center; }
.bcontrols .btnrow { justify-content: center; }
.bprompt { font-size: 19px; }
.wbtn { text-transform: none; padding: 4px; display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
.wbtn .wchip { font-size: 16px; }
.wbtn.on { outline: 2px solid var(--gold); }
.swaprow { align-items: center; }
.swaprow small { font-size: 14px; }
.bresult h2 { margin: 4px 0; font-size: 26px; }
.bresult.good h2 { color: #9ac070; } .bresult.bad h2 { color: #e06060; }
.blog { background: var(--soot); border: 1px solid var(--edge); padding: 4px 8px; font-size: 16px; max-height: 190px; overflow: auto; }
.blog .player { color: #b8c8a0; } .blog .enemy { color: #d08070; }

@media (max-width: 820px) {
  .fleetscreen { grid-template-columns: 1fr; } .fleetscreen .side { position: static; }
  .scard { flex-basis: 128px; width: 128px; } .scard.small { flex-basis: 104px; width: 104px; }
  .bside { gap: 6px; padding: 4px; }
  /* phones: map on top (most of the screen), the system panel below it; the page scrolls */
  .fitscreen { flex-direction: column; height: auto; }
  .fitscreen .mapcol { flex: none; }
  .fitscreen .mapbox { flex: none; height: 62vh; height: 62dvh; }
  .fitscreen .sysbox { flex: none; }
  #syscanvas { height: auto; aspect-ratio: 400 / 250; }
  .fitscreen .side { height: auto; overflow: visible; }
  .side { width: auto; }
  #nav { width: 48px; } .nav-btn em { display: none; }
  /* top bar: buttons on the first row, resources in one scrollable row below */
  #top { flex-wrap: wrap; row-gap: 6px; padding: 6px 8px; }
  #top-res { order: 10; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  #top-res::-webkit-scrollbar { display: none; }
  .res, .res-sep { flex: 0 0 auto; }
  .res b { font-size: 17px; } .res small { font-size: 13px; }
  .logo { font-size: 15px; letter-spacing: 2px; margin-right: auto; }
  #cycle { font-size: 10px; }
  #top > .btn { padding: 4px 7px; font-size: 10px; }
  #main { padding: 8px; }
  .bld, .tech { flex-wrap: wrap; } .bld .right, .tech .right { text-align: left; }
  .bhead .grow > b { font-size: 16px; }
}
@media (max-width: 480px) {
  .board .scard { padding: 3px; } .bside { gap: 4px; padding: 4px; } .lane-empty { min-height: 70px; }
  .board .sc-img { height: 44px; }
  .board .sc-name { font-size: 14px; } .board .sc-type, .board .sc-stats, .board .sc-rar { display: none; }
  .board .sc-weps { display: none; }
  .bhead2 .btnrow { margin: 0; }
  .logo { display: none; }
  .colony .sys-head, .planet-panel .sys-head { flex-wrap: wrap; }
  #cycle { margin-right: auto; }
  .side { overflow: visible; }
}

/* demolish: a small red ✕ next to Upgrade */
.btn.demolish { font-family: var(--font-body); font-size: 18px; line-height: 1; padding: 3px 8px; min-width: 0; vertical-align: middle; }

/* ---------- tutorial ---------- */
#tutorial { position: fixed; right: 18px; bottom: calc(5vh + 34px); z-index: 9; width: min(440px, calc(100vw - 24px)); max-height: 70vh; overflow: auto;
  background: rgba(20, 18, 16, .97); border: 2px solid var(--gold); box-shadow: 0 0 0 2px #000, 6px 6px 0 #000, 0 0 30px rgba(208, 160, 32, .18); padding: 12px 14px; }
#tutorial.top { bottom: auto; top: 64px; }
#tutorial.center { right: 50%; bottom: 50%; transform: translate(50%, 50%); width: min(520px, calc(100vw - 24px)); }
#tutorial .tut-head { display: flex; align-items: baseline; gap: 10px; }
#tutorial h2 { margin: 0; font-family: var(--font-head); font-size: 14px; letter-spacing: 1px; color: var(--gold); text-transform: uppercase; }
#tutorial .tut-step { font-family: var(--font-head); font-size: 10px; color: var(--ash); }
#tutorial p { margin: 8px 0 10px; font-size: 20px; line-height: 1.2; }
#tutorial .btnrow { display: flex; align-items: center; gap: 6px; }
#tutorial .grow { flex: 1; }
.tut-dots { display: flex; gap: 4px; margin-bottom: 10px; }
.tut-dots i { width: 8px; height: 8px; background: var(--edge); }
.tut-dots i.past { background: var(--edge-hi); }
.tut-dots i.on { background: var(--gold); }
.tut-focus { outline: 2px solid var(--gold) !important; outline-offset: 3px; animation: tutpulse 1.3s steps(2, jump-none) infinite; position: relative; z-index: 2; }
@keyframes tutpulse { 0% { outline-color: var(--gold); } 100% { outline-color: rgba(208, 160, 32, .25); } }
@media (prefers-reduced-motion: reduce) { .tut-focus { animation: none; } }
@media (max-width: 820px) { #tutorial { right: 12px; left: 12px; width: auto; bottom: calc(5vh + 12px); max-height: 46vh; padding: 10px 12px; } #tutorial p { font-size: 17px; margin: 6px 0 8px; } #tutorial.top { top: 56px; } #tutorial.center { left: 12px; right: 12px; bottom: 50%; transform: translateY(50%); width: auto; } }
