:root {
  --sb: 232px;
  --steel: #2a2d2a;
  --steel-2: #3b3f3a;
  --edge: #111;
  --accent: #d83a2c;
  --text: #e8e2d0;
  --gold: #f0c850;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #000; color: var(--text); font: 13px/1.35 "Segoe UI", Tahoma, sans-serif; overflow: hidden; user-select: none; }
#app { display: flex; height: 100vh; }
#view-wrap { position: relative; flex: 1; overflow: hidden; }
#view { display: block; cursor: none; }
#messages { position: absolute; left: 10px; top: 8px; pointer-events: none; font-weight: 600; text-shadow: 1px 1px 0 #000, 0 0 4px #000; }
#messages div { color: #9fe07a; transition: opacity .6s; }
#speed-badge { position: absolute; right: 10px; top: 8px; color: var(--gold); font-weight: 700; text-shadow: 1px 1px 0 #000; }

#sidebar { width: var(--sb); display: flex; flex-direction: column; background: linear-gradient(90deg, #1b1d1b, var(--steel) 12%, var(--steel-2) 50%, var(--steel) 88%, #1b1d1b); border-left: 2px solid var(--edge); padding: 6px; gap: 6px; }
#credits { text-align: center; font: 700 20px/1.2 Consolas, monospace; color: var(--gold); background: #0b0c0b; border: 2px inset #555; padding: 3px; letter-spacing: 1px; }
#radar-wrap { position: relative; background: #000; border: 2px inset #555; aspect-ratio: 1; }
#minimap { width: 100%; height: 100%; display: block; image-rendering: pixelated; cursor: crosshair; }
#radar-off { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #6a6; font: 700 12px Consolas, monospace; letter-spacing: 2px; pointer-events: none; }
#sb-tools { display: flex; gap: 4px; }
#sb-tools button { flex: 1; }
button { background: linear-gradient(#5a5e58, #3a3d39); color: var(--text); border: 1px solid #111; border-top-color: #7a7e78; border-radius: 2px; padding: 5px 6px; font: 600 12px "Segoe UI", sans-serif; cursor: pointer; }
button:hover { background: linear-gradient(#6c706a, #474a46); }
button.on { background: linear-gradient(#8a3a2a, #5a2218); border-color: #c85; }
#sb-main { flex: 1; display: flex; gap: 4px; min-height: 0; }
#power { position: relative; width: 12px; background: #0b0c0b; border: 1px inset #555; }
#power-fill { position: absolute; left: 1px; right: 1px; bottom: 0; background: linear-gradient(#6f6, #2a2); transition: height .4s; }
#power-fill.warn { background: linear-gradient(#ff6, #aa2); }
#power-fill.low { background: linear-gradient(#f66, #a22); animation: blink .6s steps(2) infinite; }
#power-use { position: absolute; left: -3px; right: -3px; height: 2px; background: #fff; box-shadow: 0 0 3px #fff; transition: bottom .4s; }
@keyframes blink { 50% { opacity: .45; } }
.col { flex: 1; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; scrollbar-width: thin; }
.cameo { position: relative; width: 100%; aspect-ratio: 4 / 3; border: 1px solid #000; cursor: pointer; flex-shrink: 0; }
.cameo[hidden] { display: none; }
.cameo img { width: 100%; height: 100%; display: block; image-rendering: auto; }
.cameo:hover { outline: 1px solid #ddd; }
.cameo.busy img { filter: grayscale(.8) brightness(.6); }
.cameo .clock { position: absolute; inset: 0; display: none; background: conic-gradient(transparent calc(var(--p, 0) * 360deg), rgba(0, 0, 0, .62) 0); }
.cameo .state { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; font: 700 11px Consolas, monospace; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; }
.cameo.ready .state { color: #7f7; animation: blink .8s steps(2) infinite; }
.cameo .count { position: absolute; right: 3px; top: 1px; font: 700 12px Consolas, monospace; color: #fff; text-shadow: 1px 1px 0 #000; }
.cameo .cost { position: absolute; left: 2px; bottom: 0; font: 600 9px Consolas, monospace; color: var(--gold); text-shadow: 1px 1px 0 #000; opacity: .85; }
#tooltip { position: fixed; z-index: 30; max-width: 240px; background: rgba(12, 14, 12, .95); border: 1px solid #666; padding: 6px 8px; pointer-events: none; }
#tooltip span { color: #bbb; }

.overlay { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, #3a0e0a 0%, #120606 55%, #000 100%); }
.overlay[hidden] { display: none; }
.overlay.dim { background: rgba(0, 0, 0, .72); }
.logo { font: 900 64px/1 Impact, "Arial Black", sans-serif; letter-spacing: 6px; margin: 0 0 6px; color: #ddd; text-shadow: 0 4px 0 #000, 0 0 24px rgba(255, 60, 30, .35); }
.logo span { color: var(--accent); }
.sub { margin: 0 0 18px; color: #b9a; letter-spacing: 3px; text-transform: uppercase; }
.panel { background: rgba(20, 22, 20, .92); border: 2px solid #555; border-top-color: #888; padding: 18px 22px; min-width: 420px; max-width: 760px; box-shadow: 0 10px 40px #000; display: flex; flex-direction: column; gap: 12px; }
.panel.small { min-width: 320px; }
.panel h2 { margin: 0; text-align: center; letter-spacing: 4px; font: 900 32px Impact, sans-serif; }
.factions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.faction { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px; border: 2px solid #333; cursor: pointer; background: #111; }
.faction small { color: #999; font-size: 11px; }
.faction input { display: none; }
.faction img { width: 46px; height: 46px; }
.faction span { font: 700 15px "Segoe UI", sans-serif; letter-spacing: 1px; }
.faction:has(input:checked) { border-color: var(--gold); background: #231c0e; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.grid label, .panel.small label { display: flex; flex-direction: column; gap: 3px; color: #bbb; font-size: 12px; }
select, input[type=text] { background: #0d0e0d; color: var(--text); border: 1px solid #555; padding: 5px; font: 13px "Segoe UI", sans-serif; }
button.big { padding: 10px; font: 900 18px Impact, sans-serif; letter-spacing: 3px; background: linear-gradient(#b8382a, #6c1c14); border-color: #300; border-top-color: #e77; }
button.big:hover { background: linear-gradient(#d0463a, #7e241a); }
.help summary { cursor: pointer; color: var(--gold); }
.help ul { margin: 6px 0 0; padding-left: 18px; color: #bbb; }
.bar { width: 320px; height: 10px; border: 1px solid #666; background: #111; }
#load-fill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
#end-stats { width: 100%; border-collapse: collapse; }
#end-stats td { padding: 3px 6px; border-bottom: 1px solid #333; }
#end-stats td:not(:first-child) { text-align: right; font-family: Consolas, monospace; }
#powers { display: flex; gap: 4px; }
#powers:empty { display: none; }
.power-btn { position: relative; flex: 1; max-width: 72px; aspect-ratio: 4 / 3; border: 1px solid #000; cursor: pointer; }
.power-btn img { width: 100%; height: 100%; display: block; }
.power-btn .clock { position: absolute; inset: 0; background: conic-gradient(transparent calc(var(--p, 0) * 360deg), rgba(0, 0, 0, .62) 0); }
.power-btn span { position: absolute; left: 0; right: 0; bottom: 1px; text-align: center; font: 700 10px Consolas, monospace; color: #fff; text-shadow: 1px 1px 0 #000; }
.power-btn.ready { outline: 2px solid #ffd24a; animation: blink 1s steps(2) infinite; }
.power-btn.ready .clock { display: none; }
