/* ── Data Team Claude Grand Prix — night-race theme ─────────────────── */

:root {
  --bg: #0b1120;
  --bg-2: #0e1730;
  --panel: #121c36;
  --panel-2: #182347;
  --line: #24325e;
  --text: #e8edfb;
  --muted: #93a1c8;
  --gold: #ffd166;
  --gold-2: #f4a825;
  --green: #34d399;
  --red: #fb7185;
  --accent: #7aa2ff;
  --asphalt: #151d38;
  --lane-h: 34px;
  --rank-w: 48px;
  --finish-w: 92px;
  --radius: 14px;
  --font-display: "Racing Sans One", "Arial Black", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 500px at 70% -10%, #1b2b5e66, transparent 60%),
    radial-gradient(900px 400px at 10% 0%, #3b1d5e33, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}
.hidden { display: none !important; }
a { color: var(--accent); }

/* ── Full-screen entry cards ── */
.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px #00000066;
  padding: 36px 32px;
}
.center-card { width: min(430px, 100%); text-align: center; }
.big-flag { font-size: 52px; line-height: 1; margin-bottom: 8px; }
.brand {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.1;
  margin: 8px 0 10px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--gold), #fff2c9, var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sm { font-family: var(--font-display); font-size: 24px; margin: 6px 0 14px; letter-spacing: 1px; }
.brand-inline { font-family: var(--font-display); letter-spacing: 1px; }
.gold-text { color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--red); font-size: 13.5px; margin-top: 10px; }

input[type="password"], input[type="text"], select {
  width: 100%;
  padding: 12px 14px;
  margin: 8px 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
select { appearance: none; cursor: pointer; }
.pin-box {
  text-align: center;
  font-size: 26px !important;
  letter-spacing: 14px;
  font-family: var(--font-body);
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin: 6px 0;
  width: 100%;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(90deg, var(--gold), var(--gold-2)); color: #201500; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover:not(:disabled) { border-color: var(--accent); }
.btn.danger { background: #61233a; color: #ffd9e1; border: 1px solid #a03a58; }
.btn-row { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.linklike {
  background: none; border: none; color: var(--muted);
  cursor: pointer; text-decoration: underline; font-size: 13.5px; padding: 4px;
}
.linklike:hover { color: var(--text); }

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: #0c132866;
  backdrop-filter: blur(6px);
}
.topbar-title { font-size: 18px; }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
#whoami strong { color: var(--text); }

/* ── Race track ── */
.race-section { padding: 18px 20px 6px; }
.race-caption {
  display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px;
  font-family: var(--font-display);
  letter-spacing: 2px;
  font-size: 15px;
  color: var(--gold);
  margin-bottom: 10px;
}
.race-sub { font-family: var(--font-body); letter-spacing: 0; font-size: 12.5px; color: var(--muted); }
.race-scroll { overflow-x: auto; border-radius: var(--radius); }
.race-track {
  position: relative;
  min-width: 680px;
  background:
    repeating-linear-gradient(90deg, transparent 0 120px, #ffffff05 120px 121px),
    linear-gradient(180deg, #131c39, var(--asphalt));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.lane {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: var(--lane-h);
  transition: transform .9s cubic-bezier(.22,1,.36,1);
  border-bottom: 1px dashed #ffffff12;
}
.lane.is-me { background: #ffd16610; }
.lane-rank {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--rank-w);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  border-right: 1px solid #ffffff14;
  background: #0b112066;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 15px;
}
.lane-run {
  position: absolute;
  left: calc(var(--rank-w) + 12px);
  right: calc(var(--finish-w) + 14px);
  top: 0; bottom: 0;
}
.racer {
  position: absolute;
  top: 50%;
  transform: translate(-6px, -50%);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: left .9s cubic-bezier(.22,1,.36,1);
  cursor: default;
  white-space: nowrap;
  z-index: 2;
}
.racer-emoji { font-size: 20px; filter: drop-shadow(0 2px 3px #000a); }
.racer-chip {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  background: #0b1120cc;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}
.racer.flip {
  flex-direction: row-reverse;
  transform: translate(calc(-100% + 28px), -50%);
}
.racer-emoji { display: inline-block; transform: scaleX(-1); }
.racer .star { font-size: 13px; }
.phase-line {
  position: absolute; top: 0; bottom: 0;
  border-left: 1px dashed #7aa2ff44;
  z-index: 1;
}
.phase-line span {
  position: absolute; top: 2px; left: 4px;
  font-size: 10px; color: #7aa2ff88; letter-spacing: 1px;
}
.finish-zone {
  position: absolute; top: 0; bottom: 0; right: 0;
  width: var(--finish-w);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  background: #100f1d;
  border-left: 2px solid var(--gold-2);
  z-index: 3;
}
.finish-checkers {
  position: absolute; left: -12px; top: 0; bottom: 0; width: 10px;
  background:
    repeating-conic-gradient(#e8edfb 0% 25%, #0b1120 0% 50%) 0 0 / 10px 10px;
  opacity: .9;
}
.gold-star {
  font-size: 30px;
  animation: pulse 2.2s ease-in-out infinite;
}
.gold-label {
  font-family: var(--font-display);
  font-size: 11px;
  text-align: center;
  color: var(--gold);
  letter-spacing: 1px;
  line-height: 1.3;
}
.gold-label span { font-size: 14px; }
@keyframes pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px #ffd16688); }
  50% { transform: scale(1.15); filter: drop-shadow(0 0 14px #ffd166cc); }
}

/* ── Panels ── */
.panel { margin: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.panel-title { font-family: var(--font-display); letter-spacing: 1.5px; font-size: 17px; margin: 2px 0 12px; }

/* Collapsible panel header (leaderboard) */
.collapse-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 2px 0; margin: 0 0 12px;
  background: none; border: none; color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.collapse-toggle:hover { color: var(--gold); }
.collapse-toggle .chevron {
  display: inline-block; font-size: 13px; color: var(--muted);
  transition: transform .2s ease;
}
.collapse-toggle .collapse-hint {
  margin-left: auto; font-family: var(--font-body); font-size: 11.5px;
  letter-spacing: 0; color: var(--muted); text-transform: uppercase;
}
.panel.collapsed .collapse-toggle { margin-bottom: 0; }
.panel.collapsed .chevron { transform: rotate(-90deg); }

/* ── Leaderboard ── */
.table-scroll { overflow-x: auto; }
#leaderboard { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
#leaderboard th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  letter-spacing: .5px; text-transform: uppercase;
  padding: 6px 10px; border-bottom: 1px solid var(--line);
}
#leaderboard td { padding: 8px 10px; border-bottom: 1px solid #1b2750; vertical-align: middle; }
#leaderboard tr.is-me td { background: #ffd16612; }
#leaderboard tr:last-child td { border-bottom: none; }
.rank-cell { font-size: 15px; width: 34px; }
.th-progress { min-width: 160px; }
.progress-outer {
  position: relative; height: 10px; border-radius: 999px;
  background: #0b1120; border: 1px solid var(--line); overflow: hidden;
}
.progress-inner {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width .7s ease;
}
.pct-label { font-size: 11.5px; color: var(--muted); margin-left: 6px; }
.reward-chip {
  display: inline-block; background: #3a2c05; color: var(--gold);
  border: 1px solid var(--gold-2); border-radius: 999px;
  padding: 2px 9px; font-weight: 700; font-size: 12px; white-space: nowrap;
}
.reward-chip.phase {
  background: #10233d; color: var(--accent); border-color: #35478a;
  padding: 2px 8px; font-size: 11.5px;
}
.name-cell { font-weight: 600; white-space: nowrap; }

/* ── Courses ── */
.phase-block { margin-bottom: 16px; }
.phase-head {
  font-family: var(--font-display); letter-spacing: 1px; font-size: 14px;
  color: var(--accent); margin: 14px 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.phase-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.course {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 14px; margin-bottom: 8px;
  transition: border-color .15s ease;
}
.course:hover { border-color: #35478a; }
.course.done { border-color: #2b5c46; background: #10251f55; }
.course input[type="checkbox"] {
  width: 20px; height: 20px; margin-top: 2px; accent-color: var(--green); cursor: pointer; flex: none;
}
.course input[type="checkbox"]:disabled { cursor: not-allowed; opacity: .35; }
.course-body { flex: 1; min-width: 0; }
.course-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.course-title { font-weight: 700; font-size: 14.5px; color: var(--text); text-decoration: none; }
.course-title:hover { color: var(--gold); text-decoration: underline; }
.hours-chip {
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px; white-space: nowrap;
}
.course-desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }

/* ── Claim banner ── */
.claim-banner {
  margin: 14px 20px 0;
  border: 1px solid var(--gold-2);
  background: linear-gradient(90deg, #3a2c0533, #3a2c0577);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.claim-banner .btn { width: auto; margin: 0; }
.claim-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.claim-text { font-size: 14.5px; }

/* ── Footer ── */
.footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px 18px; gap: 10px;
}

/* ── Tooltip ── */
.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: #0b1120f2; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font-size: 12.5px; max-width: 260px;
  box-shadow: 0 10px 30px #000a; line-height: 1.5;
}
.tooltip strong { color: var(--gold); }

/* ── Modal ── */
.modal-root {
  position: fixed; inset: 0; z-index: 50;
  background: #060a14cc;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal { width: min(440px, 100%); text-align: left; max-height: 85vh; overflow-y: auto; }
.modal h3 { font-family: var(--font-display); letter-spacing: 1px; margin: 2px 0 10px; }
.admin-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 4px; border-bottom: 1px solid #1b2750; font-size: 13.5px;
}
.admin-row .btn { width: auto; padding: 6px 12px; font-size: 12.5px; margin: 0; }
.admin-row .nopin { color: var(--muted); font-size: 12px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #0b1120f2; border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 10px 18px; font-size: 13.5px; z-index: 70;
  box-shadow: 0 10px 30px #000a;
}
.toast.err { border-color: var(--red); }

/* ── Confetti ── */
.confetti-piece {
  position: fixed; top: -14px; z-index: 80; pointer-events: none;
  width: 9px; height: 14px; border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: .9; }
}

@media (max-width: 640px) {
  .panel { margin: 12px 10px; padding: 12px; }
  .race-section { padding: 12px 10px 4px; }
  .claim-banner { margin: 10px 10px 0; }
  .topbar { padding: 12px 12px; }
  .brand { font-size: 28px; }
}
