@font-face { font-family: 'Saira Condensed'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/saira-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Saira Condensed'; font-weight: 700; font-style: normal; font-display: swap; src: url('/fonts/saira-condensed-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Saira Condensed'; font-weight: 800; font-style: normal; font-display: swap; src: url('/fonts/saira-condensed-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'Figtree'; font-weight: 400; font-style: normal; font-display: swap; src: url('/fonts/figtree-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Figtree'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/figtree-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Figtree'; font-weight: 700; font-style: normal; font-display: swap; src: url('/fonts/figtree-latin-700-normal.woff2') format('woff2'); }

:root {
  color-scheme: dark;
  --ink: #0a1124;
  --panel: #111b36;
  --panel-2: #16224a;
  --line: #2b4586;
  --line-soft: #1e2e5c;
  --text: #e8eeff;
  --muted: #94a3cc;
  --system: #5cc8ff;
  --ok: #59e3a6;
  --warn: #ffb84d;
  --danger: #ff6b81;
  --rank-E: #9aa6bf;
  --rank-D: #4fd1a5;
  --rank-C: #4da3ff;
  --rank-B: #a184ff;
  --rank-A: #ffb84d;
  --rank-S: #ff5c7a;
  --rank: var(--rank-E);
  --display: 'Saira Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --cut: 10px;
}
.rank-E { --rank: var(--rank-E); } .rank-D { --rank: var(--rank-D); } .rank-C { --rank: var(--rank-C); }
.rank-B { --rank: var(--rank-B); } .rank-A { --rank: var(--rank-A); } .rank-S { --rank: var(--rank-S); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--ink); color: var(--text);
  font: 400 1rem/1.5 var(--body);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body::before {
  content: ''; position: fixed; inset: 0 0 auto 0; height: 340px; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse 70% 100% at 50% 0%, color-mix(in srgb, var(--rank) 22%, transparent), transparent 70%);
}
a { color: var(--system); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; line-height: 1.1; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--system); outline-offset: 2px; }
[hidden] { display: none !important; }

main { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px 24px; }
.topbar { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.brand { font-size: 1.9rem; font-weight: 800; }
.who { color: var(--muted); font-size: .9375rem; }
.stack > * + * { margin-top: 16px; }

/* Panneaux : angles droits, deux crochets d'angle en couleur */
.panel {
  position: relative; background: var(--panel); border: 1px solid var(--line-soft); padding: 16px;
}
.panel::before, .panel::after { content: ''; position: absolute; width: 12px; height: 12px; border: 0 solid var(--system); pointer-events: none; }
.panel::before { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; }
.panel::after { bottom: -1px; right: -1px; border-bottom-width: 2px; border-right-width: 2px; }
.panel > h2, .panel > h3 { margin-bottom: 10px; }

/* Rang : l'élément principal de l'écran d'accueil */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; padding: 8px 0 4px; }
.rank-letter {
  font-family: var(--display); font-weight: 800; font-size: 8.5rem; line-height: .78; color: var(--rank);
  text-shadow: 0 0 42px color-mix(in srgb, var(--rank) 55%, transparent);
  min-width: 1ch; text-align: center;
}
.hero-info .level { font-family: var(--display); font-weight: 700; font-size: 2.2rem; line-height: 1; margin-bottom: 10px; }
.bar { height: 8px; background: var(--line-soft); position: relative; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--rank, var(--system)); transition: width .5s ease; }
.bar.sys > span { background: var(--system); }
.bar.ok > span { background: var(--ok); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.stat .num { font-size: 1.5rem; display: block; line-height: 1.1; }
.stat { min-width: 0; }

/* Quête */
.quest-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.quest-item:first-of-type { border-top: 0; padding-top: 0; }
.quest-item .name { font-weight: 600; }
.quest-item .frac { font-family: var(--display); font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.quest-item .bar { grid-column: 1 / -1; }
.quest-item.done .name, .quest-item.done .frac { color: var(--ok); }
.done-banner { border-left: 3px solid var(--ok); padding: 4px 0 4px 12px; margin-bottom: 12px; }
.done-banner strong { font-family: var(--display); font-size: 1.3rem; }

/* Boutons : angles coupés */
.btn {
  appearance: none; border: 0; cursor: pointer; font: 700 1rem/1 var(--body); color: var(--ink); background: var(--system);
  padding: 13px 20px; min-height: 46px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 9px 14px; min-height: 38px; font-size: .9375rem; --cut: 8px; }
.btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { background: var(--panel-2); filter: none; }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.link-btn { appearance: none; background: none; border: 0; color: var(--system); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

/* Navigation du bas */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--ink) 92%, transparent); border-top: 1px solid var(--line-soft);
  backdrop-filter: blur(8px); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 2px 9px; color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 600; border-top: 2px solid transparent; margin-top: -1px; }
.tabs a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current='page'] { color: var(--system); border-top-color: var(--system); }

/* Formulaires */
label { display: block; font-weight: 600; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
input[type='text'], input[type='password'], input[type='time'], input[type='number'], select {
  width: 100%; background: var(--ink); color: var(--text); border: 1px solid var(--line); padding: 12px; font: inherit; min-height: 46px; border-radius: 0;
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--system); outline-offset: 0; }
.checks { display: grid; gap: 6px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-soft); cursor: pointer; font-weight: 600; margin: 0; }
.check input { width: 20px; height: 20px; accent-color: var(--system); margin: 0; }
.error { color: var(--danger); font-weight: 600; margin: 8px 0 0; }
.notice { border-left: 3px solid var(--warn); padding: 4px 0 4px 12px; }
.notice.info { border-left-color: var(--system); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); }
.seg button { appearance: none; border: 0; background: transparent; color: var(--muted); font: 600 .9375rem var(--body); padding: 11px 6px; cursor: pointer; min-height: 44px; }
.seg button[aria-pressed='true'] { background: var(--system); color: var(--ink); }

/* Entraînement */
.counter { font-family: var(--display); font-weight: 800; font-size: 5.5rem; line-height: .95; font-variant-numeric: tabular-nums; }
.counter small { font-size: 1.6rem; font-weight: 600; color: var(--muted); }
.cam { position: relative; background: #000; width: 100%; aspect-ratio: 3 / 4; max-height: 68vh; overflow: hidden; border: 1px solid var(--line-soft); }
.cam video, .cam canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cam.mirror video, .cam.mirror canvas { transform: scaleX(-1); }
.cam .hud-count { position: absolute; top: 8px; left: 12px; font-family: var(--display); font-weight: 800; font-size: 4rem; line-height: 1; text-shadow: 0 2px 12px rgba(0, 0, 0, .8); font-variant-numeric: tabular-nums; }
.cam .hud-msg { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 14px; background: color-mix(in srgb, var(--ink) 82%, transparent); font-weight: 600; }
.hud-msg.ok { color: var(--ok); } .hud-msg.warn { color: var(--warn); }
.cam .idle { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.steps .btn { padding: 10px 4px; }
.timer { font-family: var(--display); font-weight: 800; font-size: 4.2rem; font-variant-numeric: tabular-nums; line-height: 1; }

/* Classement */
.board { list-style: none; margin: 12px 0 0; padding: 0; }
.board li { display: grid; grid-template-columns: 2.2rem 2.4rem 1fr auto; gap: 10px; align-items: center; padding: 11px 8px; border-top: 1px solid var(--line-soft); }
.board li.me { background: var(--panel-2); border-left: 3px solid var(--system); }
.board .pos { font-family: var(--display); font-weight: 700; color: var(--muted); text-align: right; }
.board .chip { font-family: var(--display); font-weight: 800; font-size: 1.5rem; color: var(--rank); text-align: center; line-height: 1; }
.board .who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .val { font-family: var(--display); font-weight: 700; font-size: 1.2rem; font-variant-numeric: tabular-nums; }

/* Fiches et illustrations */
details.guide { border-top: 1px solid var(--line-soft); padding: 12px 0; }
details.guide:first-of-type { border-top: 0; }
details.guide summary { cursor: pointer; font-family: var(--display); font-weight: 700; font-size: 1.35rem; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.guide summary::-webkit-details-marker { display: none; }
details.guide summary::after { content: '+'; color: var(--system); font-size: 1.5rem; }
details.guide[open] summary::after { content: '\2212'; }
details.guide ol, details.guide ul { margin: 6px 0 12px; padding-left: 1.2rem; }
details.guide li { margin-bottom: 4px; }
.figure { width: 100%; max-width: 360px; display: block; margin: 12px 0; background: var(--ink); border: 1px solid var(--line-soft); }
.figure line, .figure circle { stroke: var(--system); stroke-width: 4; stroke-linecap: round; fill: none; }
.figure circle { stroke-width: 3.5; }
.figure .ground { stroke: var(--line); stroke-width: 2; }
.figure .prop { stroke: var(--muted); stroke-width: 3; }

/* Historique 14 jours */
.hist { display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; align-items: end; height: 52px; margin-top: 10px; }
.hist span { display: block; background: var(--line); min-height: 3px; height: 3px; }
.hist span.done { background: var(--ok); }

/* Fenêtres plein écran */
#overlay { position: fixed; inset: 0; z-index: 50; background: radial-gradient(ellipse 90% 55% at 50% 28%, color-mix(in srgb, var(--rank) 20%, var(--ink)), var(--ink) 75%); display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.sheet { width: 100%; max-width: 440px; text-align: center; }
.sheet .big-letter { font-family: var(--display); font-weight: 800; font-size: 11rem; line-height: .8; color: var(--rank); text-shadow: 0 0 60px color-mix(in srgb, var(--rank) 60%, transparent); margin: 6px 0 14px; }
.sheet .gain { font-family: var(--display); font-weight: 800; font-size: 3.2rem; color: var(--system); line-height: 1; margin-bottom: 4px; }
.sheet .lines { text-align: left; margin: 16px 0; }
.sheet .lines p { padding: 8px 0; border-top: 1px solid var(--line-soft); margin: 0; }
.rankup .big-letter { animation: rise .9s cubic-bezier(.2, .8, .2, 1) both; }
.rankup .banner { animation: fadein .6s .5s both; }
body.boot .rank-letter { animation: rise .8s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: scale(1.5); filter: blur(10px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: var(--panel-2); border: 1px solid var(--line); padding: 12px 18px; max-width: 92vw; font-weight: 600; }

/* Connexion */
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth h1 { font-size: 3.2rem; font-weight: 800; margin-bottom: 6px; }
.auth .tagline { color: var(--muted); margin-bottom: 20px; }

@media (min-width: 560px) { .rank-letter { font-size: 9.5rem; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Utilitaires (pas d'attribut style inline : la politique de sécurité les bloque) */
.m0 { margin: 0; } .mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; } .mt10 { margin-top: 10px; } .mt12 { margin-top: 12px; }
.mt14 { margin-top: 14px; } .mt16 { margin-top: 16px; } .mb6 { margin-bottom: 6px; } .my10 { margin: 10px 0; }
.g8 { gap: 8px; } .g10 { gap: 10px; } .wrap { flex-wrap: wrap; } .fw6 { font-weight: 600; } .fw7 { font-weight: 700; } .pointer { cursor: pointer; }
a.plain { display: block; color: inherit; text-decoration: none; }
.equip { margin: 0; }
.wsteps { margin: 0 0 8px; }
