* { box-sizing: border-box; }
:root {
  --bg: #fffaf0;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --card: #ffffff;
  --line: #e7e1d4;
  --accent: #ff5a36;
  --good: #1fa55b;
  --bad: #e03131;
}
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; max-width: 1100px; margin: 0 auto;
}
.topbar a.back {
  text-decoration: none; font-weight: 600; padding: 8px 14px;
  border-radius: 999px; background: #fff; border: 1px solid var(--line);
}
.topbar a.back:hover { background: #f3efe6; }
.logo { font-weight: 800; font-size: 1.1rem; text-decoration: none; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px 60px; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; margin: 20px 0 8px; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 1.1rem; margin: 0 0 28px; }
.btn {
  font: inherit; font-weight: 700; cursor: pointer; border: none;
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 12px;
  transition: transform .08s ease, background .2s;
}
.btn:hover { background: #333; }
.btn:active { transform: scale(0.96); }
.btn.alt { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.alt:hover { background: #f3efe6; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px; box-shadow: 0 2px 0 rgba(0,0,0,.03);
}
.center { text-align: center; }
footer { text-align: center; color: var(--muted); padding: 30px 20px; font-size: .9rem; }

/* ---------- Bouton mode sombre ---------- */
.theme-toggle {
  position: fixed; right: 16px; bottom: 16px; z-index: 1000; width: 50px; height: 50px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); font-size: 1.4rem; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.18); transition: transform .15s;
}
.theme-toggle:hover { transform: scale(1.1) rotate(-12deg); }

/* ---------- Mode sombre ---------- */
html[data-theme="dark"] {
  --bg: #16161a; --ink: #f1f1f3; --muted: #a0a0aa; --card: #222228; --line: #34343c;
  color-scheme: dark;
}
html:where([data-theme="dark"]) body { background: var(--bg); color: var(--ink); }
html:where([data-theme="dark"]) .btn { background: #f1f1f3; color: #16161a; }
html:where([data-theme="dark"]) .btn:hover { background: #d8d8de; }
html[data-theme="dark"] .btn.alt { background: var(--card); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] .btn.alt:hover { background: #2c2c34; }
html[data-theme="dark"] .topbar a.back { background: var(--card); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] .topbar a.back:hover { background: #2c2c34; }
html[data-theme="dark"] small:not(#pct) { color: var(--muted) !important; }

/* Accueil */
html[data-theme="dark"] .card { color: #f1f1f3; border: 1px solid #ffffff14; }
html[data-theme="dark"] .card.c1 { background: #5a3d1c; } html[data-theme="dark"] .card.c2 { background: #2d5227; }
html[data-theme="dark"] .card.c3 { background: #1d4f5a; } html[data-theme="dark"] .card.c4 { background: #5a2658; }
html[data-theme="dark"] .card.c5 { background: #55541f; } html[data-theme="dark"] .card.c6 { background: #3b3470; }

/* Cartes / boîtes génériques */
html[data-theme="dark"] .stat, html[data-theme="dark"] .item, html[data-theme="dark"] .receipt,
html[data-theme="dark"] .rule .body, html[data-theme="dark"] .try, html[data-theme="dark"] .up,
html[data-theme="dark"] .choice, html[data-theme="dark"] .say, html[data-theme="dark"] .act,
html[data-theme="dark"] textarea, html[data-theme="dark"] .ctrl input { background: var(--card); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] .bar, html[data-theme="dark"] .timer, html[data-theme="dark"] .badge,
html[data-theme="dark"] .endings span { background: #34343c; }
html[data-theme="dark"] .badge.on, html[data-theme="dark"] .endings span.on, html[data-theme="dark"] .scale .row.me { background: #55541f; }

/* Mot de passe */
html[data-theme="dark"] .rule.ok .head { background: #1e4a30; color: #9ee6b8; } html[data-theme="dark"] .rule.ok { border-color: #2f6e48; }
html[data-theme="dark"] .rule.ko .head { background: #5a2020; color: #ffb3b3; } html[data-theme="dark"] .rule.ko { border-color: #8a3030; }
html[data-theme="dark"] .win { background: #1e4a30; }

/* Bouton fuyant */
html[data-theme="dark"] body:not(.statue-page) .arena { background: #1d1d22; border-color: var(--line); }
html[data-theme="dark"] .victory { background: #2b2a14; }
html[data-theme="dark"] .bubble { background: #f1f1f3; color: #16161a; }

/* Bouton inutile */
html[data-theme="dark"] .up:hover:not(:disabled) { background: #2c2c34; }
html[data-theme="dark"] body.disco { animation: discoDark 2s linear infinite; }
@keyframes discoDark { 0% { background: #4a2d10; } 25% { background: #1f4a1a; } 50% { background: #103f4a; } 75% { background: #4a1048; } 100% { background: #4a2d10; } }

/* Pigeon */
html[data-theme="dark"] .choice:hover { background: #3a3220; border-color: #8a6d2d; }
html[data-theme="dark"] .say:before { border-bottom-color: var(--ink); }

/* Gérard */
html[data-theme="dark"] .stage { background: linear-gradient(#1c2a33, #202024); border-color: var(--line); }
html[data-theme="dark"] .stage.dark { background: linear-gradient(#0e0e18, #1a1a24); }
html[data-theme="dark"] .stage .bubble { background: #2c2c34; color: var(--ink); border-color: #55555f; }
html[data-theme="dark"] .stage .bubble.urgent { background: #5a2020; border-color: var(--bad); }
html[data-theme="dark"] .act:hover:not(:disabled) { background: #22402a; }
html[data-theme="dark"] .over { background: rgba(22,22,26,.96); color: var(--ink); }

/* Chaussettes */
html[data-theme="dark"] .drawer { background: #5e4630; box-shadow: inset 0 0 0 8px #4a3622, 0 8px 0 #2e2114; }
html[data-theme="dark"] .sock { background: #3a3129; }
html[data-theme="dark"] .sock.wrong { background: #6a2a2a; }
html[data-theme="dark"] .sock.sel { outline-color: #f1f1f3; }

/* Escargots */
html[data-theme="dark"] .track { background: #2f5a28; }
html[data-theme="dark"] .lane .name { color: #cdeec4; }
html[data-theme="dark"] .pad { background: #2c2c34; color: var(--ink); box-shadow: 0 6px 0 #0c0c0e; }
html[data-theme="dark"] .pad.next { background: #b8951f; color: #16161a; }
html[data-theme="dark"] .caster { background: #000; }

/* Statue */
html[data-theme="dark"] body.statue-page { background: #1b1a17; }
html[data-theme="dark"] .statue-page #zone { background: radial-gradient(circle, #2c2c34 0%, #2c2c34 60%, #1a1a1f 100%); border-color: #f1f1f3; color: var(--ink); }
html[data-theme="dark"] .statue-page #zone.live { border-color: #3ddc84; } html[data-theme="dark"] .statue-page #zone.danger { border-color: #ff6b6b; }
html[data-theme="dark"] .statue-page #dot { background: #f1f1f3; }
html[data-theme="dark"] .statue-page .result { background: rgba(27,26,23,.96); }
html[data-theme="dark"] .statue-page .shout { background: #f1f1f3; color: #16161a; }

/* ===========================================================================
   Composants communs (arcade.js)
   =========================================================================== */

/* Bouton son, pose dans la barre du haut */
.ar-sound {
  font: inherit; font-size: 1.1rem; line-height: 1; cursor: pointer;
  width: 40px; height: 40px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: inherit;
}
.ar-sound:hover { background: #f3efe6; }
.ar-sound.off { opacity: .55; }

/* Choix de la difficulte */
.ar-diffs { margin: 0 0 18px; }
.ar-diff-ligne { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ar-diff {
  font: inherit; font-weight: 700; font-size: .88rem; cursor: pointer;
  padding: 8px 16px; border-radius: 14px; min-width: 96px;
  background: var(--card); border: 2px solid var(--line); color: inherit;
  transition: transform .1s, border-color .15s;
}
.ar-diff span { display: block; font-size: 1.5rem; line-height: 1.2; }
.ar-diff:hover { transform: translateY(-2px); }
.ar-diff.on { border-color: var(--accent); background: #fff3ee; }
.ar-diff-info { text-align: center; color: var(--muted); font-size: .86rem; margin-top: 8px; min-height: 1.4em; }

/* Succes */
.ar-succes-titre { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.ar-succes-titre span { color: var(--muted); font-size: .86rem; }
.ar-badges { display: flex; flex-wrap: wrap; gap: 7px; }
.ar-badge {
  font-size: 1.4rem; width: 44px; height: 44px; border-radius: 12px; cursor: help;
  display: flex; align-items: center; justify-content: center;
  background: #eee; filter: grayscale(1); opacity: .4;
}
.ar-badge.on { background: #fdffb6; filter: none; opacity: 1; }

/* Notifications */
.ar-toasts { position: fixed; left: 16px; bottom: 16px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; max-width: 290px; }
.ar-toast {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px;
  font-size: .88rem; box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: ar-in .3s ease-out;
}
.ar-toast b { display: block; }
@keyframes ar-in { from { opacity: 0; transform: translateX(-22px); } to { opacity: 1; transform: none; } }

/* Fenetres */
.ar-over { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.ar-modal {
  background: var(--card); color: var(--ink); border-radius: 18px; padding: 26px;
  max-width: 470px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.ar-modal h2 { margin: 0 0 10px; }
.ar-modal p { margin: 0 0 16px; }
.ar-modal .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Mode sombre */
html[data-theme="dark"] .ar-sound:hover { background: #2c2c34; }
html[data-theme="dark"] .ar-diff { background: var(--card); }
html[data-theme="dark"] .ar-diff.on { background: #43281f; border-color: var(--accent); }
html[data-theme="dark"] .ar-badge { background: #34343c; }
html[data-theme="dark"] .ar-badge.on { background: #55541f; }

/* ---------- Compte et classement en ligne (comptes.js) ---------- */
.cpt-compte { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.cpt-compte[hidden] { display: none; }
.cpt-txt { flex: 1; min-width: 190px; font-size: .95rem; }
.cpt-compte .btn { padding: 9px 16px; }
.cpt-liens { display: flex; gap: 14px; flex-wrap: wrap; width: 100%; }
.cpt-lien { font: inherit; font-size: .84rem; color: var(--muted); background: none; border: none; padding: 2px 0; text-decoration: underline; cursor: pointer; }
.cpt-lien:hover { color: var(--ink); }
.cpt-choix { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.cpt-select { font: inherit; font-weight: 700; width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: inherit; }
.cpt-diffs { display: flex; flex-wrap: wrap; gap: 6px; }
.cpt-diffs[hidden] { display: none; }
.cpt-diff { font: inherit; font-size: .84rem; font-weight: 700; cursor: pointer; padding: 7px 12px; border-radius: 999px; border: 2px solid var(--line); background: var(--card); color: inherit; }
.cpt-diff.on { border-color: var(--accent); background: #fff3ee; }
.cpt-liste { list-style: none; margin: 0; padding: 0; }
.cpt-liste li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; }
.cpt-liste li:nth-child(odd) { background: #f7f3ea; }
.cpt-liste li.moi { background: #fff0c2; font-weight: 700; }
.cpt-liste li.cpt-trou { justify-content: center; color: var(--muted); background: none; padding: 0 12px; }
.cpt-rang { width: 2.4em; flex: none; text-align: center; font-weight: 800; }
.cpt-pseudo { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpt-valeur { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cpt-etat { color: var(--muted); margin: 6px 2px; }
.cpt-etat:empty { display: none; }
.cpt-pied { color: var(--muted); font-size: .82rem; margin: 10px 2px 0; }
.cpt-pied:empty { display: none; }
.ar-modal.cpt-fenetre { text-align: left; }
.ar-modal .cpt-intro { color: var(--muted); font-size: .92rem; }
.cpt-form label { display: block; font-weight: 700; font-size: .9rem; margin: 12px 0 0; }
.cpt-form label[hidden] { display: none; }
.cpt-form input { display: block; width: 100%; margin-top: 5px; font: inherit; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: inherit; }
.ar-modal .cpt-erreur { color: var(--bad); font-weight: 700; margin: 10px 0 0; min-height: 1.3em; }
.cpt-form .row { margin-top: 14px; justify-content: flex-start; }
.cpt-form > .cpt-lien { display: block; margin: 14px 0 0; }
.btn.cpt-danger { background: var(--bad); color: #fff; }
html[data-theme="dark"] .cpt-diff.on { background: #43281f; }
html[data-theme="dark"] .cpt-liste li:nth-child(odd) { background: #2a2a31; }
html[data-theme="dark"] .cpt-liste li.moi { background: #4a3f16; }
html[data-theme="dark"] .cpt-liste li.cpt-trou { background: none; }
html[data-theme="dark"] .btn.cpt-danger { background: #e05555; color: #fff; }
.cpt-barre {
  font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; margin-right: 8px;
  padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: inherit;
  max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cpt-barre:hover:not(:disabled) { background: #f3efe6; }
.cpt-barre:disabled { opacity: .55; cursor: default; }
html[data-theme="dark"] .cpt-barre:hover:not(:disabled) { background: #2c2c34; }
.cpt-sync { display: block; font-size: .82rem; color: var(--good); margin-top: 2px; }
.cpt-sync.attente { color: var(--muted); }
