/* Thème sobre, pensé d'abord pour téléphone. Les styles propres à chaque jeu sont dans games/<jeu>/ui.js. */
:root {
  --bg: #14181f; --panel: #1d232d; --panel-2: #262e3b; --line: #343e4f;
  --text: #e8eaf0; --muted: #98a2b3; --accent: #e0a23c; --accent-ink: #1b1405;
  --good: #4cc38a; --bad: #e5605c; --info: #5aa2e6;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 760px; margin: 0 auto; padding: 12px 12px calc(28px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
main.in-game { max-width: 900px; }
h1 { font-size: 1.9rem; margin: 18px 0 0; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
h3 { font-size: 0.95rem; margin: 10px 0 4px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 40px 0; }
.grow { flex: 1; min-width: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.panel.accent { border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }

button {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 16px; min-height: 44px; cursor: pointer; touch-action: manipulation;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 650; }
button.ghost { background: transparent; }
button.small { padding: 5px 10px; min-height: 34px; font-size: 0.88rem; }
button.big { width: 100%; margin-top: 12px; font-size: 1.05rem; }

input:not([type=checkbox]):not([type=radio]) {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; min-width: 0;
}
label { display: block; font-weight: 600; margin-bottom: 6px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 10px 0 0; cursor: pointer; }
label.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
label.chip { background: var(--panel-2); border-radius: 999px; padding: 6px 12px; margin: 6px 0 0; align-items: center; }
.code-input { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 700; text-align: center; max-width: 9.5em; }

/* Accueil */
.home { max-width: 460px; }

/* Lobby */
.lobby-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.lobby-head .code { font-size: 1.5rem; letter-spacing: 0.18em; margin-left: 8px; color: var(--accent); }
.lobby-head > div:first-child { flex: 1; }
.lobby-head .row.grow { order: 3; flex-basis: 100%; }
.lobby-head .link { font-size: 0.85rem; min-height: 34px; padding: 5px 8px; }
.lobby-head .row.grow button { flex: none; }
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.players li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 8px; border-radius: 8px; background: var(--panel-2); }
.players li.turn { box-shadow: inset 3px 0 0 var(--accent); }
.players li.me .pname { font-weight: 700; }
.players .pname { overflow-wrap: anywhere; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); flex: none; }
.off .dot { background: var(--muted); }
.off .pname { color: var(--muted); }
.tag { font-size: 0.72rem; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.warn { color: var(--bad); border-color: var(--bad); }
.players button { margin-left: auto; }
.players button + button { margin-left: 0; }

.games { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.game-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px; }
.game-card.picked { border-color: var(--accent); }
.game-card.disabled { opacity: 0.6; }
.game-card p { font-size: 0.9rem; color: var(--muted); margin: 0 0 4px; }
.option { margin-top: 12px; }
.option.sub { margin-left: 30px; }
.history { margin: 0; padding-left: 18px; font-size: 0.92rem; }

/* Partie */
.game-head { display: flex; gap: 10px; align-items: center; }
.banner { text-align: center; padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); margin: 0; }
.banner.mine { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.game { display: grid; gap: 12px; justify-items: center; }
.game > * { max-width: 100%; }
.game .wide { width: 100%; justify-self: stretch; }
.results { text-align: center; border-color: var(--accent); }
.results .row { justify-content: center; flex-wrap: wrap; }
.ranking { display: inline-block; text-align: left; margin: 0 0 8px; }
.series { text-align: center; font-size: 0.9rem; margin: 0; }
.table-players summary, .log summary { cursor: pointer; font-weight: 600; }
.table-players[open] summary { margin-bottom: 8px; }
.log { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; font-size: 0.88rem; }
.log ol { list-style: none; margin: 8px 0 0; padding: 0; max-height: 11em; overflow-y: auto; display: grid; gap: 3px; color: var(--muted); }
.log li:first-child { color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
.seat-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; list-style: none; margin: 0; padding: 0; }
.seat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 104px; text-align: center; font-size: 0.9rem; }
.seat.turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.seat.out { opacity: 0.5; }
.seat .sname { font-weight: 650; display: block; overflow-wrap: anywhere; }

/* Fenêtre des règles */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: end center; z-index: 20; }
.modal-box { background: var(--panel); border-radius: 16px 16px 0 0; padding: 16px; width: min(680px, 100%); max-height: 85vh; overflow-y: auto; }
@media (min-width: 700px) { .modal { place-items: center; } .modal-box { border-radius: 16px; } }
.rules h2 { font-size: 1.1rem; margin-top: 12px; }
.rules h3 { color: var(--accent); }
.rules ul { padding-left: 20px; margin: 0 0 8px; }
.rules li { margin-bottom: 4px; }

#toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #fff; color: #111; padding: 10px 16px; border-radius: 10px; max-width: 92vw; opacity: 0;
  pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 30; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--bad); color: #fff; text-align: center; padding: 6px; z-index: 40; font-size: 0.9rem; }

@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
