/* ===== Design tokens =====
   Palette : nuit urbaine (indigo profond, pas noir pur) + citrouille comme
   unique accent chaud. Typo condensée pour les titres (esprit affiche/
   avis de recherche), sans-serif neutre pour le contenu lisible en
   mouvement, dans la rue, au téléphone.
*/
:root {
  --night: #1a1530;
  --night-deep: #120e24;
  --panel: #241d3f;
  --panel-border: #4a4160;
  --pumpkin: #f2762e;
  --pumpkin-dim: #c4561c;
  --moon: #f4efe1;
  --moon-dim: #cfc8b8;
  --wolf-red: #d64550;
  --success: #7fb069;
  --radius: 14px;
  --font-display: "Oswald", "Arial Narrow", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(ellipse at top, var(--night) 0%, var(--night-deep) 70%);
  color: var(--moon);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* Dans un navigateur mobile, 100vh = hauteur SANS la barre d'adresse : le bas de la
   page passait dessous. 100dvh suit la hauteur réellement visible (100vh reste en
   secours pour les vieux navigateurs). */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Écran joueur : hauteur fixée à l'écran visible, rien ne défile sauf l'intérieur des
   panneaux. Sinon, glisser sur la carte faisait aussi défiler la page. */
body.app-fixed {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 0.4em;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }

p { line-height: 1.5; color: var(--moon-dim); }

a { color: var(--pumpkin); }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.screen--center {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.pumpkin-mark {
  font-size: 3.2rem;
  line-height: 1;
  margin-bottom: 6px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.btn {
  display: block;
  width: 100%;
  padding: 16px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  text-align: center;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  margin-bottom: 12px;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn--primary { background: var(--pumpkin); color: var(--night-deep); }
.btn--wolf { background: var(--wolf-red); color: var(--moon); }
.btn--danger { background: var(--wolf-red); color: var(--moon); }
.btn--ghost {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--moon);
}

input, select {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--night-deep);
  color: var(--moon);
  font-size: 1rem;
  margin-bottom: 12px;
}

.field-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--moon-dim);
  margin-bottom: 6px;
  display: block;
}

/* ---- Top bar (score / timer, présent sur runner & wolf) ---- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top)); /* encoche (iPhone en paysage, etc.) */
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
}

.topbar__stat { text-align: center; }
.topbar__stat .value {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--pumpkin);
}
.topbar__stat .label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--moon-dim);
}
.topbar__stat.wolf .value { color: var(--wolf-red); }

/* ---- Map ---- */
#map {
  flex: 1;
  width: 100%;
  min-height: 200px;
  background: var(--night-deep);
}

.map-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.map-fab {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 420px;
  z-index: 500;
}

/* Boutons sur la carte joueur : retour au nord + orientation boussole */
.map-tools {
  position: absolute; top: 12px; right: 12px; z-index: 500;
  display: flex; flex-direction: column; gap: 10px;
}
.map-tool {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--panel-border); color: var(--moon);
  font-size: 1.3rem; line-height: 1; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.map-tool.is-on { background: var(--pumpkin); border-color: var(--pumpkin); color: var(--night-deep); }
/* La flèche du nord tourne avec la carte pour toujours pointer vers le nord */
#north-btn span { display: flex; flex-direction: column; align-items: center; color: var(--wolf-red); font-size: 1rem; transition: transform 0.1s linear; }
#north-btn small { font-size: 0.65rem; color: var(--moon); font-family: var(--font-display); }

/* ---- Capture / AR screen ---- */
.capture-view {
  position: fixed;
  inset: 0;
  background: black;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.capture-view video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.capture-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pumpkin-sprite {
  position: absolute;
  top: 42%;
  font-size: 4.5rem;
  filter: drop-shadow(0 0 18px rgba(242,118,46,0.7));
  transition: left 0.08s linear, opacity 0.2s ease, transform 0.15s ease;
}

.capture-hint {
  position: absolute;
  bottom: calc(130px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  text-align: center;
  color: var(--moon);
  font-family: var(--font-display);
  font-size: 1.1rem;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

.capture-shutter {
  position: absolute;
  bottom: calc(40px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 5px solid var(--moon);
  background: var(--pumpkin);
}

.capture-shutter:disabled {
  background: transparent;
  border-color: rgba(244,239,225,0.35);
}

.capture-close {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top));
  right: 20px;
  z-index: 1001;
  background: rgba(0,0,0,0.5);
  color: var(--moon);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
}

/* ---- QR ---- */
.qr-box {
  background: var(--moon);
  padding: 18px;
  border-radius: var(--radius);
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

/* ---- Toast / feedback ---- */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--pumpkin);
  padding: 14px 20px;
  border-radius: 10px;
  z-index: 2000;
  font-family: var(--font-display);
  max-width: 90%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.toast--danger { border-color: var(--wolf-red); }

.role-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-display);
}
.role-pill.runner { background: rgba(242,118,46,0.18); color: var(--pumpkin); }
.role-pill.wolf { background: rgba(214,69,80,0.18); color: var(--wolf-red); }

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--panel-border);
}
.list-row:last-child { border-bottom: none; }

.leaflet-popup-content-wrapper { background: var(--panel); color: var(--moon); }
.leaflet-popup-tip { background: var(--panel); }

/* ===== Ajouts v2 (équipes) ===== */

/* Sans cette règle, un `display:flex` posé sur un élément empêche l'attribut
   [hidden] de le cacher (c'était la cause du bug de la fenêtre QR). */
[hidden] { display: none !important; }

/* min-height: 0 : sans ça, un enfant flex refuse de rétrécir et ne défile jamais */
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; max-width: 480px; margin: 0 auto; width: 100%; }

.team-title { font-family: var(--font-display); font-size: 1.6rem; margin: 4px 0 2px; }

.member-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.member-chip {
  padding: 6px 12px; border-radius: 999px; font-size: 0.9rem;
  background: var(--night-deep); border: 1px solid var(--panel-border); color: var(--moon);
}
.member-chip.is-done { border-color: var(--success); color: var(--success); }
.member-chip.is-me { font-weight: 700; }

.team-strip {
  background: var(--panel); border-top: 1px solid var(--panel-border);
  padding: 10px 14px 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom)); /* barre d'accueil iPhone */
}
.team-strip .member-list { margin-top: 6px; }
.team-strip__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--moon-dim); }

.rank-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--panel-border);
}
.rank-row:last-child { border-bottom: none; }
.rank-row .pos { font-family: var(--font-display); font-size: 1.3rem; width: 2ch; color: var(--pumpkin); }
.rank-row .name { flex: 1; }
.rank-row .meta { text-align: right; font-size: 0.85rem; color: var(--moon-dim); }
.rank-row .count { display: block; font-family: var(--font-display); font-size: 1.1rem; color: var(--moon); }
.rank-row.is-mine { background: rgba(242,118,46,0.12); border-radius: 10px; padding-left: 8px; padding-right: 8px; }

.route-line { font-size: 0.82rem; color: var(--moon-dim); margin-top: 4px; }

/* Lobby joueur : liste de toutes les équipes après le tirage */
.lobby-team-row { padding: 12px 0; border-bottom: 1px solid var(--panel-border); }
.lobby-team-row:last-child { border-bottom: none; }
.lobby-team-row strong { font-family: var(--font-display); font-size: 1.1rem; }
.lobby-team-row.is-mine { background: rgba(242,118,46,0.12); border-radius: 10px; padding-left: 8px; padding-right: 8px; }
.warn { color: var(--pumpkin); font-size: 0.85rem; }
.icon-btn {
  background: transparent; border: 1px solid var(--panel-border); color: var(--moon-dim);
  border-radius: 8px; padding: 2px 9px; cursor: pointer; font-size: 0.9rem;
}

.pumpkin-num {
  position: relative; width: 40px; height: 40px; font-size: 36px; line-height: 40px; text-align: center;
}

/* Marqueurs de carte : citrouille du joueur et position GPS (point bleu pulsant) */
.map-pumpkin {
  font-size: 44px; line-height: 52px; text-align: center;
  filter: drop-shadow(0 0 8px rgba(242,118,46,0.8));
}
.map-me {
  border-radius: 50%; background: #3b9cff; border: 3px solid #fff;
  box-shadow: 0 0 0 0 rgba(59,156,255,0.6); animation: me-pulse 2s infinite;
}
@keyframes me-pulse {
  0% { box-shadow: 0 0 0 0 rgba(59,156,255,0.6); }
  70% { box-shadow: 0 0 0 14px rgba(59,156,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(59,156,255,0); }
}
.pumpkin-num b {
  position: absolute; right: -6px; top: -8px; min-width: 18px; height: 18px; line-height: 18px;
  border-radius: 9px; background: var(--night-deep); color: var(--moon); font-size: 11px;
  border: 1px solid var(--pumpkin); font-family: var(--font-body);
}
