@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --bg:        #0B0E14;
  --panel:     #131820;
  --panel-2:   #1A2029;
  --line:      #262E3A;
  --text:      #E7ECF3;
  --muted:     #8A94A6;
  --cs2:       #F5A623;
  --cs2-dim:   #4A3A1C;
  --eafc:      #35D488;
  --eafc-dim:  #1B3A2C;
  --action:    #5B8CFF;
  --danger:    #F0546B;
  --radius:    10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(91,140,255,0.08), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(245,166,35,0.06), transparent 35%);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
}

h1, h2, h3, h4, .display {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 .4em;
  text-transform: uppercase;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

a { color: var(--action); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Top bar ---------- */
.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(11,14,20,0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 8px; display: block; }
.brand .dot { width: 10px; height: 10px; border-radius: 2px; background: var(--cs2); box-shadow: 0 0 0 3px var(--eafc-dim); transform: rotate(45deg); }
.brand .dot::after { content:''; }

.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a { color: var(--muted); font-weight: 500; font-size: .95rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links .user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 20px; color: var(--text);
}
.avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cs2), var(--eafc));
  display: inline-block;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: 'Rajdhani', sans-serif; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; font-size: .92rem;
  padding: 11px 22px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
.btn:hover { text-decoration: none; filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--action); color: #0B0E14; }
.btn-cs2 { background: var(--cs2); color: #1a1204; }
.btn-eafc { background: var(--eafc); color: #052014; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--action); }
.btn-danger { background: var(--danger); color: #2a0410; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: .8rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; filter: none; }

/* ---------- Hero ---------- */
.hero {
  padding: 84px 0 60px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.hero .wrap { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center; }
.eyebrow {
  font-family: 'IBM Plex Mono', monospace; font-size: .78rem; color: var(--action);
  letter-spacing: .12em; text-transform: uppercase; margin-bottom: 14px; display:block;
}
.hero h1 { font-size: 3.4rem; line-height: 1.02; margin-bottom: 18px; }
.hero h1 .accent-cs2 { color: var(--cs2); }
.hero h1 .accent-eafc { color: var(--eafc); }
.hero p.lede { color: var(--muted); font-size: 1.08rem; max-width: 46ch; margin-bottom: 30px; }
.cta-row, .hero .cta-row { display: flex; gap: 14px; flex-wrap: wrap; }

/* signature bracket visual */
.bracket-art { position: relative; height: 320px; }
.bracket-art svg { width: 100%; height: 100%; }
.bracket-art .node {
  fill: var(--panel); stroke: var(--line); stroke-width: 1;
}
.bracket-art .node-text { font-family: 'IBM Plex Mono', monospace; font-size: 10px; fill: var(--muted); }
.bracket-art .line { stroke: var(--line); stroke-width: 2; fill: none; }
.bracket-art .line-live { stroke: var(--cs2); stroke-dasharray: 4 4; animation: dash 1.6s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -16; } }
.bracket-art .pulse { animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- Section headers ---------- */
.section { padding: 56px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 26px; flex-wrap: wrap; gap: 12px;}
.section-head h2 { font-size: 1.7rem; margin: 0; }
.section-head p { color: var(--muted); margin: 4px 0 0; font-size: .95rem; }

.tabs { display: flex; gap: 8px; background: var(--panel); border: 1px solid var(--line); padding: 4px; border-radius: 999px; }
.tabs a {
  padding: 8px 16px; border-radius: 999px; font-family: 'Rajdhani', sans-serif;
  font-weight: 600; letter-spacing: .03em; text-transform: uppercase; font-size: .82rem; color: var(--muted);
}
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active.cs2 { background: var(--cs2-dim); color: var(--cs2); }
.tabs a.active.eafc { background: var(--eafc-dim); color: var(--eafc); }
.tabs a.active.all { background: var(--panel-2); color: var(--text); }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 20px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s ease, transform .15s ease;
}
.card:hover { border-color: #333d4d; transform: translateY(-2px); }
.tag {
  display: inline-flex; align-items: center; gap: 6px; width: fit-content;
  font-family: 'IBM Plex Mono', monospace; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
}
.tag.cs2 { color: var(--cs2); border-color: var(--cs2-dim); background: rgba(245,166,35,.06); }
.tag.eafc { color: var(--eafc); border-color: var(--eafc-dim); background: rgba(53,212,136,.06); }
.tag.status-open { color: var(--eafc); }
.tag.status-locked, .tag.status-in_progress { color: var(--cs2); }
.tag.status-finished { color: var(--muted); }

.card h3 { font-size: 1.25rem; margin: 0; }
.card .meta { color: var(--muted); font-size: .87rem; display: flex; flex-direction: column; gap: 4px; }
.card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
.progress-bar { height: 5px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--action), var(--eafc)); }

.empty {
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted);
}

/* ---------- Forms ---------- */
.auth-shell { min-height: calc(100vh - 68px); display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 36px; width: 100%; max-width: 420px;
}
.panel.wide { max-width: 720px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,7,10,.72); backdrop-filter: blur(3px);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-box { max-width: 440px; width: 100%; margin: 0; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 11px 13px; border-radius: 8px; font-family: 'Inter', sans-serif; font-size: .95rem;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--action); }
.field .hint { color: var(--muted); font-size: .78rem; margin-top: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.radio-cards { display: flex; gap: 12px; }
.radio-cards label {
  flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted);
}
.radio-cards input { width: auto; }
.radio-cards label:has(input:checked) { border-color: var(--action); color: var(--text); background: rgba(91,140,255,.06); }

.alert {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: .9rem;
  border: 1px solid var(--line);
}
.alert-error { border-color: rgba(240,84,107,.4); background: rgba(240,84,107,.08); color: #ff8fa0; }
.alert-info { border-color: rgba(91,140,255,.4); background: rgba(91,140,255,.08); color: #a9c1ff; }
.alert-success { border-color: rgba(53,212,136,.4); background: rgba(53,212,136,.08); color: #7feab3; }

.muted-link { color: var(--muted); font-size: .88rem; text-align: center; margin-top: 18px; }

/* ---------- Tournament detail ---------- */
.t-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap; margin-bottom: 8px; }
.t-header h1 { font-size: 2.2rem; margin: 10px 0; }
.t-header .meta-row { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.t-header .meta-row strong { color: var(--text); }

.participant-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.participant-list li {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-size: .92rem;
}
.seed-badge { font-family: 'IBM Plex Mono', monospace; color: var(--muted); font-size: .78rem; }

/* ---------- Bracket board ---------- */
.bracket-board { display: flex; gap: 46px; overflow-x: auto; padding: 14px 4px 30px; }
.bracket-round { display: flex; flex-direction: column; justify-content: space-around; gap: 22px; min-width: 230px; }
.bracket-round .round-label { font-family:'IBM Plex Mono',monospace; font-size:.72rem; text-transform:uppercase; letter-spacing:.1em; color: var(--muted); margin-bottom: 4px; }
.match-node {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  position: relative;
}
.match-node.ready { border-color: var(--action); }
.match-node.played { border-color: var(--line); }
.slot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; font-size: .88rem; border-bottom: 1px solid var(--line);
}
.slot:last-child { border-bottom: none; }
.slot.winner { color: var(--eafc); font-weight: 600; }
.slot .score { font-family: 'IBM Plex Mono', monospace; }
.slot .tbd { color: var(--muted); font-style: italic; }
.match-actions { padding: 8px 12px; border-top: 1px dashed var(--line); }
.match-actions form { display: flex; gap: 6px; align-items: center; }
.match-actions input[type=number] {
  width: 46px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 5px; border-radius: 5px; text-align: center;
}

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--line); padding: 34px 0; color: var(--muted); font-size: .85rem; }
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .bracket-art { height: 220px; order: -1; }
  .hero h1 { font-size: 2.4rem; }
  .field-row { grid-template-columns: 1fr; }
  .nav-links { gap: 12px; }
}
