:root {
  --void: #0a0414;
  --plum: #170a2c;
  --plum-2: #231043;
  --line: rgba(197, 139, 255, .18);
  --violet: #8b3dff;
  --orchid: #c58bff;
  --gold: #f2c14e;
  --gold-hi: #ffe7a3;
  --ember: #ff5a3c;
  --danger: #e5484d;
  --ok: #3ecf8e;
  --ink: #fbf6ff;
  --muted: #a99bbf;
  --display: "Big Shoulders Display", "Oswald", "Arial Narrow", Impact, sans-serif;
  --text: "Sora", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: var(--text);
  font-size: 15px;
  color: var(--ink);
  background: radial-gradient(ellipse at 20% -10%, #2b1157 0, transparent 55%), var(--void);
}
h2 { margin: 0 0 14px; font-size: 17px; font-weight: 700; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

.brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: 64px;
  line-height: .9;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(242, 193, 78, .35);
}
.brand.small { font-size: 36px; }

/* ----- Connexion ----- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 32px;
  border-radius: 24px;
  background: var(--plum);
  box-shadow: inset 0 0 0 1px var(--line), 0 30px 80px rgba(0, 0, 0, .5);
}
.login-box p { margin: 0 0 12px; color: var(--muted); }
.login-box label { font-weight: 600; }
.error { color: #ff8a8d; min-height: 1.2em; margin: 4px 0 0 !important; }

input {
  min-width: 0;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
  box-shadow: inset 0 0 0 1px var(--line);
}
input:focus { box-shadow: inset 0 0 0 2px var(--violet); outline: none; }

/* ----- Boutons ----- */
.btn {
  min-height: 56px;
  padding: 12px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--plum-2);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, opacity .15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.2); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .28; cursor: not-allowed; }
.btn.small { min-height: 44px; font-size: 14px; }
.btn.huge { width: 100%; min-height: 76px; font-size: 22px; }
.btn.gold { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #2a1600; box-shadow: 0 0 24px rgba(242, 193, 78, .25); }
.btn.ember { background: var(--ember); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-soft { background: rgba(229, 72, 77, .18); box-shadow: inset 0 0 0 1px rgba(229, 72, 77, .6); }
.btn.ghost { background: transparent; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; }

/* ----- Mise en page ----- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.pills { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.pill { padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: rgba(255, 255, 255, .06); }
.pill.ok { background: rgba(62, 207, 142, .16); color: var(--ok); }
.pill.bad { background: rgba(229, 72, 77, .2); color: #ff8a8d; }
.pill.warn { background: rgba(242, 193, 78, .16); color: var(--gold); }

.grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 24px; padding: 24px; max-width: 1500px; margin: 0 auto; }
@media (max-width: 1000px) { .grid { grid-template-columns: 1fr; } }
.col { display: flex; flex-direction: column; gap: 20px; }

.panel { padding: 20px; border-radius: 20px; background: var(--plum); box-shadow: inset 0 0 0 1px var(--line); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.count { font-family: var(--display); font-weight: 900; font-size: 32px; color: var(--gold); }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.row input { flex: 1 1 140px; }
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.empty { color: var(--muted); list-style: none; }

/* ----- Statut de la partie ----- */
.status {
  padding: 26px 28px;
  border-radius: 24px;
  background: linear-gradient(150deg, #2a1150, #12071f);
  box-shadow: inset 0 0 0 1.5px rgba(242, 193, 78, .35);
}
.status-phase { font-weight: 700; color: var(--orchid); font-size: 16px; }
.status-big {
  margin: 4px 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: 72px;
  line-height: 1;
  overflow-wrap: anywhere;
}
.status-sub { color: var(--muted); font-size: 16px; }
.status[data-phase="registration"] { box-shadow: inset 0 0 0 2px var(--violet), 0 0 40px rgba(139, 61, 255, .35); }
.status[data-phase="exploding"] { box-shadow: inset 0 0 0 2px var(--ember), 0 0 40px rgba(255, 90, 60, .35); }
.status[data-phase="finished"] .status-big { color: var(--gold); }
.status.paused .status-phase::after { content: "  En pause"; color: var(--gold); }

.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.controls #btnClose { grid-column: 1 / -1; }
@media (max-width: 560px) { .controls { grid-template-columns: 1fr 1fr; } }

/* ----- Joueurs ----- */
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; max-height: 340px; overflow: auto; }
.players li { padding: 5px 10px; border-radius: 9px; background: rgba(139, 61, 255, .16); font-size: 14px; font-weight: 600; }
.players li.dead { background: transparent; color: var(--muted); text-decoration: line-through; box-shadow: inset 0 0 0 1px var(--line); }
.players li.holder { background: var(--ember); color: #fff; }
.players li.winner { background: var(--gold); color: #2a1600; }
.players li small { opacity: .7; margin-left: 4px; text-decoration: none; }

.chat { list-style: none; margin: 0; padding: 0; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.chat b { color: var(--orchid); }
.chat .tag { margin-left: 6px; font-size: 12px; padding: 1px 7px; border-radius: 6px; background: rgba(255, 255, 255, .08); }
.chat .tag.ok { background: rgba(62, 207, 142, .2); color: var(--ok); }

/* ----- Cagnotte ----- */
.pot-amount { font-family: var(--display); font-weight: 900; font-size: 64px; line-height: 1; color: var(--gold); }
.pot-sub { color: var(--muted); margin-top: 4px; }

/* ----- Nouvelle manche ----- */
.field-label { display: block; margin: 12px 0 8px; font-weight: 600; color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  min-height: 48px;
  min-width: 68px;
  padding: 8px 14px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
  box-shadow: inset 0 0 0 1px var(--line);
  font-weight: 700;
  cursor: pointer;
}
.chips button.sel { background: var(--violet); box-shadow: 0 0 18px rgba(139, 61, 255, .55); }
.chips input { width: 110px; flex: 0 1 110px; }
.chips input.sel { box-shadow: inset 0 0 0 2px var(--violet); }
.after { min-height: 1.3em; margin: 14px 0 10px; color: var(--muted); }
.after.bad { color: #ff8a8d; }

/* ----- Réglages ----- */
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary h2 { display: inline; }
details summary::after { content: " +"; color: var(--muted); }
details[open] summary::after { content: " −"; }
.settings { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.settings fieldset { margin: 0; padding: 12px 14px 14px; border: 1px solid var(--line); border-radius: 14px; display: flex; gap: 12px; flex-wrap: wrap; }
.settings legend { padding: 0 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.settings label { display: flex; align-items: center; gap: 8px; flex: 1 1 150px; font-size: 14px; }
.settings label input { width: 90px; }
.check { gap: 10px !important; }
.check input { width: 22px !important; height: 22px; accent-color: var(--violet); }

/* ----- Historique ----- */
.table-wrap { overflow-x: auto; }
.history { width: 100%; border-collapse: collapse; font-size: 14px; }
.history th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.history td { padding: 8px; border-bottom: 1px solid rgba(255, 255, 255, .04); vertical-align: top; }
.history .win { color: var(--gold); font-weight: 700; }
.history .void { color: var(--muted); }
.history details { margin-top: 4px; color: var(--muted); font-size: 12px; }

.test { box-shadow: inset 0 0 0 1px rgba(242, 193, 78, .4); }

/* ----- Notifications ----- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 120px);
  max-width: min(640px, calc(100% - 32px));
  padding: 14px 20px;
  border-radius: 14px;
  background: var(--plum-2);
  box-shadow: inset 0 0 0 1px var(--line), 0 20px 50px rgba(0, 0, 0, .5);
  font-weight: 600;
  transition: transform .3s ease;
  z-index: 10;
}
.toast.on { transform: translate(-50%, 0); }
.toast.err { background: #4a1418; box-shadow: inset 0 0 0 1px var(--danger); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ----- Roue du mois ----- */
.segs { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.segs li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .04); box-shadow: inset 0 0 0 1px var(--line); }
.segs .amt { font-family: var(--display); font-weight: 900; font-size: 28px; color: var(--gold); min-width: 92px; }
.segs .pct { color: var(--muted); font-size: 13px; min-width: 44px; }
.segs .st { flex: 1; font-size: 14px; }
.segs li.taken .amt { color: var(--muted); text-decoration: line-through; }
.segs li.locked .st { color: var(--gold); }
.segs button { min-height: 36px; padding: 4px 10px; font-size: 12px; }
.newmonth { margin-top: 16px; }
.newmonth summary { cursor: pointer; font-weight: 600; color: var(--orchid); }
.nm-body { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.nm-rows { display: flex; flex-wrap: wrap; gap: 8px; }
.nm-rows .nm-row { display: flex; align-items: center; gap: 4px; }
.nm-rows input { width: 76px; }
.nm-rows button { min-height: 40px; width: 40px; padding: 0; border: 0; border-radius: 10px; background: rgba(255,255,255,.06); cursor: pointer; }
.spin-btn { min-height: 96px; font-size: 30px; animation: glowPulse 1.2s ease-in-out infinite alternate; }
@keyframes glowPulse { to { box-shadow: 0 0 48px rgba(242, 193, 78, .7); } }
.status[data-phase="wheel_ready"], .status[data-phase="wheel_spinning"] { box-shadow: inset 0 0 0 2px var(--gold), 0 0 40px rgba(242, 193, 78, .3); }

.version { color: var(--muted); font-size: 12px; white-space: nowrap; }

.intro-btn { width: 100%; background: linear-gradient(90deg, #6d28d9, #a855f7); color: #fff; font-size: 18px; letter-spacing: .02em; }
.intro-row { display: flex; gap: 10px; }
.intro-row .intro-btn { flex: 1; }
#btnIntroStop { min-width: 120px; }
