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

:root {
  /* Core palette */
  --navy:        #0a1628;
  --navy-mid:    #0f2044;
  --navy-soft:   #1a3057;
  --accent:      #c8a84b;   /* FIFA gold */
  --accent-dim:  #a8893a;
  --accent-bg:   #fdf8ee;
  --accent-glow: rgba(200,168,75,0.25);
  --red-brand:   #cc0000;

  /* Surface */
  --bg:          #f4f6f9;
  --bg2:         #ffffff;
  --bg3:         #f0f3f7;
  --bg4:         #e4e9f0;
  --border:      #d0d8e4;
  --border-light:#e8ecf2;

  /* Status */
  --green:       #059669;
  --green-bg:    #ecfdf5;
  --green-border:#a7f3d0;
  --blue:        #1d4ed8;
  --blue-light:  #eff6ff;
  --blue-border: #bfdbfe;
  --red:         #dc2626;

  /* Text */
  --text:        #0a1628;
  --text2:       #3d5278;
  --text3:       #7a92b4;

  /* Misc */
  --radius:      10px;
  --radius-lg:   16px;
  --shadow-sm:   0 1px 4px rgba(10,22,40,0.08), 0 1px 2px rgba(10,22,40,0.04);
  --shadow:      0 4px 18px rgba(10,22,40,0.1), 0 2px 6px rgba(10,22,40,0.06);
  --shadow-lg:   0 12px 48px rgba(10,22,40,0.16);
  --transition:  0.15s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* ── HEADER ──────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 60%, #1a2e5a 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(10,22,40,0.4);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-title { display: flex; align-items: center; gap: 14px; }

.header-logo-wrap {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  flex-shrink: 0;
}
.trophy { font-size: 1.4rem; line-height: 1; }

.header-title h1 {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}
.subtitle {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
  margin-top: 1px;
  letter-spacing: 0.02em;
}

.header-actions { display: flex; align-items: center; gap: 6px; }

.header-social {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 8px;
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  transition: all 0.18s ease;
  text-decoration: none;
  flex-shrink: 0;
}
.header-social:hover {
  color: var(--accent);
  background: rgba(200,168,75,0.15);
  border-color: rgba(200,168,75,0.35);
  transform: translateY(-1px);
}

/* ── HERO BANNER ─────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 50%, #1a3a6a 100%);
  color: #fff;
  padding: 52px 24px 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 80% at 20% 50%, rgba(200,168,75,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 50%, rgba(200,168,75,0.06) 0%, transparent 70%);
  pointer-events: none;
}
.hero-inner { position: relative; max-width: 700px; margin: 0 auto; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(200,168,75,0.15);
  border: 1px solid rgba(200,168,75,0.35);
  color: var(--accent);
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 5px 14px; border-radius: 20px;
  margin-bottom: 18px;
}
.hero h2 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 14px;
}
.hero h2 span { color: var(--accent); }
.hero-sub {
  font-size: 1rem;
  color: rgba(255,255,255,0.65);
  max-width: 480px;
  margin: 0 auto 28px;
  line-height: 1.65;
}
.hero-cta {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent);
  color: var(--navy);
  font-size: 0.875rem; font-weight: 800;
  padding: 12px 28px; border-radius: 10px;
  text-decoration: none;
  border: none; cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.01em;
}
.hero-cta:hover { background: #d4b45a; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(200,168,75,0.4); }

/* ── PROGRESS STRIP ──────────────────────────────── */
.progress-strip {
  background: var(--navy-mid);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 0 24px;
}
.progress-inner {
  max-width: 1440px; margin: 0 auto;
  display: flex; align-items: center; gap: 0;
}
.progress-step {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px 14px 0;
  color: rgba(255,255,255,0.4);
  font-size: 0.78rem; font-weight: 600;
  transition: color var(--transition);
}
.progress-step.active { color: var(--accent); }
.progress-step.done   { color: rgba(255,255,255,0.65); }
.step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 900;
  flex-shrink: 0;
}
.progress-step.done .step-num { background: var(--green); border-color: var(--green); color: #fff; }
.progress-step.active .step-num { background: var(--accent); border-color: var(--accent); color: var(--navy); }
.step-sep { color: rgba(255,255,255,0.15); font-size: 0.8rem; padding: 0 4px; }

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 44px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1a45c4; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.15);
}
.btn-secondary:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.25); }

.btn-ghost {
  background: #fff; color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); border-color: var(--text3); }

.btn-simulate {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  color: var(--navy);
  border: none; font-weight: 800;
}
.btn-simulate:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 4px 14px var(--accent-glow); }

/* ── MAIN ────────────────────────────────────────── */
main { max-width: 1440px; margin: 0 auto; padding: 36px 24px 80px; }

/* ── SECTION HEADERS ─────────────────────────────── */
.section-header { margin-bottom: 20px; }
.section-header-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.section-header-row h2 { margin: 0; }
.section-header .hint { margin: 0; }

.section-tag {
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.step-badge {
  width: 28px; height: 28px;
  background: var(--navy);
  color: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 900;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.section-label {
  font-size: 0.65rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text3);
}

.section-header h2 {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
}

.hint { font-size: 0.82rem; color: var(--text3); margin-top: 4px; line-height: 1.6; }
.badge-gold { color: var(--accent); font-weight: 700; }
.badge-silver { color: var(--text2); font-weight: 600; }

#groups-section { margin-bottom: 56px; }
#thirds-section { margin-bottom: 56px; }

/* ── SECTION DIVIDER ─────────────────────────────── */
.section-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 0 0 56px;
}

/* ── GROUPS GRID ─────────────────────────────────── */
.groups-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 560px)  { .groups-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px)  { .groups-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .groups-grid { grid-template-columns: repeat(4, 1fr); } }

/* ── GROUP CARD ──────────────────────────────────── */
.group-card {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.group-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.group-header {
  padding: 12px 14px 10px;
  background: var(--navy);
  display: flex;
  align-items: center;
  gap: 10px;
}
.group-header-badge {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; font-weight: 900; color: var(--navy);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.group-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* Group table */
.group-table {
  width: 100%;
  border-collapse: collapse;
}
.group-table thead th {
  padding: 6px 6px;
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  background: var(--bg3);
  border-bottom: 1px solid var(--border-light);
}
.group-table thead th.th-team { text-align: left; padding-left: 12px; }

.group-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
  cursor: grab;
}
.group-table tbody tr:last-child { border-bottom: none; }
.group-table tbody tr:hover { background: var(--bg3); }
.group-table tbody tr.dragging { opacity: 0.96; }
.group-table tbody tr.drag-over { background: var(--blue-light); outline: 2px solid var(--blue); outline-offset: -2px; }

/* Row qualification coloring */
.group-table tbody tr.rank-1 td.td-rank { border-left: 3px solid var(--accent); }
.group-table tbody tr.rank-2 td.td-rank { border-left: 3px solid #94a3b8; }
.group-table tbody tr.rank-3.third-selected td.td-rank { border-left: 3px solid var(--green); }
.group-table tbody tr.rank-3.third-selected { background: var(--green-bg); }
.group-table tbody tr.rank-3.third-selected:hover { background: #d1fae5; }

.group-table td {
  padding: 9px 6px;
  font-size: 0.78rem;
  color: var(--text);
  text-align: center;
  vertical-align: middle;
}
.group-table td.td-rank {
  width: 28px;
  font-size: 0.7rem; font-weight: 700;
  color: var(--text3);
  padding-left: 10px;
  border-left: 3px solid transparent;
}
.group-table td.td-team { text-align: left; min-width: 110px; }
.td-team-inner { display: flex; align-items: center; gap: 8px; }
.team-flag { font-size: 1.15rem; flex-shrink: 0; line-height: 1; }
.team-name {
  font-size: 0.78rem; font-weight: 600;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 90px;
}

/* Move controls */
.group-table td.td-actions { width: 32px; padding: 4px; }
.move-controls { display: flex; flex-direction: column; gap: 0; align-items: center; }
.move-btn {
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg2);
  color: var(--text3);
  cursor: pointer;
  font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 900px) {
  .move-btn { width: 28px; height: 22px; font-size: 0.6rem; border-radius: 4px; }
}
.move-btn:hover { background: var(--navy); color: var(--accent); border-color: var(--navy); }
.move-btn:disabled { opacity: 0.2; cursor: not-allowed; }

/* Qualify 3rd button */
.group-table td.td-qualify { width: 36px; text-align: center; padding: 4px; }
.qualify-third-btn {
  background: var(--bg2);
  color: var(--text3);
  border: 1px solid var(--border);
  cursor: pointer;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 0.8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 900px) {
  .qualify-third-btn { width: 30px; height: 30px; font-size: 0.7rem; }
}
.qualify-third-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-bg); }
.qualify-third-btn.selected { background: var(--green); color: #fff; border-color: var(--green); }

/* Group footer */
.group-footer {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg3);
  border-top: 1px solid var(--border-light);
}
.qualify-tag {
  font-size: 0.62rem; font-weight: 700;
  padding: 3px 9px; border-radius: 4px;
  display: flex; align-items: center; gap: 4px;
}
.qualify-tag.auto { background: var(--accent-bg); color: var(--accent-dim); border: 1px solid rgba(200,168,75,0.3); }
.qualify-tag.third { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }

/* ── THIRDS SECTION ──────────────────────────────── */
.thirds-table-container {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  max-width: 580px;
}

.thirds-table {
  width: 100%;
  border-collapse: collapse;
}
.thirds-table thead th {
  padding: 6px 6px;
  font-size: 0.6rem; font-weight: 800;
  color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.06em;
  text-align: center;
  background: var(--bg3);
  border-bottom: 1px solid var(--border-light);
}
.thirds-table thead th.th-team { text-align: left; padding-left: 12px; }
.thirds-table thead th.th-status { text-align: left; }

.thirds-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
  cursor: grab;
}
.thirds-table tbody tr:last-child { border-bottom: none; }
.thirds-table tbody tr:hover { background: var(--bg3); }
.thirds-table tbody tr.dragging { opacity: 0.96; }
.thirds-table tbody tr.drag-over { background: var(--blue-light); outline: 2px solid var(--blue); outline-offset: -2px; }

.third-row.third-qualified { background: var(--green-bg); }
.third-row.third-qualified:hover { background: #d1fae5; }
.third-row.third-eliminated { opacity: 0.45; }
.third-row.third-cutoff { border-bottom: 2px dashed var(--accent) !important; }

.thirds-table td { padding: 8px 6px; font-size: 0.78rem; text-align: center; vertical-align: middle; }
.thirds-table td.td-rank { width: 30px; font-size: 0.7rem; font-weight: 700; color: var(--text3); }
.thirds-table td.td-group-badge { width: 36px; }
.thirds-table td.td-team { text-align: left; }
.thirds-table td.td-third-status { text-align: left; white-space: nowrap; }
.thirds-table td.td-actions { width: 32px; padding: 4px; }

.qualify-tag.eliminated-tag { background: var(--bg3); color: var(--text3); border: 1px solid var(--border); }

/* ── BRACKET SECTION ─────────────────────────────── */
#bracket-section { margin-top: 0; }

.bracket-pending-msg {
  text-align: center; padding: 60px 20px; color: var(--text3);
}
.bracket-pending-msg .pending-icon { font-size: 3rem; display: block; margin-bottom: 12px; opacity: 0.4; }
.bracket-pending-msg p { font-size: 0.9rem; }

/* ── BRACKET HEADER ACTIONS ──────────────────────── */
.bracket-actions {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}

/* ── DESKTOP BRACKET ─────────────────────────────── */
.bracket-desktop { display: none; }
@media (min-width: 900px) {
  .bracket-desktop { display: block; }
  .bracket-mobile  { display: none; }
}

#bracket-scroll-hint {
  text-align: center; font-size: 0.7rem; color: var(--text3);
  padding: 10px 0 0; letter-spacing: 0.04em;
}

/* ── TOURNAMENT TREE — deep navy stage ───────────── */
#bracket-rounds {
  background: linear-gradient(180deg, #07111f 0%, #0a1628 100%);
  border-radius: 18px;
  padding: 24px 18px 28px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.04);
}

.bracket-tree {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #1e3a5f transparent;
}
.bracket-tree::-webkit-scrollbar { height: 5px; }
.bracket-tree::-webkit-scrollbar-thumb { background: #1e3a5f; border-radius: 3px; }

.bracket-side { display: flex; align-items: flex-start; }

.tree-col {
  display: flex; flex-direction: column;
  flex-shrink: 0; width: 138px; position: relative;
}
.bracket-side-left .tree-col:not(:last-child)::after {
  content: ''; position: absolute;
  right: 0; top: 32px; bottom: 0;
  width: 1px; background: rgba(255,255,255,0.04); pointer-events: none;
}
.bracket-side-right .tree-col:not(:first-child)::before {
  content: ''; position: absolute;
  left: 0; top: 32px; bottom: 0;
  width: 1px; background: rgba(255,255,255,0.04); pointer-events: none;
}

.col-label {
  height: 32px; display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 900; text-transform: uppercase;
  letter-spacing: 0.12em; background: transparent;
  white-space: nowrap; margin-bottom: 4px;
  color: rgba(255,255,255,0.5);
}
.col-label.final-badge {
  font-size: 0.68rem; letter-spacing: 0.1em;
}

.bracket-center {
  display: flex; flex-direction: column; flex-shrink: 0; width: 144px;
}

.tree-pair { display: flex; flex-direction: column; position: relative; }
.tree-pair::after {
  content: ''; position: absolute;
  right: 0; top: 25%; bottom: 25%;
  width: 2px; background: rgba(255,255,255,0.07);
  border-radius: 1px;
}
.bracket-side-right .tree-pair::after { right: auto; left: 0; }

.tree-slot { display: flex; align-items: center; justify-content: center; position: relative; }
.bracket-side-left .tree-slot::after {
  content: ''; position: absolute;
  right: 0; top: 50%; width: 10px; height: 2px;
  background: rgba(255,255,255,0.1);
}
.bracket-side-right .tree-slot::after {
  content: ''; position: absolute;
  left: 0; top: 50%; width: 10px; height: 2px;
  background: rgba(255,255,255,0.1);
}
.bracket-side-left .sf-slot::after,
.bracket-side-right .sf-slot::after { display: none; }

/* ── TREE CARD ───────────────────────────────────── */
.tree-card {
  background: #162035;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  transition: box-shadow 0.15s ease, transform 0.12s ease;
  width: 118px;
  flex-shrink: 0;
}
.tree-card:hover {
  box-shadow: 0 6px 22px rgba(0,0,0,0.55);
  transform: translateY(-1px);
}
.tree-card.pending {
  opacity: 0.4;
  pointer-events: none;
  background: #0d1a2e;
  border-color: rgba(255,255,255,0.04);
}
.tree-card.final-match {
  width: 130px;
  background: #1a2840;
  border-color: rgba(200,168,75,0.5);
  box-shadow: 0 0 0 1px rgba(200,168,75,0.3), 0 6px 28px rgba(200,168,75,0.15);
}

.tree-card-hdr {
  display: flex; flex-direction: column;
  padding: 5px 8px 4px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  gap: 2px;
}
.tree-hdr-top {
  font-size: 0.6rem; font-weight: 700;
  color: rgba(255,255,255,0.55);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: 0.02em;
}
.tree-hdr-venue {
  font-size: 0.55rem;
  color: rgba(255,255,255,0.3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.tree-team-btn {
  width: 100%;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px;
  background: transparent; border: none;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  font-size: 0.76rem; font-weight: 700;
  text-align: left;
  transition: background 0.12s ease;
  min-height: 34px;
  white-space: nowrap;
  border-left: 3px solid transparent;
}
.tree-team-btn:last-child { border-bottom: none; }
.tree-team-btn:hover:not(:disabled) {
  background: rgba(200,168,75,0.1);
  border-left-color: var(--accent);
  color: #fff;
}
.tree-team-btn:disabled { cursor: default; }
.tree-team-btn.winner {
  background: rgba(200,168,75,0.15);
  color: var(--accent);
  font-weight: 800;
  border-left: 3px solid var(--accent);
}
.tree-team-btn.winner:hover { background: rgba(200,168,75,0.22); }
.tree-team-btn.eliminated {
  opacity: 0.35;
  color: rgba(255,255,255,0.4);
}
.tree-team-btn.tbd {
  color: rgba(255,255,255,0.2); cursor: default; font-weight: 400;
  justify-content: center; font-style: italic; font-size: 0.68rem;
  border-left-color: transparent;
}

.btn-flag { font-size: 1.25rem; flex-shrink: 0; line-height: 1; }
.tree-code {
  flex: 1;
  font-size: 0.73rem; font-weight: 800;
  letter-spacing: 0.05em;
  overflow: hidden; text-overflow: ellipsis;
}
.tree-rank {
  font-size: 0.54rem; font-weight: 700;
  color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 1px 4px;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}
.btn-check {
  font-size: 0.9rem;
  flex-shrink: 0;
  font-weight: 900;
}

/* ── MATCH CARD (mobile + legacy) ───────────────── */
.match-card {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
  width: 190px;
  flex-shrink: 0;
}
.match-card:hover { box-shadow: var(--shadow); }
.match-card.pending { opacity: 0.4; pointer-events: none; }
.match-card.final-match {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg), var(--shadow);
}

.match-meta {
  padding: 4px 9px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border-light);
  display: flex; justify-content: space-between; gap: 4px;
  font-size: 0.58rem; color: var(--text3); font-weight: 500;
}

.match-team-btn {
  width: 100%;
  display: flex; align-items: center; gap: 7px;
  padding: 6px 9px;
  background: transparent; border: none;
  color: var(--text); cursor: pointer;
  font-size: 0.76rem; font-weight: 600;
  text-align: left;
  transition: background var(--transition);
  min-height: 36px;
  border-bottom: 1px solid var(--border-light);
}
.match-team-btn:last-child { border-bottom: none; }
.match-team-btn:hover:not(:disabled) { background: var(--blue-light); }
.match-team-btn:disabled { cursor: default; }
.match-team-btn.winner { background: var(--green-bg); color: var(--green); font-weight: 700; }
.match-team-btn.eliminated { opacity: 1; text-decoration: none; }

.match-label, .mobile-match-label {
  padding: 2px 9px 4px;
  font-size: 0.58rem; color: var(--blue); font-weight: 600;
  background: var(--blue-light);
  border-top: 1px solid var(--blue-border);
  text-align: center; letter-spacing: 0.02em;
}
.match-team-btn.tbd { color: var(--text3); font-style: italic; cursor: default; font-weight: 400; font-size: 0.72rem; }

.btn-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-check { color: var(--green); font-size: 0.75rem; flex-shrink: 0; font-weight: 800; }

/* ── MOBILE BRACKET (accordion) ─────────────────── */
.bracket-mobile { display: block; }
@media (min-width: 900px) { .bracket-mobile { display: none; } }

.bracket-accordion { display: flex; flex-direction: column; gap: 8px; }

.accordion-round {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  cursor: pointer;
  background: var(--bg3);
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  border-bottom: 1px solid var(--border-light);
}
.accordion-header:hover { background: var(--bg4); }
.accordion-title { font-size: 0.875rem; font-weight: 700; color: var(--text); }
.accordion-meta { display: flex; align-items: center; gap: 8px; }
.accordion-status { font-size: 0.72rem; color: var(--text3); }
.accordion-arrow { color: var(--text3); font-size: 0.7rem; transition: transform var(--transition); }
.accordion-round.open .accordion-arrow { transform: rotate(180deg); }

.accordion-body { display: none; padding: 10px; flex-direction: column; gap: 8px; }
.accordion-round.open .accordion-body { display: flex; }

.mobile-match-card {
  background: var(--bg3);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
}
.mobile-match-card.final-match { border-color: var(--accent); background: var(--accent-bg); }

.mobile-match-meta {
  padding: 5px 12px;
  font-size: 0.63rem; color: var(--text3); font-weight: 500;
  background: var(--bg2);
  border-bottom: 1px solid var(--border-light);
  display: flex; justify-content: space-between;
}

.mobile-match-team {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: transparent; border: none;
  color: var(--text); cursor: pointer;
  font-size: 0.85rem; font-weight: 600;
  text-align: left;
  transition: background var(--transition);
  min-height: 48px;
  border-bottom: 1px solid var(--border-light);
  -webkit-tap-highlight-color: transparent;
}
.mobile-match-team:last-child { border-bottom: none; }
.mobile-match-team:hover:not(:disabled),
.mobile-match-team:active:not(:disabled) { background: var(--blue-light); }
.mobile-match-team:disabled { cursor: default; }
.mobile-match-team.winner { background: var(--green-bg); color: var(--green); font-weight: 700; }
.mobile-match-team.eliminated { opacity: 1; text-decoration: none; }
.mobile-match-team.tbd { color: var(--text3); font-style: italic; cursor: default; font-weight: 400; }

/* ── TOAST ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--navy);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.85rem; font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  transition: transform 0.3s cubic-bezier(0.34,1.4,0.64,1);
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.08);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); border-color: rgba(255,255,255,0.1); }
.toast.success { background: #065f46; border-color: rgba(255,255,255,0.1); }

/* ── CONFIRM DIALOG ──────────────────────────────── */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(7,17,31,0.6);
  z-index: 200; display: flex;
  align-items: center; justify-content: center;
  padding: 16px; backdrop-filter: blur(6px);
}
.confirm-overlay.hidden { display: none; }
.confirm-dialog {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 28px;
  max-width: 400px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.confirm-dialog p { margin-bottom: 22px; color: var(--text); line-height: 1.65; font-size: 0.9rem; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── CHAMPION MODAL ──────────────────────────────── */
.champion-overlay {
  position: fixed; inset: 0;
  background: rgba(7,17,31,0.75);
  z-index: 300; display: flex;
  align-items: center; justify-content: center;
  padding: 16px; backdrop-filter: blur(8px);
}
.champion-overlay.hidden { display: none; }
.champion-modal {
  background: linear-gradient(155deg, var(--navy-mid) 0%, #1a2e5a 100%);
  border: 1px solid rgba(200,168,75,0.4);
  border-radius: 20px;
  padding: 44px 36px;
  text-align: center;
  max-width: 360px; width: 100%;
  box-shadow: 0 0 60px rgba(200,168,75,0.2), var(--shadow-lg);
  animation: champPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes champPop {
  from { transform: scale(0.72); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.champion-trophy { font-size: 3.5rem; margin-bottom: 8px; display: block; }
.champion-modal h2 { font-size: 1.25rem; font-weight: 800; color: rgba(255,255,255,0.9); margin-bottom: 16px; letter-spacing: -0.01em; }
.champion-flag { font-size: 4rem; margin: 12px 0; display: block; }
.champion-name { font-size: 1.6rem; font-weight: 900; color: var(--accent); margin-bottom: 28px; letter-spacing: -0.02em; }
.champion-modal .btn-primary { background: var(--accent); color: var(--navy); font-weight: 800; }
.champion-modal .btn-primary:hover { background: #d4b45a; }

/* ── FOOTER ──────────────────────────────────────── */
footer {
  background: var(--navy);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 28px 24px;
}
.footer-inner {
  max-width: 1440px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
}
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-logo {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
}
.footer-name { font-size: 0.82rem; font-weight: 700; color: rgba(255,255,255,0.7); }
.footer-legal { font-size: 0.72rem; color: rgba(255,255,255,0.25); }

/* Powered by / Créé par */
.footer-powered {
  display: flex; align-items: center; gap: 8px;
}
.footer-powered-label {
  font-size: 0.75rem; color: rgba(255,255,255,0.35);
  font-weight: 500;
}
.footer-lpodcan {
  font-size: 0.85rem; font-weight: 800;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
}
.footer-lpodcan:hover { color: #d4b45a; }
.footer-social-links { display: flex; align-items: center; gap: 6px; margin-left: 2px; }
.footer-social {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 7px;
  color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.18s ease;
  text-decoration: none;
}
.footer-social:hover {
  color: var(--accent);
  background: rgba(200,168,75,0.12);
  border-color: rgba(200,168,75,0.3);
}

/* ── UTILITY ─────────────────────────────────────── */
.hidden { display: none !important; }

/* Touch drag — hold progress */
tr.drag-pending {
  position: relative;
  background: var(--bg3);
}
tr.drag-pending::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  border-radius: 0 2px 2px 0;
  animation: hold-progress 0.35s ease-out forwards;
  z-index: 2;
}
@keyframes hold-progress {
  from { width: 0%; }
  to   { width: 100%; }
}

/* Touch drag — lifted state */
tr.dragging {
  position: relative;
  z-index: 10;
  transform: scale(1.03) rotate(-0.8deg);
  box-shadow: 0 8px 28px rgba(10,22,40,0.22), 0 2px 8px rgba(10,22,40,0.12);
  background: #fff;
  border-radius: 8px;
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  opacity: 0.96;
  transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.15s ease,
              outline-color 0.1s ease;
}
tr.dragging td {
  border-bottom: none !important;
}

/* Target row highlight */
tr.drag-over {
  background: var(--blue-light);
  outline: 2px dashed var(--blue);
  outline-offset: -2px;
}

tr.touch-placeholder td { background: var(--blue-light); }
tr.touch-placeholder { outline: 2px dashed var(--blue); outline-offset: -2px; }

/* ── AD ZONES ────────────────────────────────────── */
.ad-zone {
  text-align: center;
  margin: 0 auto;
  overflow: hidden;
}
.ad-zone--leaderboard {
  max-width: 728px;
  min-height: 90px;
  padding: 12px 24px;
}
.ad-zone--rectangle {
  max-width: 340px;
  min-height: 260px;
  padding: 16px 24px;
}
.ad-zone--footer {
  padding-top: 24px;
  padding-bottom: 8px;
}
/* Placeholder visuel tant qu'AdSense n'est pas activé */
.ad-zone ins {
  background: var(--bg4);
  border-radius: 8px;
  display: block;
  min-height: inherit;
}

/* ── SHARE CARD (hors-écran, capturée par html2canvas) ── */
#share-card {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1080px;
  height: 1080px;
  overflow: hidden;
  pointer-events: none;
}
.sc-bg {
  width: 1080px;
  height: 1080px;
  background: linear-gradient(145deg, #07111f 0%, #0a1628 45%, #0f2044 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  position: relative;
  border: 6px solid #c8a84b;
  box-sizing: border-box;
}
.sc-bg::before {
  content: '';
  position: absolute;
  inset: 20px;
  border: 1px solid rgba(200,168,75,0.25);
  border-radius: 24px;
  pointer-events: none;
}
.sc-logo {
  position: absolute;
  top: 52px;
  font-size: 38px;
  font-weight: 800;
  color: #c8a84b;
  letter-spacing: 1px;
}
.sc-by {
  position: absolute;
  top: 100px;
  font-size: 26px;
  color: rgba(200,168,75,0.6);
  font-weight: 500;
}
.sc-flag {
  font-size: 220px;
  line-height: 1;
  margin-bottom: 24px;
  margin-top: -40px;
}
.sc-name {
  font-size: 88px;
  font-weight: 900;
  color: #c8a84b;
  text-align: center;
  padding: 0 60px;
  line-height: 1.1;
  margin-bottom: 16px;
}
.sc-label {
  font-size: 36px;
  color: #fff;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.8;
  margin-bottom: 0;
}
.sc-url {
  position: absolute;
  bottom: 52px;
  font-size: 26px;
  color: rgba(255,255,255,0.4);
  font-weight: 400;
  letter-spacing: 1px;
}

/* ── SHARE BUTTONS (champion modal) ──────────────── */
.champion-share {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 16px 0 8px;
  flex-wrap: wrap;
}
.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  min-height: 40px;
}
.btn-share:active { transform: scale(0.96); }
.btn-share--twitter { background: #000; color: #fff; }
.btn-share--twitter:hover { background: #222; }
.btn-share--native { background: var(--accent); color: var(--navy); }
.btn-share--native:hover { background: var(--accent-dim); }
.btn-share:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ── PROGRESS BAR ────────────────────────────────── */
.progress-bar-wrap { height: 3px; background: var(--bg4); }
.progress-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--green));
  width: 0%;
  transition: width 0.4s ease;
}
.third-counter {
  display: flex; align-items: center; gap: 8px;
  background: var(--accent-bg);
  border: 1px solid rgba(200,168,75,0.3);
  border-radius: 8px; padding: 7px 14px;
}
.counter-label { font-size: 0.75rem; color: var(--accent-dim); font-weight: 600; }
.counter-value { font-size: 1rem; font-weight: 800; color: var(--accent-dim); }
.counter-value.complete { color: var(--green); }
