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

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #22263a;
  --border: #2a2e3f;
  --text: #e4e6ed;
  --text-dim: #8b8fa3;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.15);
  --green: #00cec9;
  --orange: #fdcb6e;
  --red: #ff7675;
  --blue: #74b9ff;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 10px;
}

html { font-size: 15px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s ease;
}
.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h1 { font-size: 1.15rem; font-weight: 700; }
.badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.nav-links { list-style: none; padding: 12px 0; flex: 1; }
.nav-links li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.nav-links li a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.6; }
.nav-links li a:hover { color: var(--text); background: var(--accent-glow); }
.nav-links li a:hover svg { opacity: 1; }
.nav-links li a.active {
  color: var(--accent-light);
  background: var(--accent-glow);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav-links li a.active svg { opacity: 1; }

/* Main */
main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
#topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
#menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  margin-right: 16px;
}
#breadcrumb { font-size: 0.95rem; color: var(--text-dim); font-weight: 500; }
#breadcrumb .bc-link {
  color: var(--accent-light);
  cursor: pointer;
  text-decoration: none;
}
#breadcrumb .bc-link:hover { text-decoration: underline; }

#page-container {
  padding: 24px;
  flex: 1;
}

/* Loading */
.loading-spinner { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 0; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-spinner p { margin-top: 12px; color: var(--text-dim); font-size: 0.85rem; }

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
  cursor: pointer;
}
.card:hover { border-color: var(--accent); background: var(--bg-card-hover); transform: translateY(-2px); }
.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-subtitle { color: var(--text-dim); font-size: 0.82rem; margin-bottom: 10px; }
.card-team { color: var(--accent-light); font-size: 0.78rem; font-weight: 500; margin-bottom: 8px; }
.team-label { color: var(--accent-light); font-weight: 600; }
.card-desc { color: var(--text-dim); font-size: 0.85rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  background: var(--accent-glow);
  color: var(--accent-light);
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(108, 92, 231, 0.3);
}
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.score-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
}
.score-high { background: rgba(0, 206, 201, 0.15); color: var(--green); }
.score-mid { background: rgba(253, 203, 110, 0.15); color: var(--orange); }
.score-low { background: rgba(255, 118, 117, 0.15); color: var(--red); }

/* Stat Cards */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-card .label { font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; }
.stat-card .value.accent { color: var(--accent-light); }
.stat-card .value.green { color: var(--green); }
.stat-card .value.blue { color: var(--blue); }

/* Section headers */
.section-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 16px; }
.section-subtitle { font-size: 0.85rem; color: var(--text-dim); margin-top: -10px; margin-bottom: 16px; }

/* Detail Page */
.detail-page { max-width: 960px; margin: 0 auto; }

/* -- Hero -- */
.proj-hero {
  display: flex; gap: 24px; align-items: flex-start; margin-bottom: 32px;
}
.proj-hero-text { flex: 1; min-width: 0; }
.proj-title { font-size: 1.7rem; font-weight: 800; line-height: 1.25; margin-bottom: 8px; }
.proj-team-line { margin-bottom: 12px; }
.proj-team-name {
  color: var(--accent-light); font-weight: 600; font-size: 0.92rem;
}
.proj-team-members {
  color: var(--text-dim); font-size: 0.82rem; margin-left: 6px;
}
.proj-team-members::before { content: '\2014\00a0'; }
.proj-description {
  font-size: 0.95rem; line-height: 1.7; color: var(--text-dim); margin-bottom: 12px;
}
.proj-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.proj-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 8px; font-size: 0.82rem; font-weight: 500;
  text-decoration: none; border: 1px solid var(--border); color: var(--text);
  transition: all 0.15s;
}
.proj-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.proj-btn-accent {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.proj-btn-accent:hover { background: var(--accent-light); border-color: var(--accent-light); color: #fff; }

.proj-hero-scores {
  display: flex; flex-direction: column; gap: 12px; flex-shrink: 0;
}
.proj-score-ring {
  width: 90px; text-align: center; padding: 14px 8px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-card);
}
.proj-score-ring.score-high { border-color: rgba(0,206,201,0.4); }
.proj-score-ring.score-mid { border-color: rgba(253,203,110,0.4); }
.proj-score-ring.score-low { border-color: rgba(255,118,117,0.4); }
.proj-score-value { font-size: 1.6rem; font-weight: 800; }
.score-high .proj-score-value { color: var(--green); }
.score-mid .proj-score-value { color: var(--orange); }
.score-low .proj-score-value { color: var(--red); }
.proj-score-label { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* -- Story flow -- */
.proj-story {
  position: relative; padding-left: 32px; margin-bottom: 32px;
}
.proj-story::before {
  content: ''; position: absolute; left: 14px; top: 8px; bottom: 8px;
  width: 2px; background: var(--border); border-radius: 1px;
}
.proj-story-step {
  display: flex; gap: 16px; align-items: flex-start;
  margin-bottom: 20px; position: relative;
}
.proj-story-step:last-child { margin-bottom: 0; }
.proj-story-icon {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.9rem; flex-shrink: 0;
  position: relative; left: -32px; margin-right: -16px;
  z-index: 1;
}
.proj-story-problem { background: rgba(255,118,117,0.2); color: var(--red); }
.proj-story-innovation { background: rgba(0,206,201,0.2); color: var(--green); }
.proj-story-impact { background: rgba(116,185,255,0.2); color: var(--blue); }
.proj-story-content h3 {
  font-size: 0.85rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 6px;
}
.proj-story-problem + .proj-story-content h3 { color: var(--red); }
.proj-story-content p { font-size: 0.9rem; line-height: 1.65; color: var(--text-dim); }
/* Color the h3 based on sibling icon */
.proj-story-step:nth-child(1) .proj-story-content h3 { color: var(--red); }
.proj-story-step:nth-child(2) .proj-story-content h3 { color: var(--green); }
.proj-story-step:nth-child(3) .proj-story-content h3 { color: var(--blue); }

/* -- Gallery -- */
.proj-gallery { margin-bottom: 32px; }

/* -- Evaluation -- */
.proj-eval { margin-bottom: 24px; }
.proj-eval-heading {
  font-size: 0.95rem; font-weight: 600; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.proj-eval-section { margin-bottom: 20px; }

/* Radar hexagon chart */
.proj-radar-wrap {
  display: flex; justify-content: center; margin-bottom: 24px;
}
.radar-svg { width: 340px; height: 340px; overflow: visible; }

/* Gallery: main + thumbnails */
.gallery-main {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  min-height: 300px; max-height: 520px;
}
.gallery-main img, .gallery-main video {
  width: 100%; height: 100%; max-height: 520px;
  object-fit: contain; display: block;
}
.gallery-main img { cursor: pointer; }
.gallery-thumbs {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 10px 0; scroll-snap-type: x mandatory;
}
.gallery-thumb {
  width: 72px; height: 52px; object-fit: cover;
  border-radius: 6px; border: 2px solid transparent;
  cursor: pointer; flex-shrink: 0; scroll-snap-align: start;
  opacity: 0.6; transition: all 0.15s;
}
.gallery-thumb:hover { opacity: 0.9; }
.gallery-thumb.active { border-color: var(--accent); opacity: 1; }
.gallery-thumb-video {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg-card); border: 2px solid transparent; gap: 2px;
  color: var(--accent-light); width: 72px; height: 52px;
}
.gallery-thumb-video svg { width: 18px; height: 18px; }
.gallery-thumb-video span { font-size: 0.6rem; }

/* Member links */
.proj-member-link { color: var(--accent-light); cursor: pointer; text-decoration: none; }
.proj-member-link:hover { text-decoration: underline; }

.proj-footer { color: var(--text-dim); font-size: 0.78rem; text-align: center; padding: 16px 0; border-top: 1px solid var(--border); margin-top: 8px; }

/* Generic detail-section (still used by peer table, etc.) */
.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.detail-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 10px; color: var(--accent-light); }
.detail-section p { font-size: 0.9rem; line-height: 1.65; color: var(--text-dim); }

/* Judge Scores */
.judge-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}
.judge-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.judge-name { font-weight: 600; font-size: 1rem; }
.judge-overall { font-size: 1.3rem; font-weight: 700; }
.criteria-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.criteria-item { display: flex; flex-direction: column; gap: 4px; }
.criteria-label { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.3px; }
.criteria-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.criteria-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.criteria-val { font-size: 0.78rem; font-weight: 600; }
.judge-comment { font-size: 0.85rem; color: var(--text-dim); line-height: 1.6; padding: 12px; background: rgba(0,0,0,0.2); border-radius: 6px; margin-top: 10px; }
.judge-marks { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.mark-tag { padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; font-weight: 600; text-transform: capitalize; }
.mark-innovative { background: rgba(0, 206, 201, 0.15); color: var(--green); }
.mark-impactful { background: rgba(253, 203, 110, 0.15); color: var(--orange); }
.mark-technical { background: rgba(116, 185, 255, 0.15); color: var(--blue); }
.mark-presentation { background: rgba(162, 155, 254, 0.15); color: var(--accent-light); }

/* Peer Scores */
.peer-scores-section { margin-top: 16px; }
.peer-table { width: 100%; border-collapse: collapse; }
.peer-table th, .peer-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.peer-table th { color: var(--text-dim); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.3px; }
.peer-table tr:hover td { background: var(--accent-glow); }

/* Leaderboard */
.leaderboard-table { width: 100%; border-collapse: collapse; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.leaderboard-table th, .leaderboard-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.leaderboard-table th { background: rgba(0,0,0,0.2); color: var(--text-dim); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.leaderboard-table td { font-size: 0.9rem; }
.leaderboard-table tr:hover td { background: var(--accent-glow); }
.leaderboard-table .rank { font-weight: 700; color: var(--accent-light); width: 50px; }
.rank-1 { color: #ffd700 !important; }
.rank-2 { color: #c0c0c0 !important; }
.rank-3 { color: #cd7f32 !important; }
.clickable-row { cursor: pointer; }
.sorted-col { background: var(--accent-glow); }

/* Topics */
.track-section { margin-bottom: 32px; }
.track-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; color: var(--accent-light); }
.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
  display: flex;
  gap: 14px;
}
.topic-num { font-size: 1.1rem; font-weight: 700; color: var(--accent); min-width: 30px; }
.topic-content { flex: 1; }
.topic-content h4 { font-size: 0.92rem; margin-bottom: 4px; }
.topic-content .category { font-size: 0.72rem; color: var(--accent-light); margin-bottom: 6px; }
.topic-content p { font-size: 0.82rem; color: var(--text-dim); line-height: 1.5; }

/* Teams table */
.teams-table { width: 100%; border-collapse: collapse; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.teams-table th, .teams-table td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.teams-table th { background: rgba(0,0,0,0.2); color: var(--text-dim); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.teams-table a { color: var(--accent-light); text-decoration: none; }
.teams-table a:hover { text-decoration: underline; }

/* Search */
.search-bar {
  width: 100%;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 20px;
  outline: none;
  transition: border-color 0.15s;
}
.search-bar:focus { border-color: var(--accent); }
.search-bar::placeholder { color: var(--text-dim); }
#project-search-bar-wrap { position: sticky; top: var(--topbar-h); z-index: 10; background: var(--bg); padding: 8px 0; }
#project-search-bar-wrap label { font-size: 0.82rem; color: var(--text-dim); white-space: nowrap; cursor: pointer; user-select: none; }
#project-table-wrap { min-height: 200px; }

/* Screenshots */
.screenshots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 10px; }
.screenshots-grid img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s;
}
.screenshots-grid img:hover { transform: scale(1.03); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; cursor: default;
}
.lightbox img { max-width: 80%; max-height: 85%; border-radius: 8px; user-select: none; }
.lb-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.1); border: none; color: #fff;
  font-size: 2rem; width: 48px; height: 48px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  backdrop-filter: blur(4px);
}
.lb-btn:hover { background: rgba(255,255,255,0.25); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
.lb-counter {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.6); font-size: 0.85rem; font-weight: 500;
}

/* Sidebar backdrop (mobile) */
#sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}
#sidebar-backdrop.visible { display: block; }

/* Responsive */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); z-index: 100; }
  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.4); }
  main { margin-left: 0; }
  #menu-toggle { display: block; }
  .cards-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .criteria-grid { grid-template-columns: 1fr 1fr; }
  .detail-page { max-width: 100%; }
  .proj-hero { flex-direction: column; }
  .proj-hero-scores { flex-direction: row; }
  .proj-title { font-size: 1.3rem; }
  .radar-svg { width: 300px; height: 300px; }
  .gallery-main { min-height: 200px; max-height: 360px; }
  .gallery-main img, .gallery-main video { max-height: 360px; }
  .leaderboard-table, .teams-table, .project-table { font-size: 0.8rem; }
  .leaderboard-table th, .leaderboard-table td,
  .teams-table th, .teams-table td { padding: 8px 10px; }
  .judge-top-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select { width: 100%; }
  .lb-btn { width: 36px; height: 36px; font-size: 1.4rem; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
  .lightbox img { max-width: 92%; max-height: 80%; }
  #project-search-bar-wrap { flex-direction: column; align-items: stretch !important; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3e4f; }

/* Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar label { font-size: 0.85rem; color: var(--text-dim); font-weight: 600; }
.filter-bar select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  min-width: 180px;
}
.filter-bar select:focus { border-color: var(--accent); }

/* Member chips */
.members-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.member-chip {
  background: rgba(116, 185, 255, 0.12);
  color: var(--blue);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(116, 185, 255, 0.25);
  white-space: nowrap;
  cursor: default;
}

/* Project table rows */
.project-table td { vertical-align: top; }
.project-row-title { font-weight: 600; font-size: 0.92rem; margin-bottom: 2px; }
.project-row-desc { font-size: 0.78rem; color: var(--text-dim); line-height: 1.4; }

/* Judge top-3 sections on dashboard */
.judge-top-section { margin-bottom: 24px; }
.judge-section-name { font-size: 0.95rem; font-weight: 600; color: var(--accent-light); margin-bottom: 10px; }
.judge-top-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.card-compact { padding: 14px; }
.card-compact .card-title { font-size: 0.92rem; }
.card-compact .card-desc { display: none; }
@media (max-width: 768px) { .judge-top-row { grid-template-columns: 1fr; } }

/* Comment cell in tables */
.comment-cell { max-width: 200px; font-size: 0.8rem; color: var(--text-dim); }
.comment-cell span { cursor: help; }

/* Animations */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
