/* === World Cup 2026 Bracket — Apple-style === */

:root {
  /* Light theme (default) */
  --bg:        #ffffff;
  --bg-soft:   #f5f5f7;
  --bg-card:   #ffffff;
  --bg-elev:   #ffffff;
  --bg-glass:  rgba(255, 255, 255, 0.72);

  --line:      #e5e5e7;
  --line-2:    #d2d2d7;

  --ink:       #1d1d1f;
  --ink-2:     #424245;
  --ink-3:     #86868b;
  --ink-4:     #a1a1a6;

  --accent:    #0071e3;
  --accent-2:  #0077ed;
  --accent-bg: rgba(0, 113, 227, 0.08);

  --gold:      #b88a3a;
  --gold-bg:   linear-gradient(135deg, #f5d77c, #c69a3f);
  --gold-soft: rgba(184, 138, 58, 0.10);
  --gold-line: rgba(184, 138, 58, 0.35);

  --green:     #1d8649;
  --red:       #d33545;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow:    0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
}

[data-theme="dark"] {
  --bg:        #000000;
  --bg-soft:   #0a0a0d;
  --bg-card:   #131316;
  --bg-elev:   #1c1c1f;
  --bg-glass:  rgba(20, 20, 22, 0.72);

  --line:      #28282b;
  --line-2:    #3a3a3d;

  --ink:       #f5f5f7;
  --ink-2:     #d2d2d7;
  --ink-3:     #86868b;
  --ink-4:     #6e6e73;

  --accent:    #2997ff;
  --accent-2:  #4ba6ff;
  --accent-bg: rgba(41, 151, 255, 0.14);

  --gold:      #f5d77c;
  --gold-soft: rgba(245, 215, 124, 0.10);
  --gold-line: rgba(245, 215, 124, 0.28);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:    0 4px 16px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Inter", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.005em;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

#root { min-height: 100vh; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* ============ HEADER ============ */
.header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  position: relative;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  display: grid; place-items: center;
  font-weight: 600; font-size: 13px;
  letter-spacing: -0.02em;
}
[data-theme="dark"] .brand-mark { background: #fff; color: #000; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title {
  font-size: 15px; font-weight: 600; letter-spacing: -0.015em;
  color: var(--ink);
}
.brand-sub {
  font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.01em;
  margin-top: 1px;
}
.header-actions { display: flex; align-items: center; gap: 10px; }

/* ── Reset dropdown ─────────────────────────────────── */
.reset-wrap { position: relative; }
.reset-trigger {
  display: flex; align-items: center; gap: 5px;
}
.reset-chevron {
  transition: transform 0.22s ease;
  flex-shrink: 0;
}
.reset-chevron.open { transform: rotate(180deg); }

.reset-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 50;
  min-width: 190px;
  animation: reset-drop 0.2s cubic-bezier(0.22,1,0.36,1);
  transform-origin: top right;
}
@keyframes reset-drop {
  from { opacity: 0; transform: scale(0.92) translateY(-6px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);     }
}
.reset-option {
  display: flex; flex-direction: column; align-items: flex-start;
  width: 100%; padding: 11px 16px;
  background: transparent; border: none;
  cursor: pointer; text-align: left;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink);
  transition: background 0.15s ease;
  gap: 2px;
}
.reset-option + .reset-option { border-top: 1px solid var(--line); }
.reset-option:hover { background: var(--bg-soft); }
.reset-option-sub {
  font-size: 11px; font-weight: 400; color: var(--ink-3);
}
.reset-option-all { color: var(--red); }
.reset-option-all:hover { background: rgba(211,53,69,0.06); }

.btn {
  appearance: none; border: 1px solid transparent;
  background: transparent; color: var(--ink-2);
  padding: 7px 14px; border-radius: 999px;
  font: inherit; font-size: 13px; font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.32, 0.72, 0, 1);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--bg-soft); color: var(--ink); }
.btn-icon {
  padding: 0; width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ink-2);
}
.btn-icon:hover { background: var(--bg-soft); color: var(--ink); }
.btn-icon svg { width: 16px; height: 16px; }

.progress-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--bg-soft);
  font-size: 12px; color: var(--ink-2);
  letter-spacing: -0.005em;
}
.progress-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.progress-pill.complete .dot { background: var(--gold); }

/* ── Knockout bar ── */
.knockout-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.knockout-bar-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-3);
}
.btn-predict {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 16px;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  border: none; border-radius: 999px;
  font: inherit; font-size: 12px; font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.30);
  transition: opacity 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.btn-predict:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.40);
}
@media (max-width: 900px) {
  .knockout-bar.hidden { display: none; }
}

/* ── Prediction modal ── */
.predict-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.48);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  animation: fadein 0.18s ease;
}
.predict-modal {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: 82vh;
  display: flex; flex-direction: column;
  animation: slideup 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.predict-modal-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.predict-modal-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink);
}
.predict-modal-title svg { color: #7c3aed; flex-shrink: 0; }
[data-theme="dark"] .predict-modal-title svg { color: #a78bfa; }
.predict-close {
  appearance: none; background: transparent; border: none;
  color: var(--ink-3); cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  transition: all 0.15s ease;
}
.predict-close:hover { color: var(--ink); background: var(--bg-soft); }

.predict-modal-bd {
  flex: 1; overflow-y: auto;
  padding: 20px;
}

/* Setup */
.predict-setup { display: flex; flex-direction: column; gap: 14px; }
.predict-desc {
  font-size: 13.5px; color: var(--ink-2); line-height: 1.55;
  margin: 0; letter-spacing: -0.005em;
}
.predict-warn {
  font-size: 13px; color: var(--ink-3); margin: 0;
  padding: 12px 14px;
  background: var(--bg-soft); border-radius: 8px;
  border: 1px solid var(--line);
}
.predict-run-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  appearance: none;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff; border: none;
  border-radius: 10px; font: inherit; font-size: 13px; font-weight: 600;
  padding: 11px 20px; cursor: pointer;
  width: 100%;
  transition: opacity 0.18s ease;
}
.predict-run-btn:hover:not(:disabled) { opacity: 0.88; }
.predict-run-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.predict-btn-spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.predict-error {
  font-size: 12.5px; color: var(--red); margin: 0;
  padding: 9px 13px;
  background: rgba(211, 53, 69, 0.07);
  border-radius: 8px; border: 1px solid rgba(211, 53, 69, 0.18);
}

/* Loading */
.predict-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px;
  padding: 44px 20px;
}
.predict-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--line);
  border-top-color: #7c3aed;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
.predict-loading-msg {
  font-size: 14px; color: var(--ink-3);
  margin: 0; letter-spacing: -0.005em;
  animation: predict-msg-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes predict-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ MAIN LAYOUT ============ */
.main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bracket-wrap {
  position: relative;
  overflow: auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex: 7 1 0%;
  min-height: 0;
  transition: flex-grow 0.4s ease;
}
.bracket-stage {
  min-width: 1500px;
  min-height: 100%;
  padding: 24px 32px 32px;
  display: grid;
  grid-template-columns:
    minmax(140px, 1fr)
    minmax(140px, 1fr)
    minmax(140px, 1fr)
    minmax(140px, 1fr)
    minmax(180px, 1.3fr)
    minmax(140px, 1fr)
    minmax(140px, 1fr)
    minmax(140px, 1fr)
    minmax(140px, 1fr);
  gap: 0 22px;
  align-items: stretch;
}

.col {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  position: relative;
  min-width: 0;
  padding-top: 20px;
}
.col-label {
  position: absolute; top: -2px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3);
  background: var(--bg);
  padding: 2px 10px;
  border-radius: 999px;
}

/* ============ MATCH CARD ============ */
.match {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  transition:
    border-color 0.2s ease,
    box-shadow 0.25s ease,
    transform 0.2s ease;
}
.match:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow-sm);
}
.match.has-winner {
  border-color: var(--gold-line);
  box-shadow: 0 0 0 1px var(--gold-line), var(--shadow-sm);
}

.match-slot {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  border: none; background: transparent;
  width: 100%;
  text-align: left;
  color: var(--ink);
  font: inherit;
  position: relative;
  transition: background 0.18s ease, opacity 0.3s ease;
}
.match-slot:not(.empty):not(:disabled):hover { background: var(--bg-soft); }
.match-slot + .match-slot { border-top: 1px solid var(--line); }

.match-slot.winner {
  background: var(--gold-soft);
}
.match-slot.winner .slot-name { color: var(--ink); font-weight: 600; }
.match-slot.winner .slot-code { color: var(--gold); }

.match-slot.eliminated { opacity: 0.42; }
.match-slot.eliminated .slot-name { text-decoration: line-through; text-decoration-color: var(--ink-4); }

.match-slot.empty {
  color: var(--ink-4);
  cursor: default;
  background: var(--bg-soft);
}
.match-slot.empty:hover { background: var(--bg-soft); }

.match-slot.highlighted {
  background: var(--accent-bg);
}
.match-slot.highlighted .slot-name { color: var(--accent); font-weight: 600; }

/* check icon on winner */
.winner-check {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%) scale(0);
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--gold-bg);
  display: grid; place-items: center;
  color: #fff;
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.winner-check svg { width: 9px; height: 9px; }

@keyframes pop-in {
  0%   { transform: translateY(-50%) scale(0) rotate(-30deg); opacity: 0; }
  60%  { transform: translateY(-50%) scale(1.18) rotate(0); opacity: 1; }
  100% { transform: translateY(-50%) scale(1) rotate(0); opacity: 1; }
}

/* Flag */
.flag {
  width: 22px; height: 16px;
  border-radius: 3px;
  flex: 0 0 auto;
  object-fit: cover;
  background: var(--bg-soft);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] .flag { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }

.slot-code {
  font-weight: 600; font-size: 11px; letter-spacing: 0.02em;
  color: var(--ink-3);
  width: 32px; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.slot-name {
  font-size: 13px; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.slot-placeholder {
  font-size: 12px; color: var(--ink-4);
  letter-spacing: -0.005em;
}
.bracket-stage .slot-name { display: none; }

.match-meta {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 9px; font-weight: 600; color: var(--ink-4);
  letter-spacing: 0.06em;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 6px;
  z-index: 2;
}
.match-meta.left { left: -8px; }

/* === ADVANCEMENT ANIMATION === */
/* When a team's identity in a slot CHANGES (advance from previous round),
   we animate the slot in. Trigger via key={team} remount + .slot-advance class. */
.slot-content {
  display: contents;
}
.slot-content.advance-in {
  animation: advance-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes advance-in {
  0%   { opacity: 0; transform: translateX(-12px) scale(0.96); }
  60%  { opacity: 1; transform: translateX(2px)  scale(1.01); }
  100% { opacity: 1; transform: translateX(0)    scale(1); }
}
.match-slot.advance-flash {
  animation: advance-flash 0.9s ease-out;
}
@keyframes advance-flash {
  0%   { background: var(--accent-bg); box-shadow: inset 0 0 0 999px var(--accent-bg); }
  100% { background: transparent; box-shadow: inset 0 0 0 999px transparent; }
}

/* connector lines */
.col-side-l { padding-right: 22px; }
.col-side-r { padding-left: 22px; }
.col-side-l .match::after {
  content: ""; position: absolute;
  top: 50%; right: -22px; width: 22px; height: 1px;
  background: var(--line-2);
}
.col-side-r .match::after {
  content: ""; position: absolute;
  top: 50%; left: -22px; width: 22px; height: 1px;
  background: var(--line-2);
}

/* FINAL column */
.col-final {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px;
  padding: 0 12px;
}
.champion {
  width: 100%;
  border-radius: var(--radius-lg);
  padding: 22px 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.champion.crowned {
  border-color: var(--gold-line);
  box-shadow:
    0 0 0 1px var(--gold-line),
    0 30px 80px rgba(184, 138, 58, 0.25),
    var(--shadow-lg);
  background:
    radial-gradient(120% 100% at 50% 0%, var(--gold-soft), transparent 70%),
    var(--bg-card);
  animation: champion-rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes champion-rise {
  0%   { transform: translateY(8px) scale(0.96); opacity: 0.6; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.trophy {
  width: 40px; height: 40px; margin: 0 auto 10px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--gold-bg);
  color: #fff;
  font-size: 18px;
  position: relative;
  box-shadow: 0 4px 14px rgba(184, 138, 58, 0.4);
}
.champion.crowned .trophy {
  animation: trophy-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}
@keyframes trophy-bounce {
  0%   { transform: scale(0) rotate(-30deg); }
  60%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.champion-label {
  font-size: 10px; letter-spacing: 0.18em;
  color: var(--gold); text-transform: uppercase;
  font-weight: 600; margin-bottom: 8px;
}
.champion-name {
  font-size: 22px; font-weight: 600; letter-spacing: -0.025em;
  margin-top: 4px;
  min-height: 28px;
  color: var(--ink);
}
.champion-flag {
  margin: 8px auto 0; width: 36px; height: 26px;
  border-radius: 4px;
}
.champion-empty { color: var(--ink-4); font-weight: 400; }

/* ============ GROUPS PANE ============ */
.groups-wrap {
  flex: 3 1 0%;
  min-height: 0;
  overflow: auto;
  padding: 18px 28px 24px;
  background: var(--bg-soft);
  transition: flex-grow 0.4s ease;
}
.main.groups-expanded .bracket-wrap  { flex-grow: 0; min-height: 0; overflow: hidden; }
.main.groups-expanded .groups-wrap   { flex-grow: 10; }
.main.groups-collapsed .groups-wrap  { flex-grow: 0; min-height: 0; overflow: hidden; }
.main.groups-collapsed .bracket-wrap { flex-grow: 10; }
.groups-hint {
  font-size: 12px; color: var(--ink-3);
  letter-spacing: -0.005em;
}

/* === Bottom tabs === */
.bottom-tabs {
  position: relative;
  display: flex; align-items: center; gap: 4px;
  margin-bottom: 14px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line);
}
.groups-resize-btns {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
}
.groups-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-3);
  padding: 4px 6px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: color 0.18s ease, background 0.18s ease;
}
.groups-expand-btn:hover { color: var(--ink); background: var(--bg); }
.groups-expand-btn.active { color: var(--accent); }
.bottom-tab {
  appearance: none; border: none;
  background: transparent;
  color: var(--ink-3);
  font: inherit; font-size: 13px; font-weight: 500;
  letter-spacing: -0.01em;
  padding: 8px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.bottom-tab:hover { color: var(--ink); }
.bottom-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
.bottom-tab-pill {
  font-size: 10px; font-weight: 600;
  padding: 1px 7px; border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.bottom-tab.active .bottom-tab-pill {
  background: var(--ink); color: var(--bg);
}
.bottom-tabs-spacer { flex: 1; }

/* === Thirds panel === */
.thirds-panel { width: 100%; }
.thirds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.third-card {
  appearance: none;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  position: relative;
  font: inherit;
  color: var(--ink);
  transition: all 0.18s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex; flex-direction: column; gap: 8px;
}
.third-card:hover:not(:disabled) {
  border-color: var(--line-2);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.third-card:disabled { opacity: 0.4; cursor: not-allowed; }
.third-card.selected {
  border-color: var(--green);
  background: rgba(29, 134, 73, 0.06);
  box-shadow: 0 0 0 1px var(--green), var(--shadow-sm);
}
[data-theme="dark"] .third-card.selected {
  background: rgba(50, 215, 75, 0.10);
  border-color: #32d74b;
  box-shadow: 0 0 0 1px #32d74b, var(--shadow-sm);
}
.third-card.unmatched {
  border-color: #d97706;
  box-shadow: 0 0 0 1px #d97706, var(--shadow-sm);
  background: rgba(217, 119, 6, 0.06);
}
.third-card-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px;
}
.third-group {
  color: var(--ink-3); text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 600;
}
.third-slot {
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  background: var(--green); color: #fff;
  letter-spacing: 0.04em;
}
[data-theme="dark"] .third-slot { background: #32d74b; color: #000; }
.third-slot.muted { background: var(--bg-soft); color: var(--ink-4); }
.third-slot.warn { background: #d97706; color: #fff; }
.third-card-body {
  display: flex; align-items: center; gap: 10px;
}
.third-card-body .flag { width: 26px; height: 18px; }
.third-team-name {
  font-size: 14px; font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.third-team-code {
  font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.04em; font-weight: 600;
}
.third-card-foot { font-size: 11px; color: var(--ink-3); letter-spacing: -0.005em; }
.third-allowed { line-height: 1.4; }
.third-check {
  position: absolute; top: 10px; right: 10px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--green); color: #fff;
  display: grid; place-items: center;
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.third-check svg { width: 11px; height: 11px; }
.third-card.selected .third-card-head .third-group { color: var(--green); }
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.group-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 12px 10px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.group-card:hover { box-shadow: var(--shadow-sm); }
.group-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 2px;
}
.group-letter {
  font-size: 13px; font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.group-letter .label {
  font-size: 10px; color: var(--ink-3); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-right: 4px;
}
.group-status {
  font-size: 10px; color: var(--ink-3);
  letter-spacing: 0.04em; text-transform: uppercase;
  font-weight: 500;
}

.group-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px;
  border-radius: var(--radius-sm);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}
.group-row:hover { background: var(--bg-soft); }
.group-row + .group-row { margin-top: 2px; }

.rank-badge {
  width: 20px; height: 20px;
  border-radius: 6px;
  background: var(--bg-soft);
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
  display: grid; place-items: center;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}
.rank-1 { background: var(--gold-soft); color: var(--gold); }
.rank-2 { background: var(--accent-bg); color: var(--accent); }
.rank-3 { background: rgba(29, 134, 73, 0.10); color: var(--green); }
.rank-3.disabled { opacity: 0.4; background: var(--bg-soft); color: var(--ink-4); }
.rank-4 { background: var(--bg-soft); color: var(--ink-4); }

.row-code {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  width: 30px; flex-shrink: 0;
  letter-spacing: 0.02em;
}
.row-name {
  font-size: 13px; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 500; letter-spacing: -0.005em;
  color: var(--ink);
}

.row-arrows {
  display: flex; flex-direction: column; gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.group-row:hover .row-arrows { opacity: 1; }
.arrow-btn {
  appearance: none; border: 1px solid var(--line);
  background: var(--bg-card); color: var(--ink-3);
  width: 18px; height: 11px; padding: 0;
  border-radius: 3px;
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 7px;
  transition: all 0.12s ease;
}
.arrow-btn:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.arrow-btn:disabled { opacity: 0.3; cursor: default; }
.arrow-btn:disabled:hover { background: var(--bg-card); color: var(--ink-3); border-color: var(--line); }

.group-row.highlighted {
  background: var(--accent-bg);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.group-row.highlighted .row-name { color: var(--accent); }

.third-toggle {
  appearance: none; border: 1px solid var(--line);
  background: var(--bg-card); color: var(--ink-3);
  font-size: 9px; font-weight: 600; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 999px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.15s ease;
}
.third-toggle:hover:not(:disabled) {
  border-color: var(--green);
  color: var(--green);
}
.third-toggle.active {
  background: rgba(29, 134, 73, 0.10);
  border-color: rgba(29, 134, 73, 0.4);
  color: var(--green);
}
[data-theme="dark"] .third-toggle.active {
  background: rgba(50, 215, 75, 0.14);
  border-color: rgba(50, 215, 75, 0.4);
  color: #32d74b;
}
.third-toggle:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ FINAL match wrapper ============ */
.final-match-wrap {
  width: 100%;
}
.final-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3);
  text-align: center;
  margin-bottom: 8px;
}

/* ============ JOURNEY DRAWER ============ */
.journey {
  position: fixed;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 30;
  max-width: calc(100vw - 32px);
  animation: journey-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes journey-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.journey-team {
  display: flex; align-items: center; gap: 12px;
  padding-right: 14px;
  border-right: 1px solid var(--line);
}
.journey-team .flag { width: 28px; height: 20px; }
.journey-team .name { font-weight: 600; letter-spacing: -0.01em; font-size: 14px; }
.journey-team .code { font-size: 11px; color: var(--ink-3); letter-spacing: 0.02em; }
.journey-steps {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.journey-step {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-soft);
  color: var(--ink-2);
  font-weight: 500;
  letter-spacing: -0.005em;
}
.journey-step .step-label {
  font-size: 9px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 600;
}
.journey-step.win {
  background: var(--gold-soft);
  color: var(--gold);
}
.journey-step.loss {
  background: rgba(211, 53, 69, 0.08);
  color: var(--red);
}
.journey-step.live {
  background: var(--accent-bg);
  color: var(--accent);
}
.journey-step.crown {
  background: var(--gold-bg);
  color: #fff;
  box-shadow: 0 4px 12px rgba(184, 138, 58, 0.3);
}
.journey-close {
  margin-left: 4px;
  appearance: none; background: transparent; border: none;
  color: var(--ink-3); cursor: pointer;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  transition: all 0.15s ease;
}
.journey-close:hover { color: var(--ink); background: var(--bg-soft); }

/* Players button in drawer */
.journey-players-btn {
  appearance: none; border: 1px solid var(--accent);
  background: var(--accent-bg); color: var(--accent);
  font: inherit; font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 12px; border-radius: 999px;
  cursor: pointer; white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease;
}
.journey-players-btn:hover { background: var(--accent); color: #fff; }

/* Coach chip in drawer */
.journey-coach {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: var(--bg-soft); color: var(--ink-2);
  letter-spacing: -0.005em; white-space: nowrap;
}
.journey-coach-flag {
  width: 16px; height: 12px;
  border-radius: 2px; object-fit: cover;
  vertical-align: middle;
}

/* ── Squad modal ───────────────────────────────────────── */
.squad-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  animation: fadein 0.18s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.squad-modal {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 420px; max-width: calc(100vw - 32px);
  max-height: 70vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: slideup 0.22s cubic-bezier(0.22,1,0.36,1);
}
@keyframes slideup { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }

.squad-modal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.squad-modal-header .flag { width: 24px; height: 17px; }
.squad-modal-title {
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
  flex: 1; min-width: 0;
}
.squad-modal-coach {
  font-size: 12px; color: var(--ink-3);
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.squad-coach-flag {
  width: 16px; height: 12px; border-radius: 2px; object-fit: cover;
}
.squad-modal-close {
  appearance: none; background: transparent; border: none;
  color: var(--ink-3); cursor: pointer;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  transition: all 0.15s ease; flex-shrink: 0;
}
.squad-modal-close:hover { color: var(--ink); background: var(--bg-soft); }

.squad-list {
  overflow-y: auto;
  flex: 1;
  padding: 6px 0;
}
.squad-empty { padding: 24px; text-align: center; color: var(--ink-3); font-size: 13px; }
.squad-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 16px;
  transition: background 0.12s ease;
}
.squad-row:hover { background: var(--bg-soft); }
.squad-club-logo {
  width: 22px; height: 22px; object-fit: contain; flex-shrink: 0;
}
.squad-club-initial {
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg-soft); border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700; color: var(--ink-3);
  text-transform: uppercase;
}
.squad-player-name {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 500;
  letter-spacing: -0.005em; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.squad-player-club {
  font-size: 11px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 110px;
}
.squad-player-value {
  font-size: 12px; font-weight: 600;
  color: var(--gold); white-space: nowrap;
  margin-left: 4px;
}

/* ============ TAB BAR (mobile only) ============ */
.tab-bar { display: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .groups-resize-btns { display: none; }
  .tab-bar {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
    padding: 8px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .tab-bar button {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--ink-2);
    padding: 10px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.005em;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
  }
  .tab-bar button.active {
    color: var(--ink);
    background: var(--bg-soft);
  }
  .bracket-wrap.hidden, .groups-wrap.hidden { display: none; }
  .bracket-stage { padding: 18px 14px; }
  .header { padding: 10px 14px; }
  .brand-text { display: none; }
  .progress-pill { display: none; }
  .groups-grid { grid-template-columns: 1fr; }
  .journey { left: 8px; right: 8px; transform: none; max-width: none; flex-wrap: wrap; }
  @keyframes journey-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* scrollbars */
.bracket-wrap::-webkit-scrollbar,
.groups-wrap::-webkit-scrollbar { width: 10px; height: 10px; }
.bracket-wrap::-webkit-scrollbar-thumb,
.groups-wrap::-webkit-scrollbar-thumb {
  background: var(--line-2); border-radius: 999px; border: 2px solid var(--bg);
}
.groups-wrap::-webkit-scrollbar-thumb { border-color: var(--bg-soft); }
.bracket-wrap::-webkit-scrollbar-track,
.groups-wrap::-webkit-scrollbar-track { background: transparent; }
.bracket-wrap::-webkit-scrollbar-thumb:hover,
.groups-wrap::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }
