/* Next Technologies brand — warm palette */
:root {
  --mocha: #230F05;
  --merlot: #69140A;
  --crimson: #CD1405;
  --crimson-2: #ab1509;
  --scarlet: #FF0F05;
  --coral: #FF5541;
  --lemon: #F5EC5A;
  --lemon-soft: #FAF6CC;
  --ivory: #FFFFF0;
  --paper: #FFFFFF;
  --ink: #230F05;
  --muted: #6b524a;
  --line: rgba(35, 15, 5, 0.10);
  --line-strong: rgba(35, 15, 5, 0.18);
  --gradient-warm: linear-gradient(135deg, var(--merlot) 0%, var(--scarlet) 55%, var(--lemon) 100%);
  --gradient-soft: linear-gradient(180deg, var(--ivory) 0%, #FFF5E6 100%);
  --shadow-xs: 0 1px 2px rgba(35, 15, 5, 0.06);
  --shadow-sm: 0 2px 6px rgba(35, 15, 5, 0.08);
  --shadow-md: 0 6px 24px rgba(35, 15, 5, 0.12);
  --shadow-lg: 0 16px 40px rgba(35, 15, 5, 0.18);
  --shadow-glow: 0 0 0 4px rgba(205, 20, 5, 0.18);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --primary-font: "DM Sans", "Hellix", "Century Gothic", system-ui, -apple-system, sans-serif;
  --easing: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--primary-font);
  background: var(--gradient-soft);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Type scale ---------- */
h1 { font-size: clamp(24px, 3vw, 32px); margin: 0 0 8px; letter-spacing: -0.02em; line-height: 1.15; font-weight: 700; }
h2 { font-size: clamp(18px, 2vw, 22px); margin: 0 0 8px; letter-spacing: -0.01em; line-height: 1.25; font-weight: 700; }
h3 { font-size: 17px; margin: 0 0 6px; line-height: 1.3; font-weight: 600; }
p { margin: 0 0 12px; line-height: 1.55; }
p.lead { font-size: 17px; line-height: 1.5; }
p.muted, .muted { color: var(--muted); font-size: 14px; }
p.err, .err { color: var(--crimson); font-weight: 600; padding: 10px 14px; background: rgba(205, 20, 5, 0.06); border-radius: 8px; border-left: 3px solid var(--crimson); }
small { color: var(--muted); }

/* Focus styles — accessible, brand-aware */
:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline-offset: 3px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--crimson);
  background-image: linear-gradient(90deg, var(--merlot) 0%, var(--crimson) 50%, var(--scarlet) 100%);
  color: var(--ivory);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ivory); text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px;
  background: var(--ivory);
  border-radius: 10px;
  position: relative;
  flex: 0 0 auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.brand-mark::before {
  content: "n";
  position: absolute;
  inset: 0;
  display: grid; place-items: center;
  font-weight: 800;
  color: var(--crimson);
  font-size: 28px;
  font-family: var(--primary-font);
  line-height: 1;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-weight: 800; letter-spacing: -0.01em; font-size: 14px; }
.brand-text em { font-style: normal; font-size: 11px; opacity: 0.92; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 1px; }

.topbar-nav { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.topbar-nav a { color: var(--ivory); text-decoration: none; opacity: 0.92; padding: 4px 0; border-bottom: 2px solid transparent; transition: all 0.15s var(--easing); }
.topbar-nav a:hover { opacity: 1; border-bottom-color: var(--lemon); }
.topbar-nav .who { padding-left: 12px; border-left: 1px solid rgba(255, 255, 240, 0.35); opacity: 0.92; font-weight: 500; }
.link-btn { background: none; border: 0; color: var(--ivory); cursor: pointer; font: inherit; opacity: 0.85; padding: 0; transition: opacity 0.15s; }
.link-btn:hover { opacity: 1; text-decoration: underline; }

@media (max-width: 600px) {
  .topbar { padding: 10px 14px; }
  .topbar-nav { gap: 10px; font-size: 13px; }
  .topbar-nav .who { display: none; }
  .topbar-nav a:not(:last-child) { display: none; }
}

.main { flex: 1 0 auto; max-width: 980px; width: 100%; margin: 0 auto; padding: 20px 16px 40px; }
.footer { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  animation: cardIn 0.35s var(--easing) both;
}
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; margin-top: 48px; padding: 32px; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Hero (public landing) ---------- */
.hero {
  background: var(--gradient-warm);
  background-size: 200% 200%;
  color: var(--ivory);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  animation: heroShimmer 18s ease infinite;
}
@keyframes heroShimmer {
  0%,100% { background-position: 0% 50%; }
  50%     { background-position: 100% 50%; }
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(245, 236, 90, 0.25) 0%, transparent 45%);
  pointer-events: none;
}
.hero h1 {
  font-size: clamp(32px, 5vw, 52px);
  margin: 0 0 12px;
  letter-spacing: -0.025em;
  font-weight: 800;
  line-height: 1.05;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  position: relative;
}
.hero p.lead {
  color: var(--ivory);
  opacity: 0.95;
  font-size: 18px;
  max-width: 56ch;
  position: relative;
}
.hero .pill-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 240, 0.18);
  border: 1px solid rgba(255, 255, 240, 0.3);
  color: var(--ivory);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  backdrop-filter: blur(8px);
}
.hero .pill-live::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--lemon);
  box-shadow: 0 0 0 0 rgba(245, 236, 90, 0.6);
  animation: pulse 1.6s var(--easing) infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245, 236, 90, 0.6); }
  70%  { box-shadow: 0 0 0 10px rgba(245, 236, 90, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 236, 90, 0); }
}

.tiles { display: grid; gap: 14px; grid-template-columns: 1fr; margin-top: 24px; position: relative; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .tiles { grid-template-columns: repeat(4, 1fr); } }

.tile {
  display: block;
  background: var(--paper);
  color: var(--ink);
  padding: 22px 20px;
  border-radius: var(--radius);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  transition: transform 0.2s var(--easing), box-shadow 0.2s var(--easing), border-color 0.2s var(--easing);
  position: relative;
}
.tile h3 { color: var(--crimson); margin: 0 0 6px; font-weight: 700; }
.tile p { font-size: 14px; color: var(--muted); margin: 0; line-height: 1.45; }
.tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--coral);
}
.tile.primary-tile {
  background: var(--lemon);
  border: 2px solid var(--mocha);
  box-shadow: var(--shadow-md);
}
.tile.primary-tile h3 { color: var(--mocha); font-size: 18px; }
.tile.primary-tile p { color: var(--mocha); }
.tile.primary-tile::after {
  content: "→";
  position: absolute;
  top: 22px; right: 20px;
  font-size: 22px;
  font-weight: 700;
  color: var(--crimson);
  transition: transform 0.2s var(--easing);
}
.tile.primary-tile:hover::after { transform: translateX(4px); }
.tile.primary-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 5px; }
.form label > span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.form input, .form select, .form textarea {
  font: inherit;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px rgba(205, 20, 5, 0.12);
}
.form .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 11px 18px;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s var(--easing), box-shadow 0.15s, background 0.15s, border-color 0.15s;
  position: relative;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--crimson);
  color: var(--ivory);
  border-color: var(--crimson);
  box-shadow: 0 4px 14px rgba(205, 20, 5, 0.32);
}
.btn.primary:hover {
  background: var(--crimson-2);
  border-color: var(--crimson-2);
  box-shadow: 0 8px 20px rgba(205, 20, 5, 0.4);
}
.btn.ghost { background: transparent; border-style: dashed; color: var(--mocha); }
.btn.ghost:hover { background: var(--lemon-soft); border-color: var(--mocha); border-style: solid; }
.btn.danger { background: var(--paper); color: var(--crimson); border-color: var(--crimson); }
.btn.danger:hover { background: var(--crimson); color: var(--ivory); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn.large { padding: 14px 22px; font-size: 16px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

/* ---------- Search & results ---------- */
.search input { width: 100%; }
.results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow-xs);
}
.results li {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: background 0.12s;
}
.results li:first-child { border-top: 0; }
.results li:hover { background: var(--lemon-soft); }
.results .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pill.delegate { background: var(--lemon); color: var(--mocha); }
.pill.sponsor { background: var(--crimson); color: var(--ivory); }
.or {
  text-align: center;
  color: var(--muted);
  margin: 16px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  position: relative;
}
.or::before, .or::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 32px);
  height: 1px;
  background: var(--line);
}
.or::before { left: 0; }
.or::after { right: 0; }

/* ---------- Status row & session header ---------- */
.status-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.session-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 14px; color: var(--muted); }
.session-meta .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ivory);
  color: var(--crimson);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 13px;
  border: 1px solid var(--line);
}
.session-meta .chip.am { background: linear-gradient(135deg, #FFF7C2, var(--lemon)); color: var(--mocha); border-color: rgba(35, 15, 5, 0.15); }
.session-meta .chip.pm { background: linear-gradient(135deg, var(--coral), var(--scarlet)); color: var(--ivory); border-color: var(--scarlet); }
.hello {
  background: var(--lemon);
  color: var(--mocha);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 14px;
  border: 1px solid rgba(35, 15, 5, 0.15);
}

/* ---------- Steps ---------- */
.step { animation: fadeIn 0.18s var(--easing); }
.step.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Score entry ---------- */
.big-score input {
  font-size: 56px;
  text-align: center;
  padding: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  background: var(--lemon-soft);
  border-color: var(--lemon);
}
.big-score input:focus { background: var(--paper); }
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 10px 0;
}
.qbtn {
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 16px 0;
  font: inherit;
  font-weight: 700;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.12s var(--easing);
  font-variant-numeric: tabular-nums;
}
.qbtn:hover { background: var(--lemon-soft); border-color: var(--mocha); transform: translateY(-1px); }
.qbtn:active { transform: translateY(0) scale(0.97); background: var(--lemon); }

details summary { color: var(--muted); cursor: pointer; padding: 8px 0; font-size: 13px; font-weight: 600; }
details[open] summary { color: var(--ink); }
fieldset.stream-toggle { border: 1px solid var(--line-strong); border-radius: 10px; padding: 12px 14px; }
fieldset.stream-toggle legend { font-size: 12px; color: var(--muted); padding: 0 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.radio { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; cursor: pointer; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--mocha);
  color: var(--ivory);
  padding: 14px 22px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  animation: toastIn 0.25s var(--easing);
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.toast.hidden { display: none; }
.toast.error { background: var(--crimson); }

/* ---------- Recent / list ---------- */
.recent { list-style: none; padding: 0; margin: 0; }
.recent li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  gap: 12px;
}
.recent li:first-child { border-top: 0; }
.recent .empty {
  padding: 28px 16px;
  text-align: center;
  background: var(--lemon-soft);
  border-radius: 12px;
  border: 1px dashed var(--line-strong);
  color: var(--mocha);
  font-weight: 500;
}
.recent .empty::before {
  content: "🎯";
  display: block;
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.7;
}

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th {
  background: var(--ivory);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  position: sticky; top: 0;
}
.table .num, .table .total { text-align: right; font-variant-numeric: tabular-nums; }
.table .total { font-weight: 800; color: var(--crimson); font-size: 16px; }
.table .rank { width: 44px; font-weight: 800; color: var(--mocha); font-variant-numeric: tabular-nums; }
.table tr.top { background: linear-gradient(90deg, rgba(245, 236, 90, 0.35), rgba(245, 236, 90, 0.10)); }
.table tr.top .rank { color: var(--crimson); position: relative; }
.table tr.top .rank::before { content: "🏆 "; }
.table input.inline, .table select.inline { padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 7px; font: inherit; width: 100%; background: var(--paper); }
.table input.inline.tight { width: 80px; }
.table input.inline:focus, .table select.inline:focus { outline: none; border-color: var(--crimson); box-shadow: 0 0 0 2px rgba(205, 20, 5, 0.15); }
.table .actions { white-space: nowrap; }
.table.small { font-size: 12px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; word-break: break-all; }

/* Card-style rows on small screens */
@media (max-width: 760px) {
  .table.responsive thead { display: none; }
  .table.responsive tbody { display: grid; gap: 12px; }
  .table.responsive tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    padding: 14px;
    background: var(--paper);
    box-shadow: var(--shadow-xs);
  }
  .table.responsive td {
    border: 0;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
  }
  .table.responsive td::before {
    content: attr(data-label);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 2px;
  }
  .table.responsive td.full { grid-column: 1 / -1; }
  .table.responsive td.actions { grid-column: 1 / -1; display: flex; flex-direction: row; justify-content: flex-end; gap: 8px; padding-top: 6px; border-top: 1px dashed var(--line); margin-top: 4px; }
  .table.responsive td.actions::before { display: none; }
}

/* ---------- KPIs ---------- */
.kpis { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 16px; }
.kpis li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-xs);
}
.kpis .k { display: block; font-size: 32px; font-weight: 800; color: var(--crimson); letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpis .v { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }

/* ---------- Prose ---------- */
.prose { line-height: 1.65; }
.prose h2 { margin-top: 24px; color: var(--crimson); }
.prose ul, .prose ol { padding-left: 22px; }
.prose .prize-list li { margin-bottom: 8px; }

/* ---------- Tabs ---------- */
.board-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 6px;
  background: var(--ivory);
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
}
.tab {
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font: inherit;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  transition: all 0.15s var(--easing);
}
.tab:hover { color: var(--ink); }
.tab.active {
  background: var(--crimson);
  color: var(--ivory);
  box-shadow: 0 2px 8px rgba(205, 20, 5, 0.3);
}
.board.hidden { display: none; }

/* ---------- Success card (registration) ---------- */
.success-card {
  background: linear-gradient(135deg, var(--lemon) 0%, var(--lemon-soft) 100%);
  border-radius: var(--radius);
  padding: 24px;
  margin: 16px 0;
  border: 2px solid var(--mocha);
  text-align: center;
  animation: pop 0.4s var(--easing);
}
.success-card::before {
  content: "🎉";
  display: block;
  font-size: 44px;
  margin-bottom: 8px;
}
.success-card h2 { color: var(--mocha); margin-top: 0; font-size: 22px; }
.success-card p { color: var(--mocha); }
.success-card .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
@keyframes pop {
  0%   { transform: scale(0.95); opacity: 0; }
  60%  { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Public leader board emphasis ---------- */
.table.leader tbody tr {
  transition: background 0.12s;
}
.table.leader tbody tr:hover { background: var(--lemon-soft); }

.hidden { display: none !important; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
