/* RAX — Iron Horizon */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  background: #0a0c10;
  color: #cfd6df;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}
.hidden { display: none !important; }
#app { width: 100%; height: 100%; }

/* ============ GAME LAYOUT ============ */
#game-root { display: flex; width: 100%; height: 100%; }
#viewport-wrap { position: relative; flex: 1; min-width: 0; }
#view { display: block; width: 100%; height: 100%; background: #000; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px;
  pointer-events: none;
  font-size: 13px; color: #9fb2c8;
  text-shadow: 0 1px 2px #000;
}
#topbar button { pointer-events: auto; }
#btn-menu {
  background: rgba(20,26,34,.85); color: #cfd6df; border: 1px solid #3a4656;
  padding: 2px 10px; font-size: 15px; cursor: pointer; border-radius: 3px;
}
#btn-menu:hover { background: #2a3546; }
#clock { font-variant-numeric: tabular-nums; }
#fps { opacity: .5; font-size: 11px; }

#notifications {
  position: absolute; left: 10px; bottom: 44px;
  display: flex; flex-direction: column-reverse; gap: 3px;
  pointer-events: none; max-width: 46%;
}
.notif {
  background: rgba(10,14,20,.78); border-left: 3px solid #4a90d9;
  padding: 3px 10px; font-size: 13px; border-radius: 2px;
  animation: notifin .18s ease-out;
}
.notif.warn { border-left-color: #e0b23a; color: #f0d78a; }
.notif.bad  { border-left-color: #e04a3a; color: #f0968a; }
.notif.good { border-left-color: #58c26e; color: #a8e8b4; }
@keyframes notifin { from { transform: translateX(-12px); opacity: 0; } }

#selection-info {
  position: absolute; left: 10px; bottom: 8px;
  font-size: 12px; color: #9fb2c8; text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

/* ============ SIDEBAR ============ */
#sidebar {
  width: 208px; flex: none;
  background: linear-gradient(180deg, #161b23, #10141b);
  border-left: 2px solid #2c3644;
  display: flex; flex-direction: column;
  padding: 6px;
  gap: 6px;
}
#credits-row {
  text-align: center; font-size: 19px; font-weight: 600;
  color: #ffd76a; letter-spacing: 1px;
  background: #0b0e13; border: 1px solid #2c3644; border-radius: 3px;
  padding: 3px 0; font-variant-numeric: tabular-nums;
}
#radar-wrap {
  position: relative; width: 100%; aspect-ratio: 1;
  background: #05070a; border: 1px solid #2c3644; border-radius: 3px;
  overflow: hidden;
}
#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;
  background: repeating-linear-gradient(0deg, #05070a, #05070a 3px, #0a1018 3px, #0a1018 6px);
  color: #446; font-size: 13px; letter-spacing: 3px;
}
#power-row { display: flex; align-items: center; gap: 6px; }
#power-bar {
  position: relative; flex: 1; height: 12px;
  background: #0b0e13; border: 1px solid #2c3644; border-radius: 2px; overflow: hidden;
}
#power-fill { height: 100%; width: 0%; background: #58c26e; transition: width .3s, background .3s; }
#power-fill.low { background: #e0b23a; }
#power-fill.out { background: #e04a3a; }
#power-drain-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; opacity: .8; }
#power-label { font-size: 13px; }

#mode-row { display: flex; gap: 4px; }
#mode-row button {
  flex: 1; padding: 5px 0; background: #1b2430; color: #cfd6df;
  border: 1px solid #3a4656; border-radius: 3px; cursor: pointer; font-size: 14px;
}
#mode-row button:hover { background: #2a3546; }
#mode-row button.active { background: #3d5a80; border-color: #6a9fd8; }
#btn-superweapon { color: #ff9a3a; font-weight: 700; }
#btn-superweapon.ready { animation: swpulse 1s infinite; }
@keyframes swpulse { 50% { background: #5a3010; border-color: #ff9a3a; } }
#sw-timer { font-size: 10px; display: block; font-weight: 400; }

#tab-row { display: flex; gap: 4px; }
.tab-btn {
  flex: 1; padding: 6px 0; background: #151b24; color: #8ea2ba;
  border: 1px solid #2c3644; border-radius: 3px 3px 0 0; cursor: pointer; font-size: 15px;
}
.tab-btn.active { background: #2a3a50; color: #fff; border-color: #4a6a94; }
.tab-btn .badge { font-size: 9px; color: #ffd76a; }

#build-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 5px;
  align-content: start;
  padding-right: 2px;
}
#build-grid::-webkit-scrollbar { width: 6px; }
#build-grid::-webkit-scrollbar-thumb { background: #2c3644; border-radius: 3px; }

.build-btn {
  position: relative; border: 1px solid #3a4656; border-radius: 3px;
  background: #10151d; cursor: pointer; padding: 0; overflow: hidden;
  aspect-ratio: 1.15;
}
.build-btn canvas { display: block; width: 100%; height: 100%; }
.build-btn:hover { border-color: #6a9fd8; }
.build-btn.locked { opacity: .38; cursor: not-allowed; }
.build-btn.cantafford { border-color: #7a3030; }
.build-btn .cost {
  position: absolute; right: 2px; bottom: 1px; font-size: 10px; color: #ffd76a;
  text-shadow: 0 1px 2px #000; pointer-events: none;
}
.build-btn .bname {
  position: absolute; left: 3px; top: 1px; font-size: 9px; color: #cfd6df;
  text-shadow: 0 1px 2px #000; pointer-events: none; letter-spacing: .3px;
}
.build-btn .queue-count {
  position: absolute; left: 2px; bottom: 1px; font-size: 11px; font-weight: 700;
  color: #fff; text-shadow: 0 1px 2px #000; pointer-events: none;
}
.build-btn .progress {
  position: absolute; inset: 0; pointer-events: none;
  background: conic-gradient(rgba(0,0,0,0) var(--p), rgba(0,0,0,.62) var(--p));
}
.build-btn .ready-label {
  position: absolute; inset: auto 0 0 0; text-align: center;
  background: rgba(40,120,60,.85); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 0; pointer-events: none; animation: swpulse 1s infinite;
}
.build-btn .paused-label {
  position: absolute; inset: auto 0 0 0; text-align: center;
  background: rgba(140,100,20,.85); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 0; pointer-events: none;
}

/* ============ OVERLAYS ============ */
.overlay {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(4,6,10,.72); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
}
.panel {
  background: #141a23; border: 1px solid #3a4656; border-radius: 6px;
  padding: 26px 34px; text-align: center; min-width: 300px;
  box-shadow: 0 12px 50px #000;
}
.panel h1 { font-size: 34px; letter-spacing: 6px; margin-bottom: 14px; }
.panel h2 { letter-spacing: 4px; margin-bottom: 16px; color: #9fb2c8; }
.panel button {
  display: block; width: 100%; margin: 7px 0; padding: 9px;
  background: #1b2430; color: #cfd6df; border: 1px solid #3a4656;
  border-radius: 3px; cursor: pointer; font-size: 14px; letter-spacing: 1px;
}
.panel button:hover { background: #2a3546; border-color: #6a9fd8; }
.settings-block { text-align: left; margin: 14px 0; font-size: 13px; }
.settings-block label { display: block; margin: 8px 0; color: #9fb2c8; }
.settings-block input[type=range] { width: 130px; vertical-align: middle; float: right; }
#end-title.victory { color: #6ae08a; text-shadow: 0 0 24px #2a8a4a; }
#end-title.defeat { color: #e05a4a; text-shadow: 0 0 24px #8a2a1a; }
#end-stats { font-size: 13px; color: #9fb2c8; margin-bottom: 12px; text-align: left; }
#end-stats table { width: 100%; border-collapse: collapse; }
#end-stats td, #end-stats th { padding: 3px 8px; border-bottom: 1px solid #222b38; }
#end-stats th { color: #cfd6df; text-align: left; }
#end-stats td { text-align: right; font-variant-numeric: tabular-nums; }

#help-overlay { flex-direction: column; font-size: 14px; }
#help-overlay .panel { max-height: 84vh; overflow-y: auto; text-align: left; }
#help-overlay table { border-collapse: collapse; font-size: 13px; }
#help-overlay td { padding: 3px 12px 3px 0; color: #9fb2c8; }
#help-overlay td:first-child { color: #ffd76a; white-space: nowrap; }

/* ============ MENUS ============ */
#menu-root {
  position: absolute; inset: 0; overflow-y: auto;
  background:
    radial-gradient(1200px 500px at 50% -10%, #1a2433 0%, transparent 60%),
    radial-gradient(900px 500px at 80% 110%, #2a1a14 0%, transparent 55%),
    #0a0c10;
}
.menu-screen {
  min-height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 30px 20px; gap: 10px;
}
#title-art { max-width: 92vw; height: auto; }
.game-title {
  font-size: 84px; letter-spacing: 26px; font-weight: 900; margin-left: 26px;
  color: #e8edf4; text-shadow: 0 0 34px #3a6aa8, 0 4px 0 #1a2433;
  margin-top: -40px;
}
.game-subtitle { letter-spacing: 12px; color: #b87a3a; font-size: 17px; margin-left: 12px; margin-bottom: 20px; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.menu-buttons.row { flex-direction: row; }
.big-btn {
  min-width: 240px; padding: 12px 30px; font-size: 16px; letter-spacing: 3px;
  background: #151d28; color: #cfd6df; border: 1px solid #3a4656;
  border-radius: 4px; cursor: pointer;
}
.big-btn:hover { background: #24334a; border-color: #6a9fd8; color: #fff; }
.big-btn.primary { background: #2a4a2a; border-color: #4a8a4a; }
.big-btn.primary:hover { background: #3a6a3a; }
.menu-footer { margin-top: 26px; color: #46536a; font-size: 12px; letter-spacing: 2px; }

#skirmish-menu h2, #howto-menu h2 { letter-spacing: 6px; color: #9fb2c8; margin-bottom: 18px; }
#skirmish-cols { display: flex; gap: 34px; flex-wrap: wrap; justify-content: center; }
#map-col, #slot-col { background: #10151d; border: 1px solid #2c3644; border-radius: 6px; padding: 16px; }
#map-col h3, #slot-col h3 { font-size: 12px; letter-spacing: 3px; color: #6a7a92; margin-bottom: 10px; }
#map-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; max-height: 180px; overflow-y: auto; }
.map-item {
  padding: 6px 12px; background: #151d28; border: 1px solid #2c3644;
  border-radius: 3px; cursor: pointer; font-size: 14px; text-align: left; color: #cfd6df;
}
.map-item:hover { border-color: #6a9fd8; }
.map-item.selected { background: #2a3a50; border-color: #6a9fd8; color: #fff; }
.map-item small { color: #6a7a92; float: right; }
#map-preview { display: block; margin: 0 auto; border: 1px solid #2c3644; border-radius: 3px; image-rendering: pixelated; }
#map-desc { font-size: 12px; color: #6a7a92; margin-top: 8px; max-width: 230px; }
#slot-list { display: flex; flex-direction: column; gap: 8px; }
.slot {
  display: flex; gap: 6px; align-items: center;
  background: #151d28; border: 1px solid #2c3644; border-radius: 4px; padding: 8px 10px;
}
.slot select {
  background: #0b0e13; color: #cfd6df; border: 1px solid #3a4656;
  border-radius: 3px; padding: 4px 5px; font-size: 13px;
}
.slot .slot-tag { width: 66px; font-size: 12px; color: #6a7a92; letter-spacing: 1px; }
.slot .color-chip { width: 16px; height: 16px; border-radius: 3px; border: 1px solid #000; }
.slot button.remove {
  background: none; border: none; color: #7a4646; cursor: pointer; font-size: 15px; padding: 0 4px;
}
.slot button.remove:hover { color: #e05a4a; }
#btn-add-ai {
  padding: 7px; background: #151d28; color: #6a9fd8; border: 1px dashed #3a4656;
  border-radius: 4px; cursor: pointer; font-size: 13px;
}
#btn-add-ai:hover { border-color: #6a9fd8; }
.row { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.row label { font-size: 13px; color: #9fb2c8; }
.row select { background: #0b0e13; color: #cfd6df; border: 1px solid #3a4656; border-radius: 3px; padding: 4px 6px; margin-left: 8px; }

#howto-body { max-width: 640px; background: #10151d; border: 1px solid #2c3644; border-radius: 6px; padding: 20px 26px; font-size: 14px; line-height: 1.55; color: #9fb2c8; }
#howto-body h4 { color: #e8edf4; margin: 12px 0 4px; letter-spacing: 1px; }
#howto-body b { color: #ffd76a; }
