/* KAELEN DOUR 2.5D RTS — Stile Interfaccia di Gioco */
:root {
  --bg-dark: #0f1613;
  --panel-bg: #15221c;
  --panel-border: #735d3d;
  --gold: #e2c286;
  --gold-glow: rgba(226, 194, 134, 0.35);
  --green-allied: #4cd476;
  --red-enemy: #e64c4c;
  --text-main: #f0e6d2;
  --text-muted: #a89f89;
  --active-btn: #3a5c43;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg-dark);
  color: var(--text-main);
  font: 14px/1.4 Georgia, serif;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* Header Risorse Tattico */
#rts-header {
  height: 48px;
  background: linear-gradient(90deg, #131f19, #1e3328, #131f19);
  border-bottom: 2px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 0 3px 12px rgba(0,0,0,0.6);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-brand h1 {
  margin: 0;
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 0.5px;
}
.header-brand span {
  font-size: 11px;
  color: var(--text-muted);
}

.rts-resources {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(15, 25, 20, 0.85);
  border: 1px solid #4a3e29;
  padding: 4px 14px;
  border-radius: 4px;
}
.res-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}
.res-icon {
  font-size: 14px;
}
.res-label {
  color: var(--text-muted);
  font-size: 10.5px;
}
.res-item b {
  color: var(--gold);
  font-family: monospace, sans-serif;
  font-size: 13px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-actions button, .header-actions .nav-btn {
  background: #1b2c22;
  border: 1px solid var(--panel-border);
  color: #eeddbb;
  padding: 5px 11px;
  font-size: 11.5px;
  border-radius: 3px;
  text-decoration: none;
  cursor: pointer;
}
.header-actions button:hover, .header-actions .nav-btn:hover {
  background: var(--active-btn);
  border-color: var(--gold);
  color: #fff;
}

/* Layout Centrale */
#game-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

#viewport-wrapper {
  flex: 1;
  position: relative;
  background: #182820;
  overflow: hidden;
}

canvas#battlefield {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}

/* Drag Selection Box */
#selection-box {
  position: absolute;
  display: none;
  border: 1.5px solid #62ff92;
  background: rgba(98, 255, 146, 0.15);
  pointer-events: none;
  z-index: 5;
}

/* Banner Avvisi Tattici */
#tactical-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 26, 21, 0.92);
  border: 1px solid var(--panel-border);
  padding: 6px 18px;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  z-index: 6;
  pointer-events: none;
}
#bannerText {
  font-size: 12px;
  color: var(--gold);
  font-weight: 500;
}

/* D-Pad Telecamera a Schermo */
#cam-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 6;
  background: rgba(16, 26, 21, 0.88);
  border: 1px solid var(--panel-border);
  padding: 8px;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.dpad-cross {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.dpad-row {
  display: flex;
  gap: 2px;
}
.dpad-cross button {
  width: 30px;
  height: 28px;
  background: #1e3126;
  border: 1px solid #554731;
  color: #eedcba;
  font-size: 12px;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dpad-cross button:hover {
  background: var(--active-btn);
  border-color: var(--gold);
  color: #fff;
}
.zoom-btns {
  display: flex;
  gap: 4px;
}
.zoom-btns button {
  background: #1e3126;
  border: 1px solid #554731;
  color: #eedcba;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 3px;
  cursor: pointer;
}
.zoom-btns button:hover {
  background: var(--active-btn);
  border-color: var(--gold);
  color: #fff;
}

/* Dashboard Inferiore Tattica */
#rts-dashboard {
  height: 175px;
  background: var(--panel-bg);
  border-top: 2px solid var(--panel-border);
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 0 -4px 18px rgba(0,0,0,0.65);
}

.dash-sec {
  background: #121c17;
  border: 1px solid #4d402b;
  border-radius: 4px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}
.sec-header {
  font-size: 11px;
  font-weight: bold;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
  border-bottom: 1px solid #3d3221;
  padding-bottom: 3px;
}

.sec-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.tab-btn {
  background: #1a2a21;
  border: 1px solid #4d402b;
  color: #d6cab3;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--active-btn);
  border-color: var(--gold);
  color: #fff;
  font-weight: bold;
}

/* Minimappa Radar */
#minimap-sec {
  width: 175px;
  flex-shrink: 0;
  align-items: center;
}
.minimap-box {
  width: 154px;
  height: 106px;
  border: 1px solid #635338;
  background: #15221b;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
}
#minimapCanvas {
  width: 100%;
  height: 100%;
  display: block;
}
.minimap-legend {
  display: flex;
  justify-content: space-between;
  width: 154px;
  font-size: 9.5px;
  color: #a49a83;
  margin-top: 4px;
}
.minimap-legend span {
  display: flex;
  align-items: center;
  gap: 3px;
}
.minimap-legend i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* Ispettore Unità */
#inspector-sec {
  width: 300px;
  flex-shrink: 0;
  overflow-y: auto;
}
.hint-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
}
.unit-card-view {
  font-size: 12px;
  line-height: 1.5;
}
.hp-bar-outer {
  width: 100%;
  height: 8px;
  background: #2a1b1b;
  border: 1px solid #5a3838;
  border-radius: 3px;
  margin: 4px 0 6px;
  overflow: hidden;
}
.hp-bar-inner {
  height: 100%;
  background: #4cd476;
  width: 100%;
  transition: width 0.2s;
}
.command-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 6px;
}
.cmd-btn {
  background: #1d2e24;
  border: 1px solid #574830;
  color: #f1e2c4;
  font-size: 11px;
  padding: 5px 6px;
  border-radius: 3px;
  cursor: pointer;
}
.cmd-btn:hover {
  background: var(--active-btn);
  border-color: var(--gold);
  color: #fff;
}

/* Caserma Reclutamento */
#barracks-sec {
  flex: 1;
  overflow-y: auto;
}
.recruit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 6px;
  overflow-y: auto;
}
.recruit-btn {
  background: #17241d;
  border: 1px solid #4d402b;
  border-radius: 4px;
  color: var(--text-main);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.1s ease;
}
.recruit-btn:hover:not(:disabled) {
  background: #23372c;
  border-color: var(--gold);
  transform: translateY(-1px);
}
.recruit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.r-icon {
  font-size: 20px;
}
.r-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.r-info b {
  color: var(--gold);
  font-size: 12px;
}
.r-info small {
  font-size: 10px;
  color: var(--text-muted);
}
.r-cost {
  font-size: 10px;
  color: #7ce39f;
  margin-top: 2px;
  font-family: monospace;
}

/* Modale Fine Partita */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 11, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-card {
  width: 440px;
  background: linear-gradient(145deg, #182820, #0f1a14);
  border: 2px solid var(--panel-border);
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  border-radius: 6px;
  padding: 24px;
  text-align: center;
}
.modal-card h2 {
  margin: 0 0 10px;
  font-size: 26px;
  color: var(--gold);
  letter-spacing: 1px;
}
.modal-card p {
  color: #d6ceb8;
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 16px;
}
.modal-stats {
  background: #111a15;
  border: 1px solid #443725;
  padding: 12px;
  border-radius: 4px;
  font-size: 12px;
  color: #bfae8e;
  line-height: 1.6;
  margin-bottom: 20px;
  text-align: left;
}
.modal-btn {
  background: linear-gradient(180deg, #426b4c, #2b4632);
  border: 1px solid var(--gold);
  color: #fff;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  display: block;
  width: 100%;
  margin-bottom: 10px;
}
.modal-btn:hover {
  background: linear-gradient(180deg, #4f7e5a, #35563e);
}
.modal-btn-sub {
  color: var(--gold);
  text-decoration: underline;
  font-size: 12px;
  display: inline-block;
}
