:root {
  --night: #0e2240;
  --night-2: #18335c;
  --ice: #dff1ff;
  --snow: #f5f9fd;
  --ink: #13233b;
  --muted: #5d6f88;
  --line: #d3dfec;
  --blue: #1f8fd6;
  --go: #1d9a62;
  --stop: #c93a48;
  --gold: #e9a91c;
  --display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 500 15px/1.5 var(--body); color: var(--ink); background: var(--snow); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.muted { color: var(--muted); }
small { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ── boutons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 800 14px var(--body); color: var(--ink); text-decoration: none;
  background: #fff; border: 2px solid var(--line); border-radius: 10px;
  padding: 9px 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #aac0d8; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tab:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 2px;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.big { padding: 14px 18px; font-size: 16px; border-radius: 12px; }
.btn.primary { background: var(--night); border-color: var(--night); color: #fff; }
.btn.go { background: var(--go); border-color: var(--go); color: #fff; }
.btn.danger { background: var(--stop); border-color: var(--stop); color: #fff; }
.btn.ghost { background: transparent; }
.danger-text { color: var(--stop); }

input, select, textarea {
  font: 600 15px var(--body); color: var(--ink);
  width: 100%; padding: 9px 11px; border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
textarea { resize: vertical; }
input[type=color] { width: 56px; height: 40px; padding: 3px; cursor: pointer; }
input[type=range] { padding: 0; border: 0; accent-color: var(--night); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--night); }

/* ── connexion ── */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--night); padding: 20px; }
.login-card { width: min(380px, 100%); background: #fff; border-radius: 18px; padding: 32px; display: grid; gap: 12px; }
.login-card .brand { color: var(--night); font-size: 38px; margin-bottom: 8px; }
.err { color: var(--stop); font-weight: 700; margin: 0; }

/* ── structure ── */
.app { display: grid; grid-template-columns: 280px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
.top {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 14px;
  background: var(--night); color: #fff; padding: 12px 22px;
}
.top .btn { color: #fff; border-color: rgba(255,255,255,.3); }
.brand { font: 400 26px var(--display); letter-spacing: .3px; }
.storage { flex: 1; font-size: 13px; opacity: .7; }

.side { background: #fff; border-right: 2px solid var(--line); padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.side h2 { font-size: 15px; color: var(--muted); }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.events button {
  width: 100%; text-align: left; font: 700 15px var(--body); color: var(--ink);
  background: none; border: 0; border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.events button:hover { background: var(--snow); }
.events button[aria-current=true] { background: var(--ice); color: var(--night); }
.events small { margin: 0; }
.new-event { display: grid; gap: 8px; margin-top: auto; padding-top: 16px; border-top: 2px solid var(--line); }
.new-event label { font-weight: 800; }

.main { padding: 26px 30px 60px; min-width: 0; }
.empty { color: var(--muted); padding: 60px 0; text-align: center; font-size: 17px; }
.event-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.event-head h1 { font: 400 36px var(--display); color: var(--night); flex: 1; }
.head-actions { display: flex; gap: 8px; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 18px 0 22px; }
.tab {
  font: 800 15px var(--body); color: var(--muted); background: none; border: 0;
  padding: 10px 16px; border-bottom: 3px solid transparent; margin-bottom: -2px; cursor: pointer;
}
.tab[aria-selected=true] { color: var(--night); border-bottom-color: var(--night); }

.card { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 20px; }
.card h3 { font-size: 16px; margin-bottom: 12px; }

/* ── pilotage ── */
.control-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; }
.live { grid-row: span 2; }
.state-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chip { font: 800 14px var(--body); padding: 6px 14px; border-radius: 999px; background: var(--ice); color: var(--night); }
.chip.playing { background: var(--go); color: #fff; }
.chip.paused { background: var(--gold); color: #2a1d00; }
.chip.reveal { background: var(--night); color: #fff; }
.chip.ended, .chip.countdown { background: var(--stop); color: #fff; }
.live-time { font: 400 54px var(--display); color: var(--night); font-variant-numeric: tabular-nums; }
.progress { position: relative; height: 22px; border-radius: 11px; background: var(--ice); margin: 14px 0 18px; overflow: hidden; }
#liveBar { height: 100%; width: 0; background: linear-gradient(90deg, #36b6ff, #ffc94a 70%, #ff5a5a); transition: width .4s; }
.thr { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--night); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 20px; }
.stats div { background: var(--snow); border-radius: 12px; padding: 10px 12px; }
.stats dt { font-size: 13px; color: var(--muted); font-weight: 700; }
.stats dd { margin: 0; font: 400 30px var(--display); color: var(--night); font-variant-numeric: tabular-nums; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .btn { white-space: normal; text-align: center; }
.actions.secondary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.links label { display: block; font-weight: 800; font-size: 13px; margin: 10px 0 4px; }
.link-row { display: flex; gap: 6px; }
.link-row input { font-size: 13px; }
.qr-row { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.qr-row img { border: 2px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; }
.top-list { margin: 0; padding-left: 24px; display: grid; gap: 4px; }
.top-list li { font-weight: 700; }
.top-list span { color: var(--muted); font-weight: 600; }

/* ── paramètres ── */
.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; align-items: start; }
fieldset { border: 2px solid var(--line); border-radius: 16px; padding: 14px 18px 18px; margin: 0; background: #fff; display: grid; gap: 12px; }
legend { font: 400 20px var(--display); color: var(--night); padding: 0 6px; }
.field label { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; margin-bottom: 4px; }
.field.row { display: flex; gap: 18px; flex-wrap: wrap; }
.field.row label { flex-direction: column; align-items: flex-start; gap: 4px; font-weight: 700; }
output { font-weight: 800; color: var(--blue); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button { border-radius: 999px; }
.image-box { display: flex; gap: 14px; align-items: flex-start; }
.img-preview {
  width: 176px; aspect-ratio: 16 / 9; border-radius: 10px; flex: none; overflow: hidden;
  display: grid; place-items: center; background: repeating-conic-gradient(#e6edf5 0 25%, #fff 0 50%) 0 0 / 16px 16px;
  border: 2px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 700;
}
.img-preview img { width: 100%; height: 100%; object-fit: contain; }
.image-actions { display: grid; gap: 8px; justify-items: start; }
.upload { cursor: pointer; }
.file-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.phone-preview {
  border-radius: 14px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
}
.phone-preview b { font: 400 24px var(--display); }
.phone-preview i { width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #b7d0ea 80%); }
.save-bar {
  grid-column: 1 / -1; position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 14px;
  background: linear-gradient(transparent, var(--snow) 30%); padding: 18px 0 6px;
}

/* ── historique ── */
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 13px; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--snow); }
#gameDetail { margin-top: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--night); color: #fff; font-weight: 800; padding: 12px 20px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(14, 34, 64, .3); z-index: 10;
}
.toast.bad { background: var(--stop); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 2px solid var(--line); }
  .new-event { margin-top: 0; }
  .control-grid { grid-template-columns: 1fr; }
  .live { grid-row: auto; }
  .main { padding: 20px 16px 60px; }
  .settings { grid-template-columns: 1fr; }
}

/* ═════════════ mini-jeux : éléments communs ═════════════ */
.login-logo { justify-self: center; border-radius: 16px; }
.login-card .brand { text-align: center; }
.top-logo { border-radius: 8px; background: #fff; }
.game-badge {
  font: 800 13px var(--body); padding: 5px 12px; border-radius: 999px;
  background: var(--ice); color: var(--night); white-space: nowrap;
}
.events .game { font-weight: 800; color: var(--night); }
[data-hide] { display: none !important; }
fieldset { min-width: 0; }
fieldset.wide { grid-column: 1 / -1; }
.field.row label.grow { flex: 1; min-width: 160px; }
.img-preview.square { width: 110px; aspect-ratio: 1; }
.image-box { flex-wrap: wrap; }
.image-actions { min-width: 0; flex: 1 1 160px; }
.image-actions .btn { white-space: normal; text-align: center; }
.table-wrap { overflow-x: auto; }
