/* ═══════════════════════════════════════════════════════════════════════════
   UlmLag – Challenge Dashboard
   Dark theme, mobile-first
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --color-a: #3b82f6;
  --color-b: #ef4444;
  --bg-dark:   #0f1117;
  --bg-card:   #1a1d27;
  --bg-card2:  #21253a;
  --border:    rgba(255,255,255,0.1);
  --text-muted: #8b92a5;
  --header-h: 72px;
  --tabbar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-dark);
  color: #e8eaf0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  height: 100dvh;
  overflow: hidden;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */

.app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: #111827;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  padding: 0 12px;
  z-index: 100;
  gap: 16px;
}

.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--tabbar-h);
  background: #111827;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.app-content {
  position: fixed;
  top: var(--header-h);
  bottom: var(--tabbar-h);
  left: 0; right: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */

.team-score {
  display: flex; align-items: center; gap: 6px;
  flex: 0 0 auto; max-width: 140px;
}

.team-name {
  font-size: 0.85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.zone-count {
  font-size: 1.5rem; font-weight: 800; line-height: 1;
}

#score-a .zone-count { color: var(--color-a); }
#score-b .zone-count { color: var(--color-b); }


.header-center {
  text-align: center; flex-shrink: 0;
}

.game-title {
  font-size: 0.65rem; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
}

.timer {
  font-size: 1.5rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.timer.danger { color: #ef4444; animation: pulse 1s infinite; }
.timer.warning { color: #fbbf24; }
.timer.paused { color: #6b7a99; animation: none; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

/* ─── Notification bell (absolute in header) ─────────────────────────────── */

.btn-notif {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.1rem; padding: 4px 6px;
  border-radius: 6px; transition: color 0.15s;
  line-height: 1;
}
.btn-notif:hover { color: #e8eaf0; }
.btn-notif.active { color: #fbbf24; }
.btn-notif.denied { color: #ef4444; opacity: 0.5; cursor: not-allowed; }

/* ─── Tab Bar ─────────────────────────────────────────────────────────────── */

.tab-btn {
  flex: 1; border: none; background: none; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px;
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; cursor: pointer;
  transition: color 0.15s;
  padding: 0;
}

.tab-btn i { font-size: 1.2rem; }
.tab-btn.active { color: var(--color-a); }

/* ─── Tab Panes ────────────────────────────────────────────────────────────── */

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

/* ─── Not-started overlay ──────────────────────────────────────────────────── */

.not-started-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 60px 20px; text-align: center;
  color: var(--text-muted);
}

.not-started-msg i { color: var(--text-muted); }

/* ─── Challenge Cards ──────────────────────────────────────────────────────── */

.challenge-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; flex-direction: column;
  height: 100%;
  overflow: hidden;
  transition: border-color 0.2s;
}

.challenge-card.type-normal  { border-top: 3px solid #6b7280; }
.challenge-card.type-steal   { border-top: 3px solid #f59e0b; }
.challenge-card.type-vs      { border-top: 3px solid #a855f7; }

.challenge-card-header {
  padding: 10px 14px 6px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}

.challenge-name {
  font-weight: 700; font-size: 1rem; line-height: 1.3;
  flex: 1;
}

.type-badge {
  font-size: 0.6rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; padding: 3px 8px; border-radius: 99px;
  white-space: nowrap; flex-shrink: 0;
}

.type-badge.normal { background: #374151; color: #9ca3af; }
.type-badge.steal  { background: #451a03; color: #fbbf24; }
.type-badge.vs     { background: #3b0764; color: #c084fc; }

.challenge-desc {
  padding: 4px 14px 10px;
  font-size: 0.9rem; line-height: 1.5;
  color: #c9d1e0;
  flex: 1;
}

.claim-info {
  margin: 0 14px 10px;
  font-size: 0.82rem;
  font-style: italic;
  color: #6b7a99;
}

.claim-info i { font-style: normal; margin-right: 3px; }

.steal-desc-block {
  margin: 0 10px 10px;
  background: #2d1f00;
  border: 1px solid #854d0e;
  border-radius: 8px;
  padding: 8px 12px;
}

.steal-desc-label {
  font-size: 0.65rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1px; color: #fbbf24; margin-bottom: 4px;
  display: flex; align-items: center; gap: 4px;
}

.steal-desc-text {
  font-size: 0.88rem; color: #fde68a; line-height: 1.4;
}

.challenge-actions {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex; gap: 6px; flex-wrap: wrap;
}

.btn-team-a { background: var(--color-a); color: #fff; border: none; }
.btn-team-a:hover { background: #2563eb; color: #fff; }
.btn-team-b { background: var(--color-b); color: #fff; border: none; }
.btn-team-b:hover { background: #dc2626; color: #fff; }

.challenge-actions .btn {
  flex: 1; font-size: 0.8rem; padding: 6px 8px;
  border-radius: 8px; font-weight: 600;
}

.btn-remove {
  flex: 0 0 100% !important;
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.75rem !important;
  padding: 4px 8px !important;
}

.btn-remove:hover { background: rgba(255,255,255,0.05); color: #ef4444; border-color: #ef4444; }

/* ─── Zone Map (Leaflet) ────────────────────────────────────────────────────── */

#tab-zones { height: 100%; overflow: hidden; }
#tab-zones.active { display: flex; flex-direction: column; }
#zone-map { flex: 1; min-height: 0; width: 100%; }

/* Override Leaflet defaults for dark theme */
.leaflet-container { background: #0f1117; }
.leaflet-tile-pane { filter: brightness(0.85) saturate(0.9); }

/* Location toggle control */
.location-control { background: transparent !important; border: none !important; box-shadow: none !important; }
.location-btn {
  background: rgba(17, 24, 39, 0.88);
  border: 1px solid rgba(255,255,255,0.18);
  color: #a8b2c8;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: all 0.15s;
  white-space: nowrap;
}
.location-btn:hover { border-color: rgba(255,255,255,0.35); color: #e8eaf0; }
.location-btn.active { background: rgba(34,197,94,0.15); border-color: #22c55e; color: #22c55e; }

/* Team jump control */
.team-jump-control {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.team-jump-btn {
  background: rgba(17, 24, 39, 0.88);
  border: 1px solid var(--team-color, rgba(255,255,255,0.18));
  color: var(--team-color, #a8b2c8);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
  white-space: nowrap;
  width: 100%;
}
.team-jump-btn:hover {
  filter: brightness(1.3);
  border-color: #e8eaf0;
}

/* User name labels on map */
.user-label {
  background: rgba(17,24,39,0.82) !important;
  border: 1px solid rgba(255,255,255,0.15) !important;
  box-shadow: none !important;
  color: #e8eaf0 !important;
  font-weight: 600 !important;
  font-size: 0.72rem !important;
  border-radius: 4px !important;
  padding: 1px 5px !important;
}

/* Zone number labels */
.zone-label {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  color: rgba(255,255,255,0.85) !important;
  font-weight: 700 !important;
  font-size: 0.7rem !important;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9) !important;
  pointer-events: none !important;
}

/* ─── Zone Picker map (in modals) ──────────────────────────────────────────── */

.zone-picker-map-wrap {
  height: 280px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

/* Dark-theme active state for picker toggle btn-group */
.btn-group .btn-outline-secondary.active {
  background: #3b4259;
  border-color: #6b7a99;
  color: #e8eaf0;
}

/* ─── Zone Picker (in modals) ───────────────────────────────────────────────── */

.zone-picker {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
}

.zone-picker .zp-cell {
  aspect-ratio: 1;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.7rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s;
  user-select: none;
}

.zone-picker .zp-cell.unclaimed { background: #1e2233; border-color: #2d3452; color: #4b5e8a; }
.zone-picker .zp-cell.team-a    { background: rgba(59,130,246,0.2); border-color: #3b82f6; color: #93c5fd; }
.zone-picker .zp-cell.team-b    { background: rgba(239,68,68,0.2);  border-color: #ef4444; color: #fca5a5; }
.zone-picker .zp-cell.disabled  { opacity: 0.25; cursor: not-allowed; pointer-events: none; }
.zone-picker .zp-cell.selected  { border-color: #fff !important; box-shadow: 0 0 0 3px rgba(255,255,255,0.3); transform: scale(1.1); }
.zone-picker .zp-cell:not(.disabled):hover { transform: scale(1.08); }

/* ─── Log ─────────────────────────────────────────────────────────────────── */

.log-entry {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  color: #c9d1e0;
}

.log-entry:last-child { border-bottom: none; }

/* ─── Admin ─────────────────────────────────────────────────────────────────── */

.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.admin-section-title {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px;
  color: #a8b2c8; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}

/* Override Bootstrap text-muted inside admin cards for readable contrast */
.admin-section .text-muted { color: #a8b2c8 !important; }

.challenge-pool-item {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex; align-items: flex-start; gap: 10px;
}

.pool-item-body { flex: 1; min-width: 0; }
.pool-item-name { font-weight: 600; font-size: 0.9rem; }
.pool-item-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pool-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Used-challenge rows in admin – high contrast */
.used-challenge-label { color: #c9d1e0; }

/* ─── VS modal winner buttons ─────────────────────────────────────────────── */

.vs-winner-btn {
  padding: 12px; font-weight: 700; font-size: 1rem;
  background: var(--bg-card2); border: 2px solid var(--border);
  color: #fff;
  border-radius: 10px; transition: all 0.15s;
}

.vs-winner-btn.selected-a { background: rgba(59,130,246,0.3); border-color: var(--color-a); }
.vs-winner-btn.selected-b { background: rgba(239,68,68,0.3);  border-color: var(--color-b); }

/* ─── Game Over ───────────────────────────────────────────────────────────── */

.game-over-banner {
  background: linear-gradient(135deg, #1a1d27, #0f1117);
  border: 1px solid #fbbf24;
  border-radius: 12px;
  padding: 20px; text-align: center;
  margin: 16px;
}

/* ─── Rules sub-tabs ────────────────────────────────────────────────────────── */

.rules-subtab-bar {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 8px 12px 0;
  gap: 4px;
}
.rules-subtab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #a8b2c8;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: -1px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.rules-subtab-btn:hover { color: #e8eaf0; }
.rules-subtab-btn.active { color: #e8eaf0; border-bottom-color: #6366f1; }

/* Challenge list in Rules > Challenges tab */
.challenge-list-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.challenge-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.challenge-list-name {
  font-weight: 600;
  color: #e8eaf0;
  font-size: 0.9rem;
}
.challenge-list-desc {
  color: #a8b2c8;
  font-size: 0.82rem;
  margin-bottom: 0;
  line-height: 1.5;
}
.challenge-list-claim {
  color: #6b7280;
  font-size: 0.78rem;
  margin-top: 6px;
  margin-bottom: 0;
  font-style: italic;
}
.challenge-list-steal {
  color: #a8b2c8;
  font-size: 0.82rem;
  margin-top: 8px;
  margin-bottom: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ─── Rules ─────────────────────────────────────────────────────────────────── */

.rules-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.9rem;
  color: #c9d1e0;
  line-height: 1.7;
}

.rules-list li + li { margin-top: 4px; }

/* ─── Statistics Tab ────────────────────────────────────────────────────────── */

.stats-winner {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  border: 2px solid;
  border-radius: 14px;
  padding: 18px 24px;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}
.stats-winner.draw {
  color: #a8b2c8;
  border-color: rgba(255,255,255,0.15);
}

.stats-score {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}
.stats-team-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}
.stats-team-score.right { }
.stats-zone-count {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.stats-team-name {
  font-size: 0.78rem;
  color: inherit;
  opacity: 0.85;
  text-align: center;
}
.stats-area {
  font-size: 0.68rem;
  opacity: 0.6;
  margin-top: 2px;
}
.stats-bar {
  flex: 1;
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
}
.stats-bar > div { transition: width 0.4s ease; }

.stats-section {
  margin-top: 20px;
}
.stats-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #a8b2c8;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stats-zone-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}
.stats-zone-table th {
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-align: left;
}
.stats-zone-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: #c9d1e0;
  vertical-align: middle;
}
.stats-zone-table .zone-num {
  color: #6b7280;
  white-space: nowrap;
  width: 60px;
}
.stats-zone-table tbody tr:hover { background: rgba(255,255,255,0.03); }

.stats-challenge-link {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.25);
  text-underline-offset: 2px;
}
.stats-challenge-link:hover {
  color: #e8eaf0;
  text-decoration-color: rgba(255,255,255,0.6);
}
.sc-desc {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #c9d1e0;
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2d3452; border-radius: 99px; }
