/* ===== RoboCup Championship Styles ===== */

:root {
  --bg-1: #0f1511;
  --bg-2: #17231c;
  --panel: rgba(19, 29, 23, 0.92);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #edf2ee;
  --muted: #b9c6bd;
  --accent: #f2b134;
  --accent-text: #1a1a1a;
  --danger: #e74c3c;
  --success: #2ecc71;
  --shadow: rgba(0, 0, 0, 0.28);
  --team1: rgb(242, 177, 52);
  --team2: rgb(68, 156, 232);
}

/* ===== Light mode ===== */
body.light {
  --bg-1: #f0f4f1;
  --bg-2: #e4ece6;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(0, 0, 0, 0.10);
  --text: #1a2a1e;
  --muted: #5a7060;
  --accent: #d4950e;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --success: #27ae60;
  --shadow: rgba(0, 0, 0, 0.12);
}

body.light {
  background:
    radial-gradient(circle at top left, #d8ead0 0%, transparent 32%),
    radial-gradient(circle at bottom right, #cde0d4 0%, transparent 24%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

body.light input,
body.light select {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.15);
}

body.light .nav-btn-accent.outline {
  border-color: var(--accent);
}

/* ===== Theme toggle ===== */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.theme-toggle-icon {
  font-size: 14px;
  line-height: 1;
  user-select: none;
}

.theme-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.theme-switch-track {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 11px;
  cursor: pointer;
  transition: background .25s;
  border: 1px solid var(--panel-border);
}

.theme-switch input:checked + .theme-switch-track {
  background: var(--accent);
}

.theme-switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  transition: transform .25s;
}

.theme-switch input:checked + .theme-switch-track::after {
  transform: translateX(18px);
  background: var(--accent-text);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(circle at top left, #22372a 0%, transparent 32%),
    radial-gradient(circle at bottom right, #1b2b21 0%, transparent 24%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
}

.hidden { display: none !important; }

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top Bar ---------- */
.top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(8px);
}
.top-bar-left { flex-shrink: 0; }
.top-bar-nav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.top-bar-right { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.logo { margin: 0; font-size: 22px; white-space: nowrap; }
.logo-accent { color: var(--accent); }

.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  box-shadow: none;
  width: auto;
  transition: color .2s, background .2s;
}
.nav-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); transform: none; box-shadow: none; }
.nav-btn.active { color: var(--accent); background: rgba(242,177,52,0.08); }

.nav-btn-accent {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
  width: auto;
}
.nav-btn-accent:hover { opacity: 0.85; transform: none; box-shadow: none; }
.nav-btn-accent.outline {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.nav-btn-small {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  box-shadow: none;
  width: auto;
}
.nav-btn-small:hover { color: var(--text); transform: none; box-shadow: none; }

#userBadge span { font-size: 14px; margin-right: 6px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 32px;
  width: 360px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  width: auto;
  box-shadow: none;
  padding: 0;
}
.modal-close:hover { color: var(--text); transform: none; box-shadow: none; }
.modal h2 { margin: 0 0 20px; }

/* ---------- Forms / Inputs ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field span { color: var(--muted); font-size: 13px; }

input, select {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.18);
  color: var(--text);
  font: inherit;
}
input[type="file"] { display: none; }

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  width: auto;
  box-shadow: none;
}
.btn-primary:hover { opacity: 0.85; transform: none; box-shadow: none; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  display: inline-block;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  width: auto;
  box-shadow: none;
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); transform: none; box-shadow: none; }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}
.model-badge.has { background: rgba(46,204,113,0.15); color: var(--success); border: 1px solid rgba(46,204,113,0.3); }
.model-badge.none { background: rgba(231,76,60,0.12); color: var(--danger); border: 1px solid rgba(231,76,60,0.25); }

.upload-label { cursor: pointer; text-align: center; }
.error-text { color: var(--danger); font-size: 13px; margin: 4px 0; }
.success-text { color: var(--success); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.mt-8 { margin-top: 8px; }

/* ---------- Pages ---------- */
.page-content {
  flex: 1;
  padding: 24px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}
.page { display: none; }
.page.active { display: block; }

/* ---------- Leaderboard Table ---------- */
.lb-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}
.lb-table th, .lb-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.lb-table th { color: var(--muted); font-size: 13px; font-weight: 600; }
.lb-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ---------- Match list ---------- */
.match-list { margin-top: 12px; }
.match-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  margin-bottom: 6px;
  font-size: 14px;
}
.match-item .score { font-weight: bold; font-size: 16px; }
.match-item .vs { color: var(--muted); }
.match-item button {
  margin-left: auto;
  width: auto;
  padding: 6px 14px;
  font-size: 12px;
  box-shadow: none;
}

/* ---------- Play grid ---------- */
.play-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 20px;
}
.card h3 { margin: 0 0 8px; font-size: 16px; }

.code-hint {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre;
  margin-top: 8px;
}

.auth-wall {
  text-align: center;
  padding: 60px 0;
  color: var(--muted);
  font-size: 18px;
}

/* ---------- Watch ---------- */
.watch-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}
.watch-canvas-wrap { display: flex; justify-content: center; }
#pitch {
  width: min(100%, 1200px);
  height: auto;
  border-radius: 18px;
  box-shadow: 0 22px 60px var(--shadow);
  background: #16351f;
}
.watch-sidebar {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px;
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 16px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.site-footer p { margin: 0; }
.site-footer a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.3);
}
.site-footer a:hover { border-bottom-color: var(--accent); }
.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.footer-sep { color: var(--muted); opacity: 0.5; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .top-bar { flex-wrap: wrap; }
  .top-bar-nav { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; }
  .watch-layout { grid-template-columns: 1fr; }
  .play-grid { grid-template-columns: 1fr; }
}

/* ---------- Logo link ---------- */
.logo-link { text-decoration: none; color: inherit; }
.logo-link:hover .logo { opacity: 0.85; }

/* ---------- Nav: tournament button ---------- */
.nav-btn-tournament {
  color: var(--accent) !important;
  font-weight: 600;
}
.nav-btn-tournament.active {
  background: rgba(242,177,52,0.14) !important;
}

/* ---------- Page header row ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.page-header h2 { margin: 0; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ---------- Match notification banner ---------- */
.match-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: linear-gradient(90deg, rgba(46,204,113,0.15), rgba(46,204,113,0.06));
  border-bottom: 1px solid rgba(46,204,113,0.25);
  font-size: 14px;
}
.match-banner-icon { font-size: 18px; }
.match-banner span:nth-child(2) { flex: 1; }
.btn-accent-sm {
  background: var(--success);
  color: #0f1511;
  border: none;
  border-radius: 7px;
  padding: 5px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}
.btn-accent-sm:hover { opacity: 0.85; }
.btn-ghost-sm {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
}
.btn-ghost-sm:hover { color: var(--text); background: rgba(255,255,255,0.05); }

/* ---------- Tournament hero ---------- */
.tournament-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(120deg, rgba(242,177,52,0.08), rgba(242,177,52,0.03));
  border: 1px solid rgba(242,177,52,0.2);
  border-radius: 18px;
  padding: 28px 32px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.tournament-title {
  display: flex;
  align-items: center;
  gap: 18px;
}
.trophy-icon { font-size: 48px; line-height: 1; }
.tournament-title h2 { margin: 0 0 4px; font-size: 22px; }
.tournament-title p { margin: 0; }

/* ---------- Countdown ---------- */
.countdown-wrap { text-align: center; }
.countdown-label { color: var(--muted); font-size: 12px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .05em; }
.countdown-box {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}
.countdown-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 54px;
}
.countdown-unit span {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.countdown-unit small {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.countdown-sep {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.5;
  padding-top: 4px;
}
.deadline-passed {
  color: var(--muted);
  font-size: 16px;
  padding: 12px 0;
  display: block;
}

/* ---------- Tournament grid ---------- */
.tournament-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ---------- Registration badge ---------- */
.reg-badge {
  display: inline-block;
  background: rgba(46,204,113,0.12);
  border: 1px solid rgba(46,204,113,0.3);
  color: var(--success);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
}

/* ---------- Participant list items ---------- */
.participant-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 14px;
}
.participant-item:last-child { border-bottom: none; }

/* ---------- Auth wall (small, inside card) ---------- */
.auth-wall-sm { padding: 16px 0; }

@media (max-width: 900px) {
  .tournament-grid { grid-template-columns: 1fr; }
  .tournament-hero { flex-direction: column; align-items: flex-start; }
}

/* ===== Home page ===== */

.home-student-badge {
  display: inline-block;
  background: rgba(242,177,52,0.12);
  border: 1px solid rgba(242,177,52,0.3);
  color: var(--accent);
  border-radius: 20px;
  padding: 4px 16px;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.home-banner-github-label {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 3px 10px;
  margin-top: 4px;
}

.home-hero {
  text-align: center;
  padding: 40px 20px 20px;
}
.home-title {
  font-size: 32px;
  margin: 0 0 10px;
  letter-spacing: -.01em;
}
.home-subtitle {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}

/* ---------- Deadline countdown bar ---------- */
.deadline-bar {
  margin: 18px 20px 0;
  padding: 14px 24px;
  background: linear-gradient(135deg, rgba(220,50,50,0.13) 0%, rgba(220,100,50,0.08) 100%);
  border: 1px solid rgba(220,80,50,0.35);
  border-radius: 12px;
  text-align: center;
}
.deadline-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.deadline-timer {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #f26d3d;
  font-variant-numeric: tabular-nums;
}
.deadline-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  opacity: .75;
}
.deadline-expired .deadline-timer {
  color: var(--muted);
}

/* ---------- Home banners ---------- */
.home-banners {
  display: flex;
  gap: 32px;
  justify-content: center;
  padding: 36px 20px 20px;
  flex-wrap: wrap;
}

.home-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 360px;
  min-height: 340px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 36px 28px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);

  filter: grayscale(1) brightness(0.75);
  transition: filter 0.35s ease, transform 0.35s ease, border-color 0.35s ease;
}
.home-banner:hover {
  filter: grayscale(0) brightness(1);
  transform: scale(1.05);
  border-color: var(--accent);
}

.home-banner-art {
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1;
}
.home-banner-robot { font-size: 72px; }
.home-banner-vs {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -.02em;
}
.home-banner-trophy { font-size: 96px; line-height: 1; }
.home-banner-ball { font-size: 28px; }
.home-banner-stars { font-size: 20px; letter-spacing: 4px; }
.home-banner-title {
  margin: 8px 0 0;
  font-size: 20px;
  text-align: center;
  letter-spacing: -.01em;
}
.home-banner-desc {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

/* ---------- Home info grid ---------- */
.home-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 8px 20px 40px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
.home-info-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 20px;
}
.home-info-icon { font-size: 32px; margin-bottom: 10px; }
.home-info-card h3 { margin: 0 0 8px; font-size: 15px; }
.home-info-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.home-info-card code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ---------- Tournament rules list ---------- */
.rules-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 2;
}
.rules-list strong { color: var(--text); }

/* ---------- Wide card (spans 2 cols) ---------- */
.card-wide {
  grid-column: span 2;
}

@media (max-width: 860px) {
  .home-info-grid { grid-template-columns: 1fr; }
  .home-banners { flex-direction: column; align-items: center; }
  .card-wide { grid-column: span 1; }
}

/* ---------- Rules section headings ---------- */
.rules-section-title {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  margin: 18px 0 6px;
  text-transform: uppercase;
}
.rules-section-title:first-of-type { margin-top: 8px; }

/* ---------- Tournament grid (wider for rules card) ---------- */
.tournament-grid {
  grid-template-columns: 1fr 1fr;
}
.tournament-grid .card-wide {
  grid-column: span 2;
}