/* Styles communs aux trois pages. Aucune ressource distante : polices système. */

:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --panel: #171a1f;
  --line: #2a2f37;
  --text: #e8eaed;
  --muted: #8b929c;
  --accent: #f5b83d;
  --accent-ink: #1a1300;
  --ok: #4cc38a;
  --warn: #f5b83d;
  --bad: #ef6461;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
[hidden] { display: none !important; }

button {
  font: inherit;
  color: var(--text);
  background: #232830;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover:not(:disabled) { border-color: #4a515c; }
button:active:not(:disabled) { background: #2d333c; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.primary:active:not(:disabled) { background: #e0a52e; }
button.danger { border-color: #6b2a29; color: #ffb3b1; }
button.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; border-radius: 7px; }

/* --- Pages joueur et acteur ------------------------------------------------ */

.setup {
  min-height: 100dvh;
  max-width: 26rem;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.25rem;
  text-align: center;
}
.setup p { margin: 0; color: var(--muted); }
.setup .primary { padding: 1.1rem; font-size: 1.15rem; }
.numbers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; }
.number { aspect-ratio: 1; font-size: 1.6rem; font-weight: 650; padding: 0; }
.number.taken { opacity: 0.35; }
.number.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); opacity: 1; }
.message { min-height: 1.5em; color: var(--bad) !important; }
.conn { font-size: 0.85rem; }
.conn::before { content: "● "; color: var(--ok); }
.conn.off::before { color: var(--bad); }

/* Écran de jeu : noir total, rien ne doit éclairer le labyrinthe. */
.lock {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #000;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: none;
}
.lock .dot {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4a0e0d;
}
.lock .dot[data-status="ok"] { background: #0c3a1c; }
.lock .dot[data-status="warn"] { background: #403005; }
.lock .hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 2rem);
  margin: 0;
  padding: 0 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: #3d3d3d;
}
.nosleep { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* --- Régie ----------------------------------------------------------------- */

.regie { max-width: 78rem; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
.topbar h1 { margin-right: auto; }
.phase { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 650; padding: 0.35rem 0.8rem; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); }
.phase::before { content: ""; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--muted); }
.phase[data-phase="running"]::before { background: var(--ok); }
.phase[data-phase="won"]::before { background: var(--accent); }
.banner { background: #4a1716; border: 1px solid #7c2b29; border-radius: var(--radius); padding: 0.6rem 0.9rem; }

.grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 60rem) {
  .grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
}
.col { display: grid; gap: 1rem; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: grid; gap: 0.85rem; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.panel-head .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.4rem 0.5rem; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; border-bottom: 1px solid var(--line); }
td { border-bottom: 1px solid #20242a; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tr.offline td:not(:first-child) { color: #5a616b; }
td.who { font-weight: 650; }
td.act { text-align: right; }
.flag::before { content: "●"; margin-right: 0.35rem; color: #4a515c; }
.flag.ok::before { color: var(--ok); }
.flag.warn::before { color: var(--warn); }
.flag.bad::before { color: var(--bad); }

.chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; background: #1d2127; cursor: pointer; user-select: none; -webkit-user-select: none; }
.chip:has(input:checked) { border-color: var(--accent); background: #2e2610; }
.chip:has(input:disabled) { opacity: 0.45; cursor: default; }
.chip.offline { color: var(--muted); }
.chip input { accent-color: var(--accent); margin: 0; }
.sounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.5rem; }
.sounds button { padding: 0.9rem 0.6rem; font-weight: 600; overflow-wrap: anywhere; }
.volume { display: flex; align-items: center; gap: 0.6rem; flex: 1 1 14rem; }
.volume input { flex: 1; accent-color: var(--accent); }
.volume output { width: 3.2rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

.lights { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.light { width: 3.4rem; height: 3.4rem; border-radius: 50%; padding: 0; font-weight: 650; font-size: 1.1rem; background: #14171b; color: var(--muted); }
.light[aria-pressed="true"] { background: #ffd66b; border-color: #ffe9a8; color: #2a1e00; box-shadow: 0 0 18px #f5b83d88; }

.log { list-style: none; margin: 0; padding: 0; max-height: 22rem; overflow-y: auto; font-size: 0.86rem; }
.log li { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; padding: 0.25rem 0; border-bottom: 1px solid #20242a; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log li[data-type="ignored"] span { color: var(--muted); }
.log li[data-type="game"] span { color: var(--accent); }
.log .empty { display: block; color: var(--muted); border: 0; }

.qr { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.qr img { width: 11rem; height: 11rem; background: #fff; border-radius: 8px; }
.qr dl { margin: 0; display: grid; gap: 0.5rem; min-width: 0; flex: 1 1 12rem; }
.qr dt { color: var(--muted); font-size: 0.8rem; }
.qr dd { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86rem; overflow-wrap: anywhere; }
.note { margin: 0; color: var(--muted); font-size: 0.85rem; }

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: #4a1716; border: 1px solid #7c2b29; padding: 0.6rem 1rem; border-radius: var(--radius); z-index: 20; max-width: calc(100vw - 2rem); }
