:root {
  --bg: #0b1a14;
  --bg-2: #10241c;
  --card: #132d23;
  --line: #22493a;
  --text: #eef5f1;
  --muted: #8fb3a3;
  --red: #e5484d;
  --red-soft: #3a1a1c;
  --green: #3ddc84;
  --green-soft: #173b2b;
  --gold: #f5c542;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: radial-gradient(ellipse at top, #17382b 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Flocons de neige (générés par common.js) */
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.flake {
  position: absolute; top: -2em; color: #fff; line-height: 1; user-select: none;
  animation: flake-fall linear infinite;
}
.flake span { display: inline-block; animation: flake-sway ease-in-out infinite alternate; }
@keyframes flake-fall { to { transform: translateY(calc(100vh + 4em)) rotate(240deg); } }
@keyframes flake-sway { from { transform: translateX(-24px); } to { transform: translateX(24px); } }
@media (prefers-reduced-motion: reduce) {
  .flake, .flake span { animation: none; }
  .flake { top: var(--rest-top); }
}

.hero, main { position: relative; z-index: 1; max-width: 900px; margin: 0 auto; padding: 0 16px; }

.hero { padding-top: 48px; padding-bottom: 24px; text-align: center; }
.eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: .15em; font-size: .8rem; font-weight: 600; margin: 0; }
h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1.6rem, 6vw, 2.8rem);
  margin: 16px 0;
  color: var(--text);
  text-shadow: 3px 3px 0 var(--red);
}
.address { font-weight: 600; margin: 0 0 12px; }
.intro { color: var(--muted); max-width: 620px; margin: 0 auto; }

h2 { margin: 0 0 4px; font-size: 1.3rem; }
.hint { color: var(--muted); margin: 0 0 16px; font-size: .95rem; }
.muted { color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  scroll-margin-top: 72px;
}

/* Formulaires */
input {
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
}
input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }

.btn {
  font: inherit; font-weight: 600;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--red); border-color: var(--red); }
.btn.primary:hover { filter: brightness(1.1); }
.link { background: none; border: none; color: var(--gold); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }

.login { max-width: 420px; margin: 0 auto 48px; }
.login form { display: grid; gap: 16px; margin-top: 16px; }
.error { color: var(--red); margin: 0; min-height: 1.5em; }

.inline-form { display: flex; gap: 8px; margin-top: 16px; }
.game-form { display: grid; grid-template-columns: 2fr 1fr 3fr auto; gap: 8px; margin-bottom: 16px; }

/* Navigation */
.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center;
  padding: 12px 16px; margin-bottom: 24px;
  background: rgba(11, 26, 20, .9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tabs a { color: var(--text); text-decoration: none; font-weight: 600; }
.tabs a:hover { color: var(--gold); }
.whoami { margin-left: auto; color: var(--muted); font-size: .9rem; }

/* Votes */
.vote-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.vote-item {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.vote-item.leading { border-color: var(--gold); }
.vote-title { font-weight: 600; }
.meta { color: var(--muted); font-size: .85rem; }
.count { font-family: 'Press Start 2P', monospace; font-size: 1rem; color: var(--gold); }
.badge { background: var(--gold); color: #1a1a1a; font-size: .7rem; padding: 2px 8px; border-radius: 99px; margin-left: 6px; vertical-align: middle; }
.empty { padding: 12px; }

.vote-btn {
  font: inherit; font-weight: 600; font-size: .9rem;
  min-width: 120px; padding: 8px 12px;
  border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--text);
  border: 1px dashed var(--muted);
}
#game-list .vote-btn { min-width: 64px; }
.vote-btn:hover { border-color: var(--green); }
.vote-btn.on { background: var(--green-soft); border: 1px solid var(--green); color: var(--green); }

.del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 4px; }
.del:hover { color: var(--red); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font-size: .78rem; padding: 2px 8px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); }
.chip.me { border-color: var(--gold); color: var(--gold); }

/* Checklist */
.checklist { display: grid; gap: 10px; }
.check-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
}
.check-label { font-weight: 600; }
.icon { display: inline-block; width: 1.8em; }
.spots { font-weight: 400; font-size: .8rem; color: var(--gold); margin-left: 1.8em; }
.segmented { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg {
  font: inherit; font-size: .85rem;
  background: transparent; color: var(--muted);
  border: none; border-right: 1px solid var(--line);
  padding: 8px 12px; cursor: pointer;
}
.seg:last-child { border-right: none; }
.seg:hover { color: var(--text); }
.seg.on.have { background: var(--green-soft); color: var(--green); font-weight: 600; }
.seg.on.need { background: var(--red-soft); color: var(--red); font-weight: 600; }
.seg.on.none { background: var(--card); color: var(--text); }

/* Récap */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; font-weight: 600; }
th { color: var(--muted); font-weight: 500; }
tr.me td:first-child { color: var(--gold); }
tr.totals td { font-weight: 600; border-bottom: none; border-top: 2px solid var(--line); }
.have { color: var(--green); }
.need { color: var(--red); font-weight: 600; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 100px);
  background: var(--red); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-weight: 600; transition: transform .25s; z-index: 10;
}
.toast.show { transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .card { padding: 16px; }
  .game-form { grid-template-columns: 1fr 1fr; }
  .game-form input[name="title"], .game-form input[name="note"] { grid-column: 1 / -1; }
  .vote-item { grid-template-columns: 1fr auto auto; }
  .vote-btn { grid-column: 1 / -1; min-width: 0; }
  .segmented { width: 100%; }
  .seg { flex: 1; padding: 8px 6px; }
  .whoami { margin-left: 0; width: 100%; }
}

/* ---------- Tournois ---------- */
.hero-small { padding-top: 32px; padding-bottom: 16px; }
.tab-page { margin-left: auto; color: var(--gold) !important; }

select {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
.tournament-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.tournament-form .btn { grid-column: 1 / -1; }

.tournament-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.champion {
  background: linear-gradient(90deg, rgba(245, 197, 66, .2), transparent);
  border-left: 3px solid var(--gold); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px;
}

.teams { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 16px; }
.team { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }

.round-title { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; margin-bottom: 8px; }

.bracket { display: flex; gap: 24px; overflow-x: auto; padding-bottom: 8px; }
.round { display: flex; flex-direction: column; justify-content: space-around; gap: 12px; min-width: 170px; }
.round-title { text-align: center; }
.match { display: grid; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg-2); }
.match.bye { opacity: .5; }

.side {
  font: inherit; font-size: .9rem; text-align: left;
  background: transparent; color: var(--text);
  border: none; border-bottom: 1px solid var(--line);
  padding: 8px 12px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side:last-child { border-bottom: none; }
.side:hover:not(:disabled) { background: var(--card); }
.side:disabled { cursor: default; }
.side.won { background: var(--green-soft); color: var(--green); font-weight: 700; }
.side.won::after { content: ' ✔'; }
.side.lost { color: var(--muted); text-decoration: line-through; }

.league-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.league-match {
  display: grid; grid-template-columns: 1fr auto 1fr; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg-2);
}
.league-match .side { border-bottom: none; border-right: 1px solid var(--line); }
.league-match .side:last-child { border-right: none; text-align: right; }
.league-match .side.draw { text-align: center; color: var(--muted); font-size: .8rem; }
.league-match .side.draw.won { color: var(--gold); background: rgba(245, 197, 66, .12); }
.league-match .side.draw.won::after { content: ''; }
.standings td:nth-child(2) { text-align: left; }

@media (max-width: 640px) {
  .tournament-form { grid-template-columns: 1fr; }
  .tab-page { margin-left: 0; }
}

/* ---------- Admin ---------- */
.btn.small { padding: 4px 10px; font-size: .8rem; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
#account-table td:first-child { font-weight: 600; }
tr.is-hidden td:first-child { color: var(--muted); font-style: italic; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--gold); cursor: pointer; }

/* ---------- Messages ---------- */
.message-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; margin: 12px 0 16px; }
textarea {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  width: 100%; resize: vertical; min-height: 44px;
}
textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.message-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; max-height: 420px; overflow-y: auto; }
.message { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.message.mine { border-left: 3px solid var(--gold); }
.message-head { display: flex; align-items: baseline; gap: 10px; font-size: .9rem; }
.message-head .del { margin-left: auto; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
@media (max-width: 640px) { .message-form { grid-template-columns: 1fr; } }

/* ---------- Choix des week-ends ---------- */
.date-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.date-form select, .date-form input { flex: 1 1 220px; width: auto; }

/* ---------- Modification d'un jeu ---------- */
.owner-actions { display: flex; flex-direction: column; gap: 2px; }
.vote-item.editing { display: block; border-color: var(--gold); }
.game-edit { margin: 0; }
.edit-actions { display: flex; gap: 8px; }
@media (max-width: 640px) {
  .owner-actions { flex-direction: row; }
  .edit-actions { grid-column: 1 / -1; }
}

/* ---------- Modification d'un tournoi ---------- */
.tournament.editing { border-color: var(--gold); }
.tournament-edit { margin-top: 12px; }
.tournament-edit .full { grid-column: 1 / -1; margin: 0; }
select:disabled, input:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Équipes créées par les joueurs ---------- */
/* Une ligne par équipe : nom + remplissage | membres | action | suppression */
.team { display: grid; grid-template-columns: minmax(140px, max-content) 1fr auto 24px; gap: 12px; align-items: center; }
.team .chips { margin-top: 0; }
.team.mine { border-color: var(--gold); }
.team-head { display: flex; align-items: baseline; gap: 8px; }
.create-team { grid-template-columns: 1fr auto; border-style: dashed; }
.create-team input { padding: 6px 10px; }
@media (max-width: 640px) {
  .team { grid-template-columns: 1fr auto; }
  .team .chips { grid-column: 1 / -1; grid-row: 2; }
}
.small-text { font-size: .8rem; }
