/* ============================================================
   Vallam Kali - Kerala Boat Race Web App
   ============================================================ */

:root {
  --primary:      #c0392b;
  --primary-dk:   #922b21;
  --accent:       #f1c40f;
  --team1:        #c0392b;
  --team2:        #2980b9;
  --team3:        #27ae60;
  --water:        #0a4a6e;
  --shore:        #27ae60;
  --bg:           #0d1b2a;
  --surface:      #1a2a3a;
  --surface2:     #243447;
  --text:         #ecf0f1;
  --text-muted:   #95a5a6;
  --border:       rgba(255,255,255,0.12);
  --radius:       12px;
  --shadow:       0 4px 24px rgba(0,0,0,0.5);
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  /* Prevent iOS bounce scroll */
  overscroll-behavior: none;
}

/* Prevent double-tap zoom on buttons and interactive elements */
.btn, button, input, select, textarea {
  touch-action: manipulation;
}

/* ============================================================
   VIEWS
   ============================================================ */
.view { display: none; }
.view.active { display: flex; flex-direction: column; min-height: 100vh; }

/* Race view overrides: sidebar + canvas side-by-side */
#view-race.active {
  flex-direction: row;
  height: 100vh;
  min-height: unset;
  overflow: hidden;
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
#view-login {
  justify-content: center;
  align-items: center;
  background: radial-gradient(ellipse at center, #0d2035 0%, #060d14 100%);
  position: relative;
  overflow: hidden;
}

#view-login::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--shore));
}

.auth-container {
  width: 100%;
  max-width: 460px;
  padding: 24px 16px;
  z-index: 1;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .boat-icon {
  font-size: 56px;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 20px rgba(241,196,15,0.6));
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(241,196,15,0.4);
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
  letter-spacing: 1px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: var(--text);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(241,196,15,0.15);
}

.error-msg {
  display: none;
  color: #e74c3c;
  font-size: 13px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(231,76,60,0.1);
  border-radius: 6px;
  border: 1px solid rgba(231,76,60,0.3);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dk);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(192,57,43,0.4);
}

.btn-gold {
  background: var(--accent);
  color: #1a1a1a;
}
.btn-gold:hover:not(:disabled) {
  background: #f39c12;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(241,196,15,0.5);
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--text);
}

.btn-team-team1 {
  background: var(--team1);
  color: white;
}
.btn-team-team1:hover:not(:disabled) {
  background: #a93226;
  transform: translateY(-1px);
}

.btn-team-team2 {
  background: var(--team2);
  color: white;
}
.btn-team-team2:hover:not(:disabled) {
  background: #2471a3;
  transform: translateY(-1px);
}

.btn-team-team3 {
  background: var(--team3);
  color: white;
}
.btn-team-team3:hover:not(:disabled) {
  background: #1e8449;
  transform: translateY(-1px);
}

.btn-danger {
  background: transparent;
  color: #e74c3c;
  border: 1px solid rgba(231,76,60,0.4);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(231,76,60,0.1);
}

.leave-team-btn {
  background: rgba(231,76,60,0.15);
  color: #e74c3c;
  border: 1px solid rgba(231,76,60,0.5);
  width: 100%;
  font-weight: 700;
}
.leave-team-btn:hover:not(:disabled) {
  background: rgba(231,76,60,0.28);
  border-color: #e74c3c;
}

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}

/* ============================================================
   RACE VIEW — Sidebar + Canvas layout
   ============================================================ */
#view-race {
  background: var(--bg);
}

/* Sidebar: contains header, lobby, score, swipe controls */
.race-sidebar {
  width: 270px;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border);
}

/* Main area: canvas fills all remaining space */
.race-main {
  flex: 1;
  height: 100vh;
  overflow: hidden;
  background: #000010;
  position: relative;
}

#race-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
}


/* ── Race HUD bar (landscape, one-line, floats at top of canvas) ── */
.race-hud {
  display: none; /* shown only in landscape via media query */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 15;
  height: 38px;
  align-items: center;
  justify-content: space-between;
  padding: 0 52px 0 12px; /* 52px right clears nothing; 12px left */
  background: linear-gradient(
    to bottom,
    rgba(10, 18, 28, 0.92) 0%,
    rgba(10, 18, 28, 0.7) 80%,
    transparent 100%
  );
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: none; /* don't block canvas swipes */
  gap: 8px;
}


.hud-team {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.hud-team.hud-team2 {
  justify-content: flex-end;
}

.hud-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hud-dot-team1 { background: var(--team1); box-shadow: 0 0 4px var(--team1); }
.hud-dot-team2 { background: var(--team2); box-shadow: 0 0 4px var(--team2); }

.hud-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
  letter-spacing: 0.3px;
}

.hud-score {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  min-width: 26px;
  text-align: center;
}

.hud-team1 .hud-score { color: #ff6b6b; }
.hud-team2 .hud-score { color: #74b9ff; }

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

.hud-timer {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}

.hud-timer.urgent { color: #e74c3c; }

/* Collapse team cards to single column inside the narrow sidebar */
.race-sidebar .teams-grid {
  grid-template-columns: 1fr;
}

/* Mobile portrait: stack canvas on top, sidebar below */
@media (max-width: 640px) and (orientation: portrait) {
  #view-race.active {
    flex-direction: column;
  }
  .race-sidebar {
    width: 100%;
    height: auto;
    max-height: 46vh;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    order: 2;
  }
  .race-main {
    flex: 1;
    min-height: 54vh;
    height: 54vh;
    order: 1;
  }
  .race-sidebar .teams-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ============================================================
   LANDSCAPE PHONE — retractable sidebar + canvas-top HUD
   Targets phones rotated landscape (height ≤ 500px)
   ============================================================ */

/* Hamburger toggle button — hidden by default, shown in landscape mobile */
#sidebar-toggle-btn {
  display: none;
  position: absolute;
  top: 46px; /* below HUD */
  left: 8px;
  z-index: 20;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: rgba(10, 18, 28, 0.75);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Show hamburger in landscape on small screens during race */
@media (max-height: 520px) and (orientation: landscape) {
  #sidebar-toggle-btn {
    display: flex;
  }

  /* When sidebar is collapsed, hide it completely */
  #view-race.sidebar-collapsed .race-sidebar {
    display: none;
  }
}

/* Race HUD always visible when race view is active */
#view-race.active .race-hud {
  display: flex;
}

.race-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
}

.race-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 1;
  min-width: 0;
}

.race-header-title .logo-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.race-header-title .logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-width: 0;
}

/* Make logout button always clearly visible */
#logout-btn {
  background: rgba(231,76,60,0.15) !important;
  border-color: rgba(231,76,60,0.45) !important;
  color: #ff6b6b !important;
  white-space: nowrap;
}

#connection-status {
  font-size: 11px;
  color: var(--text-muted);
}

/* Hide connection status text on narrow screens so logout button fits */
@media (max-width: 400px) {
  #connection-status { display: none !important; }
}

/* .canvas-section removed — canvas now lives in .race-main which fills full height */

/* ============================================================
   LOBBY PANEL
   ============================================================ */
#lobby-panel {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
}

.lobby-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
  color: var(--accent);
}

.lobby-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 16px;
}

.teams-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 480px) {
  .teams-grid { grid-template-columns: 1fr; }
}

.team-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.team-card.my-team {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 20px rgba(241,196,15,0.2);
}

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

.team-header.team-team1 { background: linear-gradient(135deg, var(--team1), #922b21); }
.team-header.team-team2 { background: linear-gradient(135deg, var(--team2), #1a5276); }
.team-header.team-team3 { background: linear-gradient(135deg, var(--team3), #145a32); }

.team-header h3 { font-size: 15px; font-weight: 700; }

.team-count {
  font-size: 12px;
  background: rgba(0,0,0,0.3);
  padding: 2px 8px;
  border-radius: 20px;
}

.players-list {
  padding: 10px 14px;
  min-height: 60px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
}

.player-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text);
}

.player-chip.me {
  background: rgba(241,196,15,0.2);
  border-color: var(--accent);
  color: var(--accent);
}

.empty-team {
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

.team-actions {
  padding: 8px 14px;
  display: flex;
  justify-content: center;
  background: rgba(0,0,0,0.2);
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding-bottom: 16px;
}

.lobby-actions .start-btn {
  width: 100%;
  max-width: 320px;
  padding: 14px;
  font-size: 16px;
  letter-spacing: 1px;
}

.config-link {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  text-decoration: underline;
}

/* ============================================================
   RACE PANEL (during race)
   ============================================================ */
#race-panel {
  display: none;
  padding: 12px 16px;
}

.score-board {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.score-item {
  text-align: center;
  min-width: 0;        /* allow grid cell to shrink below content size */
  overflow: hidden;
}

.score-item .team-name {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-item .score-num {
  font-size: 28px;
  font-weight: 700;
}

.score-item.team1 .score-num { color: var(--team1); }
.score-item.team2 .score-num { color: var(--team2); }
.score-item.team3 .score-num { color: var(--team3); }

.score-divider {
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 700;
}

.timer-display {
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.timer-display.urgent {
  color: #e74c3c;
  animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

/* ============================================================
   SWIPE AREA
   ============================================================ */
#swipe-area {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  margin: 8px 16px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  min-height: 120px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  position: relative;
  overflow: hidden;
}

#swipe-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(241,196,15,0.05) 0%, transparent 70%);
  pointer-events: none;
}

#swipe-area:active { cursor: grabbing; }

.swipe-instruction {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.swipe-arrows {
  font-size: 32px;
  color: var(--accent);
  letter-spacing: 8px;
  animation: swipeHint 2s ease-in-out infinite;
}

@keyframes swipeHint {
  0%, 100% { opacity: 0.4; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(8px); }
}

#swipe-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  font-weight: 900;
  color: var(--accent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
  text-shadow: 0 0 20px rgba(241,196,15,0.8);
}

#swipe-feedback.active { opacity: 1; }

.swipe-team-indicator {
  font-size: 12px;
  font-weight: 700;
  margin-top: 6px;
  padding: 3px 12px;
  border-radius: 20px;
}

.swipe-team-indicator.team1 { background: rgba(192,57,43,0.3); color: #e74c3c; }
.swipe-team-indicator.team2 { background: rgba(41,128,185,0.3); color: #5dade2; }

/* ============================================================
   RESULTS PANEL
   ============================================================ */
#results-panel {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  justify-content: center;
  align-items: center;
  padding: 16px;
  overflow-y: auto;
  /* safe-area insets for notch phones */
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.results-card {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 20px 20px 24px;
  text-align: center;
  width: 100%;
  max-width: 440px;
  /* ensure card stays visible when keyboard or system chrome is up */
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  box-shadow: 0 0 60px rgba(241,196,15,0.3), 0 8px 32px rgba(0,0,0,0.6);
  animation: popIn 0.5s cubic-bezier(0.175,0.885,0.32,1.275);
}

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

/* Canvas boat illustration inside the results card */
.winner-canvas {
  display: block;
  width: 100%;
  height: 140px;
  border-radius: 12px;
  margin-bottom: 12px;
  background: #0d3d5e;
}

/* Portrait mobile: tighten up vertical spacing */
@media (max-width: 480px) and (orientation: portrait) {
  #results-panel {
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .results-card {
    padding: 14px 14px 18px;
    border-radius: 16px;
    max-height: calc(100dvh - 24px);
  }
  .winner-canvas {
    height: 110px;
    margin-bottom: 8px;
  }
  .results-trophy { font-size: 44px; margin-bottom: 6px; }
  #results-winner { font-size: 22px; margin-bottom: 12px; }
  #results-score { gap: 8px; margin-bottom: 14px; }
  .result-score-item { padding: 8px 10px; }
  .result-swipes { font-size: 16px; }
}

/* Very small screens (e.g. iPhone SE portrait) */
@media (max-width: 360px) {
  .winner-canvas { height: 90px; }
  .results-trophy { font-size: 36px; }
  #results-winner { font-size: 18px; }
}

.results-trophy { font-size: 56px; margin-bottom: 10px; }

#results-winner {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(241,196,15,0.5);
  margin-bottom: 20px;
}

#results-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.result-score-item {
  text-align: center;
  padding: 12px 16px;
  background: var(--surface2);
  border-radius: 12px;
  border: 1px solid var(--border);
  flex: 1;
}

.result-score-item.winner {
  border-color: var(--accent);
  background: rgba(241,196,15,0.1);
}

.result-team-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.result-swipes {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.result-vs {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 700;
}

/* ============================================================
   CONFIG PANEL
   ============================================================ */
#config-panel {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.7);
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.config-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 360px;
}

.config-card h3 {
  margin-bottom: 16px;
  font-size: 16px;
}

/* ============================================================
   SPECTATOR BADGE
   ============================================================ */
.spectator-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(241,196,15,0.15);
  border: 1px solid rgba(241,196,15,0.4);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  transition: transform 0.3s ease;
  pointer-events: none;
}

#toast.show { transform: translateX(-50%) translateY(0); }
#toast.toast-error { background: #c0392b; color: white; }
#toast.toast-success { background: #27ae60; color: white; }
#toast.toast-info { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

/* ============================================================
   UTILITY
   ============================================================ */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

/* Auth link spacing */
.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Progress bar for race */
.race-progress-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.race-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.race-progress-fill.team1 { background: linear-gradient(90deg, var(--team1), #e74c3c); }
.race-progress-fill.team2 { background: linear-gradient(90deg, var(--team2), #5dade2); }
.race-progress-fill.team3 { background: linear-gradient(90deg, var(--team3), #2ecc71); }

/* Waiting state animation */
.waiting-anim {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 8px 0;
}

.waiting-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: waitBounce 1.2s ease-in-out infinite;
}

.waiting-dot:nth-child(2) { animation-delay: 0.2s; }
.waiting-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes waitBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   ADMIN SECTION
   ============================================================ */
.admin-section {
  background: rgba(231,76,60,0.08);
  border: 1px solid rgba(231,76,60,0.25);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.admin-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #e74c3c;
  margin-bottom: 10px;
}

.admin-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Status banners */
.status-banner {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
}

.status-waiting {
  background: rgba(149,165,166,0.15);
  border: 1px solid rgba(149,165,166,0.3);
  color: var(--text-muted);
}

.status-fixtures {
  background: rgba(39,174,96,0.15);
  border: 1px solid rgba(39,174,96,0.4);
  color: #2ecc71;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }

/* ============================================================
   MALAYALAM SUBTITLE
   ============================================================ */
.malayalam-sub {
  font-family: 'Noto Sans Malayalam', 'Nirmala UI', 'Kartika', sans-serif;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 1px;
  margin-top: 2px;
}

/* ============================================================
   PORTRAIT ORIENTATION TIP (non-blocking banner)
   ============================================================ */
#orient-tip {
  display: none;
  position: fixed;
  bottom: env(safe-area-inset-bottom, 12px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 20, 30, 0.88);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 500;
  z-index: 500;
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 768px) and (orientation: portrait) {
  #view-race.active ~ #orient-tip {
    display: block;
  }
}

/* ============================================================
   COPYRIGHT FOOTER
   ============================================================ */
.copyright-footer {
  position: fixed;
  bottom: 6px;
  right: 12px;
  font-family: 'Noto Sans Malayalam', 'Nirmala UI', 'Kartika', sans-serif;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.28);
  pointer-events: none;
  z-index: 1000;
  letter-spacing: 0.3px;
  user-select: none;
}

/* ============================================================
   Leaderboard */
.lb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  margin-bottom: 8px;
}
.lb-wins-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.lb-win-card {
  text-align: center;
  padding: 6px 4px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  min-width: 0;
}
.lb-win-card.lb-team1 { border-color: rgba(192,57,43,0.5); }
.lb-win-card.lb-team2 { border-color: rgba(41,128,185,0.5); }
.lb-win-card .lb-team-name {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-win-card .lb-wins {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}
.lb-win-card.lb-team1 .lb-wins { color: var(--team1); }
.lb-win-card.lb-team2 .lb-wins { color: var(--team2); }
.lb-win-card .lb-wins-label {
  font-size: 9px;
  color: var(--text-muted);
}
.lb-tie-badge {
  grid-column: 1 / -1;
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}
.lb-race-row {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  gap: 4px;
  align-items: center;
  font-size: 10px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.lb-race-num  { color: var(--text-muted); }
.lb-race-winner { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-race-score  { color: var(--text-muted); white-space: nowrap; }
.lb-race-date   { color: var(--text-muted); font-size: 9px; white-space: nowrap; }
.lb-history-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ============================================================
   Desktop warning overlay */
#desktop-warning {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(10, 30, 50, 0.97);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.desktop-warning-box {
  max-width: 320px;
}
.desktop-warning-box h2 {
  font-size: 22px;
  color: var(--gold);
  margin: 12px 0 8px;
}
.desktop-warning-box p {
  font-size: 14px;
  color: var(--text-muted);
  margin: 4px 0;
}

/* ============================================================
   App-level error */
#app-error {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  background: #922b21;
  color: white;
  text-align: center;
  padding: 12px;
  font-size: 14px;
  z-index: 9999;
}
