:root {
  --bg-main: #0a0d16;
  --bg-card: rgba(18, 24, 38, 0.85);
  --bg-card-hover: rgba(26, 35, 56, 0.95);
  --border-subtle: rgba(255, 255, 255, 0.08);

  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-cyan: #06b6d4;
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-blue: #3b82f6;

  --color-tecnica: #06b6d4;
  --color-carroza: #8b5cf6;
  --color-carruaje: #ec4899;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.45;
}

/* Ambient glow blobs */
.background-decorations {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  filter: blur(140px);
  opacity: 0.14;
  border-radius: 50%;
}

.blob-1 { width: 500px; height: 500px; background: var(--accent-purple); top: -100px; left: -100px; }
.blob-2 { width: 600px; height: 600px; background: var(--accent-pink); top: 40%; right: -150px; }
.blob-3 { width: 450px; height: 450px; background: var(--accent-cyan); bottom: -100px; left: 30%; }

/* Broadcast banner */
.broadcast-banner {
  background: linear-gradient(90deg, #180d2b 0%, #0d1e34 50%, #071f28 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.45rem 1.5rem;
  font-size: 0.8rem;
  position: relative;
  z-index: 20;
}

.banner-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.live-tag {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-heading);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #f43f5e;
  text-transform: uppercase;
  font-size: 0.76rem;
}

.pulse {
  width: 8px;
  height: 8px;
  background: #f43f5e;
  border-radius: 50%;
  box-shadow: 0 0 10px #f43f5e;
  animation: pulse 1.3s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.storage-tag {
  color: #6ee7b7;
  font-size: 0.76rem;
  font-weight: 600;
}

.quick-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-sm {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* Header */
.app-header {
  position: relative;
  z-index: 10;
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(10, 13, 22, 0.75);
  backdrop-filter: blur(14px);
}

.header-main {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.fne-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f472b6;
  background: rgba(236, 72, 153, 0.12);
  border: 1px solid rgba(236, 72, 153, 0.3);
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.4rem;
}

.app-title {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 3.2vw, 2.3rem);
  font-weight: 800;
  line-height: 1.15;
}

.gradient-text {
  background: linear-gradient(135deg, #a78bfa 0%, #f472b6 50%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 0.2rem;
}

/* Group Switcher (A / B) */
.group-switcher {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.group-switch-label {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-left: 0.5rem;
}

.switch-buttons {
  display: flex;
  gap: 0.35rem;
}

.switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}

.switch-btn .dot-b, .switch-btn .dot-a {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.switch-btn .dot-b { background: #10b981; }
.switch-btn .dot-a { background: #3b82f6; }

.switch-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.switch-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.switch-btn[data-group="B"].active {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

.switch-btn[data-group="A"].active {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

/* ================= 3 BOARDS GRID ================= */
.boards-container {
  max-width: 1600px;
  margin: 1.5rem auto 3rem;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.board-column {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Column Accent Borders */
.board-tecnica { border-top: 3px solid var(--color-tecnica); }
.board-carroza { border-top: 3px solid var(--color-carroza); }
.board-carruaje { border-top: 3px solid var(--color-carruaje); }

.board-header {
  padding: 1.1rem 1.15rem 0.9rem;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-subtle);
}

.board-title-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.board-icon {
  font-size: 1.6rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.board-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.2;
}

.board-count {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
}

.board-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.board-search {
  position: relative;
  display: flex;
  align-items: center;
}

.board-search svg {
  position: absolute;
  left: 0.75rem;
  color: var(--text-dim);
}

.board-search input {
  width: 100%;
  background: rgba(10, 13, 22, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.75rem 0.45rem 2.2rem;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.board-search input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25);
  background: #111827;
}

.board-sort-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.6rem;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
}

.board-sort-select option {
  background: #131b2e;
  color: var(--text-main);
}

/* ================= PODIUM EN VIVO (TOP 3) ================= */
.podium-box {
  margin: 0.85rem 0.85rem 0.25rem;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.95) 0%, rgba(10, 15, 29, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 20px rgba(0, 0, 0, 0.35);
}

.podium-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.55rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.podium-label {
  font-family: var(--font-heading);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fbbf24;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.podium-tag {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  text-transform: uppercase;
}

.podium-items {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.podium-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  gap: 0.55rem;
  transition: var(--transition);
}

.podium-item.place-1 {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.16) 0%, rgba(245, 158, 11, 0.04) 100%);
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.1);
}

.podium-item.place-2 {
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.14) 0%, rgba(148, 163, 184, 0.03) 100%);
  border-color: rgba(148, 163, 184, 0.35);
}

.podium-item.place-3 {
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.13) 0%, rgba(217, 119, 6, 0.03) 100%);
  border-color: rgba(217, 119, 6, 0.35);
}

.podium-item.place-other {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.14) 0%, rgba(56, 189, 248, 0.04) 100%);
  border-color: rgba(139, 92, 246, 0.35);
}

.place-medal {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.85rem;
  min-width: 44px;
  white-space: nowrap;
}

.place-1 .place-medal { color: #fbbf24; }
.place-2 .place-medal { color: #e2e8f0; }
.place-3 .place-medal { color: #f59e0b; }
.place-other .place-medal { color: #c084fc; }

.place-info {
  flex: 1;
  min-width: 0;
}

.place-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.place-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.place-score {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.88rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  white-space: nowrap;
}

.place-1 .place-score {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.16);
  border-color: rgba(251, 191, 36, 0.45);
}

.podium-item.empty {
  opacity: 0.55;
  border-style: dashed;
}

.empty-text {
  color: var(--text-dim) !important;
  font-style: italic;
}

.empty-score {
  color: var(--text-dim) !important;
  background: transparent !important;
  border: none !important;
}

/* Board Items List */
.board-list {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: calc(100vh - 430px);
  min-height: 400px;
  overflow-y: auto;
}

/* Custom Scrollbar */
.board-list::-webkit-scrollbar {
  width: 5px;
}
.board-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* School Card */
.school-item-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: var(--transition);
}

.school-item-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.school-item-card.rank-1 {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(255, 255, 255, 0.02));
}

.card-top-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.card-order-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
}

.order-pill {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  white-space: nowrap;
}

.badge-grp {
  font-family: var(--font-heading);
  font-size: 0.64rem;
  font-weight: 800;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-grp-b {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-grp-a {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.rank-1 .order-pill {
  background: #fbbf24;
  color: #451a03;
}

.school-info {
  flex: 1;
  min-width: 0;
}

.school-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--text-main);
  word-break: break-word;
}

.school-loc {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.cat-pill-wrapper {
  margin-left: auto;
  flex-shrink: 0;
}

.category-select {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}

.category-select:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.25);
}

.category-select option {
  background: #111827;
  color: #fff;
  font-size: 0.85rem;
}

/* Card Controls Row */
.card-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.score-widget {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.15rem 0.3rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.step-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-main);
  width: 24px;
  height: 24px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-btn:hover {
  background: var(--accent-purple);
  color: #fff;
}

.score-input {
  width: 65px;
  background: transparent;
  border: none;
  color: #fff;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 900;
  text-align: center;
  outline: none;
}

.award-widget {
  flex: 1;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.award-select {
  width: 100%;
  background: rgba(10, 13, 22, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}

.award-select.shared-highlight {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

.badge-shared {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(236, 72, 153, 0.25));
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.5);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--accent-purple);
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  opacity: 0;
  transform: translateY(15px);
  pointer-events: none;
  transition: all 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-size: 0.82rem;
}

.footer-note {
  margin-top: 0.25rem;
  font-size: 0.76rem;
  color: #6ee7b7;
}

/* Responsive for Mobile / Tablet */
@media (max-width: 1080px) {
  .boards-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .board-list {
    max-height: 550px;
  }
}
