/* Ironfront — RTS prototype styles */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: #32405a transparent;
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #32405a; border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: #495d82; }
*::-webkit-scrollbar-corner { background: transparent; }

html, body {
  height: 100%;
  background: #0b0e13;
  color: #d7dde6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.dim { color: #7c8695; }
.hidden { display: none !important; }

/* --- Top bar ------------------------------------------------------------- */

#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  background: linear-gradient(180deg, #1b2233 0%, #10151f 100%);
  border-bottom: 1px solid #2b3549;
  box-shadow: 0 1px 0 rgba(255, 200, 120, 0.1), 0 6px 18px rgba(0, 0, 0, 0.42);
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
}

.brand {
  font-weight: 800;
  letter-spacing: 3.2px;
  font-size: 13.5px;
  color: #f4e8c9;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.75);
  white-space: nowrap;
}
.brand .dim { font-size: 10px; letter-spacing: 1.2px; font-weight: 700; color: #ffba52; text-transform: uppercase; }

.player-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 155px;
  min-width: 0;
  background: rgba(18, 25, 38, 0.88);
  border: 1px solid #2d3a52;
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: #e8edf4;
  white-space: nowrap;
}
#player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.pf-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3fa7ff;
  box-shadow: 0 0 6px rgba(63, 167, 255, 0.55);
  flex: 0 0 auto;
}

.stat-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}
.stat { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  background: rgba(11, 15, 24, 0.74);
  border: 1px solid #242e42;
  border-radius: 5px;
  color: #e4eaf3;
  font-weight: 600;
}
.stat-pill.dim { color: #95a2b7; font-weight: 600; }
.stat-pill .st-ico { font-size: 12px; opacity: 0.9; line-height: 1; display: inline-flex; color: #9fb0c8; }
.stat-pill .st-ico.st-coin { color: #ffd36b; }
.ico-svg { width: 14px; height: 14px; display: block; flex: 0 0 auto; }
.tb-btn.icon-btn .ico-svg { width: 15px; height: 15px; }
.tb-ico { display: inline-flex; }
.tb-ico .ico-svg { width: 13px; height: 13px; }
.stat-pill .st-lbl {
  font-size: 9.5px;
  letter-spacing: 1px;
  color: #7c899e;
  font-weight: 700;
}
.time-pill { color: #d6deea; }
.stat.warn { color: #ffba52; border-color: rgba(255, 186, 82, 0.45); }
.stat.full { color: #ff6b60; font-weight: 700; border-color: rgba(255, 107, 96, 0.48); background: rgba(66, 20, 20, 0.45); }
.inc-rate { font-size: 11px; color: #6ee084; font-weight: 700; }

.spacer { flex: 1; min-width: 4px; }

.tb-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  background: linear-gradient(#1f2738, #171d2b);
  color: #dce3ee;
  border: 1px solid #2e384e;
  border-radius: 5px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.tb-btn.icon-btn {
  width: 30px;
  padding: 0;
  font-size: 13.5px;
  line-height: 1;
}
#btn-music { font-size: 15px; font-weight: 700; }
.tb-btn:hover:not(:disabled) { background: #263046; border-color: #445575; color: #fff; }
.tb-btn.accent { background: linear-gradient(#1b3456, #152742); border-color: #32649e; color: #d4ecff; }
.tb-btn.accent:hover:not(:disabled) { background: linear-gradient(#23446f, #1a3355); border-color: #4db3ff; color: #fff; }
.tb-btn:disabled { opacity: 0.42; cursor: default; }
.tb-btn.icon-btn.armed,
.tb-btn.icon-btn.armed:hover {
  width: auto;
  padding: 0 8px;
  background: linear-gradient(#6a2226, #4a171b);
  border-color: #ff6b60;
  color: #ffe1dd;
}
.tb-btn.active {
  background: rgba(232, 179, 57, 0.16);
  border-color: #d6a235;
  color: #ffe28a;
  box-shadow: 0 0 10px rgba(232, 179, 57, 0.14);
}
.tb-btn kbd, #prod-hint kbd, .sel-tips kbd, .key-list kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9.5px;
  font-weight: 700;
  color: #c5d1e3;
  border: 1px solid #3c4a66;
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0 4px;
  background: #131926;
  line-height: 1.35;
}

.speed-group {
  display: inline-flex;
  height: 28px;
  border: 1px solid #2e384e;
  border-radius: 5px;
  overflow: hidden;
  background: #141925;
}
.spd-btn {
  background: transparent;
  color: #8f9bad;
  border: none;
  border-right: 1px solid #262f42;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.spd-btn:last-child { border-right: none; }
.spd-btn:hover:not(:disabled) { background: #1f2738; color: #e8edf4; }
.spd-btn:disabled { opacity: 0.45; cursor: default; }
.spd-btn.selected { background: #1f4b7d; color: #eef7ff; }

/* --- Stage / canvas ------------------------------------------------------- */

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}
#game-canvas.attack-mode {
  cursor: cell;
  box-shadow: inset 0 0 0 2px rgba(255, 85, 75, 0.55);
}

#base-alert {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 25;
  background: rgba(150, 24, 20, 0.92);
  border: 1px solid #ff7a70;
  color: #fff2f0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.2px;
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 60, 50, 0.4);
  animation: alert-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes alert-pulse {
  from { opacity: 0.78; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1.02); }
}

#pause-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 24;
  background: rgba(20, 26, 38, 0.92);
  border: 1px solid #e8b339;
  color: #ffe08a;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  padding: 5px 14px;
  border-radius: 999px;
  pointer-events: none;
}

/* --- Toasts ---------------------------------------------------------------- */

#toasts {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  z-index: 30;
}

.toast {
  background: rgba(18, 22, 31, 0.92);
  border: 1px solid #3a4356;
  color: #ffd9a8;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  animation: toast-in 0.15s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Overlay panels ---------------------------------------------------------- */

#overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 12, 0.72);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 26;
}

/* Main menu: painted key art behind a frosted panel. */
#overlay.menu-bg {
  background-color: #0b0e13;
  background-image:
    linear-gradient(180deg, rgba(6, 8, 12, 0.25) 0%, rgba(6, 8, 12, 0.55) 60%, rgba(6, 8, 12, 0.9) 100%),
    url('assets/sprites/menu_art.jpg');
}
/* The start menu covers the whole window (top + bottom bars are inactive
   there), so the panel gets the full height instead of the stage between
   the bars. z-index stays under #toasts (30) so lobby notices show. */
#overlay.menu-bg {
  position: fixed;
  z-index: 28;
}

/* Menu layout: one column on narrow windows, two side by side when wide
   (intro + controls | faction, difficulty, start) so Start is never below
   the fold on laptop-height windows. */
#menu-panel { max-width: 560px; }
/* Single column: the column wrappers vanish from layout so the sticky
   button's containing block is the whole section, not just its column. */
.menu-col { display: contents; }
/* The Start / Ready button sticks to the bottom of the panel if the window
   is so small that the panel must scroll. */
.menu-action {
  position: sticky;
  bottom: -22px;
  margin: 0 -30px -22px;
  padding: 12px 30px 18px;
  background: linear-gradient(rgba(14, 18, 26, 0), rgba(14, 18, 26, 0.92) 35%);
}
@media (min-width: 880px) {
  #menu-panel { max-width: 940px; padding: 26px 36px 28px; }
  .menu-cols {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 30px;
    text-align: left;
    align-items: start;
  }
  .menu-col { display: block; }
  .menu-col-setup { display: flex; flex-direction: column; }
  .menu-cols .tagline { text-align: left; }
  .menu-col-info .faction-buttons,
  .menu-col-info .mp-name-row { justify-content: flex-start; }
  .menu-cols ul.controls { margin: 0; max-width: none; line-height: 1.75; }
  .menu-col-setup {
    background: rgba(8, 11, 17, 0.45);
    border: 1px solid rgba(120, 150, 190, 0.18);
    border-radius: 8px;
    padding: 16px 18px 18px;
    align-self: stretch;
    text-align: center;
  }
  .menu-col-setup .menu-action {
    position: static;
    margin: auto 0 0;
    padding: 6px 0 0;
    background: none;
  }
  .menu-col-setup .big-btn { width: 100%; }
}

#overlay.menu-bg .panel {
  background: rgba(13, 17, 25, 0.84);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: rgba(130, 160, 204, 0.28);
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 220, 150, 0.16);
}

.panel {
  background: linear-gradient(180deg, #161c29 0%, #10151f 100%);
  border: 1px solid #2f3b52;
  border-radius: 10px;
  padding: 22px 30px;
  max-width: 560px;
  width: calc(100% - 32px);
  max-height: calc(100% - 24px);
  overflow-x: hidden;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.panel h1 {
  font-size: 36px;
  letter-spacing: 10px;
  margin-bottom: 10px;
  color: #f4e8c9;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.65), 0 0 26px rgba(255, 190, 90, 0.28);
}
.panel h1.win { color: #57d364; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), 0 0 24px rgba(87, 211, 100, 0.28); }
.panel h1.lose { color: #e85d52; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), 0 0 24px rgba(232, 93, 82, 0.28); }

.panel h2 {
  font-size: 19px;
  margin-bottom: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #f1e6c8;
}

.tagline { color: #b4bfd0; font-size: 13.5px; line-height: 1.55; margin-bottom: 14px; }

/* ---- Help modal 2-column layout ---- */
#help-panel {
  max-width: 840px;
  padding: 20px 26px 18px;
}
.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  text-align: left;
  margin-bottom: 12px;
}
.help-col {
  background: rgba(10, 14, 22, 0.56);
  border: 1px solid #263147;
  border-radius: 7px;
  padding: 12px 14px;
}
.help-sec {
  margin-bottom: 8px;
  color: #ffba52;
  letter-spacing: 1.8px;
}
.help-win {
  font-size: 12.5px;
  margin-bottom: 12px;
  color: #9fabbf;
}
.help-win b { color: #e8edf4; }
.help-footer { display: flex; justify-content: center; align-items: center; gap: 12px; }

/* ---- Credits ---- */
#menu-panel { position: relative; }
.credits-link {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  padding: 4px 6px;
  color: #8f9bb0;
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.credits-link:hover, .credits-link:focus-visible { color: #f1e6c8; }
#credits-panel { max-width: 640px; padding: 20px 26px 18px; }
.credits-body {
  text-align: left;
  background: rgba(10, 14, 22, 0.56);
  border: 1px solid #263147;
  border-radius: 7px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.credits-list {
  list-style: none;
  margin: 0 0 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #b4bfd0;
}
.credits-list li { padding: 2px 0; }
.credits-list b { color: #e8edf4; font-weight: 600; }
.credits-note { font-size: 12px; color: #8f9bb0; margin: 0 0 8px; }
.credits-body .help-sec:not(:first-child) { margin-top: 14px; }
.credits-body a { color: #7fb8ff; }
.credits-body a:hover { color: #b3d4ff; }
@media (max-width: 760px) {
  .help-grid { grid-template-columns: 1fr; }
}

/* ---- Game-over match statistics ---- */
#gameover-panel { max-width: 660px; padding: 20px 28px 22px; }
#gameover-panel.is-win { border-top: 2px solid #4cc968; }
#gameover-panel.is-lose { border-top: 2px solid #e2554a; }
#gameover-stats:empty { display: none; }
#gameover-stats { margin-bottom: 6px; }
.go-action {
  bottom: -22px;
  margin: 0 -28px -22px;
  padding: 12px 28px 18px;
  background: linear-gradient(rgba(16, 21, 31, 0), #111620 40%);
}
.go-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.go-tile {
  background: rgba(24, 31, 46, 0.85);
  border: 1px solid #2c374e;
  border-radius: 6px;
  padding: 6px 8px;
}
.go-tile-v { font-size: 19px; font-weight: 700; color: #f4e8c9; font-variant-numeric: tabular-nums; }
.go-tile-l { font-size: 10px; color: #8c98ac; letter-spacing: 1.1px; text-transform: uppercase; margin-top: 2px; }
.go-table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.go-table th, .go-table td { padding: 3px 8px; text-align: right; border-bottom: 1px solid #202838; }
.go-table tr:nth-child(even) td { background: rgba(255, 255, 255, 0.018); }
.go-table th { font-size: 12px; letter-spacing: 1px; white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; padding-bottom: 5px; }
.go-table td.go-label { text-align: left; color: #aab4c2; }
.go-table td { color: #d8dee8; }
.go-table td.go-best { color: #ffd97a; font-weight: 700; }
.go-table tr.go-score td { font-weight: 700; font-size: 13.5px; border-bottom-color: #3a4560; background: rgba(63, 167, 255, 0.06); }
.go-crown { color: #ffd97a; }

ul.controls {
  list-style: none;
  text-align: left;
  margin: 0 auto 16px;
  max-width: 480px;
  font-size: 12.5px;
  line-height: 1.65;
  color: #c3ccd8;
}
ul.controls b { color: #e8edf4; }
ul.key-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: none;
  margin: 0;
  line-height: 1.45;
}
ul.key-list li {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
}
ul.key-list .kcol {
  color: #e4ecf8;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}
#help-panel ul.key-list li { grid-template-columns: 102px minmax(0, 1fr); }
.mp-roster-hdr { text-align: left; margin-bottom: 8px; color: #8c9bb3; }

.big-btn {
  background: linear-gradient(#2f7df0, #1d5fc9);
  box-shadow: 0 2px 0 #123d82, 0 6px 18px rgba(31, 111, 235, 0.35);
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 26px;
  border-radius: 5px;
  cursor: pointer;
  letter-spacing: 1px;
}
.big-btn:hover { background: #3b82f6; }

.faction-row { margin-bottom: 14px; }
.faction-row .cmd-label { display: block; margin-bottom: 7px; }
.mp-faction-row { margin-bottom: 12px; }

.faction-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.faction-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1b2130;
  color: #aab4c2;
  border: 1px solid #2c3547;
  border-radius: 5px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s, opacity 0.12s;
}
.faction-btn:hover:not(:disabled) { background: #242c3f; color: #e8edf4; }
.faction-btn.selected {
  background: #1c2c42;
  border-color: var(--fac-color, #3fa7ff);
  color: #ffffff;
  box-shadow: 0 0 0 1px var(--fac-color, #3fa7ff) inset;
}
.faction-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.difficulty-row { margin-bottom: 18px; }
.difficulty-row .cmd-label { display: block; margin-bottom: 8px; }

#difficulty-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.diff-btn {
  background: #1b2130;
  color: #aab4c2;
  border: 1px solid #2c3547;
  border-radius: 5px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.diff-btn:hover { background: #242c3f; color: #e8edf4; }
.diff-btn.selected {
  background: #1c3a5e;
  border-color: #3fa7ff;
  color: #e8edf4;
}

#difficulty-desc { font-size: 12px; margin-top: 8px; min-height: 15px; }

/* --- Multiplayer lobby ------------------------------------------------------ */

.menu-tabs {
  display: inline-flex;
  background: #0e131d;
  border: 1px solid #2c3547;
  border-radius: 6px;
  padding: 3px;
  gap: 4px;
  margin-bottom: 14px;
}
.menu-tab {
  background: transparent;
  color: #93a0b4;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.menu-tab:hover { color: #e8edf4; }
.menu-tab.selected {
  background: #1e3b60;
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.mp-tagline { margin-bottom: 14px; font-size: 13px; }

.mp-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}
.mp-input {
  background: #0d121c;
  color: #eef3fa;
  border: 1px solid #334058;
  border-radius: 5px;
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 600;
  width: 240px;
  outline: none;
  user-select: text;
}
.mp-input:focus {
  border-color: #3fa7ff;
  box-shadow: 0 0 0 2px rgba(63, 167, 255, 0.22);
}

.mp-room-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(13, 18, 28, 0.72);
  border: 1px solid #283246;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 12px;
  font-size: 12.5px;
}
.mp-room-pill { color: #9ba8bd; }
.mp-room-pill b { color: #f1e6c8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.mp-room-actions { display: flex; gap: 6px; }

.mp-roster {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  text-align: left;
  min-height: 82px;
}
.mp-player {
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(20, 26, 39, 0.85);
  border: 1px solid #2b3549;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13.5px;
}
.mp-player.is-me {
  border-color: #3a6ea8;
  background: rgba(24, 38, 60, 0.9);
}
.mp-pname {
  font-weight: 700;
  color: #eef3fa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mp-you {
  font-size: 10.5px;
  font-weight: 700;
  color: #7cc4ff;
  background: rgba(63, 167, 255, 0.14);
  border: 1px solid rgba(63, 167, 255, 0.3);
  border-radius: 999px;
  padding: 0 6px;
}
.mp-faction {
  font-size: 11.5px;
  color: #8f9bad;
  margin-left: auto;
  margin-right: 6px;
}
.mp-ready-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  flex: 0 0 auto;
}
.mp-ready-pill.is-ready {
  background: rgba(54, 185, 86, 0.2);
  border: 1px solid #4cc968;
  color: #8df0a0;
}
.mp-ready-pill.is-wait {
  background: rgba(130, 145, 168, 0.14);
  border: 1px solid #3c475e;
  color: #9ba8bd;
}

.mp-status {
  font-size: 12.5px;
  margin-bottom: 14px;
  min-height: 17px;
}
.mp-status.err { color: #ff7b72; font-weight: 600; }

#btn-ready.is-ready {
  background: linear-gradient(#2fa857, #1f7d3e);
  box-shadow: 0 2px 0 #145328, 0 6px 18px rgba(47, 168, 87, 0.35);
}
#btn-ready.is-ready:hover { background: #37be64; }
.big-btn:disabled {
  opacity: 0.45;
  cursor: default;
  filter: grayscale(0.5);
}

/* --- Bottom command bar ----------------------------------------------------- */

#bottombar {
  display: flex;
  gap: 8px;
  align-items: stretch;
  height: 164px;
  flex: 0 0 164px;
  overflow: hidden;
  padding: 8px 10px;
  background: linear-gradient(180deg, #161c29 0%, #0f131c 100%);
  border-top: 1px solid #2b3549;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.44);
}

.panel-box {
  background: linear-gradient(180deg, #1b2232 0%, #131824 100%);
  border: 1px solid #2b364d;
  border-radius: 7px;
  padding: 7px 9px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

#sel-card {
  flex: 0 0 244px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#selection-info {
  font-size: 11.5px;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.sel-empty-hdr { margin-bottom: 7px; color: #8c9bb3; }
.sel-tips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 6px;
  font-size: 10.5px;
  color: #9ba8bd;
}
.sel-tips span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sel-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 3px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #eef3fa;
}
.sel-hp-line {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sel-sub {
  font-size: 10.5px;
  line-height: 1.32;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 4px;
  max-height: 40px;
  overflow-y: auto;
  margin-bottom: 2px;
}

.unit-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin-top: 6px;
}
.act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  background: linear-gradient(#20293e, #182032);
  color: #dce3ee;
  border: 1px solid #344360;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  flex: 1 1 0;
  min-width: 0;
  transition: border-color 0.12s, background 0.12s;
}
.act-btn:hover:not(:disabled) { background: #293652; border-color: #4aaeff; color: #fff; }
.act-btn:disabled { opacity: 0.42; cursor: default; }
.act-btn.active { background: #4a1c1c; border-color: #ff6b60; color: #ffd4d0; }
.act-btn.danger {
  background: linear-gradient(#581e22, #3e1418);
  border-color: #d94c45;
  color: #ffd9d6;
}
.act-btn.danger:hover:not(:disabled) {
  background: linear-gradient(#73262b, #51191e);
  border-color: #ff7970;
  color: #fff;
}
.act-btn kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  color: #a9b6cb;
  border: 1px solid #3f4d68;
  border-radius: 2px;
  padding: 0 3px;
  margin-right: 3px;
  background: #121722;
}
.act-btn.danger kbd {
  color: #ffb9b3;
  border-color: rgba(255, 130, 120, 0.45);
  background: rgba(30, 8, 10, 0.65);
}

.unit-chip {
  display: inline-block;
  background: rgba(29, 38, 56, 0.9);
  border: 1px solid #303d56;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 10.5px;
  line-height: 16px;
  color: #cfd8e6;
}

.hpbar {
  width: 100%;
  height: 7px;
  background: #0b0e14;
  border: 1px solid #2b354a;
  border-radius: 4px;
  overflow: hidden;
  margin: 3px 0 3px;
}
.hpfill { height: 100%; width: 100%; background: #57d364; transition: width 0.15s; }

#command-panel {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 824px;
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.cmd-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 5px;
  flex: 0 0 auto;
  min-height: 0;
}

.struct-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 20px;
}
.placing-badge {
  font-size: 10px;
  font-weight: 700;
  color: #ffe28a;
  background: rgba(232, 179, 57, 0.16);
  border: 1px solid rgba(232, 179, 57, 0.5);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

.prod-col {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-start;
  overflow: hidden;
}
.prod-header {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  min-height: 20px;
  min-width: 0;
}
#prod-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
  flex: 1 1 auto;
}
#prod-tabs::-webkit-scrollbar { display: none; }
.prod-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #171e2e;
  color: #9ba8bd;
  border: 1px solid #2b364d;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.prod-tab:hover:not(:disabled) { background: #222d44; color: #eef3fa; border-color: #415478; }
.prod-tab:disabled { opacity: 0.45; cursor: default; }
.prod-tab.selected { background: #1d426e; border-color: #4db3ff; color: #ffffff; }
.prod-tab.selected.pinned { border-style: dashed; }
.prod-tab .qbadge {
  background: #2f7df0;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 999px;
  padding: 0 4.5px;
  line-height: 13px;
}
.prod-tab .tbar {
  position: absolute;
  left: 0; bottom: 0;
  height: 2px;
  background: #5bc2ff;
  width: 0%;
}
.prod-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  gap: 3px;
  min-height: 0;
  overflow: hidden;
}
#production-group { flex: 0 0 auto; }
#prod-hint {
  font-size: 11.5px;
  margin: auto 0;
  padding: 8px 10px;
  border: 1px dashed #2a354b;
  border-radius: 6px;
  background: rgba(11, 15, 24, 0.42);
  color: #8c9bb3;
  text-align: center;
}

#queue-group {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}
.q-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #7c899e;
  flex: 0 0 auto;
}

.cmd-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: #8592a6;
  white-space: nowrap;
}

.cmd-sep {
  width: 1px;
  align-self: stretch;
  background: linear-gradient(180deg, transparent, #2d3850 15%, #2d3850 85%, transparent);
  flex: 0 0 auto;
}

#structure-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 110px));
  gap: 4px;
  margin: auto 0;
}

#build-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 164px));
  gap: 4px;
}

#queue {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
#queue::-webkit-scrollbar { display: none; }

.build-btn {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 36px;
  background: linear-gradient(180deg, #21293c 0%, #171d2c 100%);
  border: 1px solid #2e3950;
  border-radius: 6px;
  color: #dfe5f0;
  padding: 2px 6px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: border-color 0.12s, background 0.12s, opacity 0.12s, box-shadow 0.12s;
}
.build-btn.struct { height: 42px; padding: 3px 6px 3px 5px; gap: 5px; }
.build-btn.unit-btn { height: 34px; padding: 2px 6px 2px 5px; gap: 5px; }
.build-btn > * { position: relative; z-index: 1; }
.build-btn kbd {
  position: absolute;
  top: 2px;
  left: 3px;
  z-index: 2;
  padding: 0 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  font-weight: 700;
  line-height: 1.25;
  background: rgba(12, 16, 26, 0.88);
  border: 1px solid rgba(84, 104, 140, 0.7);
  border-radius: 3px;
  color: #b8c6dc;
  pointer-events: none;
}
.build-btn .cd-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(63, 167, 255, 0.3), rgba(255, 217, 122, 0.24));
  border-right: 1px solid rgba(255, 217, 122, 0.5);
}
.build-btn:not(.cooling) .cd-fill { display: none; } /* else its 1px edge shows at width 0 */
.build-btn.cooling:disabled { opacity: 0.72; filter: grayscale(0.25); }
.build-btn.placing {
  border-color: #f0b83a;
  background: linear-gradient(180deg, #2d3852 0%, #1f283d 100%);
  box-shadow: 0 0 0 1px rgba(240, 184, 58, 0.55) inset, 0 0 12px rgba(240, 184, 58, 0.22);
}
/* No transform lift on hover: the grids sit in overflow-hidden columns, so a
   1px lift clips the top row's border. Highlight in place instead. */
.build-btn:hover:not(:disabled) {
  border-color: #4db3ff;
  background: linear-gradient(180deg, #283550 0%, #1c253b 100%);
  box-shadow: inset 0 1px 0 rgba(120, 200, 255, 0.35);
}
.build-btn:active:not(:disabled) { background: linear-gradient(180deg, #1c253b 0%, #222c44 100%); }
.build-btn.placing:hover:not(:disabled) {
  border-color: #f0b83a;
  box-shadow: 0 0 0 1px rgba(240, 184, 58, 0.55) inset, 0 0 12px rgba(240, 184, 58, 0.22);
}
.build-btn:disabled { opacity: 0.4; filter: grayscale(0.65); cursor: default; }
.build-btn.locked { border-style: dashed; border-color: #4a5670; }

.build-btn .ico {
  image-rendering: auto;
  height: 20px;
  width: auto;
  margin-left: 3px;
  flex: 0 0 auto;
}
.build-btn .ico.art {
  image-rendering: auto;
  height: 24px;
  margin: -1px 0 -1px 3px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.55));
}
.build-btn.struct .ico,
.build-btn.struct .ico.art {
  height: 25px;
  margin: 2px 0 -2px 3px;
}
.build-btn .txt {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  flex: 1 1 auto;
}
.build-btn .bn {
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.build-btn .bc {
  font-size: 9.5px;
  color: #ffd97a;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 3px;
  gap: 1px;
  background: #1d2538;
  border: 1px solid #313f59;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #c2cce0;
  overflow: hidden;
  cursor: pointer;
  flex: 0 0 auto;
}
.chip .cnt { font-size: 8.5px; color: #8fd0ff; align-self: flex-end; line-height: 12px; }
.chip > span, .chip > .cnt { position: relative; z-index: 1; }
.chip:hover:not(:disabled) { border-color: #ff6b60; color: #ff9c94; background: #3b1e23; }
.chip:disabled { opacity: 0.45; cursor: default; }
.chip .fill {
  position: absolute;
  left: 0; bottom: 0;
  width: 0%;
  height: 100%;
  background: rgba(63, 167, 255, 0.38);
  pointer-events: none;
}

#minimap-box {
  flex: 0 0 auto;
  padding: 5px 7px 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3px;
}
.minimap-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  line-height: 1;
}
.minimap-hint { font-size: 9.5px; color: #758299; }

#minimap {
  width: 220px;
  height: 110px;
  border: 1px solid #2e3a52;
  border-radius: 5px;
  background: #0a0d13;
  cursor: pointer;
  display: block;
}

/* --- Responsive tightening for compact laptop screens ----------------------- */

@media (max-width: 1280px) {
  .brand .dim { display: none; }
  .player-badge { max-width: 135px; }
}

@media (max-width: 1240px) {
  #topbar { gap: 6px; padding: 0 8px; }
  .stat-pill { padding: 0 7px; font-size: 12px; }
  #sel-card { flex: 0 0 218px; min-width: 196px; }
  #structure-buttons { grid-template-columns: repeat(4, minmax(84px, 96px)); }
  .build-btn.struct .ico.art { height: 21px; }
  #minimap { width: 196px; height: 98px; }
  #minimap-box { justify-content: center; }
}

@media (max-width: 1120px) {
  #topbar { gap: 4px; padding: 0 6px; }
  .brand { font-size: 12px; letter-spacing: 2px; }
  .player-badge { max-width: 112px; padding: 2px 7px 2px 6px; font-size: 11px; }
  .stat-pill { padding: 0 6px; gap: 4px; font-size: 11.5px; }
  .tb-btn { padding: 0 7px; font-size: 11.5px; }
  .tb-btn.icon-btn { width: 27px; }
  .spd-btn { padding: 0 6px; font-size: 11px; }
  #bottombar { gap: 6px; padding: 7px 8px; }
  #sel-card { flex: 0 0 198px; min-width: 184px; padding: 6px 7px; }
  .act-btn { flex: 1 1 auto; padding: 3px 4px; font-size: 10px; }
  #structure-buttons { grid-template-columns: repeat(4, minmax(76px, 84px)); }
  .build-btn.struct .ico.art { height: 19px; }
  #minimap { width: 172px; height: 86px; }
}

/* Narrow windows: structures, selection card and minimap shrink first so the
   production column always keeps room for two columns of unit buttons. */
@media (max-width: 1000px) {
  .time-pill .st-ico, #btn-army .tb-lbl { display: none; }
  .player-badge { max-width: 96px; }
  #sel-card { flex: 0 0 168px; min-width: 150px; }
  .sel-sub { font-size: 10px; }
  .act-btn { font-size: 9.5px; }
  #structure-buttons { grid-template-columns: repeat(4, minmax(64px, 68px)); }
  .build-btn.struct { gap: 2px; padding: 3px 3px 3px 2px; }
  .build-btn.struct .bc { font-size: 9px; }
  .build-btn.struct .bn { display: none; }
  .build-btn.struct .ico.art { height: 18px; margin: 2px 0 -2px 0; }
  .prod-col { min-width: 200px; }
  #minimap { width: 150px; height: 75px; }
  .minimap-hint { display: none; }
}

@media (max-width: 880px) {
  .brand, .speed-group { display: none; }
  .player-badge { max-width: 84px; }
  #bottombar { gap: 5px; padding: 6px 6px; }
  #command-panel { gap: 6px; }
  #sel-card { flex: 0 0 128px; min-width: 120px; padding: 5px 6px; }
  .sel-sub, .sel-tips, .sel-chips { display: none; }
  .act-btn { font-size: 0; padding: 3px 2px; }
  .act-btn kbd { font-size: 9px; margin: 0; }
  #structure-buttons { grid-template-columns: repeat(4, 44px); }
  .build-btn.struct { justify-content: center; padding: 3px 2px; }
  .build-btn.struct .txt { display: none; }
  .build-btn.struct .ico.art { margin: 4px 0 -2px 0; }
  #minimap { width: 128px; height: 64px; }
  #minimap-box { padding: 4px 5px 5px; }
}
