/* Layout: fuldskærms 3D-hav; HUD-plader i messing og navy hviler i hjørnerne som instrumenter på et kortbord */
:root {
  --ink: #0e1a2b;
  --panel: rgba(12, 24, 40, 0.72);
  --panel-edge: rgba(214, 178, 108, 0.45);
  --brass: #d6b26c;
  --brass-dim: #9c8150;
  --paper: #f1e9d8;
  --muted: #b9c3cf;
  --warn: #f08a5d;
  --good: #8fd3b0;
  --display: "IM Fell English SC", "Iowan Old Style", Georgia, serif;
  --body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--ink); color: var(--paper); font-family: var(--body); }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#scene:active { cursor: grabbing; }

.panel {
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#topleft {
  position: fixed;
  left: max(16px, env(safe-area-inset-left, 0px));
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
#title { padding: 10px 16px 12px; }
#title h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.7rem; line-height: 1; color: var(--brass); letter-spacing: 0.02em; }
#title p { margin: 4px 0 0; font-size: 0.82rem; color: var(--muted); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }

#battery { padding: 10px 14px 12px; grid-template-columns: auto auto; align-items: center; }
#battery h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1rem; color: var(--brass); }
.lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--brass-dim); }
.guns { display: flex; gap: 5px; }
.gun { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--brass-dim); background: conic-gradient(var(--brass) var(--p, 100%), rgba(255,255,255,0.08) 0); }
.gun.ready { background: var(--brass); box-shadow: 0 0 6px rgba(214,178,108,0.6); }
.gun.off { background: rgba(240,138,93,0.2); border-color: var(--warn); box-shadow: none; }
#elev { font-size: 0.92rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

#topright {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: calc(100vw - 32px);
}
.btnrow { display: flex; gap: 8px; }
button {
  font: 500 0.9rem var(--body);
  color: var(--paper);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--brass); }
button:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
kbd {
  font: 700 0.78rem var(--body);
  display: inline-block; min-width: 1.5em; text-align: center;
  padding: 1px 5px; border-radius: 4px;
  background: rgba(214,178,108,0.16); border: 1px solid var(--panel-edge); color: var(--brass);
}
#help { padding: 12px 16px 14px; width: 290px; max-width: calc(100vw - 32px); }
#help h2 { margin: 0 0 8px; font-family: var(--display); font-weight: 400; font-size: 1.15rem; color: var(--brass); }
#help ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.9rem; }
#help li { display: flex; gap: 8px; align-items: baseline; }
#help li span:first-child { flex: none; width: 72px; }
#help p { margin: 10px 0 0; font-size: 0.82rem; color: var(--muted); line-height: 1.4; }

#enemyTag {
  position: fixed; left: 0; top: 0; pointer-events: none;
  transform: translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.8rem; text-shadow: 0 1px 4px rgba(0,0,0,0.7); white-space: nowrap;
}
#enemyTag .name { font-family: var(--display); font-size: 0.95rem; color: var(--paper); }
#enemyTag .bar { width: 84px; height: 6px; border-radius: 3px; background: rgba(0,0,0,0.45); overflow: hidden; border: 1px solid rgba(255,255,255,0.25); }
#enemyTag .fill { height: 100%; background: var(--warn); width: 100%; transition: width 0.2s; }
#enemyTag .dist { color: var(--muted); font-variant-numeric: tabular-nums; }
#enemyTag.hit .fill { background: #fff; }

#toast {
  position: fixed; left: 50%; top: 21%; transform: translateX(-50%); z-index: 12;
  display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none;
  width: min(640px, calc(100vw - 32px));
}
#toast .t {
  font-family: var(--display); font-size: 1.4rem; color: var(--paper); text-align: center;
  text-shadow: 0 2px 12px rgba(0,0,0,0.65);
  animation: toastIn 0.25s ease-out; transition: opacity 0.5s, transform 0.5s;
}
#toast .t.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

#floaters { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.floater { position: absolute; left: 0; top: 0; color: var(--paper); text-shadow: 0 1px 6px rgba(0,0,0,0.8); white-space: nowrap; will-change: transform, opacity; }
.floater.good { color: #ffd98a; }
.floater.bad { color: var(--warn); }

#fade {
  position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: #0a1422; opacity: 0; transition: opacity 0.6s ease; pointer-events: none;
}
#fade.on { opacity: 0.94; pointer-events: auto; }
#fadeDay { font: 600 0.82rem var(--body); letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted); }
#fadeTo { font-family: var(--display); font-size: clamp(1.8rem, 4vw, 2.6rem); color: var(--brass); }

#menu {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center;
  background: linear-gradient(90deg, rgba(8, 16, 28, 0.88) 0%, rgba(8, 16, 28, 0.55) 45%, rgba(8, 16, 28, 0) 75%);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  animation: fadeIn 0.8s ease-out;
}
#howTo { padding: 12px 16px; }
#howTo ul { margin: 0; padding-left: 18px; display: grid; gap: 5px; font-size: 0.92rem; line-height: 1.45; }
body.menu #topleft, body.menu #topright, body.menu #enemyPanel,
body.menu #stationTags, body.menu #touch, body.menu #enemyTag { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
#flash { position: fixed; inset: 0; background: #e4ecff; opacity: 0; pointer-events: none; z-index: 4; }
#chart, #port, #gameover { animation: fadeIn 0.25s ease-out; }
#chart > .panel, #port > .panel, #gameover .panel { animation: popIn 0.3s ease-out; }

#help, #enemyPanel { transition: opacity 0.2s; }
@media (prefers-reduced-motion: reduce) {
  #menu, #chart, #port, #gameover, #chart > .panel, #port > .panel, #gameover .panel, #eventBox, #toast .t { animation: none; }
  #fade { transition: none; }
}

#touch {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: none; gap: 8px;
  grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px);
}
#touch button { font-size: 1.1rem; padding: 0; touch-action: none; }
#touch .fire { color: var(--brass); font-family: var(--display); }
#battery .side { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ammo { display: flex; gap: 3px; }
.ammo button { padding: 1px 7px; font-size: 0.74rem; border-radius: 5px; }
.ammo button[aria-pressed="true"] { background: var(--brass); color: var(--ink); border-color: var(--brass); }

#enemyPanel {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
}
#enemyPanel header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
#enemyPanel h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1rem; color: var(--brass); }
.meters { display: flex; gap: 12px; font-size: 0.78rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.meter { display: flex; align-items: center; gap: 5px; }
.meter b { color: var(--paper); min-width: 2ch; text-align: right; }
.meter .bar { width: 56px; }
.bar { height: 6px; background: rgba(255,255,255,0.1); overflow: hidden; display: block; }
.bar > i { display: block; height: 100%; width: 100%; background: var(--good); }
.bar.low > i { background: var(--warn); }
.bar.water > i { background: #5fa8e0; }

.station {
  grid-area: var(--a);
  background: rgba(10, 20, 34, 0.78);
  border: 1px solid rgba(214,178,108,0.22);
  border-radius: 6px; padding: 4px 6px 5px;
  display: flex; flex-direction: column; gap: 3px;
  cursor: pointer; min-width: 0;
}
.station:hover, .station:focus-visible { border-color: var(--brass); outline: none; }
.station.target { border-color: var(--brass); box-shadow: inset 0 0 0 1px rgba(214,178,108,0.6); }
.station.burning { background: rgba(80, 26, 12, 0.85); }
.station .nm { font-size: 0.64rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station .bar { height: 3px; }
.station .crew { display: flex; gap: 3px; flex-wrap: wrap; min-height: 18px; }
.station .chips { display: flex; gap: 3px; flex-wrap: wrap; }
.station .chips:empty { display: none; }
.chip { font-size: 0.6rem; padding: 0 4px; border-radius: 3px; background: var(--warn); color: var(--ink); font-weight: 700; letter-spacing: 0.03em; }
.chip.leak { background: #5fa8e0; }
#crewInfo { font-size: 0.8rem; color: var(--muted); min-height: 1.3em; }
#crewInfo b { color: var(--paper); }

/* Fjendens skib som tegning: skrog nederst, master øverst, posterne hvor de hører til */
#ePlan.shipplan { position: relative; width: 100%; aspect-ratio: 400 / 260; display: block; padding: 0; background: none; clip-path: none; border-radius: 8px; overflow: hidden;
  background: linear-gradient(180deg, rgba(120, 160, 190, 0.16) 0%, rgba(120, 160, 190, 0.05) 70%, rgba(30, 70, 100, 0.25) 100%); }
#ePlan .planArt { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#ePlan .station {
  position: absolute; grid-area: auto; padding: 2px 4px 4px; gap: 1px; border-radius: 5px;
  background: rgba(10, 16, 26, 0.74); border: 1px solid rgba(214, 178, 108, 0.45);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45); justify-content: center;
}
#ePlan .station.below { background: rgba(26, 14, 8, 0.78); border-color: rgba(214, 178, 108, 0.3); }
#ePlan .station.absent { display: none; }
#ePlan .station.burning { background: rgba(120, 36, 14, 0.9); border-color: #ff8a4a; }
#ePlan .station.hit { background: rgba(240, 138, 93, 0.75); }
#ePlan .station .nm { display: flex; align-items: center; gap: 3px; color: var(--paper); }

#ePlan .station .ecrew { font-size: 0.56rem; color: var(--muted); }
#ePlan .station .tg { font-size: 0.56rem; min-height: 0; }
#ePlan .station .bar { position: absolute; left: 4px; right: 4px; bottom: 2px; height: 2px; }
#ePlan .station .chips { position: absolute; right: -3px; top: -6px; }
#ePlan .station .chip { font-size: 0.5rem; }
#ePlan .station[data-room="sails"], #ePlan .station[data-room="look"] { background: rgba(10, 16, 26, 0.5); }
#ePlan .station.aimed { border-color: #ff6a3d; box-shadow: 0 0 0 1px #ff6a3d, 0 0 10px rgba(255, 106, 61, 0.45); }

/* Fjendepanelet, udbygget */
#enemyPanel { padding: 12px 14px 14px; overflow: auto; }
#enemyPanel header h2 { font-size: 1.25rem; }
#enemyPanel header small { display: block; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.emeters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 14px; font-size: 0.78rem; }
.emeters > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.emeters label { font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.emeters label b { color: var(--paper); letter-spacing: 0; font-size: 0.78rem; }
.emeters .bar { height: 7px; }
.emeters .big .bar { height: 10px; }
.emeters .val { color: var(--paper); font-weight: 700; }
#ePlan .station { font-size: 0.7rem; }
#ePlan .station .nm { font-size: 0.62rem; }
#ePlan .station .nm .tg { margin-left: auto; }
#ePlan .station .est { font-size: 0.56rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ePlan .station .est.bad { color: #ff9a7a; font-weight: 700; }
.gbtns { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 1px; }
.egb { position: relative; width: 26px; height: 20px; padding: 0; border-radius: 4px; display: grid; place-items: center; background: rgba(255,255,255,0.06); border: 1px solid rgba(214,178,108,0.35); cursor: crosshair; }
.egb .px { width: 14px; height: 14px; }
.egb i { position: absolute; left: 2px; right: 2px; bottom: 1px; height: 2px; border-radius: 1px; background: rgba(255,255,255,0.12); overflow: hidden; }
.egb i u { display: block; height: 100%; width: 0; background: #ff8a5a; }
.egb.ready i u { background: #ff4a2a; }
.egb.off { background: rgba(120, 30, 20, 0.6); border-color: #ff6a3d; opacity: 0.7; }
.egb.off::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: #ffb09a; font-size: 0.8rem; font-weight: 700; }
.egb.aim { outline: 2px solid #ff6a3d; outline-offset: 1px; }
.egb:hover { border-color: #fff; }
.eGunsHead { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--display); color: var(--brass); font-size: 0.95rem; }
.eGunsHead small { font-family: var(--body); font-size: 0.7rem; color: var(--muted); }
.eguns { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 5px; }
.eg { display: grid; grid-template-columns: auto 1fr; gap: 2px 6px; align-items: center; padding: 4px 6px; border-radius: 6px; background: rgba(255,255,255,0.04); border: 1px solid rgba(214,178,108,0.2); font-size: 0.68rem; cursor: crosshair; }
.eg:hover { border-color: rgba(214,178,108,0.6); }
.eg .egn { display: flex; align-items: center; gap: 4px; font-weight: 700; color: var(--paper); grid-row: span 2; }
.eg .bar { height: 4px; }
.eg .bar i { background: #ff8a5a; }
.eg.ready .bar i { background: #ff4a2a; }
.eg .egt { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eg.danger .egt { color: #ffb09a; font-weight: 700; }
.eg.off { opacity: 0.45; }
.eg.idle { opacity: 0.6; }
.eg.aim { border-color: #ff6a3d; }
/* Kanoner der skal repareres */
.gcard .rep { display: none; padding: 1px 6px; font-size: 0.66rem; font-weight: 700; border-radius: 4px; background: #b8461f; border-color: #ff9a5a; color: #fff; }
.gcard.broken .rep { display: inline-block; }
.gcard.broken .gam { display: none; }
.gcard.broken { border-color: #ff6a3d; background: rgba(90, 24, 14, 0.6); opacity: 1; animation: brokenPulse 1.4s ease-in-out infinite; }
.gcard.fixing { animation: none; }
@keyframes brokenPulse { 50% { box-shadow: 0 0 0 3px rgba(255, 106, 61, 0.35); } }
.gcard.fired { animation: gunRecoil 1.1s linear; }
/* rekyl: kortet slår hurtigt ned og glider langsomt tilbage over et sekund */
@keyframes gunRecoil {
  0% { transform: translateY(0); background: rgba(255, 220, 150, 0.85); animation-timing-function: cubic-bezier(.1, .9, .3, 1); }
  7% { transform: translateY(10px); background: rgba(255, 190, 110, 0.7); animation-timing-function: cubic-bezier(.3, .05, .25, 1); }
  100% { transform: translateY(0); background: rgba(255, 255, 255, 0.04); }
}
/* Treffer på os: rød kant om skærmen */
#hurtFlash { position: fixed; inset: 0; pointer-events: none; z-index: 4; opacity: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(200, 30, 10, 0.55) 100%); transition: opacity 0.5s ease-out; }
/* Skalering af paneler */
.grip { position: absolute; width: 16px; height: 16px; z-index: 3; opacity: 0.45; touch-action: none; border: 0; padding: 0; background: none; }
.grip:hover, .grip.on { opacity: 1; }
.grip::before { content: ""; position: absolute; inset: 3px; border-color: var(--brass); border-style: solid; border-width: 0; }
.grip.br { cursor: nwse-resize; }
.grip.br::before { border-right-width: 2px; border-bottom-width: 2px; border-bottom-right-radius: 4px; }
.grip.tr { cursor: nesw-resize; }
.grip.tr::before { border-right-width: 2px; border-top-width: 2px; border-top-right-radius: 4px; }
#title, #battery, #crewPanel { position: relative; }

/* Våbenkammeret */
#armory { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(6, 12, 22, 0.6);
  padding-block: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
#armory > .panel { width: min(1040px, 100%); max-height: 100%; overflow: auto; padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
#armory h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.6rem; color: var(--brass); }
#armory h2 small { display: block; font-family: var(--body); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.arGrid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
@media (max-width: 820px) { .arGrid { grid-template-columns: 1fr; } }
.arShipWrap { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.arRow { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 8px; }
.arRow::before { content: attr(data-label); grid-column: 1 / -1; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.arShip svg { display: block; width: 100%; height: auto; }
.arH { margin: 6px 0 0; font-family: var(--display); font-weight: 400; font-size: 1.05rem; color: var(--brass); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.arH small { font-family: var(--body); font-size: 0.72rem; color: var(--muted); }
.arHold { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; min-height: 76px; padding: 8px; border: 1px dashed rgba(214, 178, 108, 0.35); border-radius: 8px; background: rgba(0, 0, 0, 0.15); }
.arHold.over, .arSlot.over { border-color: var(--brass); background: rgba(214, 178, 108, 0.14); }
.arSlot { min-height: 76px; border: 1px dashed rgba(214, 178, 108, 0.35); border-radius: 8px; display: flex; align-items: stretch; justify-content: center; position: relative; }
.arSlot.empty { align-items: center; color: var(--muted); font-size: 0.72rem; }
.arSlot .lbl { position: absolute; left: 6px; top: -1px; font-size: 0.58rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); background: var(--panel); padding: 0 4px; translate: 0 -50%; }
.wc { flex: 1; display: grid; grid-template-columns: 34px 1fr; gap: 2px 8px; align-items: center; padding: 8px 8px 7px; border-radius: 7px; background: rgba(255,255,255,0.05); border: 1px solid rgba(214,178,108,0.3); cursor: grab; text-align: left; color: var(--paper); font: inherit; }
.wc:hover { border-color: rgba(214,178,108,0.7); }
.wc.sel { border-color: var(--brass); box-shadow: 0 0 0 2px rgba(214,178,108,0.45); background: rgba(80, 60, 22, 0.6); }
.wc .px { width: 30px; height: 30px; grid-row: span 3; }
.wc b { font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc .cb { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.1); overflow: hidden; }
.wc .cb i { display: block; height: 100%; }
.wc small { font-size: 0.64rem; color: var(--muted); }
.arInfo { border: 1px solid rgba(214,178,108,0.25); border-radius: 10px; padding: 12px; background: rgba(0,0,0,0.18); display: flex; flex-direction: column; gap: 8px; font-size: 0.8rem; position: sticky; top: 0; }
.arInfo .big { display: flex; gap: 10px; align-items: center; }
.arInfo .big .px { width: 48px; height: 48px; }
.arInfo h4 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.15rem; color: var(--brass); }
.arInfo p { margin: 0; color: var(--muted); line-height: 1.4; }
.stat { display: grid; grid-template-columns: 78px 1fr 34px; gap: 6px; align-items: center; font-size: 0.72rem; }
.stat .bar { height: 6px; }
.stat b { text-align: right; font-variant-numeric: tabular-nums; }
.traits { display: flex; flex-wrap: wrap; gap: 4px; }
.traits span { font-size: 0.66rem; padding: 1px 6px; border-radius: 10px; background: rgba(214,178,108,0.18); color: var(--paper); }
.arBtns { display: flex; flex-wrap: wrap; gap: 6px; }
.wear { font-style: normal; font-size: 0.58rem; font-weight: 700; letter-spacing: 0.04em; padding: 0 4px; border-radius: 3px; margin-left: 4px; }
.w-new { background: #3f9a6c; color: #fff; } .w-good { background: #6b8f4e; color: #fff; } .w-worn { background: #b8862e; color: #1a1006; }
.w-bad { background: #c9542b; color: #fff; } .w-ruin { background: #8e1f1f; color: #fff; }
.cb .w-new, .cb i.w-new { background: #3f9a6c; } .cb i.w-good { background: #6b8f4e; } .cb i.w-worn { background: #d0a040; } .cb i.w-bad { background: #c9542b; } .cb i.w-ruin { background: #8e1f1f; }
.gcard .gname { display: flex; align-items: center; gap: 4px; font-size: 0.68rem; min-width: 0; }
.gcard .gname b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gcard .gname .px { width: 13px; height: 13px; }

/* Skrogmåler i venstre side, delt i skrogpoint */
#gauges {
  position: fixed;
  z-index: 7;
  left: max(8px, env(safe-area-inset-left, 0px));
  translate: 0 -50%;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 4px 4px;
  pointer-events: none;
}
#hullGauge, #moraleGauge { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 0; }
#moraleGauge .hgHead, #hullGauge .hgHead { display: flex; flex-direction: column; align-items: center; line-height: 1; text-shadow: 0 1px 4px rgba(0,0,0,0.8); }
#moraleGauge .hgHead b { font: 700 0.9rem var(--body); color: var(--paper); font-variant-numeric: tabular-nums; }
#moraleGauge .hgHead small, #hullGauge .hgHead small { font-size: 0.42rem; letter-spacing: 0; text-transform: uppercase; color: var(--muted); }
#mgBar { flex: 1; width: 16px; display: flex; flex-direction: column-reverse; gap: 2px; padding: 2px; border-radius: 5px; background: rgba(6, 12, 22, 0.75); border: 1px solid rgba(214, 178, 108, 0.45); box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
#mgBar i { flex: 1; border-radius: 1px; background: rgba(255,255,255,0.07); transition: background 0.3s; }

#moraleGauge.full #mgBar { box-shadow: 0 0 14px rgba(143, 208, 255, 0.7); }

#moraleGauge.mutiny #mgBar { animation: hgPulse 1s ease-in-out infinite; }
#mgNote { grid-column: 1 / -1; justify-self: start; white-space: nowrap; font: 700 0.68rem var(--body); text-shadow: 0 1px 4px rgba(0,0,0,0.9); color: var(--paper); }
#mgNote:empty { display: none; }
#mgNote.bad { color: #ff5a3c; background: rgba(40, 6, 4, 0.8); border: 1px solid #ff5a3c; border-radius: 4px; padding: 1px 6px; }
#mgNote.good { color: #8fd0ff; }
#gauges.shake { animation: hgShake 0.18s linear; }
#hullGauge .hgHead { display: flex; flex-direction: column; align-items: center; line-height: 1; text-shadow: 0 1px 4px rgba(0,0,0,0.8); }
#hullGauge .hgHead b { font: 700 0.9rem var(--body); color: var(--paper); font-variant-numeric: tabular-nums; }
#hullGauge .hgHead small { font-size: 0.5rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
#hgBar { flex: 1; display: flex; flex-direction: column-reverse; gap: 1px; padding: 2px; border-radius: 5px; background: rgba(6, 12, 22, 0.75); border: 1px solid rgba(214, 178, 108, 0.45); box-shadow: 0 4px 14px rgba(0,0,0,0.4); }
#hgBar i { flex: 1; border-radius: 1px; background: rgba(255,255,255,0.07); transition: background 0.25s; }

#hullGauge.low #hgBar { animation: hgPulse 1s ease-in-out infinite; }
@keyframes hgPulse { 50% { box-shadow: 0 0 14px rgba(224, 64, 46, 0.7); } }
#hgBar i.lost { transition: none; }
#hullGauge.shake { animation: none; }
#btnAbout.urgent { background: #b8461f; border-color: #ff9a5a; color: #fff; animation: dousePulse 1.2s ease-in-out infinite; }
#hgBar i.lost { background: #fff !important; box-shadow: 0 0 8px #fff; }
#hgBar i.ghost { background: linear-gradient(135deg, #ffd0c4 0 35%, #ff4a2a 35% 100%) !important; box-shadow: 0 0 7px rgba(255, 74, 42, 0.8); transition: none; }
#hgBar i.drain { background: rgba(255, 74, 42, 0.0) !important; transition: background 0.4s ease-out !important; }
.hgPop small { display: block; font-size: 0.42em; font-weight: 600; color: #ffc0b0; letter-spacing: 0.04em; }
.hgPop.big { color: #ff4a2a; }
.hgPop { position: fixed; z-index: 8; pointer-events: none; font: 800 1rem var(--body); line-height: 1; color: #ff7a5a; text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 10px rgba(255, 60, 30, 0.45); animation: hgPopUp 1.5s ease-out forwards; }
@keyframes hgPopUp { from { opacity: 1; translate: 0 0; scale: 1.3; } to { opacity: 0; translate: 10px -26px; scale: 1; } }

#topleft { max-width: calc(100vw - 82px); }

/* ===== HUD 2: en roligere opdeling =====
   top: én tynd bjælke med navn, ressourcer og knapper
   venstre: skrog og moral, stationer øverst, kanoner nederst
   højre: fjendens skib i kamp, ellers kompasset */
#hudTop { position: fixed; top: 0; left: 0; right: 0; z-index: 9; display: flex; align-items: center; gap: 14px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 14px max(12px, env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, rgba(6, 12, 22, 0.88) 0%, rgba(6, 12, 22, 0.6) 60%, rgba(6, 12, 22, 0) 100%); pointer-events: none; }
#hudTop > * { pointer-events: auto; }
body.menu #hudTop, body.menu #gauges { display: none !important; }
.brand { white-space: nowrap; display: flex; align-items: baseline; gap: 8px; }
.brand small { font: 700 0.62rem var(--body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
#hudTop .chips { display: flex; gap: 6px; align-items: center; min-width: 0; }
.chip2, #conds > span { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; white-space: nowrap; color: var(--muted); }
.chip2 b { color: var(--paper); font-variant-numeric: tabular-nums; }

#conds > span.neg { color: #ffb09a; border-color: rgba(255, 106, 61, 0.4); }
#conds > span.pos { color: #a8e6bf; border-color: rgba(143, 230, 168, 0.35); }
.hudBtns { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.hudBtns button { padding: 4px 10px; font-size: 0.78rem; }
#topright .btnrow { display: none; }
body:not(.in-combat) #btnDeck { display: none; }
#topright { top: calc(52px + env(safe-area-inset-top, 0px)); }
#help:not([hidden]) { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); z-index: 12; width: 340px; max-height: calc(100vh - 80px); overflow: auto; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55); }
#topleft { top: calc(56px + env(safe-area-inset-top, 0px)); }

/* stationer: en stram liste, farvet kant viser tilstanden */

#crewPanel .cphead .meter:has(#hullBarWrap), #crewPanel .cphead .meter:has(#moraleWrap) { display: none; }

#crewPanel .srow { padding: 3px 6px; border-left: 3px solid rgba(214, 178, 108, 0.35); border-radius: 4px; }
#crewPanel .srow[data-state="good"] { border-left-color: #4fc27a; }
#crewPanel .srow[data-state="bad"] { border-left-color: #e0602e; }
#crewPanel #crewInfo { font-size: 0.7rem; }

/* kanoner: en vandret række nederst til venstre */
body #battery {
  grid-template-columns: auto auto;
  grid-template-rows: auto 1fr;
}

#battery h2 { grid-column: 1 / -1; padding-right: 44px; }
body #battery .glist { align-items: stretch; }

#battery .gcard { width: 146px; grid-template-areas: "n m" "a a"; row-gap: 4px; }
#battery .gcard .gn { grid-area: n; }
#battery .gcard .gmid { grid-area: m; }
#battery .gcard .gam { grid-area: a; justify-content: flex-end; }
#battery .gcard .rep { grid-area: a; justify-self: end; }

/* kompasset til højre når der ikke er kamp; i kamp får fjendens skib pladsen */

body:not(.in-combat) #enemyPanel { display: none !important; }
#enemyPanel:not(.floating) { top: auto; }
#enemyPanel { max-height: calc(100vh - 76px); }

@media (max-width: 760px) {
  .brand small { display: none; }
  #battery { max-width: calc(100vw - 80px); }
  body.in-combat #battery { max-width: calc(100vw - 80px); }
  #crewPanel { width: 250px; }
}

/* HUD 3: større navn, tydelige ressourcer, ry-tæller, døgnskive og bredere skrog */
.brand { font: 400 2.2rem/1 "Pirata One", var(--display); color: #f2cf7a; letter-spacing: 0.02em; text-shadow: 0 2px 0 #4a2e10, 0 3px 12px rgba(0,0,0,0.6); }
.brand small { font-family: var(--body); }
.brand { font-size: 3.1rem; }
.brand #shipName { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1280px) {
  .brand { font-size: 2.2rem; }
  #hudTop { gap: 10px; }
  .chip2 { font-size: 0.82rem; padding: 2px 9px 2px 6px; gap: 5px; }
  .chip2 .px, .chip2.mat .px { width: 16px; height: 16px; }
  #hudTop .chips { gap: 4px; }
  #hudTop { flex-wrap: wrap; row-gap: 2px; }
  .hudBtns { flex: 1 0 100%; max-width: none !important; margin-top: -2px; flex-wrap: nowrap !important; }
  .hudBtns button { padding: 2px 8px; font-size: 0.72rem; }
  body #topleft { top: calc(90px + env(safe-area-inset-top, 0px)) !important; }
}
@media (max-width: 1000px) {
  .brand { font-size: 1.8rem; }
  .brand small { display: none; }
  #hudTop .chips { flex-wrap: wrap; flex: 1 1 auto; }
  body #topleft { top: calc(124px + env(safe-area-inset-top, 0px)) !important; }
}
.chip2 { font-size: 1.02rem; padding: 4px 13px 4px 9px; gap: 7px; border: 2px solid #c9a04a; background: rgba(20, 13, 4, 0.72); box-shadow: inset 0 0 0 1px rgba(255, 220, 140, 0.15), 0 2px 8px rgba(0,0,0,0.35); color: #e8d6a8; }
.chip2 b { font-size: 1.1rem; }
.chip2 .px { width: 22px; height: 22px; }
#infamyBox { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
#infStars { font-size: 0.95rem; letter-spacing: 1px; color: #6a4a40; }
#infStars i { font-style: normal; color: #ff6a3d; text-shadow: 0 0 6px rgba(255, 106, 61, 0.6); }
#infTitle { font: 700 0.58rem var(--body); letter-spacing: 0.14em; text-transform: uppercase; color: #e8b0a0; margin-top: 2px; }
#infamyBox.t5 { border-color: #ff3a1a; animation: hgPulse 1.4s ease-in-out infinite; }
body #topleft { top: calc(70px + env(safe-area-inset-top, 0px)); }

#help:not([hidden]) { top: calc(66px + env(safe-area-inset-top, 0px)); }
#gauges { grid-template-columns: 36px 24px; height: min(54vh, 480px); top: calc(50% + 10px); }
#hgBar { width: 30px; }
#hullGauge .hgHead b { font-size: 1.05rem; }
#topleft { left: calc(max(16px, env(safe-area-inset-left, 0px)) + 66px); }

.cc.ill { box-shadow: 0 0 0 2px #8fd04a; }
.cc.ill::after { content: "✚"; position: absolute; font-size: 0.55rem; color: #8fd04a; }

#gunHint.warn { color: #ffb09a; font-weight: 700; animation: dousePulse 1.2s ease-in-out infinite; border-radius: 4px; padding: 0 4px; }
#dbg { position: fixed; z-index: 40; right: 12px; top: calc(66px + env(safe-area-inset-top, 0px)); width: 330px; max-width: calc(100vw - 24px); padding: 8px 10px; font: 11px/1.45 ui-monospace, Menlo, Consolas, monospace; color: #cfe8d0; background: rgba(0, 0, 0, 0.82); border: 1px solid #4a6a4a; border-radius: 8px; white-space: pre-wrap; user-select: text; }

#port .portGrid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; flex: 1; min-height: 0; }
@media (max-width: 900px) { #port > .panel { overflow: auto; } #port .portGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
#port .cards { gap: 4px; }
#port .card { padding: 5px 7px; gap: 6px; }
#port .card .ci b { font-size: 0.8rem; }
#port .card .ci span { font-size: 0.68rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#port .card button { min-width: 58px; padding: 4px 6px; font-size: 0.78rem; }
#port h3 { font-size: 1rem; margin-bottom: 4px; }
#port h3 small { display: block; margin: 0; }
#portNotes { display: block; font: italic 400 0.8rem var(--body); color: #e8c27a; margin-top: 2px; }
#workshop { position: fixed; inset: 0; z-index: 31; display: flex; align-items: center; justify-content: center; background: rgba(6, 12, 22, 0.6);
  padding-block: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
#workshop > .panel { max-height: 100%; overflow: auto; padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 10px; }
#workshop .res span { display: inline-flex; align-items: center; gap: 4px; }
#workshop .res .px { width: 18px; height: 18px; }
.wsGrid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; align-items: start; }
#wsBuild { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
@media (max-width: 760px) { .wsGrid { grid-template-columns: 1fr; } }
#workshop h3 { margin: 0 0 6px; font-family: var(--display); font-weight: 400; font-size: 1.05rem; color: var(--brass); }
#workshop h3 small { font-family: var(--body); font-size: 0.72rem; color: var(--muted); margin-left: 6px; }
#workshop .card { padding: 5px 8px; gap: 6px; }
#workshop .card .ci b { font-size: 0.82rem; }
#workshop .card .ci span { font-size: 0.7rem; line-height: 1.25; }
#workshop .card button { min-width: 64px; padding: 4px 6px; font-size: 0.78rem; }
#pMsg, #wsMsg { flex: 1; }
.wsNote { margin: 0; font-size: 0.8rem; color: #ffd98a; }
.wsNote.bad { color: #ff9a7a; }
.wsHow { margin: 0; font-size: 0.76rem; color: var(--muted); line-height: 1.4; }
.mcost { display: inline-flex; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.72rem; }
.mcost span { display: inline-flex; align-items: center; gap: 2px; color: var(--paper); }
.mcost span.short { color: #ff8a6a; }
.mcost .px { width: 14px; height: 14px; }
.chip2.mat .px { width: 22px; height: 22px; }
.pnone { margin: 2px 0; font-size: 0.74rem; color: var(--muted); font-style: italic; }

#stationTags .stag { display: none !important; }
.sideNow { grid-column: 1 / -1; font-size: 0.74rem; padding: 3px 10px; border-radius: 4px; border-left: 4px solid; background: rgba(10, 8, 6, 0.4); }
.sideNow.port { border-color: #d2463c; } .sideNow.port b { color: #ff8a7a; }
.sideNow.stbd { border-color: #3fae5a; } .sideNow.stbd b { color: #8fe6a8; }
.sideNow.empty { background: rgba(120, 36, 14, 0.55); animation: dousePulse 1.2s ease-in-out infinite; }
#crewPanel .srow[data-id="port"] .sn b, #crewPanel .srow[data-id="port"] .sn { color: #ff8a7a; }
#crewPanel .srow[data-id="stbd"] .sn { color: #8fe6a8; }
#crewPanel .srow.enemyside { box-shadow: inset 0 0 0 2px #ffd98a; }
#crewPanel .srow.enemyside .sn::after { content: " ⚔ enemy side"; font-size: 0.6rem; color: #ffd98a; letter-spacing: 0.04em; }
#crewPanel .srow.enemyside.unmanned .sn::after { content: " ⚔ enemy side · man it!"; color: #ff8a5a; }
.gcard .gn { font-weight: 700; font-size: 0.78rem; }
.gcard.pside .gn { color: #ff8a7a; } .gcard.sside .gn { color: #8fe6a8; }
.role { font: 700 0.6rem var(--body); letter-spacing: 0.06em; text-transform: uppercase; padding: 1px 6px; clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%); color: #1a1006; }
.role.r-round { background: #d6b26c; } .role.r-chain { background: #8fc8ff; } .role.r-grape { background: #ff9a7a; } .role.r-fire { background: #ffb84d; }
.chip2 .med { font-size: 1rem; }

/* Flytbare og minimerbare paneler */
.wtools { position: absolute; z-index: 4; display: flex; gap: 2px; opacity: 0.45; transition: opacity 0.15s; }
.panel:hover > .wtools, .wtools:focus-within { opacity: 1; }
.wbtn { width: 20px; height: 18px; padding: 0; border-radius: 4px; font: 700 0.75rem/1 var(--body); display: grid; place-items: center; background: rgba(255,255,255,0.06); border: 1px solid rgba(214,178,108,0.3); color: var(--brass); }
.wbtn.wmove { cursor: grab; touch-action: none; }
.wbtn.wmove:active { cursor: grabbing; }
.panel.floating { position: fixed !important; margin: 0; z-index: 8; }
.panel.dragging { box-shadow: 0 14px 40px rgba(0,0,0,0.5); transition: none; opacity: 0.94; }
.panel.min > *:not(.wtools):not(.grip) { display: none !important; }
.panel.min { padding: 7px 56px 7px 12px !important; width: auto !important; min-width: 0 !important; height: auto !important; overflow: visible !important; }
.panel.min::before { content: attr(data-wtitle); font: 400 0.95rem var(--display); color: var(--brass); white-space: nowrap; }
.panel.min > .grip { display: none !important; }
#battery h2, #crewPanel h2 { padding-right: 44px; }
#enemyPanel header { padding-right: 48px; }
#title h1 { padding-right: 40px; }
#battery h2, #crewPanel h2, #enemyPanel header, #title h1 { cursor: grab; user-select: none; }

/* Glidende bjælker og små animationer */
.bar > i, .gbar i, .egb u, .eg .bar i { transition: width 0.18s linear; }
#hullBar, #epHullBar, #waterBar, #epWaterBar { transition: width 0.45s cubic-bezier(.2,.8,.2,1); }
.floater.big { animation: floatPop 0.38s cubic-bezier(.2, 1.7, .4, 1); }
@keyframes floatPop { from { scale: 0.3; } to { scale: 1; } }
#battleLog div:last-child { animation: logIn 0.3s ease-out; }
@keyframes logIn { from { opacity: 0; transform: translateY(6px); } }
#ePlan .station.hit { animation: cellShake 0.35s ease-out; }
@keyframes cellShake { 20% { translate: -3px 0; } 40% { translate: 3px 0; } 60% { translate: -2px 0; } 80% { translate: 1px 0; } }
#ePlan .station.ping { animation: cellPing 0.5s ease-out; }
@keyframes cellPing { from { box-shadow: 0 0 0 6px rgba(255, 106, 61, 0.7); } to { box-shadow: 0 0 0 0 rgba(255, 106, 61, 0); } }
#ePlan .station.hov, .egb.hov { border-color: #fff; box-shadow: 0 0 0 1px #fff; }
.gcard.ready:not(.idle):not(.broken):not(.off) { box-shadow: 0 0 0 1px rgba(143, 230, 168, 0.55); }
.gcard.loaded { animation: gunLoaded 0.5s ease-out; }
@keyframes gunLoaded { from { box-shadow: 0 0 0 4px rgba(143, 230, 168, 0.7); } }
#enemyPanel.sinking #ePlan::after { content: "SINKING"; position: absolute; left: 50%; top: 42%; translate: -50% -50%; rotate: -12deg; padding: 4px 16px; border: 3px solid #e0503a; border-radius: 6px; color: #ff7a5a; font: 400 2rem var(--display); letter-spacing: 0.12em; background: rgba(20, 8, 4, 0.55); animation: stampIn 0.4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes stampIn { from { scale: 2.2; opacity: 0; } }
#enemyPanel.sinking #ePlan { filter: grayscale(0.6) brightness(0.8); transition: filter 1s; }
#banner { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 13; pointer-events: none; text-align: center; opacity: 0; }
#banner b { display: block; font: 400 clamp(2rem, 5vw, 3.4rem)/1 var(--display); color: var(--brass); letter-spacing: 0.06em; text-shadow: 0 3px 18px rgba(0,0,0,0.7); }
#banner small { display: block; margin-top: 6px; font-size: 0.85rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--paper); text-shadow: 0 2px 8px rgba(0,0,0,0.8); }
#banner.bad b { color: #ff7a5a; }
#banner.show { animation: bannerIn 2.4s ease-out forwards; }
@keyframes bannerIn { 0% { opacity: 0; scale: 1.3; letter-spacing: 0.3em; } 12% { opacity: 1; scale: 1; } 75% { opacity: 1; } 100% { opacity: 0; scale: 0.96; } }
.px { width: 14px; height: 14px; flex: none; display: inline-block; vertical-align: -3px; image-rendering: pixelated; }
.px.flip { transform: scaleX(-1); }
#ePlan .px { width: 12px; height: 12px; }
.sn { display: flex; align-items: center; gap: 4px; }
.stag > span:first-child { display: flex; align-items: center; gap: 3px; }

.station .ecrew { font-size: 0.66rem; color: var(--paper); font-variant-numeric: tabular-nums; }
.station.unknown .ecrew { visibility: hidden; }
.station.hit { background: rgba(240, 138, 93, 0.6); }
.station.absent { opacity: 0.22; }
#enemyPanel .meters { flex-wrap: wrap; }
.epdist { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.epnote { margin: 0; font-size: 0.78rem; color: var(--muted); }
#enemyPanel.empty #ePlan, #enemyPanel.empty .meters { opacity: 0.35; }

#crewPanel { padding: 10px 12px 10px; display: flex; flex-direction: column; gap: 7px; width: 340px; max-width: calc(100vw - 32px); }
.cphead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
#crewPanel h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1rem; color: var(--brass); }

#chart {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 12, 22, 0.55);
  padding-block: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#chart > .panel { width: min(980px, 100%); max-height: 100%; overflow: auto; padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.chartHead { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px 16px; }
.chartHead h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.6rem; color: var(--brass); }
#chart .chartHead { flex-direction: column; align-items: center; text-align: center; gap: 2px; }
#chartTitle { display: flex; flex-direction: column; align-items: center; font-size: 2.9rem; line-height: 1.05; }
#chartTitle #chartName { font-family: "Pirata One", var(--display); letter-spacing: 0.02em; text-shadow: 0 2px 0 #4a2e10, 0 3px 12px rgba(0, 0, 0, 0.5); }
#chartSector { font-size: 0.9rem !important; letter-spacing: 0.16em !important; }
#chartSector b { font: 400 1.9rem var(--display); color: #f2cf7a; letter-spacing: 0; margin: 0 4px; vertical-align: -0.12em; }
#chart .chartHead .res { justify-content: center; font-size: 0.85rem; }
.chartHead small { display: block; font-size: 0.78rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.res { display: flex; gap: 14px; flex-wrap: wrap; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.9rem; }
.res b { color: var(--paper); }
.chartWrap { overflow-x: auto; border-radius: 8px; }
#chartSvg { width: 100%; min-width: 620px; height: auto; display: block; background: #0b1726; }
#chartSvg .grid { stroke: rgba(143, 180, 210, 0.08); stroke-width: 1; }
#chartSvg .edge { stroke: rgba(214, 178, 108, 0.32); stroke-width: 1.5; stroke-dasharray: 4 5; }
#chartSvg .edge.reach { stroke: rgba(214, 178, 108, 0.95); stroke-dasharray: none; }
#chartSvg .node circle { fill: #13263b; stroke: #9c8150; stroke-width: 1.5; }

#chartSvg .node.lost circle { fill: #3a1a14; stroke: #f08a5d; }
#chartSvg .node.reach { cursor: pointer; }
#chartSvg .node.reach circle { stroke: #d6b26c; stroke-width: 2.5; animation: pulse 1.4s ease-in-out infinite; }
#chartSvg .node.sel circle { fill: #3a2f16; stroke: #ffe3a0; stroke-width: 3; animation: none; }
#chartSvg .node.cur circle { fill: #2a3d55; stroke: #f1e9d8; stroke-width: 2.5; }
#chartSvg .node:focus { outline: none; }
#chartSvg .node:focus-visible circle { stroke: #fff; }
#chartSvg .gl path { stroke: #d6b26c; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }
#chartSvg .gl .f { fill: #d6b26c; stroke: none; }
#chartSvg .nlbl { fill: #b9c3cf; font: 600 11px "Alegreya Sans", system-ui, sans-serif; text-anchor: middle; letter-spacing: 0.04em; }
#chartSvg .fleetLbl { fill: #f2a088; font: 700 13px "Alegreya Sans", system-ui, sans-serif; letter-spacing: 0.08em; }
#chartSvg .shipMark { fill: #f1e9d8; }
@keyframes pulse { 50% { stroke-opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { #chartSvg .node.reach circle { animation: none; } }
.chartFoot { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
#nodeInfo { flex: 1 1 280px; min-width: 0; font-size: 0.92rem; color: var(--muted); line-height: 1.45; }
#nodeInfo b { color: var(--paper); font-family: var(--display); font-weight: 400; font-size: 1.1rem; }
.warn { color: var(--warn); }
.primary { background: var(--brass); color: var(--ink); border-color: var(--brass); font-weight: 700; }
.primary:disabled { opacity: 0.4; cursor: not-allowed; }

#eventBox {
  position: fixed;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
#eventBox h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.5rem; color: var(--brass); text-wrap: balance; }
#eventBox p { margin: 0; }
.choices { display: flex; flex-direction: column; gap: 6px; }
.choices button { text-align: left; padding: 9px 12px; font-size: 0.95rem; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.choices button small { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.choices button:disabled { opacity: 0.45; cursor: not-allowed; }
.fx { display: flex; flex-wrap: wrap; gap: 6px; }
.fx:empty { display: none; }
.fx span { font-size: 0.8rem; padding: 2px 9px; border-radius: 10px; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.14); }
.fx .neg { color: var(--warn); }
.fx .pos { color: var(--good); }

#port {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 12, 22, 0.55);
  padding-block: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
#port > .panel { width: min(1080px, 100%); max-height: 100%; overflow: auto; padding: 16px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
#port h3 { margin: 0 0 6px; font-family: var(--display); font-weight: 400; font-size: 1.1rem; color: var(--brass); }
#port h3 small { font-family: var(--body); font-size: 0.78rem; color: var(--muted); letter-spacing: 0.02em; margin-left: 6px; }
.portGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; align-items: start; }
@media (max-width: 860px) { .portGrid { grid-template-columns: 1fr; } }
.cards { display: flex; flex-direction: column; gap: 6px; }
.card {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(214, 178, 108, 0.18);
}
.card .ci { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card .ci b { font-weight: 700; }
.card .ci span { font-size: 0.82rem; color: var(--muted); }
.card .pips { color: var(--brass); letter-spacing: 0.15em; font-size: 0.75rem; }
.card button { flex: none; min-width: 74px; font-variant-numeric: tabular-nums; }
.card.done { opacity: 0.55; }
.portFoot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
#pMsg { color: var(--muted); font-size: 0.9rem; min-height: 1.2em; }

#splitLine { position: fixed; pointer-events: none; z-index: 2; background: rgba(214, 178, 108, 0.55); box-shadow: 0 0 12px rgba(0, 0, 0, 0.6); }
#splitLine.v { top: 0; bottom: 0; left: 50%; width: 2px; transform: translateX(-1px); }
#splitLine.h { left: 0; right: 0; top: 50%; height: 2px; transform: translateY(-1px); }
.viewLabel { position: fixed; z-index: 3; pointer-events: none; font: 400 0.95rem var(--display); color: var(--brass); letter-spacing: 0.06em; text-shadow: 0 1px 6px rgba(0,0,0,0.8); }
#battleLog {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 7;
  width: min(440px, calc(100vw - 32px)); padding: 6px 10px; pointer-events: none;
  display: flex; flex-direction: column; gap: 2px; font-size: 0.78rem; line-height: 1.35;
}
#battleLog div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
#battleLog div:last-child { color: var(--paper); }
#battleLog b { font-weight: 700; }
#battleLog .us b { color: #8fe6a8; }
#battleLog .them b { color: var(--warn); }
.floater.big { line-height: 1.25; }
.floater.big::first-line { font-family: var(--display); font-weight: 400; font-size: 1.5rem; }
.srow.hit { animation: rowHit 0.9s ease-out; }
@keyframes rowHit { from { background: rgba(255, 90, 60, 0.6); } to { background: transparent; } }

#crewPanel h2 { display: flex; align-items: center; gap: 6px; }
button.mini { padding: 0 6px; font-size: 0.8rem; line-height: 1.4; border-radius: 5px; }
.slist { display: flex; flex-direction: column; gap: 3px; }
.srow {
  padding: 4px 6px 5px; border-radius: 6px; cursor: pointer;
  background: rgba(255, 255, 255, 0.035); border: 1px solid transparent;
  display: flex; flex-direction: column; gap: 2px;
}
.srow:hover { border-color: rgba(214, 178, 108, 0.35); }
.srow:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
.srow.target { border-color: var(--brass); background: rgba(80, 60, 22, 0.55); }
.srow.burning { background: rgba(120, 36, 14, 0.6); }
.srow.unmanned .sn { color: var(--muted); }
.sl1, .sl2 { display: flex; align-items: center; gap: 6px; }
.sn { font-size: 0.78rem; font-weight: 700; width: 80px; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc { display: flex; gap: 3px; flex: 1; min-width: 0; flex-wrap: wrap; }
.sb { display: flex; gap: 3px; flex: none; }
.sb button { padding: 0; width: 22px; height: 20px; font-size: 0.9rem; line-height: 1; border-radius: 5px; }
.sb button.douse { width: auto; padding: 0 6px; font-size: 0.68rem; font-weight: 700; background: #b8461f; border-color: #ff9a5a; color: #fff; }
#btnDouse { position: fixed; left: 50%; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 6; background: #b8461f; border-color: #ff9a5a; color: #fff; font-weight: 700; padding: 8px 16px; animation: dousePulse 1.2s ease-in-out infinite; }
#btnDouse:disabled { animation: none; opacity: 0.6; }
@keyframes dousePulse { 50% { box-shadow: 0 0 0 6px rgba(255, 120, 60, 0.35); } }
#aimHover { position: fixed; left: 0; top: 0; z-index: 8; pointer-events: none; padding: 3px 8px; border-radius: 6px; font: 700 0.78rem var(--body); color: #ffd98a; background: rgba(20, 14, 8, 0.85); border: 1px solid #ff6a3d; white-space: nowrap; transform: translate(14px, -50%); }
body.aiming #scene { cursor: crosshair; }
.se { flex: 1; min-width: 0; font-size: 0.68rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.se.bad { color: var(--warn); }
.se.good { color: var(--good); }
.sl2 .bar { width: 44px; height: 3px; flex: none; }
.cc {
  flex: none;
  position: relative;
  cursor: pointer;
  font: 700 0.55rem/15px var(--body);
  text-align: center;
  box-sizing: border-box;
}

.cc .hp { position: absolute; left: 0; }

.es { width: 19px; height: 19px; border-radius: 50%; border: 1px dashed rgba(241, 233, 216, 0.28); box-sizing: border-box; flex: none; }

.cc { touch-action: none; }
.dragGhost {
  position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none;
  display: flex; gap: 6px; align-items: center; padding: 3px 10px 3px 3px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--brass); font-size: 0.82rem; color: var(--paper);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.srow.drop, .stag.drop { outline: 2px solid var(--brass); outline-offset: 1px; background: rgba(80, 60, 22, 0.8); }
#conds { margin: 3px 0 0; font-size: 0.78rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 8px; }
#conds .neg { color: var(--warn); }
#conds .pos { color: var(--good); }

#enemyTag .aimTag { font: 700 0.7rem var(--body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
#enemyTag .aimTag.bear { color: #8fe6a8; }
#enemyTag .aimTag.far { color: var(--warn); }

#escapeTag {
  position: fixed; left: 0; top: 0; z-index: 6; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font: 700 0.8rem var(--body); color: #b8ffe0; text-shadow: 0 1px 6px rgba(0,0,0,0.8); white-space: nowrap;
}
#escapeTag .ar { font-size: 1.2rem; line-height: 1; display: block; }

#battery { display: flex; flex-direction: column; gap: 6px; width: 300px; max-width: calc(100vw - 32px); }
#battery h2 { display: flex; justify-content: space-between; gap: 8px; }
#battery h2 small { font-family: var(--body); font-size: 0.74rem; color: var(--muted); }
.glist { display: flex; flex-direction: column; gap: 4px; }
.gcard {
  display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; align-items: center;
  padding: 4px 6px; border-radius: 6px; cursor: pointer;
  border: 1px solid rgba(214, 178, 108, 0.2); background: rgba(255, 255, 255, 0.04);
}
.gcard:hover { border-color: rgba(214, 178, 108, 0.5); }
.gcard.sel { border-color: var(--brass); background: rgba(80, 60, 22, 0.75); box-shadow: 0 0 0 1px var(--brass); }
.gcard.idle { opacity: 0.4; }
.gcard.off { border-color: var(--warn); }
.gcard .gn { font-family: var(--display); color: var(--brass); text-align: center; }
.gcard .gmid { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.gcard .gbar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; display: block; }
.gcard .gbar i { display: block; height: 100%; width: 0; background: var(--brass); }
.gcard.ready .gbar i { background: #8fe6a8; }
.gcard .gt { font-size: 0.7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gcard .gam { display: flex; gap: 2px; }
.gcard .gam button { padding: 0 5px; font-size: 0.66rem; border-radius: 4px; line-height: 1.5; }
.gcard .gam button[aria-pressed="true"] { background: var(--brass); color: var(--ink); border-color: var(--brass); }

body.in-combat #battery .glist { max-width: max(170px, calc(100vw - 620px - 360px)); }

.rnote { font-size: 0.68rem; color: var(--muted); line-height: 1.3; }
.rnote b.us { color: #8fe6a8; } .rnote b.her { color: #ff9a7a; }
.rng { font: 700 0.56rem var(--body); letter-spacing: 0.05em; text-transform: uppercase; padding: 1px 5px; border-radius: 3px; border: 1px solid currentColor; color: var(--muted); }
.rng.good { color: #8fe6a8; } .rng.ok { color: var(--paper); } .rng.poor { color: #ffb84d; } .rng.out { color: #ff7a5a; text-decoration: line-through; }
.gcard.outr { opacity: 0.55; }
.einfo { margin: 6px 0 2px; padding: 6px 8px; border: 1px solid rgba(214, 178, 108, 0.25); border-radius: 6px; background: rgba(10, 8, 6, 0.35); font-size: 0.72rem; line-height: 1.4; }
.einfo .eh { display: flex; align-items: center; gap: 8px; }
.einfo .eh b { font-size: 0.8rem; }
.einfo .hpb { flex: 1; height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; overflow: hidden; }
.einfo .hpb i { display: block; height: 100%; background: #8fe6a8; }
.einfo .hpb.mid i { background: #ffb84d; } .einfo .hpb.low i { background: #ff6a4a; }
.einfo .hpn { font-variant-numeric: tabular-nums; font-weight: 700; }
.einfo .k { color: var(--muted); }
.einfo .now { color: #ffd98a; }
.einfo .now.bad { color: #ff9a7a; }
#ePlan .station .hpn { font-size: 0.56rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--paper); margin-left: 3px; }
#ePlan .station .hpn.low { color: #ff8a6a; }
#coinRain { position: fixed; inset: 0; z-index: 14; pointer-events: none; overflow: hidden; }
#coinRain .coin { position: absolute; left: 0; top: 0; will-change: transform; }
#coinRain .coin .px { width: 100%; height: 100%; }
#inventory { position: fixed; inset: 0; z-index: 31; display: flex; align-items: center; justify-content: center; background: rgba(6, 12, 22, 0.6);
  padding-block: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
#inventory > .panel { width: min(980px, 100%); max-height: 100%; overflow: auto; padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.invGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px 18px; }
.invSec h3 { margin: 0 0 6px; font: 400 1.05rem var(--display); color: var(--brass); }
.invSec h3 small { font: 400 0.7rem var(--body); color: var(--muted); margin-left: 6px; }
.invList { display: flex; flex-direction: column; gap: 4px; }
.invItem { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; padding: 5px 8px; border: 1px solid rgba(214, 178, 108, 0.18); border-radius: 6px; background: rgba(10, 8, 6, 0.3); }
.invItem .px { width: 28px; height: 28px; }
.invItem b { font-size: 0.82rem; display: block; }
.invItem small { font-size: 0.68rem; color: var(--muted); line-height: 1.25; display: block; }
.invItem .n { font: 700 1rem var(--body); font-variant-numeric: tabular-nums; color: var(--paper); }
.invItem.none { opacity: 0.45; }
.invHint { font-size: 0.74rem; color: var(--muted); flex: 1; }
.cpanel { position: fixed; z-index: 6; padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 7px; }
.cpanel[hidden] { display: none !important; }
.cpanel h2 { margin: 0; padding-right: 44px; font: 400 1.05rem var(--display); color: var(--brass); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; cursor: grab; user-select: none; }
.cpanel h2 small { font-family: var(--body); font-size: 0.74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bigBtn { width: 100%; padding: 10px 14px; font: 400 1.2rem var(--display); letter-spacing: 0.04em; }
#aboutPanel:not(.floating), #rangePanel:not(.floating) { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); left: 420px; }
#aboutPanel { width: 172px; }
#aboutPanel small, #breakPanel small { font-size: 0.72rem; color: var(--muted); line-height: 1.3; }
#rangePanel { width: 244px; }
#rangePanel .rbtns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
#rangePanel .rbtns button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 4px; }
#rangePanel .rbtns button b { font: 400 1rem var(--display); }
#rangePanel .rbtns button small { font-size: 0.66rem; color: var(--muted); }
#rangePanel .rbtns button[aria-pressed="true"] { background: var(--brass); color: var(--ink); border-color: var(--brass); }
#rangePanel .rbtns button[aria-pressed="true"] small { color: var(--ink); }

#rangePanel .rbtns button:disabled { opacity: 0.45; }
#breakPanel { padding: 0; gap: 5px; background: none; border: 0; box-shadow: none; align-items: stretch; }
#breakPanel small { text-align: center; color: #f2e6c8; text-shadow: 0 1px 2px #000, 0 0 6px rgba(0, 0, 0, 0.8); }
#breakPanel .bigBtn { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }
#breakPanel .escTrack { height: 9px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5); background: rgba(10, 14, 22, 0.7); }

#breakPanel .bigBtn { font-size: 1.35rem; padding: 10px; }
#breakPanel .bigBtn:not(:disabled) { animation: dousePulse 1.2s ease-in-out infinite; }
.escTrack { display: block; height: 10px; border-radius: 5px; background: rgba(255, 255, 255, 0.1); overflow: hidden; border: 1px solid rgba(214, 178, 108, 0.35); }
.escTrack i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4a8ac0, #8fd0ff); transition: width 0.3s linear; }
#breakPanel.ready .escTrack i { background: linear-gradient(90deg, #6ac080, #b8f0a0); }

body #battery .glist, body.in-combat #battery .glist { max-width: none; width: auto; display: flex; flex-direction: row; flex-wrap: nowrap; gap: 6px; overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }

body #battery .sideNow, body #battery h2 { min-width: 260px; }
.crow.bulw { font-size: 0.74rem; color: var(--muted); justify-content: flex-start; }
.crow.bulw > span:first-child { flex: none; }
#crewPanel .evh { flex: none; font-size: 0.66rem; font-weight: 700; padding: 0 5px; border-radius: 3px; background: rgba(143, 230, 168, 0.15); color: #8fe6a8; white-space: nowrap; }
#hudTop .chips { flex-wrap: nowrap; flex: none; }
.hudBtns { max-width: 470px; }
#coinRain .coin { width: 24px; height: 24px; }
#crewPanel .evh.low { background: rgba(255, 106, 74, 0.2); color: #ff8a6a; }
#crewPanel .evh[hidden] { display: none; }
.crow { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.crow .bar { flex: 1; height: 6px; }
.crow > span:first-child { flex: 1; min-width: 0; }
#ePlan .station { cursor: crosshair; }

/* 2026-12-03: et artefakt der rører en kanon (fx Riposte Drill) farver dens ladebar i artefaktets farve (--art), og baren glimter.
   Farven sidder til kanonen er ladt. JS: gunArtMark (16-feedback-nameless), gunArtCard (14-battle-ui) */
html body .gcard.gart .gbar i { background: linear-gradient(180deg, color-mix(in srgb, var(--art) 45%, #fff), var(--art)) !important; box-shadow: 0 0 6px var(--art); }
html body .gcard .gbar.gglint { position: relative; animation: gGlint 0.9s ease-out; }
html body .gcard .gbar.gglint::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,0.95) 50%, transparent 80%); background-size: 250% 100%; animation: gGlintSweep 0.9s ease-out forwards; pointer-events: none; }
@keyframes gGlint { 0% { box-shadow: 0 0 0 0 var(--art), 0 0 14px 4px var(--art); filter: brightness(1.9); } 100% { box-shadow: 0 0 0 0 transparent; filter: none; } }
@keyframes gGlintSweep { from { background-position: 130% 0; opacity: 1; } to { background-position: -30% 0; opacity: 0; } }
.gun.gart { background: conic-gradient(var(--art) var(--p, 100%), rgba(255,255,255,0.08) 0); box-shadow: 0 0 6px var(--art); }
