:root {
  --bg: #0c0d10;
  --fg: #f4f5f7;
  --muted: #9aa0a6;
  --accent: #ffffff;
  --card: rgba(20, 22, 27, 0.72);
  --border: rgba(255, 255, 255, 0.12);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must win over the display rules below
   (.reveal/.gate use display:flex, which would otherwise keep them visible). */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Work Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* ---- Video background + animated gradient fallback ---------------------- */
.bg-video,
.bg-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.bg-video {
  object-fit: cover;
  z-index: -2;
  /* Shown when no video file is present yet. */
  background: linear-gradient(120deg, #1a1c2e, #0c0d10, #1e2330, #11131a);
  background-size: 400% 400%;
  animation: drift 24s ease infinite;
}

@keyframes drift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.bg-overlay {
  z-index: -1;
  background: radial-gradient(
      ellipse at center,
      rgba(12, 13, 16, 0.45),
      rgba(12, 13, 16, 0.85)
    );
}

@media (prefers-reduced-motion: reduce) {
  .bg-video { animation: none; }
}

/* ---- Landing ----------------------------------------------------------- */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.25rem;
  gap: 0.35rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 700;
  margin: 0.2rem 0 0;
}

.subtitle {
  color: var(--muted);
  max-width: 30rem;
  line-height: 1.5;
  margin: 0.5rem 0 1.75rem;
}

/* ---- Cards / forms ----------------------------------------------------- */
.card {
  width: 100%;
  max-width: 22rem;
  background: var(--card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  text-align: left;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.7rem 0.8rem;
  color: var(--fg);
  font-size: 0.95rem;
  transition: border-color 0.15s ease;
}

input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.55);
}

button {
  background: var(--accent);
  color: #0c0d10;
  border: none;
  border-radius: 9px;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

button:hover {
  opacity: 0.9;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.form-message {
  margin: 0;
  font-size: 0.82rem;
  min-height: 1rem;
  color: #ff8d8d;
}

.form-message.ok {
  color: #87f5b0;
}

.counter {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 1.25rem;
}

.counter span {
  color: var(--fg);
  font-weight: 600;
}

/* ---- Team reveal modal ------------------------------------------------- */
.reveal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 12, 0.7);
  backdrop-filter: blur(6px);
  z-index: 10;
  animation: fade 0.25s ease;
}

.reveal-card {
  text-align: center;
  padding: 2.5rem 2rem;
  animation: pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

.reveal-label {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}

.reveal-team {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  margin: 0.4rem 0;
}

.reveal-sub {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---- Coordinator ------------------------------------------------------- */
.coordinator-body {
  background: #0c0d10;
}

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.gate h1 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
}

.dashboard {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.dashboard-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.dashboard-head h1 {
  font-size: 1.8rem;
  margin: 0;
}

.muted {
  color: var(--muted);
  margin: 0.3rem 0 0;
}

.dashboard-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dashboard-actions input {
  min-width: 14rem;
}

.dashboard-actions button {
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
}

.teams {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 640px) {
  .teams {
    grid-template-columns: 1fr;
  }
}

.team {
  background: rgba(20, 22, 27, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}

.team h2 {
  font-size: 1.05rem;
  margin: 0 0 0.2rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.team h2 .count {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.team ul {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.team li {
  font-size: 0.9rem;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.team li .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
}

.team li .member-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}

.remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 0.2rem;
  cursor: pointer;
  width: auto;
  flex-shrink: 0;
  opacity: 0.55;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.remove-btn:hover {
  color: #ff8d8d;
  opacity: 1;
}

.team li .email {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.team li .joined {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  opacity: 0.8;
}

.team .empty {
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* ---- Entrance animations ---------------------------------------------- */
.reveal-up {
  opacity: 0;
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  animation-delay: var(--d, 0s);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal-up {
    animation: none;
    opacity: 1;
  }
}

.hero-links {
  margin-top: 1.5rem;
  display: flex;
  gap: 1.25rem;
  align-items: center;
  justify-content: center;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
  cursor: pointer;
  transition: color 0.15s ease;
}

.link-btn:hover {
  color: var(--fg);
  opacity: 1;
}

.lookup-card {
  margin-top: 1rem;
}

.hero-links a,
.ghost-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s ease;
}

.hero-links a:hover,
.ghost-link:hover {
  color: var(--fg);
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 0.85rem;
}

/* ---- Reveal coordinator callout --------------------------------------- */
.reveal-coordinator {
  margin: 0 auto 1.5rem;
  max-width: 22rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(139, 147, 255, 0.1);
}

.reveal-coordinator p {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.reveal-coordinator a {
  color: #c2c8ff;
  font-weight: 600;
  text-decoration: none;
}

/* ---- Confetti --------------------------------------------------------- */
.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

/* ---- Sonner-style toasts ---------------------------------------------- */
#toaster {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(24rem, calc(100vw - 2rem));
}

.toast {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  background: rgba(24, 26, 32, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast-leave {
  animation: toast-out 0.25s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

.toast-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-error .toast-icon {
  color: #ff8d8d;
}
.toast-success .toast-icon {
  color: #87f5b0;
}
.toast-info .toast-icon {
  color: #c2c8ff;
}

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.toast-desc {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.toast-desc a {
  color: #c2c8ff;
  text-decoration: none;
  font-weight: 500;
}

.toast-desc a:hover {
  text-decoration: underline;
}

.toast-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.toast-action {
  flex: 0 0 auto;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  cursor: pointer;
  width: auto;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.toast-action:hover {
  background: rgba(255, 255, 255, 0.12);
}

.toast-action-danger {
  border-color: rgba(255, 141, 141, 0.4);
  background: rgba(255, 141, 141, 0.12);
  color: #ff8d8d;
}

.toast-action-danger:hover {
  background: rgba(255, 141, 141, 0.22);
}

.toast-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.1rem;
  cursor: pointer;
  width: auto;
}

.toast-close:hover {
  color: var(--fg);
  opacity: 1;
}

/* ---- Leaderboard ------------------------------------------------------ */
.plain-body {
  background: #0c0d10;
}

.board {
  max-width: 46rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.board-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.board-head h1 {
  font-size: 2rem;
  margin: 0.1rem 0 0;
}

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

.edit-hint {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(20, 22, 27, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}

.row-rank {
  font-size: 1.4rem;
  font-weight: 700;
  width: 2rem;
  text-align: center;
  color: var(--muted);
  flex-shrink: 0;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.45rem;
}

.row-name {
  font-weight: 600;
}

.row-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
}

.row-score.bump {
  animation: bump 0.35s ease;
}

@keyframes bump {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.35);
    color: #87f5b0;
  }
  100% {
    transform: scale(1);
  }
}

.bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #6c75e0, #8b93ff);
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.row-members {
  display: block;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.row-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.row-controls button {
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.1rem;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.row-controls button:hover {
  background: rgba(255, 255, 255, 0.06);
  opacity: 1;
}

.score-input {
  width: 4rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---- v3: required marks, icons, panels, podium, badges ---------------- */
.req {
  color: #ff9d9d;
  font-style: normal;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.ic {
  width: 1.05em;
  height: 1.05em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.closed-banner {
  max-width: 22rem;
  margin: 0 auto;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(255, 157, 157, 0.35);
  background: rgba(255, 100, 100, 0.08);
  border-radius: var(--radius);
  color: #ffc9c9;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ---- Page nav (shared) ----------------------------------------------- */
.page-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ---- Coordinator panels ---------------------------------------------- */
.panel {
  background: rgba(20, 22, 27, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.3rem;
  margin-bottom: 1.25rem;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.panel-head h2 {
  font-size: 1.05rem;
  margin: 0;
}

.status-pill {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
}
.status-pill.open {
  color: #87f5b0;
  border-color: rgba(135, 245, 176, 0.4);
  background: rgba(135, 245, 176, 0.1);
}
.status-pill.closed {
  color: #ff9d9d;
  border-color: rgba(255, 157, 157, 0.4);
  background: rgba(255, 157, 157, 0.1);
}

/* ---- Registration toggle --------------------------------------------- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.toggle-title {
  margin: 0;
  font-weight: 500;
}

.toggle-sub {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--border);
  border-radius: 99px;
  transition: background 0.2s ease;
}
.slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}
.switch input:checked + .slider {
  background: #4caf73;
  border-color: transparent;
}
.switch input:checked + .slider::before {
  transform: translateX(20px);
}
.switch input:focus-visible + .slider {
  outline: 2px solid #c2c8ff;
  outline-offset: 2px;
}

/* ---- Score editor ---------------------------------------------------- */
.score-editor {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.6rem;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.score-team {
  font-weight: 500;
  font-size: 0.92rem;
}

.score-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.score-controls button {
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  font-size: 1.05rem;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.score-controls button:hover {
  background: rgba(255, 255, 255, 0.06);
  opacity: 1;
}

/* ---- Toolbar (search + actions) -------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.1rem;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 13rem;
}
.search-wrap .ic {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.search-wrap input {
  width: 100%;
  padding-left: 2.2rem;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
}
.btn-group button {
  font-size: 0.85rem;
  padding: 0.55rem 0.9rem;
}

/* ---- Role badges ----------------------------------------------------- */
.badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.05rem 0.35rem;
  border-radius: 5px;
  vertical-align: middle;
  margin-left: 0.15rem;
}
.badge-c {
  color: #ffe08a;
  background: rgba(255, 224, 138, 0.14);
}
.badge-v {
  color: #c2c8ff;
  background: rgba(194, 200, 255, 0.14);
}

/* ---- Podium ---------------------------------------------------------- */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.9rem;
  margin: 0.5rem 0 2rem;
  min-height: 220px;
}

.podium-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: clamp(5rem, 26%, 9rem);
}

.podium-medal {
  font-size: 1.6rem;
}

.podium-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0.25rem 0 0.5rem;
  text-align: center;
}

.podium-block {
  position: relative;
  width: 100%;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, rgba(108, 117, 224, 0.55), rgba(108, 117, 224, 0.15));
  border: 1px solid var(--border);
  border-bottom: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  transition: height 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.place-1 .podium-block {
  background: linear-gradient(180deg, rgba(255, 215, 130, 0.6), rgba(255, 215, 130, 0.12));
}
.place-2 .podium-block {
  background: linear-gradient(180deg, rgba(200, 208, 220, 0.5), rgba(200, 208, 220, 0.12));
}
.place-3 .podium-block {
  background: linear-gradient(180deg, rgba(214, 158, 110, 0.5), rgba(214, 158, 110, 0.12));
}

.podium-score {
  margin-top: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.podium-place {
  position: absolute;
  bottom: 0.4rem;
  font-size: 2rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.18);
}
