/* ==========================================================================
   style.css - Tactical Total War Formation RTS Styles
   ========================================================================== */

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.88);
  --border-color: #334155;
  --gold-accent: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.35);
  --blue-team: #3b82f6;
  --blue-glow: rgba(59, 130, 246, 0.4);
  --red-team: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.4);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
}

.hidden {
  display: none !important;
}

/* --------------------------------------------------------------------------
   LOBBY SCREEN
   -------------------------------------------------------------------------- */
#lobbyScreen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #1e293b 0%, #090d16 100%);
  padding: 20px;
  overflow-y: auto;
  z-index: 100;
}

.lobby-container {
  max-width: 860px;
  width: 100%;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 36px 40px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 40px rgba(245, 158, 11, 0.1);
}

.lobby-header {
  text-align: center;
  margin-bottom: 28px;
}

.lobby-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.lobby-title span {
  color: var(--gold-accent);
}

.lobby-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Matchmaking actions */
.lobby-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 30px;
}

.action-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.action-card:hover {
  border-color: var(--gold-accent);
  box-shadow: 0 4px 20px var(--gold-glow);
}

.action-card h3 {
  font-size: 18px;
  color: #f1f5f9;
  margin-bottom: 6px;
}

.action-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #0f172a;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  box-shadow: 0 4px 14px var(--gold-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #334155;
  color: #f8fafc;
}

.btn-secondary:hover {
  background: #475569;
  transform: translateY(-1px);
}

.custom-room-row {
  display: flex;
  gap: 10px;
}

.custom-room-row input {
  flex: 1;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
}

.custom-room-row input:focus {
  outline: none;
  border-color: var(--gold-accent);
}

/* Combat Guide */
.combat-guide {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.combat-guide h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-accent);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.unit-card-preview {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.unit-card-preview .icon {
  font-size: 26px;
  margin-bottom: 6px;
}

.unit-card-preview .title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.unit-card-preview .beats {
  font-size: 11px;
  color: #4ade80;
  margin-top: 4px;
  font-weight: 600;
}

.unit-card-preview .weak {
  font-size: 11px;
  color: #f87171;
  margin-top: 2px;
}

/* How to play instruction */
.instruction-box {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.5;
}

.instruction-box strong {
  color: #fff;
}

/* --------------------------------------------------------------------------
   GAME SCREEN
   -------------------------------------------------------------------------- */
#gameScreen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#battleCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* Top Battle HUD */
.top-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0) 100%);
  pointer-events: none;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
}

.player-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-badge.blue {
  background: rgba(37, 99, 235, 0.25);
  border: 1px solid var(--blue-team);
  color: #93c5fd;
}

.player-badge.red {
  background: rgba(220, 38, 38, 0.25);
  border: 1px solid var(--red-team);
  color: #fca5a5;
}

/* Match Strength Center Bar */
.army-strength-tracker {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 420px;
}

.strength-bars-container {
  display: flex;
  width: 100%;
  height: 14px;
  background: #18181b;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  position: relative;
}

.strength-bar-blue {
  height: 100%;
  background: linear-gradient(90deg, #1d4ed8 0%, #3b82f6 100%);
  transition: width 0.3s ease;
}

.strength-bar-red {
  height: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #b91c1c 100%);
  transition: width 0.3s ease;
}

.strength-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 11px;
  font-weight: 700;
  margin-top: 4px;
}

.strength-labels .blue-label { color: #60a5fa; }
.strength-labels .timer-label { color: #f59e0b; font-size: 12px; }
.strength-labels .red-label { color: #f87171; }

/* In-game quick buttons */
.hud-btn {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border-color);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: #334155;
  border-color: #64748b;
  color: #fff;
}

/* Floating Controls Prompt Bar */
.controls-reminder {
  position: absolute;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  color: #cbd5e1;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

.controls-reminder span {
  color: var(--gold-accent);
  font-weight: 700;
}

/* Selected Unit Card (Bottom Left) */
.selected-card {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 320px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  border-left: 4px solid var(--gold-accent);
}

.selected-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.selected-card-header .unit-avatar {
  font-size: 32px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
}

.selected-card-header .unit-title-group h3 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.selected-card-header .unit-title-group p {
  font-size: 12px;
  color: var(--gold-accent);
}

.unit-health-container {
  margin-bottom: 12px;
}

.unit-health-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 4px;
}

.unit-health-bar {
  height: 6px;
  width: 100%;
  background: #334155;
  border-radius: 3px;
  overflow: hidden;
}

.unit-health-bar-fill {
  height: 100%;
  width: 100%;
  background: #22c55e;
  transition: width 0.2s ease;
}

.selected-card-tactics {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 10px;
  border-radius: 6px;
}

.tactics-row {
  display: flex;
  gap: 6px;
}

.tactics-row .label-good { color: #4ade80; font-weight: 700; }
.tactics-row .label-bad { color: #f87171; font-weight: 700; }

/* Game Over Modal */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.modal-content {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 16px;
  padding: 36px 48px;
  text-align: center;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 28px;
}

.modal-buttons {
  display: flex;
  gap: 14px;
  justify-content: center;
}
