* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  transition: background 0.35s ease, color 0.25s ease;
}

#particle-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 248px;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  border-inline-end: 1px solid var(--border-color);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 12px;
  border-bottom: 1px solid var(--border-color);
}
.brand-title {
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: 0.4px;
  color: var(--accent-primary);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-align: start;
  transition: all 0.18s ease;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(0, 245, 212, 0.16), rgba(123, 44, 191, 0.18));
  border-color: var(--accent-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-glow);
}

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.atmosphere-banner {
  display: none;
  padding: 8px 16px;
  text-align: center;
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #0284c7, #7c3aed, #db2777);
  color: #fff;
}
body[data-atmosphere="semifinal"] .atmosphere-banner,
body[data-atmosphere="final"] .atmosphere-banner {
  display: block;
}
body[data-atmosphere="final"] .atmosphere-banner {
  background: linear-gradient(90deg, #b45309, #ffd60a, #b45309);
  color: #111827;
}

.top-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 20;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: 0.82rem;
  font-weight: 700;
}

.content-area {
  padding: 20px;
  max-width: 1220px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: 92px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-glow);
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--accent-primary);
  color: #071019;
  box-shadow: 0 4px 14px rgba(0, 245, 212, 0.25);
}
[data-theme="minimalist"] .btn-primary,
[data-theme="dark-gaming"] .btn-primary { color: #ffffff; }
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-gold {
  background: linear-gradient(135deg, #ffd60a, #f59e0b);
  color: #111827;
}
.btn-danger {
  background: var(--accent-danger);
  color: #fff;
}
.btn-sm { padding: 6px 11px; font-size: 0.78rem; border-radius: 8px; }

.input, .select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
}
.input:focus, .select:focus { border-color: var(--accent-primary); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.rarity-Common { background: #334155; color: #e2e8f0; }
.rarity-Uncommon { background: #065f46; color: #6ee7b7; }
.rarity-Rare { background: #1d4ed8; color: #93c5fd; }
.rarity-Epic { background: #6d28d9; color: #ddd6fe; }
.rarity-Legendary { background: #b45309; color: #fde68a; }
.rarity-Mythic { background: linear-gradient(90deg, #db2777, #7c3aed, #06b6d4); color: #fff; }

.progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-gold));
  transition: width 0.35s ease;
}

/* Arabic RTL + Full Harakat Support */
[dir="rtl"] { font-family: 'Tahoma', 'Amiri', 'Noto Naskh Arabic', system-ui, sans-serif; }
.arabic-text {
  direction: rtl;
  unicode-bidi: isolate;
  font-size: 1.48rem;
  line-height: 2.35;
  font-weight: 600;
  color: var(--accent-gold);
}
.jp-text {
  font-size: 1.32rem;
  line-height: 1.8;
  font-weight: 700;
  color: var(--accent-primary);
}

/* Modals & Overlays */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--accent-primary);
  border-radius: 18px;
  padding: 22px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.stadium-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #132a52 0%, #050914 100%);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  z-index: 120;
}
.stadium-overlay.open { display: flex; }

.toast-stack {
  position: fixed;
  top: 16px;
  inset-inline-end: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 150;
  pointer-events: none;
}
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--accent-primary);
  color: var(--text-primary);
  padding: 10px 15px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  animation: slideInToast 0.25s ease;
}

.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table.data-table th, table.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-color);
  text-align: start;
}
table.data-table th { color: var(--accent-primary); font-weight: 800; }

.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-color);
  padding: 6px 4px;
  justify-content: space-around;
  z-index: 40;
}
.mobile-nav button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
}
.mobile-nav button.active { color: var(--accent-primary); }

@media (max-width: 820px) {
  .sidebar { display: none; }
  .mobile-nav { display: flex; }
  .content-area { padding: 14px; padding-bottom: 84px; }
}
