:root {
  --hoi4-bg-dark: #0b0f17;
  --hoi4-panel-bg: #151c28;
  --hoi4-panel-border: #3b465c;
  --hoi4-panel-gold: #c59b27;
  --hoi4-panel-gold-light: #fef08a;
  --hoi4-text-white: #f8fafc;
  --hoi4-text-muted: #94a3b8;
  --hoi4-accent-red: #dc2626;
  --hoi4-accent-green: #16a34a;
  --hoi4-accent-blue: #0284c7;
  --hoi4-accent-gold: #d97706;
  --font-hoi4-title: 'Cinzel', 'Times New Roman', serif;
  --font-hoi4-military: 'Chakra Petch', sans-serif;
  --font-hoi4-main: 'Inter', -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  background-color: var(--hoi4-bg-dark);
  color: var(--hoi4-text-white);
  font-family: var(--font-hoi4-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ─── HOI4 TOP BAR HUD ───────────────────────────────────── */
#hoi4-top-bar {
  background: linear-gradient(180deg, #242f40 0%, #151c27 70%, #0d121b 100%);
  border-bottom: 2px solid #3e4b63;
  box-shadow: 0 4px 20px rgba(0,0,0,0.8);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  position: relative;
  z-index: 100;
}

.hoi4-top-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Metallic Flag Shield */
.hoi4-flag-frame {
  width: 44px;
  height: 38px;
  background: linear-gradient(135deg, #d4af37 0%, #7d6018 100%);
  border: 2px solid #fef08a;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.9), inset 0 1px 2px rgba(255,255,255,0.5);
  cursor: pointer;
  position: relative;
}

.hoi4-flag-icon {
  font-size: 24px;
  line-height: 1;
}

.hoi4-country-info {
  display: flex;
  flex-direction: column;
}

.hoi4-country-name {
  font-family: var(--font-hoi4-military);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.hoi4-ruler-name {
  font-size: 11px;
  color: var(--hoi4-panel-gold);
}

/* Linear Stat Strip */
.hoi4-stat-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 0 8px;
}

.hoi4-stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: var(--font-hoi4-military);
  font-size: 12px;
  white-space: nowrap;
}

.hoi4-stat-val {
  font-weight: 700;
  color: #fff;
}

.hoi4-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* World Tension Globe */
.hoi4-tension-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #182232;
  border: 1px solid #da3633;
  border-radius: 20px;
  padding: 2px 10px;
  box-shadow: 0 0 10px rgba(218, 54, 51, 0.4);
}

.tension-globe {
  font-size: 16px;
  animation: pulse-globe 2s infinite alternate;
}

@keyframes pulse-globe {
  from { transform: scale(1); filter: drop-shadow(0 0 2px #da3633); }
  to { transform: scale(1.15); filter: drop-shadow(0 0 6px #ef4444); }
}

.tension-val {
  font-family: var(--font-hoi4-military);
  font-weight: 700;
  font-size: 13px;
  color: #ff7b72;
}

/* Turn Timer & Clock */
.hoi4-clock-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.hoi4-clock-date {
  font-family: var(--font-hoi4-military);
  font-size: 12px;
  color: #cbd5e1;
}

.hoi4-turn-timer {
  background: #1e293b;
  border: 1px solid var(--hoi4-accent-blue);
  border-radius: 4px;
  padding: 1px 8px;
  font-family: var(--font-hoi4-military);
  font-size: 12px;
  font-weight: 700;
  color: #38bdf8;
}

.hoi4-turn-timer.urgent {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
  animation: pulse-red 1s infinite alternate;
}

@keyframes pulse-red {
  from { box-shadow: 0 0 4px rgba(239, 68, 68, 0.4); }
  to { box-shadow: 0 0 14px rgba(239, 68, 68, 0.9); }
}

/* ─── HOI4 NAVIGATION MENU STRIP ─────────────────────────── */
.hoi4-nav-bar {
  background: #111722;
  border-bottom: 1px solid var(--hoi4-panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  height: 36px;
}

.hoi4-tabs {
  display: flex;
  gap: 4px;
}

.hoi4-tab-btn {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid var(--hoi4-panel-border);
  color: var(--hoi4-text-muted);
  font-family: var(--font-hoi4-military);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hoi4-tab-btn:hover {
  color: #fff;
  border-color: var(--hoi4-panel-gold);
}

.hoi4-tab-btn.active {
  background: linear-gradient(180deg, #b45309 0%, #78350f 100%);
  border-color: #fef08a;
  color: #fff;
  box-shadow: 0 2px 8px rgba(180, 83, 9, 0.6);
}

.hoi4-theater-badge {
  font-family: var(--font-hoi4-military);
  font-size: 12px;
  color: var(--hoi4-panel-gold);
  background: rgba(0,0,0,0.5);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
}

/* ─── MAIN CONTENT VIEWPORT ──────────────────────────────── */
.hoi4-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}

.hoi4-pane {
  display: none;
  width: 100%;
  height: 100%;
  position: relative;
}

.hoi4-pane.active {
  display: block;
}

/* ─── MAP PANE ───────────────────────────────────────────── */
#tab-map {
  width: 100%;
  height: 100%;
  position: relative;
  background: #090e17;
}

#hoi4-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

/* Map Floating Toolbar */
.hoi4-map-toolbar {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 50;
  display: flex;
  gap: 6px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--hoi4-panel-border);
  padding: 4px 8px;
  border-radius: 6px;
}

.hoi4-map-btn {
  background: #1e293b;
  border: 1px solid var(--hoi4-panel-border);
  color: var(--hoi4-text-muted);
  font-family: var(--font-hoi4-military);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.hoi4-map-btn.active {
  background: #0284c7;
  color: #fff;
  border-color: #38bdf8;
}

/* Map Bottom HUD */
.hoi4-map-hud-bar {
  position: absolute;
  bottom: 6px;
  left: 12px;
  right: 12px;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 4px 12px;
  border-radius: 6px;
  font-family: var(--font-hoi4-military);
  font-size: 11px;
  color: var(--hoi4-text-muted);
  pointer-events: none;
}

/* HOI4 Province Inspector Card */
.hoi4-province-card {
  position: absolute;
  bottom: 34px;
  right: 14px;
  width: 250px;
  background: linear-gradient(180deg, #1c2433 0%, #0f1520 100%);
  border: 2px solid var(--hoi4-panel-gold);
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.9);
  z-index: 60;
  font-size: 12px;
}

.hoi4-province-card h4 {
  font-family: var(--font-hoi4-military);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 4px;
  margin-bottom: 6px;
}

.prov-line {
  display: flex;
  justify-content: space-between;
  color: var(--hoi4-text-muted);
  margin-bottom: 3px;
}

.prov-line span {
  font-weight: 600;
  color: #fff;
}

/* ─── HOI4 BOTTOM THEATER BAR ────────────────────────────── */
#hoi4-bottom-theater {
  background: linear-gradient(180deg, #141b27 0%, #0d121a 100%);
  border-top: 2px solid #334155;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: relative;
  z-index: 90;
}

.generals-list {
  display: flex;
  align-items: center;
  gap: 12px;
}

.general-portrait-box {
  width: 48px;
  height: 48px;
  background: #1e293b;
  border: 1.5px solid var(--hoi4-panel-gold);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

.general-avatar {
  font-size: 20px;
}

.general-divisions-badge {
  position: absolute;
  bottom: -4px;
  background: #dc2626;
  border: 1px solid #fecaca;
  color: #fff;
  font-family: var(--font-hoi4-military);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 8px;
}

.theater-orders-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-lock-orders {
  background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%);
  border: 1.5px solid #93c5fd;
  color: #fff;
  font-family: var(--font-hoi4-military);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(29, 78, 216, 0.5);
  transition: all 0.2s;
}

.btn-lock-orders.locked {
  background: linear-gradient(180deg, #15803d 0%, #166534 100%);
  border-color: #86efac;
}

/* ─── MODAL LOBBY & COUNTRY PICKER ───────────────────────── */
.hoi4-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5, 8, 15, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.hoi4-modal-card {
  background: linear-gradient(180deg, #1e2736 0%, #111722 100%);
  border: 2px solid var(--hoi4-panel-gold);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 520px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.9);
  text-align: center;
}

.hoi4-modal-card h2 {
  font-family: var(--font-hoi4-title);
  font-size: 22px;
  letter-spacing: 1px;
  color: #fef08a;
  margin-bottom: 6px;
}

.hoi4-input {
  background: #0b0f17;
  border: 1px solid var(--hoi4-panel-border);
  color: #fff;
  font-family: var(--font-hoi4-military);
  font-size: 15px;
  padding: 10px 14px;
  border-radius: 6px;
  width: 100%;
  margin-bottom: 12px;
  outline: none;
}

.hoi4-input:focus {
  border-color: var(--hoi4-panel-gold);
}

.hoi4-btn-primary {
  background: linear-gradient(180deg, #d97706 0%, #b45309 100%);
  border: 1px solid #fef08a;
  color: #fff;
  font-family: var(--font-hoi4-military);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 12px 24px;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.4);
}

/* Country Selection Cards in HOI4 Modal */
.hoi4-country-select-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 14px;
}

.hoi4-country-card {
  background: #162030;
  border: 1px solid var(--hoi4-panel-border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
}

.hoi4-country-card:hover:not(.occupied) {
  border-color: var(--hoi4-panel-gold);
  background: #1f2c42;
}

.hoi4-country-card.occupied {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ─── TAB PANES (PRODUCTION, TECH, DIPLOMACY, NEWS) ──────── */
.hoi4-scrollable-pane {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
  height: 100%;
  overflow-y: auto;
}

/* Toast */
.hoi4-toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  border: 1.5px solid var(--hoi4-panel-gold);
  color: #fff;
  font-family: var(--font-hoi4-military);
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.8);
  z-index: 99999;
  transition: opacity 0.3s;
}
