:root {
  --bg-main: #0b0f17;
  --bg-card: rgba(22, 27, 34, 0.85);
  --bg-card-hover: rgba(30, 38, 48, 0.95);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(245, 158, 11, 0.3);
  
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  
  --gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.4);
  --diamond: #38bdf8;
  --diamond-glow: rgba(56, 189, 248, 0.4);
  --emerald: #10b981;
  --crimson: #ef4444;
  --purple: #8b5cf6;
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 10% 15%, rgba(245, 158, 11, 0.07) 0%, transparent 40%),
    radial-gradient(circle at 90% 85%, rgba(56, 189, 248, 0.07) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  padding-bottom: 84px; /* Space for bottom nav */
}

/* TOP HEADER */
.top-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-ring {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--gold), #d97706);
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 14px var(--gold-glow);
}

.avatar-initial {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  background: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  letter-spacing: 0.5px;
}

.vip-badge {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.empire-rank {
  font-size: 11px;
  color: var(--text-secondary);
}

/* CURRENCY CHIPS */
.currency-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.currency-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
  transition: var(--transition);
}

.gold-chip {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.25);
}

.diamond-chip {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.25);
}

/* MAIN CONTENT */
.main-content {
  padding: 16px;
  flex: 1;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

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

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

/* CARDS */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

/* SECTION TITLES */
.section-title h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  letter-spacing: -0.2px;
}

.subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.caption {
  font-size: 12px;
  color: var(--text-muted);
}

/* 1. CITADEL HERO */
.fortress-hero-card {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  position: relative;
  margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.fortress-visual {
  position: relative;
  display: inline-block;
  margin-bottom: 12px;
}

.citadel-art {
  font-size: 64px;
  filter: drop-shadow(0 6px 16px rgba(245, 158, 11, 0.35));
  animation: floatAnim 3s ease-in-out infinite;
}

@keyframes floatAnim {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.shield-halo {
  position: absolute;
  inset: -12px;
  border-radius: var(--radius-full);
  border: 2px dashed rgba(56, 189, 248, 0.6);
  animation: rotateHalo 12s linear infinite;
}

@keyframes rotateHalo {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.shield-badge {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(14, 165, 233, 0.9);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

.fortress-details h2 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 4px;
}

.hp-gauge-container {
  margin-top: 14px;
  background: rgba(11, 15, 23, 0.6);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.hp-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.gauge-bar {
  height: 8px;
  background: #1f2937;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* GRID LAYOUTS */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.card-header-flex {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.card-icon-box {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.action-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.action-card-header h4 {
  font-size: 13px;
  font-weight: 700;
}

.card-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* SHIELD PROMO */
.shield-promo-card {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(30, 41, 59, 0.7));
  border-color: rgba(56, 189, 248, 0.3);
}

.shield-promo-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shield-promo-text h4 {
  font-size: 14px;
  font-weight: 700;
  color: #38bdf8;
}

.shield-promo-text p {
  font-size: 12px;
  color: var(--text-secondary);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 700;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  text-decoration: none;
  position: relative;
  outline: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
}

.btn-md {
  padding: 10px 18px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
  padding: 11px;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  box-shadow: 0 4px 12px var(--gold-glow);
}

.btn-emerald {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-crimson {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.btn-outline-primary {
  background: transparent;
  border: 1px dashed #3b82f6;
  color: #60a5fa;
}

/* 2. ARMY TAB */
.army-summary-banner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  text-align: center;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.9));
  border-color: rgba(255, 255, 255, 0.1);
  padding: 14px 8px;
}

.summary-stat {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}

.stat-gold {
  color: var(--gold);
}

.stat-title {
  font-size: 11px;
  color: var(--text-secondary);
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border-color);
}

.unit-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.unit-icon-frame {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.unit-info {
  flex: 1;
}

.unit-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.unit-title-row h4 {
  font-size: 14px;
  font-weight: 700;
}

.unit-owned-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
}

/* 3. WAR ROOM */
.war-radar-card {
  text-align: center;
  padding: 24px 16px;
  background: radial-gradient(circle at center, rgba(239, 68, 68, 0.15) 0%, rgba(15, 23, 42, 0.9) 70%);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.war-radar-card h3 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
}

.radar-ping-anim {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.2);
  margin: 0 auto 10px;
  position: relative;
}

.radar-ping-anim::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: var(--radius-full);
  border: 2px solid rgba(239, 68, 68, 0.6);
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  75%, 100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.target-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
}

.target-details h4 {
  font-size: 14px;
  font-weight: 700;
}

/* 4. MARKETPLACE */
.vip-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(139, 92, 246, 0.2));
  border-color: rgba(245, 158, 11, 0.3);
}

.vip-icon {
  font-size: 28px;
}

.vip-info {
  flex: 1;
}

.vip-info h4 {
  font-size: 14px;
  font-weight: 800;
  color: var(--gold);
}

.vip-info p {
  font-size: 11px;
  color: var(--text-secondary);
}

.market-filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.filter-btn.active {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

.market-listings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.market-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
}

.market-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.market-item-text h4 {
  font-size: 14px;
  font-weight: 700;
}

.price-tag {
  font-size: 13px;
  font-weight: 800;
}

/* 5. LEADERBOARD */
.leaderboard-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.lb-sub-tab {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.lb-sub-tab.active {
  background: var(--bg-card-hover);
  color: var(--gold);
  border-color: rgba(245, 158, 11, 0.4);
}

.lb-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-color);
}

.lb-item:last-child {
  border-bottom: none;
}

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

.lb-rank {
  font-size: 14px;
  font-weight: 800;
  width: 24px;
  text-align: center;
}

/* BOTTOM NAVIGATION */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: 68px;
  background: rgba(11, 15, 23, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  z-index: 100;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-icon {
  font-size: 20px;
  transition: var(--transition);
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
}

.nav-btn.active {
  color: var(--gold);
}

.nav-btn.active .nav-icon {
  transform: translateY(-2px) scale(1.1);
  filter: drop-shadow(0 0 6px var(--gold-glow));
}

.war-tab-btn.active {
  color: var(--crimson);
}

/* MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease forwards;
}

.modal-box {
  background: #161b22;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 380px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

/* FORMS */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-select, .form-input {
  width: 100%;
  padding: 10px 12px;
  background: #0d1117;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.form-select:focus, .form-input:focus {
  border-color: #3b82f6;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 300;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
