/* Entre deux lacs — thème nuit & or (kintsugi) */
:root {
  --bg: #0b1020;
  --bg-2: #10172b;
  --surface: #151d33;
  --surface-2: #1b2540;
  --line: rgba(233, 214, 160, 0.16);
  --line-strong: rgba(233, 214, 160, 0.32);
  --ink: #ece7dc;
  --ink-soft: #c9c4b8;
  --muted: #8e97ad;
  --gold: #d9b35a;
  --gold-bright: #f3d684;
  --gold-deep: #a97b2c;
  --lake: #5f8fb8;
  --ok: #7fc8a0;
  --danger: #e48a7a;
  --radius: 18px;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --nav-h: 68px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(95, 143, 184, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(217, 179, 90, 0.07), transparent 60%);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-bright); }
button, input, textarea, select { font: inherit; color: inherit; }
img, audio, video { max-width: 100%; }
[hidden] { display: none !important; }

/* Étoiles discrètes */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .55; }

.app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 0 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }

/* En-tête */
.top { padding: calc(18px + env(safe-area-inset-top)) 0 8px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 28px; line-height: 1; letter-spacing: .01em; }
.brand small { display: block; font-family: var(--sans); font-size: 11px; font-weight: 500; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); margin-top: 8px; }
.daybadge { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.daybadge b { display: block; font-family: var(--serif); font-size: 26px; color: var(--gold-bright); font-weight: 600; line-height: 1; }
.seam { height: 1px; margin: 10px 0 18px; background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold-bright) 50%, var(--gold) 80%, transparent); opacity: .5; }

.preview-banner { position: sticky; top: 0; z-index: 30; margin: 0 -16px; padding: 8px 16px; background: #3b2b0e; color: var(--gold-bright); font-size: 13px; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--gold-deep); }
.preview-banner a { color: inherit; }

/* Cartes */
.card { background: linear-gradient(180deg, var(--surface), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.card.done { border-color: rgba(217,179,90,.4); }
.eyebrow { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.eyebrow .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); }
.eyebrow .muted { color: var(--muted); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; }
h2 { font-size: 30px; margin: 6px 0 12px; }
h3 { font-size: 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.letter { font-family: var(--serif); font-size: 20px; line-height: 1.5; color: var(--ink-soft); white-space: pre-line; font-style: italic; }
.letter .sign { display: block; text-align: right; margin-top: 10px; color: var(--gold); font-style: normal; font-size: 18px; }
.clue { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: rgba(217,179,90,.07); border: 1px dashed var(--line-strong); white-space: pre-line; }
.clue-label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); font-weight: 600; margin-bottom: 6px; display: block; }
.media { margin-top: 14px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.media img { display: block; width: 100%; }
.media audio { display: block; width: 100%; }
.place-pill { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 6px 12px; border-radius: 999px; background: rgba(95,143,184,.14); color: #b9d3ea; font-size: 13px; border: 1px solid rgba(95,143,184,.3); cursor: pointer; }

/* Saisie de code */
.codeform { margin-top: 18px; display: flex; gap: 8px; }
.codeform input { flex: 1; min-width: 0; height: 52px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line-strong); background: rgba(0,0,0,.25); font-size: 18px; letter-spacing: .12em; text-transform: uppercase; outline: none; }
.codeform input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217,179,90,.18); }
.codeform input::placeholder { letter-spacing: .04em; text-transform: none; color: var(--muted); }
.btn { height: 52px; padding: 0 18px; border-radius: 14px; border: 0; background: linear-gradient(180deg, var(--gold-bright), var(--gold)); color: #241a06; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; }
.btn.ghost { background: transparent; border: 1px solid var(--line-strong); color: var(--ink); font-weight: 500; height: 44px; }
.btn.small { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.formmsg { min-height: 22px; margin-top: 8px; font-size: 14px; color: var(--danger); }
.formmsg.ok { color: var(--ok); }
.codehint { font-size: 13px; color: var(--muted); margin-top: 10px; }
.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }

.success { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: rgba(127,200,160,.08); border: 1px solid rgba(127,200,160,.3); }
.success .reward { margin-top: 8px; color: var(--gold-bright); font-weight: 600; }
.validated-tag { color: var(--ok); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

.hints { margin-top: 16px; }
.hint { padding: 12px 14px; border-left: 2px solid var(--gold); background: rgba(255,255,255,.03); border-radius: 0 10px 10px 0; margin-bottom: 8px; font-size: 15px; }
.hint img { border-radius: 8px; margin-top: 8px; }
.hintask { margin-top: 12px; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }

/* Compte à rebours */
.countdown { display: flex; gap: 10px; justify-content: center; margin: 18px 0 6px; }
.countdown div { min-width: 64px; text-align: center; padding: 10px 6px; border-radius: 12px; background: rgba(0,0,0,.25); border: 1px solid var(--line); }
.countdown b { display: block; font-family: var(--serif); font-size: 32px; color: var(--gold-bright); line-height: 1.1; font-weight: 600; }
.countdown span { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.next { text-align: center; color: var(--muted); font-size: 14px; margin: 24px 0 8px; }
.next b { color: var(--ink); font-weight: 600; }

.hero { text-align: center; padding: 36px 8px 12px; }
.hero h1 { font-size: 46px; }
.hero .sub { margin-top: 10px; color: var(--gold); letter-spacing: .22em; text-transform: uppercase; font-size: 12px; }

/* Final */
.timeline { position: relative; margin-left: 8px; padding-left: 24px; border-left: 1px solid var(--line-strong); }
.timeline .tnode { position: relative; }
.timeline .tnode::before { content: ""; position: absolute; left: -31px; top: 24px; width: 13px; height: 13px; border-radius: 50%; background: var(--bg); border: 2px solid var(--muted); }
.timeline .tnode.done::before { background: var(--gold); border-color: var(--gold-bright); box-shadow: 0 0 12px var(--gold); }
.timeline .tnode.current::before { border-color: var(--gold-bright); animation: pulse 2s infinite; }
.timeline .locked { padding: 16px 20px; margin-bottom: 16px; border-radius: var(--radius); border: 1px dashed var(--line); color: var(--muted); font-family: var(--serif); font-size: 20px; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(243,214,132,.5); } 50% { box-shadow: 0 0 0 8px rgba(243,214,132,0); } }

/* Inventaire */
.shards-wrap { display: grid; place-items: center; padding: 6px 0 2px; }
.shards { width: 100%; max-width: 340px; height: auto; overflow: visible; }
.shard-missing { fill: rgba(255,255,255,.025); stroke: rgba(201,196,184,.28); stroke-width: .8; stroke-dasharray: 2.5 2.5; }
.shard-found { fill: none; stroke-width: 1.7; stroke-linejoin: round; }
.shard-new { animation: glow 2.2s ease-out 1; }
@keyframes glow { 0% { stroke-width: 6; opacity: .2; } 100% { stroke-width: 1.7; opacity: 1; } }
.shard-num { fill: var(--muted); font-size: 9px; text-anchor: middle; dominant-baseline: central; font-family: var(--sans); opacity: .7; }
.progressline { text-align: center; font-family: var(--serif); font-size: 22px; margin-top: 8px; }
.progressline b { color: var(--gold-bright); }

.lock { display: flex; justify-content: center; gap: 8px; margin: 14px 0 6px; }
.lock .digit { width: 52px; height: 64px; border-radius: 12px; display: grid; place-items: center; font-family: var(--serif); font-size: 34px; font-weight: 600; background: rgba(0,0,0,.3); border: 1px solid var(--line-strong); color: var(--gold-bright); }
.lock .digit.empty { color: var(--muted); border-style: dashed; font-size: 26px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .ico { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: rgba(217,179,90,.1); color: var(--gold-bright); font-family: var(--serif); font-weight: 700; }
.list .ico.empty { background: rgba(255,255,255,.04); color: var(--muted); }
.list .grow { flex: 1; min-width: 0; }
.list .val { font-family: var(--serif); font-size: 22px; color: var(--gold-bright); font-weight: 600; }

/* Journal */
details.entry { border-top: 1px solid var(--line); padding: 4px 0; }
details.entry:first-of-type { border-top: 0; }
details.entry summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; }
details.entry summary::-webkit-details-marker { display: none; }
details.entry summary .t { font-family: var(--serif); font-size: 20px; font-weight: 600; }
details.entry summary .d { font-size: 12px; color: var(--muted); }
details.entry .body { padding-bottom: 14px; }
details.entry .letter { font-size: 18px; }

/* Carte */
.mapwrap { margin: 0 -16px; position: relative; }
#map { height: calc(100dvh - 190px - var(--nav-h)); min-height: 360px; background: #0a0f1c; }
.regions { display: flex; gap: 8px; margin-bottom: 12px; }
.regions button { flex: 1; height: 40px; border-radius: 12px; border: 1px solid var(--line-strong); background: transparent; cursor: pointer; }
.regions button.on { background: rgba(217,179,90,.14); border-color: var(--gold); color: var(--gold-bright); }
.leaflet-container { font-family: var(--sans); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong); }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-popup-content b { font-family: var(--serif); font-size: 18px; }
.leaflet-control-attribution { background: rgba(11,16,32,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--ink-soft) !important; }
.leaflet-bar a { background: var(--surface-2) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.pin { width: 22px; height: 22px; transform: rotate(45deg); border-radius: 4px; background: linear-gradient(135deg, var(--gold-bright), var(--gold-deep)); border: 2px solid #fff3cf; box-shadow: 0 0 14px rgba(243,214,132,.8); }
.pin.todo { background: var(--surface-2); border-color: var(--gold); box-shadow: 0 0 12px rgba(217,179,90,.5); }
.dotpin { width: 14px; height: 14px; border-radius: 50%; background: var(--lake); border: 2px solid #d6e6f5; box-shadow: 0 0 10px rgba(95,143,184,.9); }
.mapempty { position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 500; padding: 12px 14px; border-radius: 12px; background: rgba(11,16,32,.85); border: 1px solid var(--line); font-size: 14px; color: var(--ink-soft); text-align: center; }

/* Navigation */
.nav { position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0; padding: 0 12px env(safe-area-inset-bottom); background: rgba(11,16,32,.88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.nav ul { max-width: 560px; margin: 0 auto; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); height: var(--nav-h); }
.nav button { width: 100%; height: 100%; background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; letter-spacing: .04em; cursor: pointer; position: relative; }
.nav button svg { width: 24px; height: 24px; }
.nav button.on { color: var(--gold-bright); }
.nav button .badge { position: absolute; top: 10px; right: calc(50% - 22px); width: 8px; height: 8px; border-radius: 50%; background: var(--gold-bright); box-shadow: 0 0 8px var(--gold); }

/* Révélation (succès) */
.reveal { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 40%, rgba(60,44,12,.92), rgba(5,8,16,.97) 70%); animation: fadein .4s; }
.reveal .inner { max-width: 420px; text-align: center; }
.reveal svg.crack { width: 160px; height: 160px; }
.reveal svg.crack path { fill: none; stroke: var(--gold-bright); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 400; stroke-dashoffset: 400; animation: draw 1.6s ease-out forwards; filter: drop-shadow(0 0 6px var(--gold)); }
.reveal h2 { font-size: 36px; margin-top: 10px; }
.reveal p { color: var(--ink-soft); font-family: var(--serif); font-size: 20px; font-style: italic; white-space: pre-line; }
.reveal .gift { margin: 16px 0 22px; padding: 14px; border-radius: 14px; border: 1px solid var(--gold); color: var(--gold-bright); font-weight: 600; background: rgba(217,179,90,.08); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadein { from { opacity: 0; } }

/* Porte d'entrée */
.gate { min-height: 80dvh; display: grid; place-items: center; text-align: center; }
.gate form { margin-top: 20px; }

.loading { min-height: 60dvh; display: grid; place-items: center; color: var(--muted); font-family: var(--serif); font-size: 22px; font-style: italic; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal svg.crack path { stroke-dashoffset: 0; }
}
/* Fond OpenStreetMap assombri pour le thème nuit */
.leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(.9) contrast(.88) saturate(.55); }

/* Galerie de photos (ex. gros plans) */
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.gallery figure { margin: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: rgba(0,0,0,.25); }
.gallery img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.gallery figcaption { padding: 6px 10px; font-size: 12px; color: var(--muted); text-align: center; }

/* Mini-carte dans une étape */
.minimap-wrap { margin-top: 14px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.minimap { height: 220px; background: #0a0f1c; }
.minimap-label { padding: 8px 12px; font-size: 13px; color: #b9d3ea; background: rgba(95,143,184,.1); }
