:root {
  --ink: #1b0a24;
  --plum: #32123f;
  --pink: #ff3d86;
  --orange: #ff9a3c;
  --sun: #ffd23a;
  --cream: #fff3d6;
  --cash: #7ddc5f;
  --danger: #ff4438;
  --display: "Avenir Next Condensed", "Roboto Condensed", "sans-serif-condensed", "Arial Narrow", Impact, sans-serif;
  --text: "Avenir Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --edge: 4px solid var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; background: var(--ink); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; overflow-x: clip; min-height: 100%; color: var(--cream); font: 500 16px/1.4 var(--text);
  background:
    radial-gradient(circle at 5px 5px, rgb(27 10 36 / .35) 2.2px, transparent 2.6px) 0 0 / 12px 12px,
    linear-gradient(180deg, #43186a 0%, #a3246f 46%, #f2643f 78%, #ffb14a 100%) fixed;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 460px; min-height: 100vh; min-height: 100dvh; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 16px calc(16px + env(safe-area-inset-bottom));
}
.screen { display: none; flex: 1; flex-direction: column; gap: 16px; }
body[data-screen="auth"] [data-name="auth"],
body[data-screen="lobby"] [data-name="lobby"],
body[data-screen="wall"] [data-name="wall"],
body[data-screen="hunt"] [data-name="hunt"],
body[data-screen="reveal"] [data-name="reveal"],
body[data-screen="result"] [data-name="result"] { display: flex; }

h1, h2, p, figure { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }

/* ----- Bandeau ----- */
.hud { display: flex; gap: 12px; justify-content: space-between; align-items: center; padding: 12px 0; font-family: var(--display); }
.hud-player { font-weight: 800; font-size: 20px; text-transform: uppercase; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; }
.hud-score { color: var(--cash); display: flex; align-items: baseline; gap: 5px; }
.hud-score strong, .hud-score span, .timer, .readout b, .range-value, .banner, .result-points {
  paint-order: stroke fill; -webkit-text-stroke: 7px var(--ink);
}
.hud-score strong { font-size: 38px; line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; }
.hud-score span { font-size: 18px; font-weight: 800; -webkit-text-stroke-width: 5px; }
.hud-score.negative { color: var(--danger); }
.hud-score.bump strong { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.25); } }

/* ----- Affiche et logo ----- */
.poster { margin: 0 -16px; border-bottom: 6px solid var(--ink); height: min(44vh, 360px); overflow: hidden; }
.poster.small { height: clamp(130px, 24vh, 210px); margin-top: 0; border-top: 6px solid var(--ink); }
.poster svg { display: block; width: 100%; height: 100%; }
.logo { margin: -92px auto -4px; width: min(84%, 330px); position: relative; z-index: 1; }
.logo svg { display: block; width: 100%; overflow: visible; }
.logo-type { font: 900 108px var(--display); }
.logo-out { stroke: var(--cream); fill: var(--cream); stroke-width: 26; stroke-linejoin: round; }
.logo-ink { stroke: var(--ink); fill: var(--ink); stroke-width: 15; stroke-linejoin: round; }

/* ----- Panneaux et formulaires ----- */
.panel { background: var(--cream); color: var(--ink); border: var(--edge); border-radius: 6px; padding: 18px; box-shadow: 7px 7px 0 var(--ink); display: flex; flex-direction: column; gap: 14px; }
.panel h2 { font: 800 20px/1 var(--display); text-transform: uppercase; letter-spacing: .04em; }
.panel label { display: grid; gap: 5px; font-weight: 700; }
.panel input:not([type="range"]) { background: #fff; border: 3px solid var(--ink); border-radius: 4px; padding: 11px 12px; font-size: 18px; font-weight: 600; width: 100%; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; border: 3px solid var(--ink); border-radius: 4px; overflow: hidden; }
.tabs button { border: 0; background: none; padding: 10px; font: 800 18px/1.1 var(--display); text-transform: uppercase; cursor: pointer; min-height: 44px; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--sun); }
.error { color: #fff; background: #b3122b; border: 3px solid var(--ink); border-radius: 4px; padding: 8px 12px; font-weight: 700; }
.error:empty { display: none; }

.btn {
  border: var(--edge); border-radius: 6px; background: var(--sun); color: var(--ink); cursor: pointer;
  font: 900 24px/1 var(--display); text-transform: uppercase; letter-spacing: .03em;
  padding: 15px 20px; min-height: 56px; box-shadow: 5px 5px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.btn:hover { background: #ffe06e; }
.btn:active { transform: translate(5px, 5px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.big { font-size: 34px; padding: 19px; }
.btn.alt { background: var(--pink); color: #fff; font-size: 20px; min-height: 48px; padding: 11px; }
.link { background: none; border: 0; text-decoration: underline; text-underline-offset: 4px; font-weight: 700; padding: 10px; min-height: 44px; cursor: pointer; align-self: center; color: var(--ink); }
[data-name="hunt"] .link, [data-name="lobby"] .link { margin-top: auto; }
.hint { font-size: 15px; }
.hint.center { text-align: center; text-wrap: balance; color: #fff; text-shadow: 0 1px 2px rgb(27 10 36 / .7); font-weight: 600; }
.hint.big { font-size: 19px; }

/* ----- Distance ----- */
.range-value { font: 900 64px/1 var(--display); color: var(--pink); font-variant-numeric: tabular-nums; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: none; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 16px; border: 3px solid var(--ink); border-radius: 8px; background: linear-gradient(90deg, var(--sun), var(--pink)); }
input[type="range"]::-moz-range-track { height: 10px; border: 3px solid var(--ink); border-radius: 8px; background: linear-gradient(90deg, var(--sun), var(--pink)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 38px; height: 38px; margin-top: -14px; border: var(--edge); border-radius: 50%; background: #fff; }
input[type="range"]::-moz-range-thumb { width: 30px; height: 30px; border: var(--edge); border-radius: 50%; background: #fff; }
.chips { display: flex; gap: 6px; }
.chips button { flex: 1; min-height: 44px; padding: 0 2px; border: 3px solid var(--ink); border-radius: 4px; background: #fff; font: 800 16px/1 var(--display); cursor: pointer; white-space: nowrap; }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--sun); }

/* ----- Chasse ----- */
.timer { text-align: center; font: 900 72px/1 var(--display); color: #fff; font-variant-numeric: tabular-nums; -webkit-text-stroke-width: 9px; }
.timer.hot { color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.radar { position: relative; width: min(100%, 46vh, 380px); min-width: 230px; aspect-ratio: 1; margin: 0 auto; border-radius: 50%; border: 7px solid var(--ink); overflow: hidden; background: radial-gradient(circle, #2f7d55, #0d3a2e 72%); box-shadow: 0 0 0 5px var(--sun), 0 0 0 10px var(--ink); margin-block: 10px; }
.radar svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sweep { position: absolute; inset: 0; background: conic-gradient(transparent 280deg, rgb(160 255 180 / .4)); animation: spin 3s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.rings circle { fill: none; stroke: #a0ffb4; stroke-opacity: .35; stroke-width: 2; }
#ticks path { stroke: #a0ffb4; stroke-opacity: .6; stroke-width: 2; }
#ticks text { fill: var(--cream); font: 900 22px var(--display); text-anchor: middle; dominant-baseline: central; }
#ticks text.north { fill: var(--sun); }
#pointer .ray { stroke: var(--pink); stroke-width: 4; stroke-dasharray: 7 7; }
#pointer .tip { fill: var(--pink); stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; }
#blip .dot { fill: var(--pink); stroke: #fff; stroke-width: 3; }
#blip .halo { fill: var(--pink); opacity: .4; animation: halo 1.2s infinite; transform-box: fill-box; transform-origin: center; }
@keyframes halo { to { transform: scale(2); opacity: 0; } }
.me { fill: #fff; stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.readout { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: center; }
.readout b { display: block; font: 900 50px/1 var(--display); color: var(--sun); font-variant-numeric: tabular-nums; white-space: nowrap; }
.readout span { font: 800 16px/1.3 var(--display); text-transform: uppercase; letter-spacing: .06em; text-shadow: 0 1px 2px var(--ink); }

/* ----- Photo ----- */
.photo { position: relative; align-self: center; width: min(96%, 54vh, 420px); background: #fff; padding: 12px 12px 0; border: var(--edge); box-shadow: 8px 8px 0 var(--ink); transform: rotate(-2deg); animation: drop .35s cubic-bezier(.2, 1.4, .5, 1); }
@keyframes drop { from { transform: rotate(8deg) scale(1.5); opacity: 0; } }
.photo svg, .photo img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border: 3px solid var(--ink); }
.photo .rank { position: absolute; left: 22px; bottom: 68px; right: 22px; text-align: center; font-size: clamp(30px, 10vw, 46px); line-height: 1; letter-spacing: .02em; filter: drop-shadow(0 3px 0 var(--ink)); }
.photo .rank .star { color: var(--sun); paint-order: stroke fill; -webkit-text-stroke: 6px var(--ink); }
.photo figcaption { display: flex; justify-content: space-between; align-items: baseline; color: var(--ink); font: 900 30px/1 var(--display); text-transform: uppercase; padding: 10px 4px 12px; }
.photo figcaption b { font-variant-numeric: tabular-nums; }
.photo.biche figcaption b { color: #1f7a2e; }
.photo.cochon figcaption b { color: #b3122b; }
.photo.result { width: min(80%, 38vh, 320px); }
.photo.missed figcaption b { text-decoration: line-through; text-decoration-thickness: 4px; opacity: .6; }
.countdown { position: relative; height: 46px; border: var(--edge); border-radius: 6px; background: var(--ink); overflow: hidden; }
.countdown i { position: absolute; inset: 0; background: linear-gradient(90deg, var(--danger), var(--sun)); transform-origin: left; }
.countdown b { position: absolute; inset: 0; display: grid; place-items: center; font: 900 32px/1 var(--display); color: #fff; paint-order: stroke fill; -webkit-text-stroke: 6px var(--ink); font-variant-numeric: tabular-nums; }
.flee { display: grid; gap: 8px; text-align: center; font-weight: 700; color: var(--ink); text-wrap: balance; }
.flee-bar { position: relative; height: 30px; background: rgb(27 10 36 / .85); border: 3px solid var(--ink); border-radius: 4px; overflow: hidden; }
.flee-bar i { position: absolute; inset: 0; background: #1d8a7c; transform: scaleX(0); transform-origin: left; transition: transform .3s; }
.flee-bar span { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 800 17px/1 var(--display); font-variant-numeric: tabular-nums; }

/* ----- Résultat ----- */
[data-name="result"] { justify-content: center; text-align: center; padding-block: 12px; }
.banner { font: 900 clamp(48px, 15vw, 72px)/.92 var(--display); text-transform: uppercase; color: var(--sun); -webkit-text-stroke-width: 10px; transform: rotate(-4deg); animation: slam .4s cubic-bezier(.2, 1.5, .5, 1); text-wrap: balance; padding: 6px 0; }
.banner.bad { color: var(--danger); }
.banner.flat { color: var(--cream); }
@keyframes slam { from { transform: rotate(-4deg) scale(2.4); opacity: 0; } }
.result-points { font: 900 60px/1 var(--display); color: var(--cash); font-variant-numeric: tabular-nums; }
.result-points.bad { color: var(--danger); }
.result-points:empty { display: none; }

.toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translate(-50%, -160%); background: var(--ink); color: #fff; border: 3px solid var(--sun); border-radius: 6px; padding: 10px 16px; font-weight: 700; max-width: calc(100vw - 32px); width: max-content; transition: transform .25s; z-index: 10; visibility: hidden; }
.toast.on { transform: translate(-50%, 0); visibility: visible; }
.flash { position: fixed; inset: 0; background: #fff; pointer-events: none; opacity: 0; z-index: 9; }
.flash.on { animation: flash .6s ease-out; }
@keyframes flash { from { opacity: 1; } }

@media (max-height: 700px) {
  .timer { font-size: 54px; } .readout b { font-size: 40px; } .screen { gap: 11px; }
  .btn.big { font-size: 28px; padding: 13px; } .range-value { font-size: 50px; }
  .panel { padding: 14px; gap: 10px; } .poster.small { height: 104px; }
  .poster { height: 32vh; }
  .photo { width: min(96%, 44vh); } .photo .rank { font-size: 30px; }
}
@media (max-height: 620px) { .poster.small { display: none; } .modes { order: -1; } }
@media (max-width: 360px) { .chips { gap: 4px; } .chips button { font-size: 14px; border-width: 2px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .sweep { display: none; }
}

/* ----- Chasse double ----- */
.modes { gap: 10px; padding: 12px 18px; }
.leg { align-self: center; background: var(--ink); color: var(--sun); font: 800 18px/1 var(--display); text-transform: uppercase; letter-spacing: .05em; padding: 7px 14px; border-radius: 4px; margin-bottom: -8px; }
.next-leg { border: var(--edge); border-radius: 6px; background: var(--pink); color: #fff; font: 900 34px/1 var(--display); text-transform: uppercase; padding: 19px; font-variant-numeric: tabular-nums; }

/* ----- Mur de trophées ----- */
body[data-screen="wall"] {
  background:
    radial-gradient(ellipse 620px 420px at 50% 0, rgb(255 61 134 / .38), transparent 70%),
    linear-gradient(335deg, #2a1133 23px, transparent 23px) 0 0 / 58px 58px,
    linear-gradient(155deg, #301538 23px, transparent 23px) 0 0 / 58px 58px,
    linear-gradient(335deg, #2a1133 23px, transparent 23px) 29px 29px / 58px 58px,
    linear-gradient(155deg, #301538 23px, transparent 23px) 29px 29px / 58px 58px,
    #3b1b45;
}
[data-name="wall"] { gap: 10px; padding-top: 12px; }
#new-hunt, #start { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 2; padding: 15px; }
[data-name="wall"] .link { color: var(--cream); padding: 4px; }
.neon { text-align: center; font: 900 32px/1 var(--display); text-transform: uppercase; letter-spacing: .05em; color: #fff; text-shadow: 0 0 5px #fff, 0 0 12px var(--pink), 0 0 26px var(--pink), 0 0 50px var(--pink); }
.wall { display: grid; gap: 10px; align-content: start; min-height: 480px; }
.plaque { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: linear-gradient(160deg, #ffe9a0, #e8a82e 55%, #b87514); color: var(--ink); border: var(--edge); border-radius: 6px; padding: 6px 12px; box-shadow: 5px 5px 0 var(--ink); }
.plaque > div { min-width: 0; }
.plaque h2 { font: 900 26px/1.05 var(--display); text-transform: uppercase; overflow-wrap: anywhere; }
.plaque.long { flex-wrap: wrap; gap: 0 10px; }
.plaque.long > div { flex: 1 0 100%; }
.plaque.long h2 { font-size: clamp(17px, 5.4vw, 24px); overflow-wrap: anywhere; }
.plaque.long strong { margin: -4px 0 0 auto; }
.plaque p { font-weight: 700; font-size: 15px; line-height: 1.2; }
.plaque strong { font: 900 44px/1 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; color: #14591f; }
.plaque strong.bad { color: #a80f24; }
.plaque small { font-size: 18px; margin-left: 4px; }
.frames { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 6px 4px 0; }
.frame { position: relative; }
.frame:first-child { transform: rotate(-2deg); }
.frame:last-child { transform: rotate(1.6deg); }
.frame::before { content: ""; position: absolute; top: -6px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: #d9d9d9; border: 3px solid var(--ink); z-index: 1; }
.frame .pic { border: 9px solid #e8a82e; outline: 4px solid var(--ink); box-shadow: inset 0 0 0 3px var(--ink), 5px 8px 0 4px rgb(0 0 0 / .45); aspect-ratio: 8 / 7; position: relative; background: #1a0a20; overflow: hidden; }
.frame.cochon .pic { border-color: #7a4d22; }
.frame .pic svg, .frame .pic img, .shelf .pic svg, .shelf .pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.frame .rank { position: absolute; inset: auto 0 5px; text-align: center; font-size: clamp(17px, 5.6vw, 25px); line-height: 1; filter: drop-shadow(0 2px 0 var(--ink)); }
.frame .star { color: var(--sun); paint-order: stroke fill; -webkit-text-stroke: 5px var(--ink); }
.frame .pic p { height: 100%; display: grid; place-items: center; text-align: center; font: 800 20px/1.1 var(--display); text-transform: uppercase; color: #a98bb3; padding: 8px; }
.frame figcaption { position: relative; width: max-content; max-width: 100%; margin: -7px auto 0; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 3px; padding: 3px 10px 4px; font: 800 16px/1.1 var(--display); text-transform: uppercase; }
.shelf { list-style: none; margin: 0; padding: 0 4px 6px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; border-bottom: 7px solid #6b3f1c; box-shadow: 0 4px 0 var(--ink); }
.shelf li { position: relative; }
.shelf .pic { aspect-ratio: 6 / 5; border: 3px solid #e8a82e; outline: 3px solid var(--ink); overflow: hidden; background: #1a0a20; display: grid; place-items: center; }
.shelf.cochon .pic { border-color: #7a4d22; }
.shelf .empty .pic { border-style: dashed; border-color: #6d4a78; }
.shelf .empty b { font: 800 19px/1 var(--display); color: #a98bb3; filter: grayscale(1); opacity: .8; }
.shelf .count { position: absolute; right: -5px; bottom: -5px; background: var(--pink); color: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 1px 6px; font: 900 16px/1.1 var(--display); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.stats div { background: rgb(20 8 26 / .82); border: 3px solid var(--ink); border-radius: 4px; padding: 2px 4px 4px; text-align: center; }
.stats b { display: block; font: 900 26px/1.1 var(--display); color: var(--sun); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats i { font-style: normal; opacity: .6; padding: 0 3px; }
.stats span { font-size: 13px; line-height: 1.15; display: block; font-weight: 600; }
.last { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; justify-content: center; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 4px; padding: 4px 8px; font-weight: 700; font-size: 14px; }
.last .star { color: #d98a00; }
.last i { font-style: normal; opacity: .6; }
.last b { font: 900 22px/1 var(--display); color: #1f7a2e; }
.last b.bad { color: #b3122b; }

/* ----- Simulateur (développement) ----- */
.sim { position: fixed; right: 8px; bottom: 8px; z-index: 20; background: #000c; border: 2px solid #7ddc5f; border-radius: 8px; padding: 8px; font: 12px monospace; color: #fff; display: grid; grid-template-columns: repeat(3, 40px); gap: 4px; }
.sim button { height: 32px; background: #244; border: 1px solid #7ddc5f; color: #fff; border-radius: 4px; cursor: pointer; }
.sim .wide { grid-column: 1 / -1; }
