/* ─── VARIABLES & RESET ─────────────────────────────────────── */
:root {
  --bg: #0a0f1e;
  --surface: #111827;
  --surface2: #1a2236;
  --border: #1e2d4a;
  --text: #e2e8f0;
  --muted: #64748b;
  --accent: #f97316;
  --accent2: #fb923c;
  --danger: #ef4444;
  --success: #22c55e;
  --info: #3b82f6;

  --c0: #3b82f6;
  --c1: #ef4444;
  --c2: #22c55e;
  --c3: #f97316;
  --c4: #a855f7;
  --c5: #eab308;
  --c6: #14b8a6;
  --c7: #ec4899;

  --radius: 12px;
  --font-body: 'DM Sans', sans-serif;
  --font-display: 'Bebas Neue', sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ─── VIEWS ─────────────────────────────────────────────────── */
.view {
  position: fixed; inset: 0;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  background: var(--bg);
}
.view.active {
  opacity: 1;
  pointer-events: all;
  z-index: 10;
}

/* ─── NAV ────────────────────────────────────────────────────── */
#nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 14px; gap: 10px;
}
#nav.hidden { display: none; }
.nav-brand { font-family: var(--font-display); font-size: 1.3rem; letter-spacing: 0.05em; }
.nav-brand span { color: var(--accent); }
.nav-info { flex: 1; display: flex; gap: 8px; justify-content: center; font-size: 0.8rem; }
#nav-code { background: var(--surface2); padding: 3px 10px; border-radius: 20px; font-weight: 700; letter-spacing: 0.15em; font-size: 0.85rem; }
#nav-team { padding: 3px 10px; border-radius: 20px; font-size: 0.8rem; }
.btn-icon { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 6px; }

/* ─── HOME VIEW ──────────────────────────────────────────────── */
#view-home { overflow: hidden; }

.home-hero {
  height: 55vh; min-height: 280px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 50% 60%, #1a1f3a 0%, var(--bg) 70%);
}
.home-map-bg {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(249,115,22,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(249,115,22,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: gridMove 20s linear infinite;
}
@keyframes gridMove {
  0% { background-position: 0 0; }
  100% { background-position: 40px 40px; }
}
.home-title {
  font-family: var(--font-display);
  font-size: clamp(4rem, 18vw, 7rem);
  line-height: 0.85;
  text-align: center;
  letter-spacing: 0.02em;
  position: relative; z-index: 1;
}
.home-title span { color: var(--accent); }
.home-tagline {
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  position: relative; z-index: 1;
}
.home-actions {
  padding: 24px 20px;
  display: flex; flex-direction: column; gap: 12px;
}

/* ─── BUTTONS ────────────────────────────────────────────────── */
.btn {
  border: none; border-radius: var(--radius);
  font-family: var(--font-body); font-weight: 700;
  cursor: pointer; transition: all 0.15s; outline: none;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-xl { height: 56px; font-size: 1.05rem; border-radius: 14px; }
.btn-full { width: 100%; }
.btn-back {
  background: none; border: none; color: var(--muted);
  font-size: 1.4rem; cursor: pointer; padding: 0; line-height: 1;
}
.counter-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 1.3rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.counter-btn:hover { background: var(--border); }

/* ─── PAGE HEADER ────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px 8px;
}
.page-header h1 { font-family: var(--font-display); font-size: 1.8rem; letter-spacing: 0.05em; }

/* ─── FORM CARD ──────────────────────────────────────────────── */
.form-card { padding: 8px 20px 32px; display: flex; flex-direction: column; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }

input, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 13px 16px;
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--muted); }

.select-styled {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 13px 16px;
  font-size: 1rem;
  width: 100%;
  -webkit-appearance: none;
}

.counter-row {
  display: flex; align-items: center; justify-content: center; gap: 24px;
}
#num-teams-display, #num-stations-display {
  font-family: var(--font-display); font-size: 2.4rem;
  color: var(--accent); min-width: 48px; text-align: center;
}

.team-name-input {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.team-color-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}
.team-name-input input { flex: 1; }

/* ─── LOBBY ──────────────────────────────────────────────────── */
.lobby-header {
  padding: 28px 20px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.lobby-code-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 8px; }
.lobby-code {
  display: inline-flex; align-items: center; gap: 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 24px; cursor: pointer;
  transition: border-color 0.2s;
}
.lobby-code:hover { border-color: var(--accent); }
#lobby-code-text { font-family: var(--font-display); font-size: 2.4rem; letter-spacing: 0.3em; color: var(--accent); }
.copy-hint { font-size: 0.7rem; color: var(--muted); }
.lobby-hint { margin-top: 8px; color: var(--muted); font-size: 0.85rem; }

.lobby-teams { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }

.team-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.team-card-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.team-dot { width: 10px; height: 10px; border-radius: 50%; }
.team-card-name { font-weight: 700; font-size: 1rem; }
.team-card-count { margin-left: auto; color: var(--muted); font-size: 0.8rem; }
.player-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.player-chip {
  background: var(--surface2); border-radius: 20px;
  padding: 4px 12px; font-size: 0.8rem;
}
.player-chip.me { border: 1px solid var(--accent); color: var(--accent); }
.empty-team { color: var(--muted); font-size: 0.8rem; font-style: italic; }

.lobby-controls { padding: 16px 20px 32px; display: flex; flex-direction: column; gap: 12px; }
.lobby-select-label { color: var(--muted); font-size: 0.85rem; margin-bottom: 4px; }
.lobby-wait {
  padding: 24px; text-align: center; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.pulse-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* ─── TEAM GRID (JOIN) ───────────────────────────────────────── */
.team-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-btn {
  background: var(--surface2); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 14px 10px; cursor: pointer;
  font-family: var(--font-body); font-weight: 600; color: var(--text);
  font-size: 0.95rem; text-align: center; transition: all 0.15s;
}
.team-btn.selected {
  background: var(--surface);
  border-width: 3px;
  color: #fff;
  box-shadow: 0 0 0 2px currentColor, inset 0 0 0 1px rgba(255,255,255,0.1);
  transform: scale(1.03);
}
.team-btn:active { transform: scale(0.97); }

/* ─── GAME VIEWS — flex column pour que la carte ne dépasse pas ─ */
#view-chasse,
#view-chasseur {
  display: flex;
  flex-direction: column;
  overflow: hidden; /* pas de scroll global sur ces vues */
}

/* ─── GAME HEADER ────────────────────────────────────────────── */
.game-header {
  height: 52px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.game-header.hunted { background: rgba(239,68,68,0.12); }
.game-header.hunter { background: rgba(59,130,246,0.12); }
.game-title { font-family: var(--font-display); font-size: 1.1rem; letter-spacing: 0.05em; flex-shrink: 0; }

.progress-bar-wrap { flex: 1; display: flex; align-items: center; gap: 8px; }
.progress-bar-track { flex: 1; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--success); border-radius: 3px; transition: width 0.5s; }
#progress-label { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }

.hunter-score { font-size: 0.85rem; color: var(--muted); }

/* ─── TAB BAR ────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0; /* ne rétrécit pas dans le flex parent */
}
.tab {
  flex: 1; padding: 12px 0; background: none; border: none;
  color: var(--muted); cursor: pointer; font-family: var(--font-body);
  font-size: 0.9rem; font-weight: 600; border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }

/* Onglets liste/historique : block normal → scroll naturel */
.tab-content.active {
  display: block;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* scroll fluide iOS */
}

/* Onglet carte : flex pour que la map remplisse exactement */
.tab-content.active.map-tab {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* La carte remplit tout l'espace disponible */
.map-tab { flex: 1; min-height: 0; }
.map { height: 100%; width: 100%; }

/* ─── MAP ────────────────────────────────────────────────────── */
.map { height: 100%; width: 100%; }
.leaflet-container { background: #1a2236 !important; }

/* ─── STATION LIST ───────────────────────────────────────────── */
.station-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }

.station-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.station-card:active { transform: scale(0.98); }
.station-card.validated { border-color: var(--success); background: rgba(34,197,94,0.07); cursor: default; }
.station-card.validated:active { transform: none; }

.station-icon { font-size: 1.4rem; flex-shrink: 0; width: 36px; text-align: center; }
.station-info { flex: 1; min-width: 0; }
.station-name { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-lines { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.line-badge {
  font-size: 0.65rem; font-weight: 800; padding: 1px 6px;
  border-radius: 4px; background: var(--accent); color: #fff;
  font-family: var(--font-display); letter-spacing: 0.05em;
}
.station-status { flex-shrink: 0; text-align: right; }
.status-validated { color: var(--success); font-size: 1.3rem; }
.status-pending { color: var(--muted); font-size: 0.75rem; }
.station-time { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }

/* ─── VALIDATION LOG ─────────────────────────────────────────── */
.val-log { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.val-entry {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.val-entry-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.val-team-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.val-station-name { font-weight: 700; font-size: 0.95rem; }
.val-time { margin-left: auto; font-size: 0.7rem; color: var(--muted); }
.val-photos { display: flex; gap: 6px; }
.val-photo { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; transition: transform 0.15s; }
.val-photo:hover { transform: scale(1.08); border-color: var(--accent); }
.val-empty { text-align: center; color: var(--muted); padding: 48px 0; font-size: 0.9rem; }

/* ─── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--surface); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 600px;
  padding: 24px 20px 36px;
  position: relative;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--surface2); border: none; color: var(--muted);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 0.9rem;
}
.modal-box h2 { font-family: var(--font-display); font-size: 1.5rem; margin-bottom: 4px; }
.modal-sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 20px; }

.photo-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.photo-slot {
  aspect-ratio: 1; border-radius: var(--radius);
  border: 2px dashed var(--border); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; transition: border-color 0.15s; position: relative;
}
.photo-slot:hover { border-color: var(--accent); }
.photo-slot input { display: none; }
.slot-placeholder { color: var(--muted); font-size: 0.85rem; text-align: center; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot.has-photo { border-style: solid; border-color: var(--success); }

/* ─── TOASTS ─────────────────────────────────────────────────── */
#toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 500; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: 90%; max-width: 380px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 18px;
  font-size: 0.9rem; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: toastIn 0.3s ease;
  pointer-events: auto;
  display: flex; align-items: center; gap: 8px;
  max-width: 100%;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: var(--info); }
.toast.exit { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ─── GAMEOVER ───────────────────────────────────────────────── */
.gameover-container {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 20px; text-align: center; gap: 20px;
}
.gameover-title { font-family: var(--font-display); font-size: 3.5rem; color: var(--accent); }
.gameover-score { font-size: 1.6rem; font-weight: 700; }
.gameover-teams { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 400px; }
.gameover-team-row {
  background: var(--surface); border-radius: var(--radius);
  padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border);
}
.gameover-team-name { flex: 1; font-weight: 700; }
.gameover-team-stat { font-size: 0.85rem; color: var(--muted); }

/* ─── MAP LABELS ─────────────────────────────────────────────── */
.map-label {
  background: rgba(15,23,42,0.85) !important;
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 5px !important;
  color: #e2e8f0 !important;
  font-family: 'DM Sans', sans-serif !important;
  font-size: 0.65rem !important;
  font-weight: 600 !important;
  padding: 2px 6px !important;
  white-space: nowrap !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
  pointer-events: none;
}
.map-label::before { display: none !important; }
.map-label-done {
  color: #f97316 !important;
  border-color: rgba(249,115,22,0.4) !important;
}
.map-label-gray {
  color: #94a3b8 !important;
  opacity: 0.85;
}

/* ─── LEAFLET CUSTOMISATION ──────────────────────────────────── */
.pulse-marker {
  background: transparent;
  border: none;
}
.pulse-ring {
  width: 20px; height: 20px; border-radius: 50%;
  position: relative;
}
.pulse-ring::after {
  content: '';
  position: absolute; inset: -6px;
  border-radius: 50%; border: 2px solid;
  border-color: inherit; opacity: 0;
  animation: ripple 1.5s ease-out infinite;
}
@keyframes ripple {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ─── LIGHTBOX ───────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.lightbox.hidden { display: none; }
#lightbox-img {
  max-width: 95vw; max-height: 90vh;
  object-fit: contain; border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
  cursor: default;
}
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.1); border: none;
  color: #fff; width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.1rem; cursor: pointer;
}

/* ─── BARRE PARTAGE POSITION ─────────────────────────────────── */
.loc-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-share-loc {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 20px;
  background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.35);
  color: #f87171; cursor: pointer; font-family: var(--font-body);
  font-size: 0.85rem; font-weight: 600; transition: all 0.2s;
  white-space: nowrap;
}
.btn-share-loc.active {
  background: var(--danger); color: #fff; border-color: var(--danger);
  animation: locPulse 2s ease-in-out infinite;
}
@keyframes locPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}
.loc-status {
  font-size: 0.75rem; color: var(--muted); flex: 1;
}
.loc-warning {
  padding: 8px 16px;
  background: rgba(234,179,8,0.1);
  border-bottom: 1px solid rgba(234,179,8,0.2);
  color: #ca8a04;
  font-size: 0.78rem;
  flex-shrink: 0;
}

/* Marker pulsant "chassé" sur la carte chasseur */
.hunted-marker {
  position: relative;
  width: 18px; height: 18px;
}
.hunted-marker-dot {
  position: absolute; inset: 0;
  background: #ef4444; border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 6px rgba(239,68,68,0.8);
}
.hunted-marker-ring {
  position: absolute; inset: -6px;
  border-radius: 50%; border: 2px solid #ef4444;
  animation: huntedRing 1.8s ease-out infinite;
}
@keyframes huntedRing {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ─── BOUTON FIN FLOTTANT (GM) ───────────────────────────────── */
.btn-end-float {
  position: fixed; bottom: 20px; right: 16px; z-index: 150;
  background: var(--danger); color: #fff;
  border: none; border-radius: 24px;
  padding: 12px 20px; font-size: 0.9rem; font-weight: 700;
  cursor: pointer; font-family: var(--font-body);
  box-shadow: 0 4px 16px rgba(239,68,68,0.5);
  transition: all 0.2s;
}
.btn-end-float:hover { background: #dc2626; transform: scale(1.04); }
.btn-end-float.hidden { display: none !important; }

/* ─── UTILS ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
