:root {
  --bg: #0d100c; --panel: #1a1f17; --panel2: #232a1f; --line: #3a4532;
  --txt: #d8e0cc; --dim: #8a967c; --acc: #c9a227; --good: #5fc24a; --bad: #e0473c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--txt);
  font-family: 'Segoe UI', system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
#game { display: flex; height: 100%; }
#viewwrap { flex: 1; position: relative; min-width: 0; }
#view { position: absolute; inset: 0; display: block; background: #000; }
#overlay { position: absolute; inset: 0; pointer-events: none; }
#hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(16, 20, 13, .88);
  border: 1px solid var(--acc); color: #f3ead0; padding: 8px 16px; border-radius: 4px; font-size: 14px; pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .6); white-space: nowrap; }
#hint b { color: var(--acc); }
#msgs { position: absolute; left: 12px; top: 10px; pointer-events: none; font-size: 14px; font-weight: 600;
  text-shadow: 0 1px 3px #000, 0 0 2px #000; }
#msgs div { margin-bottom: 3px; color: #e9f3d8; }
#pausetag { position: absolute; top: 40%; left: 0; right: 0; text-align: center; font-size: 36px; font-weight: 900;
  letter-spacing: 6px; color: var(--acc); text-shadow: 0 2px 8px #000; pointer-events: none; }

#side { width: 236px; flex: none; background: linear-gradient(#20271c, #151a12); border-left: 2px solid var(--line);
  display: flex; flex-direction: column; padding: 8px; gap: 6px; overflow: hidden; }
#res { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; font-variant-numeric: tabular-nums; }
#res .c { color: #f0c040; } #res .o { color: #c3b6ff; } #clock { color: var(--dim); font-size: 12px; }
#power { position: relative; height: 15px; background: #0b0d09; border: 1px solid var(--line); }
#powerfill { height: 100%; background: var(--good); transition: width .3s; }
#power.low #powerfill { background: var(--bad); }
#powertxt { position: absolute; inset: 0; font-size: 10px; text-align: center; line-height: 14px; text-shadow: 0 0 2px #000; }
#mini { width: 218px; height: 218px; background: #000; border: 1px solid var(--line); image-rendering: pixelated; cursor: pointer; flex: none; }
#tools, #tabs { display: flex; gap: 4px; }
#tools button, #tabs button { flex: 1; }
button { background: var(--panel2); color: var(--txt); border: 1px solid var(--line); padding: 5px 6px; font: inherit;
  font-size: 12px; cursor: pointer; border-radius: 3px; }
button:hover { border-color: var(--acc); }
button.on { background: #3d4a2e; border-color: var(--acc); color: #fff; }
#tabs button { font-size: 11.5px; padding: 5px 2px; }
#tabs button.busy::after { content: ' •'; color: var(--acc); }
#buildgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; overflow-y: auto; flex: 1; align-content: start; min-height: 0; }
.bi { position: relative; background: #11150e; border: 1px solid var(--line); height: 80px; cursor: pointer; overflow: hidden; border-radius: 3px; }
.bi:hover { border-color: var(--acc); }
.bi img { display: block; width: 100%; height: 52px; }
.bi .nm { font-size: 10.5px; padding: 1px 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bi .cost { font-size: 10px; color: #f0c040; padding: 0 4px; }
.bi .ov { position: absolute; inset: 0; pointer-events: none; }
.bi .lab { position: absolute; top: 17px; left: 0; right: 0; text-align: center; font-weight: 800; font-size: 13px; color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000; pointer-events: none; }
.bi .cnt { position: absolute; top: 2px; right: 5px; font-weight: 800; color: #fff; text-shadow: 0 0 3px #000; pointer-events: none; }
.bi.locked { filter: grayscale(1) brightness(.45); }
.bi.ready { border-color: var(--good); animation: blink .8s infinite alternate; }
@keyframes blink { to { box-shadow: inset 0 0 14px rgba(95, 194, 74, .85); } }
#info { min-height: 62px; font-size: 12px; background: #0e110c; border: 1px solid var(--line); padding: 5px 6px; line-height: 1.35; flex: none; }
.d { color: var(--dim); }

.overlay { position: fixed; inset: 0; background: rgba(5, 8, 4, .84); display: flex; align-items: center; justify-content: center; z-index: 10; }
.hidden { display: none !important; }
.panel { background: var(--panel); border: 2px solid var(--line); padding: 24px 28px; width: min(580px, 94vw); max-height: 94vh;
  overflow: auto; border-radius: 6px; box-shadow: 0 10px 40px #000; }
h1 { margin: 0; font-size: 42px; letter-spacing: 6px; color: var(--acc); text-align: center; font-weight: 900; }
.sub { text-align: center; color: var(--dim); margin: 2px 0 18px; letter-spacing: 3px; font-size: 13px; text-transform: uppercase; }
.row { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.row label { width: 112px; flex: none; color: var(--dim); font-size: 13px; }
.choices { display: flex; gap: 4px; flex: 1; }
.choices button { flex: 1; padding: 7px 4px; }
#mapdesc { font-size: 12px; color: var(--dim); margin: -4px 0 0 122px; }
.big { display: block; width: 100%; padding: 12px; font-size: 18px; font-weight: 800; letter-spacing: 3px; margin-top: 14px;
  background: #3d4a2e; border-color: var(--acc); color: #fff; }
details { margin-top: 16px; font-size: 13px; color: var(--dim); }
summary { cursor: pointer; color: var(--txt); }
details table { margin: 8px 0; border-collapse: collapse; }
details td { padding: 2px 10px 2px 0; vertical-align: top; }
details p { line-height: 1.45; }
kbd { background: #0b0d09; border: 1px solid var(--line); padding: 0 5px; border-radius: 3px; color: var(--txt); font-size: 12px; font-family: inherit; }
#tooltip { position: fixed; width: 224px; background: #10140d; border: 1px solid var(--acc); padding: 7px 8px; font-size: 12px;
  z-index: 20; display: none; pointer-events: none; line-height: 1.4; }
#tooltip .miss { color: var(--bad); }
#endStats p { text-align: center; color: var(--dim); }
#endStats table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
#endStats td, #endStats th { padding: 6px; border-bottom: 1px solid var(--line); text-align: right; }
#endStats td:first-child, #endStats th:first-child { text-align: left; }
