*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --accent: #6ee7b7;
  --accent-dim: #34d39918;
  --text: #f0f0f0;
  --muted: #666;
  --radius: 12px;
  --slot: 96px; /* base bracket slot height */
  --conn: 24px; /* connector width */
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
#app { height: 100%; display: flex; flex-direction: row; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.hidden { display: none !important; }
.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; }
.dot { color: var(--accent); }

/* ── Sidebar ───────────────────────────────── */
.sidebar {
  width: 220px; flex-shrink: 0; display: flex; flex-direction: column;
  background: #131313; border-right: 1px solid var(--border);
  height: 100%; overflow: hidden;
}
.sidebar-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 0.9rem 0.8rem; flex-shrink: 0;
}
.sidebar-logo {
  font-size: 1rem; background: none; border: none; color: inherit;
  padding: 0; cursor: pointer; font-family: inherit; font-weight: inherit;
  letter-spacing: inherit; transition: opacity 0.15s;
}
.sidebar-logo:hover { opacity: 0.75; }
.new-btn {
  display: flex; align-items: center; gap: 0.35rem;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); font-size: 0.78rem; cursor: pointer;
  padding: 0.3rem 0.6rem; transition: color 0.15s, border-color 0.15s;
}
.new-btn:hover { color: var(--text); border-color: var(--accent); }
.sidebar-section-label {
  font-size: 0.67rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.7px; color: var(--muted); padding: 0.25rem 0.9rem 0.5rem;
}
.sidebar-list { flex: 1; overflow-y: auto; padding: 0 0.4rem 1rem; }
.sidebar-empty { font-size: 0.82rem; color: var(--muted); padding: 0.5rem 0.5rem; }
.sidebar-item {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 0.6rem; border-radius: 8px; cursor: pointer;
  transition: background 0.1s;
}
.sidebar-item:hover { background: var(--surface); }
.sidebar-item.active { background: var(--surface); }
.sidebar-item-body { flex: 1; min-width: 0; }
.sidebar-item-title {
  font-size: 0.84rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-item-meta { font-size: 0.72rem; color: var(--muted); margin-top: 1px; }
.sidebar-delete {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 0.7rem; padding: 0.45rem 0.6rem; flex-shrink: 0; border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.sidebar-delete:hover { color: #f87171; background: #f871711a; }

/* On real mouse devices only: hide until the row is hovered */
@media (hover: hover) and (pointer: fine) {
  .sidebar-delete { color: transparent; padding: 2px 4px; }
  .sidebar-item:hover .sidebar-delete { color: var(--muted); }
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none; position: fixed; top: 0.8rem; left: 0.8rem; z-index: 200;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); cursor: pointer; padding: 0.45rem;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 150;
}
.sidebar-overlay:not(.hidden) { display: block; }

@media (max-width: 680px) {
  .sidebar {
    position: fixed; left: -220px; top: 0; bottom: 0; z-index: 160;
    transition: left 0.2s ease;
  }
  .sidebar.open { left: 0; }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .chat-header { padding-left: 3.5rem; }
  .bracket-header { padding-left: 3.5rem; }
}

/* ── Chat view ─────────────────────────────── */
.chat-header {
  display: none; /* sidebar replaces header on desktop */
  align-items: center; justify-content: center;
  padding: 1.25rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
@media (max-width: 680px) {
  .chat-header { display: flex; }
}
.messages {
  flex: 1; overflow-y: auto; padding: 1.5rem 1rem;
  display: flex; flex-direction: column; gap: 1rem;
  max-width: 680px; width: 100%; margin: 0 auto;
}
.bubble {
  max-width: 85%; padding: 0.75rem 1rem; border-radius: var(--radius);
  line-height: 1.55; font-size: 0.95rem; white-space: pre-wrap;
}
.bubble.user  { align-self: flex-end; background: var(--accent); color: #0f0f0f; font-weight: 500; }
.bubble.ai    { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.bubble.thinking { color: var(--muted); font-style: italic; }

.chat-form {
  display: flex; gap: 0.5rem; padding: 1rem;
  border-top: 1px solid var(--border);
  max-width: 680px; width: 100%; margin: 0 auto; flex-shrink: 0;
}
.chat-form textarea {
  flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem 1rem;
  color: var(--text); font-size: 0.95rem; outline: none; transition: border-color 0.15s;
  resize: none; overflow-y: hidden; line-height: 1.45;
  min-height: 44px; max-height: 160px; font-family: inherit;
}
@media (max-width: 680px) {
  .chat-form textarea { font-size: 16px; } /* prevent iOS viewport zoom on focus */
}
.chat-form textarea:focus { border-color: var(--accent); }
.chat-form textarea::placeholder { color: var(--muted); }
.chat-form button {
  background: var(--accent); border: none; border-radius: var(--radius);
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #0f0f0f; flex-shrink: 0; transition: opacity 0.15s;
}
.chat-form button:disabled { opacity: 0.35; cursor: default; }
.chat-form button:not(:disabled):hover { opacity: 0.85; }

/* ── Bracket view ─────────────────────────── */
.bracket-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.back-btn, .share-btn {
  display: flex; align-items: center; gap: 0.4rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.45rem 0.85rem;
  color: var(--text); font-size: 0.85rem; cursor: pointer; transition: border-color 0.15s;
}
.back-btn:hover, .share-btn:hover { border-color: var(--accent); }

.bracket-title-row {
  display: flex; align-items: center; gap: 0.6rem;
  flex: 1; min-width: 0; padding: 0 0.5rem;
}
.bracket-title-row h1 { font-size: 1.1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.format-badge {
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 20px;
  padding: 0.2rem 0.65rem; font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* ── Bracket grid ─────────────────────────── */
.bracket-scroll { flex: 1; overflow: auto; }
.bracket {
  display: flex; align-items: flex-start;
  padding: 1.5rem; gap: 0; min-width: max-content;
}

.round { display: flex; flex-direction: column; }
.round:not(.round-final) { margin-right: var(--conn); }

.round-label {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--muted);
  margin-bottom: 0.5rem; padding-left: 2px;
  min-width: 180px;
}

.matches-col { display: flex; flex-direction: column; }

.match-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  /* height set by JS: var(--slot) * 2^(round-1) */
}

/* Vertical bracket — odd child goes DOWN from center, even goes UP */
/* Vertical sits at match card right edge; conn-left bridges the gap to the next round */
.round:not(.round-final) .matches-col .match-wrapper:not(:only-child):nth-child(odd)::before {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  width: 2px;
  height: 50%;
  background: var(--border);
  pointer-events: none;
}
.round:not(.round-final) .matches-col .match-wrapper:not(:only-child):nth-child(even)::before {
  content: '';
  position: absolute;
  left: 100%;
  bottom: 50%;
  width: 2px;
  height: 50%;
  background: var(--border);
  pointer-events: none;
}

/* Left horizontal connector (for rounds > 1, added as .conn-left div) */
.conn-left {
  position: absolute;
  right: 100%;
  top: 50%;
  width: var(--conn);
  height: 2px;
  background: var(--border);
  transform: translateY(-50%);
  pointer-events: none;
}

/* ── Match card ───────────────────────────── */
.match {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 180px;
  position: relative;
}

.team-slot {
  display: flex; align-items: center;
  padding: 0 0.85rem; gap: 0.5rem;
  font-size: 0.88rem; height: 42px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.team-slot:last-child { border-bottom: none; }
.team-slot.clickable { cursor: pointer; }
.team-slot.clickable:hover { background: var(--accent-dim); }
.team-slot.winner { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.team-slot.loser  { color: #444; text-decoration: line-through; }
.team-slot.bye    { color: var(--muted); font-style: italic; }
.team-slot.empty  { color: #333; font-style: italic; }

.seed      { font-size: 0.72rem; color: var(--muted); min-width: 16px; flex-shrink: 0; }
.team-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-icon  { font-size: 0.8rem; flex-shrink: 0; }

/* ── Winner banner ────────────────────────── */
.winner-banner {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  padding: 0.85rem; background: var(--accent-dim); border-top: 1px solid var(--accent);
  font-size: 1.05rem; font-weight: 700; color: var(--accent); flex-shrink: 0;
}

/* ── Bracket AI chat ─────────────────────── */
.ai-fab {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--accent); color: #0f0f0f;
  border: none; border-radius: 50%; width: 50px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.2rem; font-weight: 700;
  box-shadow: 0 4px 20px #00000060;
  transition: transform 0.15s, opacity 0.15s;
  z-index: 50;
}
.ai-fab:hover { transform: scale(1.08); }

.ai-panel {
  position: fixed; bottom: 0; right: 0;
  width: min(420px, 100vw); height: min(520px, 80vh);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 40px #00000080;
  z-index: 49;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.ai-panel.open { transform: translateY(0); }

.ai-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.ai-panel-title { font-size: 0.9rem; font-weight: 600; }
.ai-panel-close {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 2px;
}
.ai-panel-close:hover { color: var(--text); }

.ai-panel-messages {
  flex: 1; overflow-y: auto; padding: 0.75rem 1rem;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.ai-panel-messages .bubble { font-size: 0.88rem; max-width: 90%; }

.ai-panel-form {
  display: flex; gap: 0.4rem; padding: 0.75rem;
  border-top: 1px solid var(--border); flex-shrink: 0;
  align-items: flex-end; flex-wrap: wrap; position: relative;
}
.ai-panel-form .attach-btn { width: 36px; height: 36px; }
.ai-panel-form textarea {
  flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.55rem 0.85rem;
  color: var(--text); font-size: 0.88rem; outline: none;
  resize: none; overflow-y: hidden; line-height: 1.45;
  min-height: 36px; max-height: 120px; font-family: inherit;
}
@media (max-width: 680px) {
  .ai-panel-form textarea { font-size: 16px; }
}
.ai-panel-form textarea:focus { border-color: var(--accent); }
.ai-panel-form textarea::placeholder { color: var(--muted); }
.ai-panel-form button {
  background: var(--accent); border: none; border-radius: 8px;
  width: 36px; height: 36px; display: flex; align-items: center;
  justify-content: center; cursor: pointer; color: #0f0f0f;
  flex-shrink: 0; transition: opacity 0.15s;
}
.ai-panel-form button:disabled { opacity: 0.35; cursor: default; }

/* ── Toast ────────────────────────────────── */
.toast {
  position: fixed; bottom: 5rem; left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 0.6rem 1.1rem; border-radius: var(--radius);
  font-size: 0.88rem; z-index: 100; pointer-events: none;
  opacity: 1; transition: opacity 0.3s;
}
.toast.hidden { opacity: 0; }

/* ── Round-robin ──────────────────────────── */
.rr-view { padding: 1.5rem; display: flex; flex-direction: column; gap: 2rem; min-width: max-content; }

.standings { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-width: 340px; }
.standings table { width: 100%; border-collapse: collapse; }
.standings th { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); padding: 0.6rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.standings th.num { text-align: right; }
.standings td { padding: 0.6rem 1rem; font-size: 0.88rem; border-bottom: 1px solid var(--border); }
.standings tr:last-child td { border-bottom: none; }
.standings td.num { text-align: right; color: var(--muted); }
.standings td.pts { color: var(--accent); font-weight: 600; }
.standings td.rank { color: var(--muted); font-size: 0.75rem; }
.standings tr.leader td { background: var(--accent-dim); }

.rr-matches { display: flex; flex-direction: column; gap: 4px; min-width: 340px; }
.rr-match {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.rr-team {
  flex: 1; display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.85rem; font-size: 0.88rem; cursor: pointer;
  transition: background 0.1s;
}
.rr-team:not(.winner):not(.loser):not(.draw):hover { background: var(--accent-dim); }
.rr-team.winner { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.rr-team.loser { color: #444; text-decoration: line-through; }
.rr-team.right { flex-direction: row-reverse; text-align: right; }
.rr-divider { width: 2px; height: 36px; background: var(--border); flex-shrink: 0; }
.rr-mid { display: flex; flex-direction: column; align-items: center; gap: 2px; flex-shrink: 0; }
.rr-vs { font-size: 0.72rem; color: var(--muted); padding: 0 0.5rem; flex-shrink: 0; }
.rr-draw-btn {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  color: var(--muted); cursor: pointer; font-size: 0.78rem; font-weight: 700;
  padding: 1px 6px; flex-shrink: 0; transition: background 0.1s, color 0.1s, border-color 0.1s;
  line-height: 1.4;
}
.rr-draw-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--accent); }
.rr-team.draw { color: var(--muted); background: none; font-weight: normal; text-decoration: none; }
.draw-icon { font-size: 0.78rem; color: var(--muted); flex-shrink: 0; }
.rr-match.rr-clickable { cursor: pointer; transition: border-color 0.1s; }
.rr-match.rr-clickable:hover { border-color: var(--accent); }

/* ── Double-elimination ───────────────────── */
.de-view { display: flex; flex-direction: column; gap: 2rem; padding: 1.5rem; min-width: max-content; }
.de-section { display: flex; flex-direction: column; gap: 0.5rem; }
.de-section-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); padding-left: 2px; }
.de-gf { min-width: 0 !important; }

/* ── Scrollbars ───────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Group-stage ──────────────────────────── */
.gs-view { display: flex; flex-direction: column; gap: 2rem; padding: 1.5rem; overflow: auto; }
.gs-groups { display: flex; flex-wrap: wrap; gap: 1.5rem; min-width: max-content; }
.gs-group { display: flex; flex-direction: column; gap: 0.75rem; min-width: 300px; }
.gs-group-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent); }
.gs-standings { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.gs-standings th { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.gs-standings th.num { text-align: right; }
.gs-standings td { padding: 0.5rem 0.75rem; font-size: 0.85rem; border-bottom: 1px solid var(--border); }
.gs-standings tr:last-child td { border-bottom: none; }
.gs-standings td.num { text-align: right; color: var(--muted); }
.gs-standings td.pts { color: var(--accent); font-weight: 600; }
.gs-standings td.rank { color: var(--muted); font-size: 0.75rem; }
.gs-standings tr.advancing td { background: var(--accent-dim); }
.gs-standings tr.advancing.leader td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.gs-match-list { display: flex; flex-direction: column; gap: 4px; }
.gs-playoffs { display: flex; flex-direction: column; gap: 1rem; }
.gs-playoffs-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent); }
.ghost-match { opacity: 0.35; pointer-events: none; }
.generate-playoffs-btn { align-self: flex-start; background: var(--accent); color: #0f0f0f; border: none; border-radius: 8px; padding: 0.6rem 1.25rem; font-size: 0.88rem; font-weight: 700; cursor: pointer; transition: opacity 0.15s; }
.generate-playoffs-btn:hover { opacity: 0.85; }
.generate-playoffs-btn:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.4); }

/* ── Placement bracket (3rd place, etc.) ─────────── */
.placement-view {
  display: flex; flex-direction: column; gap: 0.75rem;
  padding: 0 1.5rem 1.5rem; border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}
.placement-section-label {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--muted); padding-top: 1.25rem;
}

/* Consolation label in group stage */
.consolation-label { color: var(--muted); }

/* ── Quick-start chips ────────────────────────── */
.quick-starts { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.25rem 0 0.75rem; }
.quick-start-btn {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 20px;
  color: var(--text); font-size: 0.8rem; padding: 0.4rem 0.85rem; cursor: pointer;
  transition: border-color 0.15s, background 0.15s; white-space: nowrap;
}
.quick-start-btn:hover { border-color: var(--accent); background: var(--accent-dim); }

/* ── File attachment ──────────────────────────── */
.chat-form { position: relative; flex-wrap: wrap; align-items: flex-end; }
.attach-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex-shrink: 0; cursor: pointer;
  color: var(--accent); background: var(--accent-dim); border: 1px solid var(--border);
  border-radius: var(--radius); transition: border-color 0.15s, background 0.15s;
}
.attach-btn:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.attach-preview {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 0.5rem;
  width: 100%; order: -1; padding: 0.5rem 0.5rem 0; background: none; border: none;
}
.attach-item {
  display: flex; align-items: flex-end; gap: 0.35rem; position: relative;
}
.attach-thumb {
  max-height: 140px; max-width: 220px; border-radius: 10px;
  object-fit: cover; border: 1px solid var(--border); display: block;
}
.attach-file-icon { font-size: 1.5rem; flex-shrink: 0; }
.attach-file-name {
  font-size: 0.82rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px;
}
.attach-remove {
  background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; font-size: 0.72rem; border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; align-self: flex-start; margin-left: 0.25rem;
  transition: color 0.15s, background 0.15s;
}
.attach-remove:hover { color: #f87171; background: #3a1a1a; border-color: #f87171; }

/* ── Chat form drag-and-drop ─────────────────────── */
.chat-form.drag-active {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.chat-form.drag-active textarea { background: transparent; }

/* ── Per-team score in bracket slots ───────────── */
.slot-score {
  font-size: 0.82rem; font-weight: 700; color: var(--muted);
  flex-shrink: 0; min-width: 14px; text-align: right;
}
.team-slot.winner .slot-score { color: var(--accent); }

/* Raw (non-parseable) score shown as a badge under the card */
.match-score-badge {
  text-align: center; padding: 3px 8px;
  border-top: 1px solid var(--border);
  font-size: 0.74rem; font-weight: 600; color: var(--accent); white-space: nowrap;
}

/* Settled bracket card → click opens the result modal */
.match.match-clickable { cursor: pointer; transition: border-color 0.1s; }
.match.match-clickable:hover { border-color: var(--accent); }

/* ── Score in RR / group rows ─────────────────── */
.rr-score {
  font-size: 0.72rem; font-weight: 600; color: var(--accent);
  text-align: center; line-height: 1.4;
  border-radius: 4px; padding: 1px 5px;
  white-space: nowrap;
}
.rr-score.score-empty { color: var(--muted); font-weight: 400; }

/* ── Team slot reassign button ────────────────── */
.reassign-btn {
  background: none; border: none; cursor: pointer; flex-shrink: 0;
  color: transparent; font-size: 0.68rem; padding: 0 3px; line-height: 1;
  border-radius: 3px; transition: color 0.1s, background 0.1s;
}
.team-slot:hover .reassign-btn { color: var(--muted); }
.reassign-btn:hover { color: var(--accent) !important; background: var(--accent-dim); }
@media (hover: none) {
  .reassign-btn { color: var(--muted); }
}

/* ── Reassign dropdown ────────────────────────── */
.reassign-select {
  position: fixed; z-index: 300;
  background: var(--surface2); border: 1px solid var(--accent);
  color: var(--text); font-size: 0.85rem; outline: none;
  border-radius: 8px; padding: 4px 6px; cursor: pointer;
  max-width: 220px; box-shadow: 0 4px 20px #00000060;
}

/* ── Editable tournament title ────────────────── */
.bracket-title-row h1 { cursor: text; }
.title-edit-input {
  background: none; border: none; border-bottom: 2px solid var(--accent);
  color: var(--text); font-size: 1.1rem; font-weight: 700;
  font-family: inherit; outline: none; padding: 0 0 1px;
  width: min(320px, 55vw);
}

/* ── Drag and drop ────────────────────────────── */
.team-slot.draggable { cursor: grab; }
.team-slot.draggable:active { cursor: grabbing; }
.team-slot.dragging { opacity: 0.4; }
.team-slot.drag-over { background: var(--accent-dim); outline: 2px dashed var(--accent); border-radius: 6px; }

/* ── Bracket tabs ─────────────────────────────── */
.bracket-tabs-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 0.45rem 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
  background: var(--bg);
}
.bracket-tab {
  display: flex; align-items: center; gap: 0.35rem;
  background: none; border: none; border-radius: 6px;
  color: var(--muted); font-size: 0.82rem; cursor: pointer;
  padding: 0.35rem 0.75rem; transition: color 0.15s, background 0.15s;
}
.bracket-tab.active { background: var(--surface2); color: var(--text); }
.bracket-tab:hover:not(.active) { color: var(--text); background: var(--surface); }

/* ── Schedule view ────────────────────────────── */
.schedule-view { display: flex; flex-direction: column; height: 100%; }
.schedule-toolbar {
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
  position: sticky; top: 0; z-index: 10; background: var(--bg);
}
.auto-schedule-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.auto-input {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 0.82rem; padding: 0.4rem 0.65rem;
  border-radius: 6px; outline: none; min-width: 0;
}
.auto-input:focus { border-color: var(--accent); }
.auto-input-courts { flex: 1; min-width: 160px; }
.auto-input-sm { width: 64px; }
.auto-schedule-btn {
  background: var(--accent-dim); border: 1px solid var(--accent);
  color: var(--accent); font-size: 0.82rem; padding: 0.4rem 0.9rem;
  border-radius: 6px; cursor: pointer; white-space: nowrap;
  transition: background 0.1s, color 0.1s; flex-shrink: 0;
}
.auto-schedule-btn:hover { background: var(--accent); color: #000; }
.auto-schedule-btn:disabled { opacity: 0.45; cursor: default; }
.replace-schedule-label {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.8rem; color: var(--muted); cursor: pointer; white-space: nowrap; user-select: none;
}
.replace-schedule-label input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

.schedule-content { flex: 1; overflow: auto; padding: 1.25rem 1.5rem; }
.schedule-empty { color: var(--muted); font-size: 0.88rem; padding: 2rem 0; text-align: center; }

/* Schedule grid */
.schedule-grid {
  display: grid; gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  width: max-content; min-width: 100%; margin-bottom: 1.75rem;
}
.sg-header {
  background: var(--surface2); font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted);
  padding: 0.45rem 0.75rem; white-space: nowrap;
}
.sg-time-label { text-align: right; }
.sg-time {
  background: var(--surface); font-size: 0.78rem; font-weight: 600;
  color: var(--muted); padding: 0.5rem 0.75rem;
  text-align: right; white-space: nowrap; align-self: center;
}
.sg-cell {
  background: var(--surface); padding: 0.35rem; min-height: 56px; min-width: 170px;
}
.sg-match {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.45rem 0.6rem;
  display: flex; flex-direction: column; gap: 0.2rem;
  cursor: pointer; position: relative; transition: border-color 0.1s; height: 100%;
}
.sg-match:hover { border-color: var(--accent); }
.sg-match.sg-settled { border-left: 3px solid var(--accent); }
.sg-teams { font-size: 0.8rem; font-weight: 500; line-height: 1.3; }
.sg-teams .sg-win { color: var(--accent); font-weight: 700; }
.sg-teams .sg-vs { color: var(--muted); font-weight: 400; }
.sg-score { font-size: 0.72rem; font-weight: 700; color: var(--accent); }
.sg-duration { font-size: 0.68rem; color: var(--muted); }

/* Compact card (unscheduled list) */
.sg-compact {
  flex-direction: row; align-items: center; gap: 0.5rem;
  min-width: 280px; max-width: 460px; height: auto;
}
.sg-compact .sg-teams { flex: 1; padding-right: 0; }

.schedule-unscheduled { margin-top: 0.5rem; }
.schedule-section-label {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--muted); margin-bottom: 0.6rem;
}
.unscheduled-list { display: flex; flex-direction: column; gap: 4px; }

/* Schedule edit modal */
.schedule-edit-modal {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.65);
}
.sem-panel {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.25rem 1.5rem; width: min(360px, 92vw);
  display: flex; flex-direction: column; gap: 1rem; box-shadow: 0 8px 40px #00000080;
}
.sem-title { font-weight: 600; font-size: 0.95rem; }
.sem-section-label {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted); margin-bottom: -0.4rem;
}
.sem-optional { text-transform: none; font-weight: 400; opacity: 0.7; }
.sem-result { display: flex; gap: 0.4rem; }
.sem-team-btn {
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 0.8rem; line-height: 1.2;
  padding: 0.5rem 0.45rem; border-radius: 6px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color 0.1s, background 0.1s, color 0.1s;
}
.sem-team-btn:hover { border-color: var(--accent); }
.sem-team-btn.selected { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.sem-draw-btn { flex: 0 0 auto; min-width: 54px; }
.sem-reset {
  margin-right: auto;
  background: none; border: 1px solid var(--border); color: var(--muted);
  font-size: 0.82rem; padding: 0.42rem 0.9rem; border-radius: 6px; cursor: pointer;
  transition: border-color 0.15s, color 0.1s;
}
.sem-reset:hover { color: #f87171; border-color: #f87171; }
.sem-fields { display: flex; flex-direction: column; gap: 0.65rem; }
.sem-label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.75rem; color: var(--muted); }
.sem-input {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 0.85rem; padding: 0.42rem 0.65rem;
  border-radius: 6px; outline: none; width: 100%; font-family: inherit;
}
.sem-input:focus { border-color: var(--accent); }
.sem-input-sm { width: 100px; }
.sem-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.sem-cancel, .sem-save {
  background: none; border: 1px solid var(--border);
  color: var(--text); font-size: 0.82rem; padding: 0.42rem 1rem;
  border-radius: 6px; cursor: pointer; transition: border-color 0.15s, background 0.1s, color 0.1s;
}
.sem-save { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.sem-save:hover { background: var(--accent); color: #000; }
.sem-cancel:hover { border-color: var(--accent); }
