/* Base (équivalent du squelette des artifacts) */
:root { color-scheme: light; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html, body { margin: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; }

/* Layout: blanc dominant, une colonne de 720px max sous un en-tête qui porte le pattern cercle ;
   cartes Gris 20 ; l'Orange Weenect ne sert qu'aux boutons, à la note choisie et à la 1re place. */
:root {
  --bg: #FFFFFF;          /* Blanc */
  --fg: #232323;          /* Anthracite */
  --surface: #F5F5F5;     /* Gris 20 */
  --muted: #575757;       /* Gris 60 */
  --accent: #FF5000;      /* Orange Weenect */
  --on-accent: #FFFFFF;
  --line: #E6E6E6;
  --line-strong: #CFCFCF;
  --field: #FFFFFF;
  --logo-light: inline-block;
  --logo-dark: none;
  --font: "Plus Jakarta Sans", Arial, sans-serif;
  --r-card: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #232323; --fg: #FFFFFF; --surface: #2E2E2E; --muted: #B4B4B4;
    --accent: #FF5000; --on-accent: #FFFFFF; --line: #3A3A3A; --line-strong: #555555;
    --field: #232323; --logo-light: none; --logo-dark: inline-block;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #232323; --fg: #FFFFFF; --surface: #2E2E2E; --muted: #B4B4B4;
  --accent: #FF5000; --on-accent: #FFFFFF; --line: #3A3A3A; --line-strong: #555555;
  --field: #232323; --logo-light: none; --logo-dark: inline-block;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 16px; line-height: 1.5; font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.gutter {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.col { max-width: 720px; margin-inline: auto; }

/* ---------- En-tête ---------- */
.top { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); background: var(--bg); }
.top .col { position: relative; padding-block: 16px 28px; display: grid; gap: 4px; }
.rings {
  position: absolute; z-index: 0; width: 300px; height: 300px;
  right: -150px; top: -100px; color: var(--accent); pointer-events: none;
}
.bar { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 26px; }
.logo { display: inline-flex; align-items: center; min-height: 32px; color: var(--fg); text-decoration: none; }
.logo img { height: 28px; width: auto; }
.logo .l-light { display: var(--logo-light); }
.logo .l-dark { display: var(--logo-dark); }
.logo-ph { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%;
  background: var(--surface); border-radius: 999px; padding: 4px 14px 4px 4px; font-size: 14px;
}
.chip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; background: var(--line); }
.chip .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .who b { font-weight: 600; }
.chip .lbl { color: var(--muted); }
h1 {
  position: relative; z-index: 1; margin: 0;
  font-weight: 800; font-size: clamp(2.25rem, 8vw, 3.25rem); line-height: 1.02; letter-spacing: -0.03em;
  text-wrap: balance; max-width: 12ch;
}
.sub { position: relative; z-index: 1; margin: 6px 0 0; font-weight: 600; font-size: 1.0625rem; }
.intro { position: relative; z-index: 1; margin: 4px 0 0; color: var(--muted); font-size: 0.9375rem; max-width: 38ch; }

/* ---------- Corps ---------- */
main.col { padding-block: 24px 64px; display: grid; gap: 28px; }
.view { display: grid; gap: 16px; min-width: 0; }
.sechead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h2 { margin: 0; font-weight: 800; font-size: 1.375rem; letter-spacing: -0.015em; }
h3 { margin: 0; font-weight: 600; font-size: 1.0625rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.875rem; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  border: 1.5px solid var(--accent); border-radius: 999px; padding: 3px 11px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; color: var(--fg);
}

/* Onglets admin */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border-radius: 999px; }
.tabs button {
  flex: 1 1 0; min-height: 40px; border: 0; border-radius: 999px; background: transparent;
  font-weight: 600; font-size: 0.9375rem; color: var(--muted); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--fg); color: var(--bg); }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 22px; border-radius: 999px; border: 1.5px solid transparent;
  font-weight: 600; font-size: 0.9375rem; cursor: pointer; text-align: center; line-height: 1.25;
}
.btn.primary { background: var(--accent); color: var(--on-accent); font-weight: 800; }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--fg); }
.btn.dark { background: var(--fg); color: var(--bg); font-weight: 800; }
.btn.link { background: transparent; border-color: transparent; color: var(--muted); text-decoration: underline; padding-inline: 8px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }

/* Messages */
.notice { background: var(--surface); border: 1.5px solid var(--fg); border-radius: 14px; padding: 14px 16px; display: grid; gap: 4px; font-size: 0.9375rem; }
.notice b { font-weight: 600; }
.empty { background: var(--surface); border-radius: var(--r-card); padding: 22px 18px; display: grid; gap: 10px; justify-items: start; }
.empty p { color: var(--muted); max-width: 46ch; }

/* Progression */
.progress { display: grid; gap: 8px; }
.progress p { font-size: 1rem; }
.progress p b { font-weight: 800; }
.meter { height: 6px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--fg); border-radius: 999px; transition: width .25s ease; }
.savestate { font-size: 0.8125rem; color: var(--muted); min-height: 1.2em; }

/* Liste des goûts à noter */
.flavors { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.flavor {
  background: var(--surface); border-radius: var(--r-card); padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap;
}
.fmeta { display: grid; gap: 2px; min-width: 0; flex: 1 1 180px; }
.fname { font-weight: 600; font-size: 1.0625rem; overflow-wrap: anywhere; }
.fby { font-size: 0.8125rem; color: var(--muted); overflow-wrap: anywhere; }
.rates { display: flex; gap: 8px; flex: none; }
.rate {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--line-strong); background: var(--bg); color: var(--fg);
  font-weight: 600; font-size: 0.9375rem; font-variant-numeric: tabular-nums; cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, transform .12s ease;
}
.rate:hover:not(:disabled) { border-color: var(--fg); }
.rate.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 800; }
.rate:active:not(:disabled) { transform: scale(0.94); }
.rate:disabled { cursor: not-allowed; opacity: 0.5; }

/* Classement */
.stats { color: var(--muted); font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.stats b { color: var(--fg); font-weight: 600; }
.rk { display: grid; gap: 18px; min-width: 0; }
.podium { display: grid; gap: 8px; align-items: end; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); }
.podium.n1 { max-width: 240px; }
.step { display: grid; gap: 8px; min-width: 0; }
.step .who { display: grid; gap: 2px; text-align: center; padding-inline: 2px; }
.pname { font-weight: 600; font-size: 0.9375rem; line-height: 1.3; overflow-wrap: anywhere; }
.pby { font-size: 0.75rem; color: var(--muted); overflow-wrap: anywhere; line-height: 1.3; }
.block {
  background: var(--surface); border-radius: 14px 14px 4px 4px;
  display: grid; justify-items: center; align-content: start; gap: 4px; padding: 14px 6px 12px;
}
.p1 .block { min-height: 150px; }
.p2 .block { min-height: 118px; }
.p3 .block { min-height: 96px; }
.medal {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--fg); font-weight: 800; font-size: 0.875rem; font-variant-numeric: tabular-nums;
}
.medal.gold { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pavg { font-weight: 800; font-size: 1.625rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.p1 .pavg { font-size: 2rem; }
.pavg small { font-size: 0.75rem; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.pvotes { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.ranklist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rrow {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.rpos { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); }
.rrow.first .rpos { color: var(--accent); }
.rname { display: grid; gap: 1px; min-width: 0; }
.rname span:first-child { font-weight: 600; overflow-wrap: anywhere; }
.rby { font-size: 0.8125rem; color: var(--muted); overflow-wrap: anywhere; }
.rscore { display: grid; justify-items: end; gap: 0; font-variant-numeric: tabular-nums; }
.rscore b { font-weight: 800; font-size: 1.0625rem; }
.rscore b small { font-weight: 600; font-size: 0.75rem; color: var(--muted); margin-left: 2px; }
.rscore span { font-size: 0.75rem; color: var(--muted); }

.revealbox { background: var(--surface); border-radius: var(--r-card); padding: 16px; display: grid; gap: 12px; }
.revealbox .state { display: grid; gap: 6px; justify-items: start; }

/* Gestion */
.addform { background: var(--surface); border-radius: var(--r-card); padding: 16px; display: grid; gap: 14px; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-weight: 600; font-size: 0.875rem; }
.field .opt { font-weight: 400; color: var(--muted); }
.field input {
  min-height: 48px; width: 100%; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--line-strong); background: var(--field); color: var(--fg); font-size: 1rem;
}
.field input::placeholder { color: var(--muted); opacity: .8; }
.field input:focus { outline: none; border-color: var(--fg); }
.formfoot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.formmsg { font-size: 0.875rem; color: var(--muted); min-height: 1.3em; }

.managelist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.mrow { display: flex; align-items: center; gap: 10px 14px; padding: 12px 2px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mrow .rname { flex: 1 1 160px; }
.mrow .mvotes { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mrow .btn { min-height: 38px; padding: 6px 14px; font-size: 0.875rem; }

.resetbox { border: 1.5px solid var(--line-strong); border-radius: var(--r-card); padding: 16px; display: grid; gap: 10px; justify-items: start; }
.resetbox p { color: var(--muted); font-size: 0.9375rem; }
.resetbox .warn { color: var(--fg); font-weight: 600; }

.loading { color: var(--muted); padding: 8px 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (min-width: 640px) {
  .top .col { padding-block: 20px 36px; }
  .rings { width: 440px; height: 440px; right: -150px; top: -10px; }
  .podium { gap: 12px; }
  .pname { font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Version serveur : identification, connexion admin, pied de page ---------- */
.card { background: var(--surface); border-radius: var(--r-card); padding: 18px 16px; display: grid; gap: 14px; }
.card > p { color: var(--muted); font-size: 0.9375rem; max-width: 52ch; }
.whoami { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; font-size: 0.875rem; color: var(--muted); }
.whoami .btn.link { min-height: 32px; padding: 4px 6px; font-size: 0.875rem; }
.formmsg.err { color: var(--fg); font-weight: 600; }
.foot { padding-block: 8px 40px; display: flex; gap: 8px 18px; flex-wrap: wrap; font-size: 0.8125rem; color: var(--muted); }
.foot a, .foot button { color: var(--muted); background: none; border: 0; padding: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.chip .initials {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--fg); color: var(--bg); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.02em;
}
