/* Piùnaise tient en trois partis pris.
   1. Le laiton de la punaise de bureau est la couleur de la maison. Il remplit
      des aplats entiers, jamais un contour.
   2. Les bonus inversent tout : aplat d'encre, lettres en laiton.
   3. Ce qui se touche est rond comme une tête de punaise, ce qui se lit est
      un bloc à angles droits.
   La police Bricolage Grotesque porte les noms de lieux en largeur étroite. */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url("/vendor/bricolage/bricolage-grotesque-latin-standard-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url("/vendor/bricolage/bricolage-grotesque-latin-ext-standard-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url("/vendor/bricolage/bricolage-grotesque-vietnamese-standard-normal.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

:root {
  --laiton: #f5c400;
  --laiton-pale: #fdeeb0;
  --encre: #151515;
  --blanc: #ffffff;
  --talus: #ecece8;
  --filet: #d6d6cf;
  --gris: #5f5f58;
  /* Couleurs de carte reprises par la légende. Le script les lit ici. */
  --carte-urbain: #dcc9ae;
  --carte-axe: #f3cb70;
  --carte-axe-bord: #c79a3c;
  --carte-frontiere: #6c7785;
  --carte-zone: #177245;
  /* Qualité d'une réponse, de la meilleure à la plus lointaine. */
  --direction: #177245;
  --moyen: #8f6a00;
  --loin: #c8641c;
  --rate: #c2301f;
  /* Couleur du fond sous un élément : la punaise du logo s'en sert pour son
     reflet, et le contour de focus pour rester visible. */
  --surface: var(--blanc);
  --focus: var(--encre);
  --bar: 52px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--talus);
  color: var(--encre);
  font-family: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
}

[hidden] { display: none !important; }

h1, h2, p { margin: 0; }

/* ---- Logo : l'accent du ù est une punaise plantée ---------------------- */

.wordmark { font-weight: 800; font-stretch: 75%; letter-spacing: -0.02em; line-height: 1; white-space: nowrap; }
.wm-u { position: relative; display: inline-block; }
/* La tête se centre sur le u, loin du point du i, et la pointe tombe sur
   son jambage droit, dans le sens d'un accent grave. */
.tack { position: absolute; left: 50%; bottom: 0.62em; width: 0.46em; height: 0.46em; transform: translateX(-36%); overflow: visible; }
.tack path { fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; }
.tack circle { fill: currentColor; }
.tack .shine { fill: var(--surface); }

/* ---- Barre du haut ----------------------------------------------------- */

.topbar {
  --surface: var(--encre);
  --focus: var(--laiton);
  flex: 0 0 var(--bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  background: var(--encre);
  color: var(--blanc);
}

.brand { display: flex; align-items: baseline; gap: 8px; padding-top: 6px; color: var(--laiton); font-size: 27px; text-decoration: none; }
.brand .daily-number { color: var(--blanc); font-size: 14px; font-weight: 500; opacity: 0.7; }

.topnav { display: flex; gap: 8px; min-width: 0; }

.navlink {
  appearance: none;
  max-width: 40vw;
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  color: var(--blanc);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.navlink:hover { background: rgba(255, 255, 255, 0.24); }

main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* ---- Éléments communs ------------------------------------------------- */

.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; align-items: stretch; }
.row > input { flex: 1 1 auto; min-width: 0; }
.row.two > .stack { flex: 1 1 0; min-width: 0; }

label { font-size: 14px; font-weight: 700; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }

input[type="text"], input[type="email"], select {
  width: 100%;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--talus);
  color: var(--encre);
  font: inherit;
}
input::placeholder { color: var(--gris); }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.primary { background: var(--encre); color: var(--blanc); }
.btn.primary:hover:not(:disabled) { background: #000; }
/* Bouton secondaire : un voile d'encre, lisible sur blanc comme sur laiton. */
.btn.outline { background: rgba(21, 21, 21, 0.09); color: var(--encre); }
.btn.outline:hover { background: rgba(21, 21, 21, 0.17); }
.btn.ghost { padding-inline: 6px; background: none; color: var(--gris); text-decoration: underline; text-underline-offset: 3px; }

.note { font-size: 14px; color: var(--gris); }
.version { margin-top: 22px; font-size: 13px; color: var(--gris); font-variant-numeric: tabular-nums; }
.version:empty { display: none; }

/* ---- Accueil : un aplat de laiton, le nom en très grand ---------------- */

.welcome { flex: 1; overflow-y: auto; background: var(--blanc); }
.welcome-hero { --surface: var(--laiton); padding: 44px 20px 26px; background: var(--laiton); }
.welcome-hero .wordmark { font-size: clamp(64px, 19vw, 150px); }
.welcome h1 { max-width: 20ch; margin-top: 18px; text-wrap: balance; font-size: clamp(26px, 5.6vw, 40px); font-weight: 700; font-stretch: 75%; line-height: 1.05; }
.welcome-body { max-width: 540px; padding: 26px 20px 40px; display: flex; flex-direction: column; gap: 22px; }
/* Les règles : une phrase d'accroche, puis un paragraphe par idée. */
.rules { display: flex; flex-direction: column; gap: 12px; font-size: 16px; line-height: 1.45; }
.lead { font-size: 20px; font-weight: 700; line-height: 1.25; }
.welcome .btn.outline { align-self: flex-start; }

/* ---- Connexion par un fournisseur ------------------------------------- */

.signin { display: flex; flex-direction: column; gap: 8px; }
/* Une seule phrase au-dessus des boutons : les boutons disent déjà le reste. */
.signin-lead { font-size: 17px; font-weight: 700; line-height: 1.3; text-wrap: balance; }
.providers { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; max-width: 360px; }
/* Bouton blanc, filet gris et logo en couleurs : la forme que Google et
   Apple demandent pour leurs boutons, reprise pour tous par cohérence. */
.btn.provider {
  gap: 12px;
  min-height: 48px;
  padding: 10px 20px;
  border: 1px solid #747775;
  background: var(--blanc);
  color: var(--encre);
  font-weight: 600;
  text-decoration: none;
}
.btn.provider:hover { background: var(--talus); }
.provider-logo { flex: none; width: 20px; height: 20px; }

/* "ou joue sans compte", entre deux filets. */
.or { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; color: var(--gris); }
.or::before, .or::after { content: ""; flex: 1; height: 1.5px; background: var(--filet); }

/* État du pseudo pendant la saisie : libre en vert, pris en rouge. */
.pseudo-state { font-size: 14px; font-weight: 600; }
.pseudo-state:empty { display: none; }
.pseudo-state.free { color: var(--direction); }
.pseudo-state.taken { color: var(--rate); }
.sheet .signin { margin-top: 18px; padding-top: 16px; border-top: 1.5px solid var(--filet); }
.dev { padding-top: 18px; border-top: 1.5px dashed var(--filet); }

@media (min-width: 900px) {
  .welcome { display: grid; grid-template-columns: 1.15fr 1fr; overflow: hidden; }
  .welcome-hero { display: flex; flex-direction: column; justify-content: flex-end; padding: 6vh 5vw; }
  .welcome-body { align-self: center; padding: 6vh 5vw; overflow-y: auto; max-height: 100%; }
}

/* ---- Partie ----------------------------------------------------------- */

.game { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Progression : une tête de punaise par lieu, en laiton pour les bonus. */
.lane { --focus: var(--laiton); flex: 0 0 auto; display: flex; align-items: center; gap: 14px; padding: 2px 14px 12px; background: var(--encre); color: var(--blanc); }
.dashes { flex: 1; list-style: none; display: flex; align-items: center; gap: 7px; margin: 0; padding: 0; }
.dashes li { flex: none; width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.26); }
.dashes li.bonus { background: rgba(245, 196, 0, 0.42); }
.dashes li.first-bonus { margin-left: 8px; }
.dashes li.now { background: var(--blanc); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28); }
.dashes li.bonus.now { background: var(--laiton); box-shadow: 0 0 0 3px rgba(245, 196, 0, 0.32); }
.dashes li.s4 { background: #3fbf7f; }
.dashes li.s3 { background: #e3c04a; }
.dashes li.s2 { background: #f0914a; }
.dashes li.s1 { background: #f0616c; }
.running { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Le lieu à trouver : un aplat de laiton sur toute la largeur, le nom en
   lettres étroites. En bonus l'aplat passe à l'encre. */
.sign {
  --surface: var(--laiton);
  flex: 0 0 auto;
  padding: 12px 16px 12px;
  background: var(--laiton);
  color: var(--encre);
}
.sign.bonus { --surface: var(--encre); --focus: var(--laiton); background: var(--encre); color: var(--laiton); }
/* Quand le compteur ne tient pas à côté du type de lieu (bonus sur téléphone),
   il passe sur la ligne du dessus : le type reste collé au nom. */
.sign-meta { display: flex; flex-wrap: wrap-reverse; justify-content: space-between; align-items: center; gap: 6px 12px; font-size: 14px; font-weight: 600; }
#category { flex: none; padding: 3px 13px; border-radius: 999px; background: var(--encre); color: var(--laiton); font-size: 15px; font-weight: 700; }.sign.bonus #category { background: var(--laiton); color: var(--encre); }
.place { margin-top: 6px; font-size: clamp(38px, 6.4vw, 64px); font-weight: 800; font-stretch: 75%; line-height: 0.95; letter-spacing: -0.015em; overflow-wrap: anywhere; text-wrap: balance; }
.place-sub { margin-top: 3px; font-size: 19px; font-weight: 600; }
.place-hint { margin-top: 6px; font-size: 15px; }
/* Texte sur le lieu, après la réponse : une colonne étroite, facile à lire. */
.place-info { max-width: 64ch; margin-top: 8px; font-size: 15px; line-height: 1.38; }
.place-info a { color: inherit; font-weight: 700; text-underline-offset: 3px; white-space: nowrap; }
.sign.bonus .place-sub, .sign.bonus .place-hint, .sign.bonus .place-info, .sign.bonus .sign-meta { color: var(--blanc); }

/* Jauge de vitesse : pleine au départ, vide quand le score atteint son plancher. */
.speed { height: 5px; margin-top: 12px; border-radius: 999px; background: rgba(21, 21, 21, 0.16); overflow: hidden; }
.speed i { display: block; width: 100%; height: 100%; border-radius: 999px; background: var(--encre); transition: width 250ms linear; }
.sign.bonus .speed { background: rgba(255, 255, 255, 0.2); }
.sign.bonus .speed i { background: var(--laiton); }
.speed-label { margin-top: 4px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.speed-label.late { font-weight: 800; }
.sign.bonus .speed-label { color: var(--blanc); }

.map-wrap { flex: 1 1 auto; min-height: 220px; position: relative; }
.map { position: absolute; inset: 0; background: #a9cfe8; }
.maplibregl-map { font: inherit; }
.maplibregl-canvas-container.maplibregl-interactive { cursor: crosshair; }
.maplibregl-canvas-container.maplibregl-interactive:active { cursor: grabbing; }

/* Légende de la carte : trois signes, plus la zone du score plein une fois
   la réponse validée. Elle laisse passer les clics vers la carte. */
.legend {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 64px);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0;
  padding: 6px 12px;
  list-style: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 600;
  color: var(--encre);
  pointer-events: none;
}
.legend li { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend i { display: block; width: 22px; }
.legend .lg-border i { height: 0; border-top: 2px solid var(--carte-frontiere); }
.legend .lg-axis i { height: 5px; background: var(--carte-axe); box-shadow: 0 -1.5px 0 var(--carte-axe-bord), 0 1.5px 0 var(--carte-axe-bord); }
.legend .lg-urban i { width: 14px; height: 12px; background: var(--carte-urbain); border: 1px solid #c8b89f; }
.legend .lg-zone i { width: 13px; height: 13px; border: 1.5px solid var(--carte-zone); border-radius: 50%; background: rgba(23, 114, 69, 0.16); }
.legend .lg-zone { display: none; }
.legend.with-zone .lg-zone { display: flex; }
.legend.no-borders .lg-border { display: none; }

.actionbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--blanc);
}
.status { min-width: 0; font-size: 15px; }
.status b { font-size: 30px; font-weight: 800; font-stretch: 75%; line-height: 1; font-variant-numeric: tabular-nums; }
.status .s4 { color: var(--direction); }
.status .s3 { color: var(--moyen); }
.status .s2 { color: var(--loin); }
.status .s1 { color: var(--rate); }
.actionbar .btn { min-width: 136px; padding: 14px 24px; font-size: 17px; }

/* Punaises sur la carte. La boîte fait 32 px de haut : la pointe du carré
   tourné de 45° tombe sur son bord bas, qui sert de point d'ancrage.
   En cours de pose la punaise est en laiton, une fois validée elle passe à
   l'encre, et le lieu cherché est vert. */
.pin-icon { width: 26px; height: 32px; }
.pin-icon.static { pointer-events: none; }
.pin-icon.draggable { cursor: grab; }
.pin-shape {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--encre);
  border: 2px solid var(--blanc);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
}
.pin-shape span { transform: rotate(45deg); color: var(--laiton); font-size: 12px; font-weight: 800; line-height: 1; }
.pin-shape.target { background: var(--direction); }
.pin-shape.target span { color: var(--blanc); }
.pin-shape.draft { background: var(--laiton); border: 2.5px solid var(--encre); }

/* ---- Fin de partie ---------------------------------------------------- */

.game.finished { overflow-y: auto; display: block; background: var(--blanc); }
.game.finished .map-wrap { height: 44dvh; min-height: 260px; }
.game.finished .sign, .game.finished .actionbar { display: none; }

.hero { --surface: var(--laiton); padding: 22px 16px 20px; background: var(--laiton); }
.hero-label { font-weight: 600; }
.hero-score { font-size: clamp(92px, 24vw, 168px); font-weight: 800; font-stretch: 75%; line-height: 0.86; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.hero-max { margin-left: 6px; font-size: 0.22em; font-weight: 600; letter-spacing: 0; }
.hero-meta { margin-top: 8px; font-weight: 600; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 10px; }
.hero .note, .hero .btn.ghost { color: var(--encre); }

/* Le récapitulatif : le lieu à gauche, les kilomètres à droite. Les bonus
   gardent leur aplat d'encre. */
.recap {
  list-style: none;
  max-width: 760px;
  margin: 6px 0 28px;
  padding: 0;
  background: var(--blanc);
  color: var(--encre);
}
.recap li {
  display: grid;
  grid-template-columns: 1fr auto 58px;
  align-items: baseline;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
}
.recap li + li { border-top: 1px solid var(--filet); }
.recap li:hover { background: var(--talus); }
.recap li.bonus { background: var(--encre); color: var(--laiton); border-top-color: rgba(255, 255, 255, 0.18); }
.recap li.bonus:hover { background: #000; }
.recap .t { min-width: 0; }
.recap .t b { display: block; font-size: 22px; font-weight: 800; font-stretch: 75%; line-height: 1.1; overflow-wrap: anywhere; }
.recap .t small { font-size: 14px; opacity: 0.9; }
.recap li.bonus .t small, .recap li.bonus .d, .recap li.bonus .pts { color: var(--blanc); }
.recap .d { font-size: 18px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.recap .pts { font-size: 15px; font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; opacity: 0.92; }

@media (min-width: 760px) {
  .hero { padding-left: 8vw; }
  .recap { margin-left: calc(8vw - 16px); }
}

/* ---- Fenêtres --------------------------------------------------------- */

.sheet {
  width: min(600px, calc(100vw - 20px));
  max-height: min(86dvh, 760px);
  padding: 20px;
  border: 0;
  border-radius: 22px;
  background: var(--blanc);
  color: var(--encre);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}
/* Fenêtre de suivi : des tableaux larges, donc toute la place disponible. */
.sheet.wide { width: min(1180px, calc(100vw - 20px)); max-height: 92dvh; }
.track-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.track-filter > * { flex: 1 1 160px; width: auto; }
.track-filter .btn { flex: 0 0 auto; }
.sheet.wide .board td { padding-block: 7px; font-size: 14px; }
/* Dernière colonne du journal : les détails passent à la ligne. */
.sheet.wide .board td.left:last-child { white-space: normal; min-width: 240px; color: var(--gris); }
.sheet::backdrop { background: rgba(21, 21, 21, 0.62); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet h2 { font-size: 34px; font-weight: 800; font-stretch: 75%; line-height: 1; }
.icon-btn { appearance: none; width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--talus); font-size: 26px; line-height: 1; color: var(--encre); cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--filet); }
.account-links { margin-top: 18px; align-items: flex-start; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab {
  appearance: none;
  padding: 8px 15px;
  border: 0;
  border-radius: 999px;
  background: var(--talus);
  color: var(--encre);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--laiton); }

.board { overflow-x: auto; }
.board table { width: 100%; border-collapse: collapse; font-size: 15px; }
.board th { text-align: right; padding: 6px 8px; color: var(--gris); font-size: 13px; font-weight: 600; white-space: nowrap; }
.board th.left, .board td.left { text-align: left; }
.board td { text-align: right; padding: 10px 8px; border-top: 1px solid var(--filet); font-variant-numeric: tabular-nums; white-space: nowrap; }
.board td.who { max-width: 200px; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.board td.main { font-weight: 800; }
.board tr.me td { background: var(--laiton-pale); }
.board .guest { margin-left: 6px; color: var(--gris); font-size: 12px; font-weight: 500; }
.board .empty { padding: 24px 8px; color: var(--gris); }
.board .note { margin-top: 10px; }

.toast {
  position: fixed;
  left: 14px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 28px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--encre);
  color: var(--blanc);
  font-size: 15px;
  z-index: 2000;
}

/* ---- Admin ------------------------------------------------------------ */

.admin { flex: 1; min-height: 0; display: flex; background: var(--blanc); }
.admin-map { flex: 1 1 55%; position: relative; min-height: 300px; }
.admin-side { flex: 1 1 45%; max-width: 480px; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.admin h2 { font-size: 28px; font-weight: 800; font-stretch: 75%; line-height: 1.05; }
.pin-list { list-style: none; margin: 0; padding: 0; }
.pin-list li { padding: 12px 0; border-top: 1px solid var(--filet); }
.pin-list li.off { opacity: 0.55; }
.pin-list b { display: block; font-weight: 800; overflow-wrap: anywhere; }
.pin-list .meta { font-size: 14px; color: var(--gris); }
.pin-list .row { margin-top: 8px; }
.pin-list .btn { padding: 6px 14px; font-size: 14px; }

@media (max-width: 760px) {
  .admin { flex-direction: column; overflow-y: auto; }
  .admin-map { flex: 0 0 46dvh; }
  .admin-side { max-width: none; overflow: visible; }
  .brand { font-size: 24px; }
  .navlink { padding: 6px 11px; font-size: 14px; }
  .actionbar .btn { min-width: 118px; }
}

@media (prefers-reduced-motion: reduce) {
  .speed i { transition: none; }
}
