/* StarFront: Galactic Warfare RTS Styling */
:root {
  --bg-dark: #0a0e17;
  --bg-panel: rgba(15, 23, 42, 0.95);
  --accent-gold: #f59e0b;
  --accent-cyan: #38bdf8;
  --accent-red: #ef4444;
  --accent-green: #10b981;
  --border-glow: rgba(56, 189, 248, 0.3);
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", Roboto, sans-serif;
  user-select: none;
}

body {
  background: radial-gradient(circle at 50% 10%, #1e1b4b 0%, var(--bg-dark) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* TOPBAR */
.rts-topbar {
  width: 100%;
  max-width: 1500px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 2px solid var(--accent-cyan);
  padding: 8px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-area .icon { font-size: 24px; }
.logo-area .title { font-size: 16px; font-weight: 900; letter-spacing: 1px; color: var(--accent-cyan); }
.logo-area .badge {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--accent-cyan);
}

.top-resource-bar {
  display: flex;
  gap: 24px;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.res-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.res-item strong { font-weight: 800; font-size: 15px; }
.res-item.minerals strong { color: #67e8f9; }
.res-item.gas strong { color: #fde047; }
.res-item.supply strong { color: #a7f3d0; }

.match-mode-tag {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  padding: 5px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* MAIN LAYOUT */
.rts-layout {
  display: flex;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 1520px;
  padding: 12px 16px 30px;
}

.panel {
  flex: 1;
  max-width: 260px;
  background: var(--bg-panel);
  border: 1px solid var(--border-glow);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.panel-box h3 {
  font-size: 13px;
  color: var(--accent-gold);
  margin-bottom: 8px;
}

.mode-btn-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-mode {
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  transition: all 0.2s;
}

.btn-mode.active {
  background: var(--accent-cyan);
  color: #0f172a;
  border-color: #7dd3fc;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

.select-styled {
  width: 100%;
  padding: 8px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 6px;
  font-size: 11px;
}

.log-scroll {
  background: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  padding: 8px;
  height: 160px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-entry.info { color: #93c5fd; }
.log-entry.alert { color: #fca5a5; font-weight: 700; }
.log-entry.success { color: #86efac; font-weight: 700; }

/* BOOSTER ACTION BOX */
.booster-box h4 {
  font-size: 12px;
  color: var(--accent-gold);
  margin-bottom: 8px;
}

.btn-tactical {
  width: 100%;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 10px;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 6px;
}

.btn-tactical:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: var(--accent-gold);
  transform: translateY(-2px);
}

.btn-tactical .t-icon { font-size: 20px; }
.btn-tactical strong { display: block; font-size: 11px; color: var(--accent-gold); }
.btn-tactical small { font-size: 9px; color: var(--text-muted); }

/* BATTLEFIELD CANVAS CONTAINER */
.battlefield-container {
  position: relative;
  width: 960px;
  height: 640px;
  background: #000;
  border: 3px solid #334155;
  border-radius: 12px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  cursor: default;
}

#rtsCanvas {
  display: block;
}

/* DRAG SELECTION BOX */
.selection-box {
  position: absolute;
  border: 1px solid #10b981;
  background: rgba(16, 185, 129, 0.15);
  pointer-events: none;
  display: none;
  z-index: 20;
}

/* RTS BOTTOM HUD */
.rts-hud {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 160px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.9) 0%, rgba(2, 6, 23, 0.98) 100%);
  border-top: 2px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 16px;
  z-index: 30;
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.7);
}

.minimap-wrapper {
  position: relative;
  width: 144px;
  height: 144px;
  background: #050b14;
  border: 2px solid #475569;
  border-radius: 6px;
  overflow: hidden;
}

#minimapCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.unit-info-card {
  flex: 1;
  height: 144px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 12px;
  gap: 14px;
}

.unit-info-card .portrait {
  width: 70px;
  height: 70px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--accent-cyan);
  border-radius: 8px;
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-details {
  flex: 1;
}

.info-details h4 {
  font-size: 15px;
  color: var(--accent-gold);
  margin-bottom: 6px;
}

.health-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.health-bar .fill {
  height: 100%;
  background: #10b981;
  transition: width 0.2s;
}

#infoDesc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* COMMAND MATRIX (3x3 ACTION BUTTONS) */
.command-matrix {
  width: 220px;
  height: 144px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 6px;
}

.cmd-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  padding: 4px;
}

.cmd-btn:hover:not(:disabled) {
  background: var(--accent-cyan);
  color: #0f172a;
  border-color: white;
}

.cmd-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cmd-btn .icon { font-size: 20px; }
.cmd-btn .name { font-size: 10px; font-weight: 700; margin-top: 2px; }
.cmd-btn .cost { font-size: 9px; color: var(--accent-gold); }

/* RIGHT PANEL & CODEX */
.ad-slot-box {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.95));
  border: 1px dashed var(--accent-gold);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  position: relative;
}

.ad-tag {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 8px;
  color: var(--accent-gold);
  font-weight: 800;
}

.ad-title { font-size: 13px; font-weight: 800; color: var(--accent-gold); margin-top: 6px; }
.ad-sub { font-size: 10px; color: var(--text-muted); margin-bottom: 8px; }
.ad-btn {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent-gold);
  color: #0f172a;
  font-size: 10px;
  font-weight: 700;
  border-radius: 12px;
}

.faction-card h3 { font-size: 13px; color: var(--accent-gold); margin-bottom: 6px; }
.f-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; margin-bottom: 8px; }
.f-units { list-style: none; font-size: 10px; line-height: 1.6; color: #cbd5e1; }
.f-units strong { color: var(--accent-cyan); }

.btn {
  padding: 10px 14px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-size: 12px;
  transition: all 0.2s;
}

.btn-secondary { background: rgba(255, 255, 255, 0.08); color: white; border: 1px solid rgba(255, 255, 255, 0.15); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.15); }

.btn-glow {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  color: white;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.6);
}

.w-100 { width: 100%; }
.mt-3 { margin-top: 14px; }

/* MODALS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-card {
  background: linear-gradient(145deg, #1e1b4b, #0f172a);
  border: 2px solid var(--accent-cyan);
  border-radius: 16px;
  padding: 26px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}

.badge-gold {
  background: var(--accent-gold);
  color: #0f172a;
  font-weight: 800;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
}

.timer-txt { font-size: 11px; color: var(--text-muted); float: right; }

.ad-content-mock {
  background: #000;
  border-radius: 10px;
  padding: 24px 16px;
  margin: 14px 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ad-spin {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  margin: 0 auto 10px;
  animation: spin 1s infinite linear;
}

@keyframes spin { to { transform: rotate(360deg); } }

.ad-progress {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  margin-top: 14px;
  overflow: hidden;
}

.ad-progress .bar {
  width: 0%;
  height: 100%;
  background: var(--accent-cyan);
  transition: width 5s linear;
}

.ad-note { font-size: 10px; color: var(--text-muted); }

@media (max-width: 1400px) {
  .rts-layout { flex-direction: column; align-items: center; }
  .panel { max-width: 960px; width: 100%; }
}

/* MODAL ACTIVE STATE */
.modal-overlay.active { display: flex; }

/* LOG ENTRY TYPES */
.log-entry.warning { color: #fcd34d; }
.log-entry.ally { color: #86efac; font-weight: 700; }
.log-entry.enemy { color: #fca5a5; font-weight: 700; }

/* TACTICAL INTEL CARD */
.intel-card { margin-bottom: 0; }
.intel-card h3 { font-size: 13px; color: var(--accent-gold); margin-bottom: 8px; }
.intel-card .intel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11px;
}
.intel-card .intel-row:last-child { border-bottom: none; }
.intel-card .intel-label { color: var(--text-muted); }
.intel-card .intel-row span:last-child { color: var(--accent-cyan); font-weight: 700; }

/* INTRO MODAL */
.intro-card {
  max-width: 520px;
  text-align: left;
}
.intro-header {
  text-align: center;
  margin-bottom: 16px;
}
.intro-header .game-logo { font-size: 40px; display: block; margin-bottom: 4px; }
.intro-header h1 { font-size: 28px; font-weight: 900; color: var(--accent-cyan); letter-spacing: 3px; margin: 0; }
.intro-header h2 { font-size: 14px; color: var(--accent-gold); letter-spacing: 2px; margin: 4px 0 0; }
.intro-story p { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-bottom: 10px; }
.intro-story p strong { color: var(--accent-cyan); }
.intro-controls {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 14px 0;
}
.intro-controls h3 { font-size: 13px; color: var(--accent-gold); margin-bottom: 8px; }
.intro-controls ul { list-style: none; }
.intro-controls li { font-size: 11px; color: #cbd5e1; padding: 3px 0; }
.intro-controls li strong { color: var(--accent-cyan); }
.btn-lg { padding: 14px 28px; font-size: 15px; width: 100%; margin-top: 8px; }
