/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:         #080e1a;
  --surface:    #111827;
  --surface-2:  #1e2a3a;
  --border:     #1e3050;
  --primary:    #00c853;
  --primary-dk: #009639;
  --gold:       #ffd700;
  --text:       #e2e8f0;
  --muted:      #6b7e9a;
  --red:        #ef4444;
  --blue:       #3b82f6;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(0,0,0,.45);
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Garantit que hidden fonctionne même sur les éléments avec display forcé en CSS */
[hidden] { display: none !important; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); }
code { font-family: 'Courier New', monospace; font-size: .9em; }
.muted { color: var(--muted); font-style: italic; }

/* ── Header ────────────────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky; top: 0; z-index: 100;
}

/* Keendoo brand */
.keendoo-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  flex-shrink: 0;
}
.keendoo-logo {
  height: 32px;
  width: auto;
  display: block;
}
.keendoo-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .02em;
}

.header-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  flex: 1;
  line-height: 1.3;
}
.header-title small { display: block; font-size: .68rem; color: var(--muted); font-weight: 400; }

.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.header-user  { font-size: .85rem; color: var(--primary); font-weight: 600; }

.btn-lang { opacity: .85; }
.btn-lang:hover { opacity: 1; }

/* ── Navigation tabs ───────────────────────────────────────────────────────── */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
}

nav button {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: .9rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color .2s, border-color .2s;
}

nav button:hover { color: var(--text); }
nav button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Main content ──────────────────────────────────────────────────────────── */
main { flex: 1; padding: 20px; max-width: 900px; margin: 0 auto; width: 100%; }

/* ── Footer ────────────────────────────────────────────────────────────────── */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .75rem;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Timezone note ─────────────────────────────────────────────────────────── */
.tz-note {
  font-size: .75rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  margin-bottom: 16px;
}

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 420px;
  margin: 48px auto 0;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo { margin-bottom: 12px; min-height: 36px; }
.login-keendoo-logo { height: 36px; width: auto; margin: 0 auto; display: block; }
.login-flags { font-size: 1.1rem; margin-bottom: 6px; }
.login-icon { font-size: 3rem; margin-bottom: 8px; }
.login-card h1 { font-size: 1.4rem; color: var(--gold); margin-bottom: 4px; }
.login-card p  { color: var(--muted); font-size: .9rem; margin-bottom: 24px; }

.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.form-group input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 1rem;
  transition: border-color .2s;
}
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #000;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
  cursor: pointer;
  transition: background .2s;
  margin-top: 4px;
}
.btn-primary:hover { background: var(--primary-dk); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.error-msg { color: var(--red); font-size: .85rem; margin-top: 12px; min-height: 1.2em; }

/* ── Predictions ───────────────────────────────────────────────────────────── */
.group-section { margin-bottom: 32px; }

.group-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.match-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: border-color .2s;
}
.match-card:not(.locked):hover { border-color: var(--primary); }
.match-card.locked { opacity: .7; }

/* ── Match meta (date + venue) ─────────────────────────────────────────────── */
.match-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.match-date  { font-size: .75rem; color: var(--muted); }
.match-venue { font-size: .72rem; color: var(--muted); flex: 1; }

.match-teams {
  display: flex;
  align-items: center;
  gap: 10px;
}

.team {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .9rem;
  flex-direction: row-reverse;  /* flag côté score, nom vers l'extérieur */
  justify-content: flex-start;  /* flex-start en row-reverse = aligné à droite */
}
.team.right {
  flex-direction: row-reverse;  /* flag côté score, nom vers l'extérieur */
  justify-content: flex-end;    /* flex-end en row-reverse = aligné à gauche */
}

.flag { font-size: 1.3rem; line-height: 1; }
.name { font-weight: 500; }

.score-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.score-input {
  width: 46px;
  height: 42px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  -moz-appearance: textfield;
}
.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.score-input:focus { outline: none; border-color: var(--primary); }

.score-static {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
}

.vs { color: var(--muted); font-size: .8rem; }

.save-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  justify-content: flex-end;
}

.btn-save {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 16px;
  font-size: .82rem;
  cursor: pointer;
  transition: all .2s;
}
.btn-save:hover { background: var(--primary); color: #000; border-color: var(--primary); }

.save-status { font-size: .8rem; color: var(--primary); min-width: 80px; }

/* ── Résultat officiel sur carte verrouillée ───────────────────────────────── */
.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  flex-wrap: wrap;
}

.result-label { color: var(--muted); }
.result-score { font-weight: 700; color: var(--text); }

.result-pts { font-weight: 700; }
.result-pts.pts-exact   { color: var(--gold); }
.result-pts.pts-correct { color: var(--primary); }
.result-pts.pts-wrong   { color: var(--muted); }

/* ── Knockout section ──────────────────────────────────────────────────────── */
.ko-header {
  border-top: 2px solid var(--gold);
  margin-top: 32px;
  padding-top: 20px;
}
.ko-header h2 { font-size: 1.1rem; color: var(--gold); margin-bottom: 0; }

.round-mult-badge {
  display: inline-block;
  background: var(--gold);
  color: #000;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 8px;
  vertical-align: middle;
}

.multiplier-badge {
  background: var(--gold);
  color: #000;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  white-space: nowrap;
}

.round-badge {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 20px;
  color: var(--text);
  margin-right: 4px;
}

/* ── Admin knockout form ───────────────────────────────────────────────────── */
.ko-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.ko-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.ko-form-row .form-group { margin-bottom: 0; }
.ko-form-row .form-group input,
.ko-form-row .form-group select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: .88rem;
}
.ko-select { cursor: pointer; }

/* ── Leaderboard ───────────────────────────────────────────────────────────── */
.leaderboard-header { margin-bottom: 16px; }
.leaderboard-header h2 { font-size: 1.1rem; color: var(--gold); }
.leaderboard-header p  { font-size: .8rem; color: var(--muted); }
.last-update-info { font-size: .75rem; color: var(--muted); margin-top: 4px; font-style: italic; }

/* ── Own row highlight ──────────────────────────────────────────────────────── */
tr.own-row { background: rgba(0, 200, 83, 0.07); }
tr.own-row td { color: var(--primary); font-weight: 600; }

/* ── Countdown ──────────────────────────────────────────────────────────────── */
.countdown { font-size: .75rem; color: var(--primary); font-weight: 600; }

/* ── Next match banner ──────────────────────────────────────────────────────── */
.next-match-banner {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.next-match-banner.nm-warn { border-left-color: var(--gold); }
.nm-label   { font-size: .68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.nm-main    { display: flex; align-items: center; gap: 12px; }
.nm-left    { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.nm-teams   { font-size: .95rem; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nm-vs      { color: var(--muted); font-size: .8rem; font-weight: 400; }
.nm-date    { font-size: .72rem; color: var(--muted); margin-bottom: 2px; }
.nm-countdown-box {
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 14px;
  text-align: center;
  flex-shrink: 0;
}
.nm-countdown { font-size: 1.05rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
#nm-prono   { font-size: .82rem; }
.nm-prono-ok   { color: var(--primary); }
.nm-prono-warn { color: var(--gold); font-weight: 700; }

/* ── Urgent banner ──────────────────────────────────────────────────────────── */
.urgent-banner { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; }
.urgent-banner .urgent-title { font-size: .8rem; font-weight: 700; color: var(--gold); margin-bottom: 10px; }
.urgent-list { display: flex; flex-direction: column; gap: 6px; }
.urgent-item { display: flex; align-items: center; gap: 10px; font-size: .82rem; padding: 5px 8px; border-radius: 6px; background: var(--surface); }
.urgent-teams { flex: 1; }
.urgent-vs { color: var(--muted); margin: 0 4px; }
.urgent-time { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.urgent-badge { font-weight: 700; font-size: .9rem; width: 20px; text-align: center; }
.urgent-item.urgent-ok .urgent-badge { color: var(--primary); }
.urgent-item.urgent-missing { border-left: 3px solid var(--gold); }
.urgent-item.urgent-missing .urgent-badge { color: var(--gold); }

/* ── Match stats ────────────────────────────────────────────────────────────── */
.match-stats { padding: 8px 12px 4px; border-top: 1px solid var(--border); }
.stats-bar { display: flex; height: 18px; border-radius: 4px; overflow: hidden; margin-bottom: 4px; gap: 1px; }
.sb-home { background: var(--blue); display: flex; align-items: center; justify-content: center; font-size: .65rem; font-weight: 700; color: #fff; min-width: 24px; }
.sb-draw { background: var(--muted); display: flex; align-items: center; justify-content: center; font-size: .65rem; font-weight: 700; color: #fff; min-width: 24px; }
.sb-away { background: var(--red); display: flex; align-items: center; justify-content: center; font-size: .65rem; font-weight: 700; color: #fff; min-width: 24px; }
.stats-detail { font-size: .7rem; color: var(--muted); }

/* ── Evolution chart ────────────────────────────────────────────────────────── */
.chart-container { margin-top: 28px; }
.chart-title { font-size: .9rem; color: var(--gold); margin-bottom: 12px; }
#evolution-chart { max-height: 320px; }

.scoring-legend {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: .82rem;
  color: var(--muted);
}
.scoring-legend span { color: var(--text); }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--surface-2);
  padding: 10px 14px;
  text-align: left;
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

tbody tr { border-top: 1px solid var(--border); }
tbody td { padding: 12px 14px; font-size: .9rem; }

.top-1 td { background: rgba(255, 215, 0, .08); }
.top-2 td { background: rgba(192, 192, 192, .06); }
.top-3 td { background: rgba(205, 127, 50, .06); }

td.rank  { font-size: 1rem; width: 50px; }
td.pseudo { font-weight: 600; }
td.pts   { color: var(--primary); white-space: nowrap; }
td.detail { color: var(--muted); font-size: .8rem; }

/* ── Button: logout ────────────────────────────────────────────────────────── */
.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: .8rem;
  line-height: 1.2;
  cursor: pointer;
  transition: all .2s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text); }

/* ── Admin styles ──────────────────────────────────────────────────────────── */
#admin-nav {
  display: flex;
  gap: 4px;
  padding: 16px 0 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
#admin-nav button {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
  padding: 8px 18px 10px;
  transition: color .15s, border-color .15s;
}
#admin-nav button:hover { color: var(--text); }
#admin-nav button.active { color: var(--primary); border-bottom-color: var(--primary); }

.admin-section { margin-bottom: 36px; }
.admin-section h2 { font-size: 1rem; color: var(--gold); margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }

.btn-sm {
  padding: 4px 10px;
  font-size: .78rem;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  transition: all .2s;
}
.btn-sm:hover { background: var(--primary); color: #000; border-color: var(--primary); }
.btn-sm.danger { border-color: var(--red); color: var(--red); }
.btn-sm.danger:hover { background: var(--red); color: #fff; }
.btn-sm:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

.has-result { color: var(--primary); font-weight: 600; }
.no-result  { color: var(--muted); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: min(400px, 95vw);
  box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 20px; color: var(--gold); }
.modal .score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.modal .score-row input {
  width: 70px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  padding: 8px;
  -moz-appearance: textfield;
}
.modal .score-row input::-webkit-outer-spin-button,
.modal .score-row input::-webkit-inner-spin-button { -webkit-appearance: none; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.codes-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.codes-controls input {
  width: 70px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font-size: .9rem;
  text-align: center;
}

/* ── Predictions layout (sidebar + content) ────────────────────────────────── */
.predictions-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.group-sidebar {
  width: 190px;
  flex-shrink: 0;
  position: sticky;
  top: 52px;
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.predictions-content { flex: 1; min-width: 0; }

.group-sidebar-btn {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--text);
  transition: border-color .15s, background .15s;
}

.group-sidebar-btn:hover { border-color: var(--muted); background: var(--surface-2); }

.group-sidebar-btn.active {
  border-color: var(--primary);
  background: var(--surface-2);
}

.gsb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.gsb-ko .gsb-header { margin-bottom: 0; }

.gsb-letter {
  font-size: .8rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: .04em;
}

.gsb-badge {
  background: #f59e0b;
  color: #1a0a00;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 7px;
  line-height: 1.5;
}

.gsb-ok {
  font-size: .75rem;
  color: var(--primary);
  font-weight: 700;
}

.gsb-teams {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gsb-team {
  font-size: .72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── My Results ────────────────────────────────────────────────────────────── */
.results-section { margin-bottom: 28px; }

.results-group-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 6px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.results-table { width: 100%; }
.results-table td, .results-table th { padding: 7px 10px; font-size: .82rem; }
.results-table tbody tr:hover { background: var(--surface-2); }

.res-match  { color: var(--text); }
.res-prono  { color: var(--muted); text-align: center; }
.res-result { text-align: center; }
.res-pts    { text-align: center; width: 64px; }

.results-total {
  text-align: right;
  font-size: .95rem;
  padding: 12px 4px;
  border-top: 2px solid var(--border);
  color: var(--muted);
}
.results-total strong { color: var(--gold); font-size: 1.1rem; margin-left: 4px; }

/* ── Rules view ─────────────────────────────────────────────────────────────── */
.rules-body { max-width: 700px; line-height: 1.75; }
.rules-body h2 { font-size: 1.15rem; color: var(--gold); margin: 0 0 12px; }
.rules-body h3 { font-size: .95rem; color: var(--primary); margin: 24px 0 10px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.rules-body h4 { font-size: .875rem; color: var(--text); margin: 16px 0 8px; }
.rules-body p  { margin-bottom: 10px; color: var(--text); }
.rules-body ol, .rules-body ul { padding-left: 22px; margin-bottom: 12px; }
.rules-body li { margin-bottom: 6px; }
.rules-body blockquote {
  background: var(--surface-2); border-left: 3px solid var(--primary);
  padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0;
  margin: 12px 0; font-size: .875rem; color: var(--text);
}
.rules-body table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.rules-body th, .rules-body td { border: 1px solid var(--border); padding: 8px 12px; font-size: .85rem; text-align: left; }
.rules-body th { background: var(--surface-2); color: var(--gold); }
.rules-welcome { color: var(--muted) !important; margin-bottom: 4px !important; }
#btn-rules-back { margin-bottom: 20px; }
.login-rules-link { text-align: center; margin-top: 16px; }
.login-rules-link a { color: var(--muted); font-size: .85rem; text-decoration: none; transition: color .15s; }
.login-rules-link a:hover { color: var(--primary); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .name { font-size: .8rem; }
  .flag { font-size: 1.1rem; }
  .score-input { width: 40px; height: 38px; font-size: 1rem; }
  main { padding: 14px; }
  .scoring-legend { gap: 10px; }
  td.detail { display: none; }

  .predictions-layout { flex-direction: column; gap: 8px; }

  .group-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    position: static;
    max-height: none;
    padding-bottom: 4px;
  }

  .group-sidebar-btn { width: auto; flex-shrink: 0; }
  .gsb-teams { display: none; }
  .gsb-header { margin-bottom: 0; }
}
