@import url("https://fonts.bunny.net/css?family=oxanium:200,300,400,500,600,700,800&display=swap");

:root {
  --bg: #0e0e0e;
  --card: #1a1a1a;
  --border: #2a2a2a;
  --fg: #f0f0f0;
  --muted: #888;
  --accent: #e10600;
  --accent-glow: rgba(225, 6, 0, 0.25);
  --font-sans: "Oxanium", "Segoe UI", system-ui, sans-serif;
}

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

  /* Trying to improve font quality */
  text-shadow: rgba(0, 0, 0, 0.01) 0 0 1px;
  font-smooth: always;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: grayscale;
  -o-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-family: var(--font-sans);
}

html {
  font-size: 16px;
}

body {
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

body::before {
  content: "";
  position: fixed;
  top: 40%;
  left: 50%;
  width: 600px;
  height: 400px;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
}

header {
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

header h1 span {
  color: var(--accent);
}

header p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

.loading {
  text-align: center;
  padding: 3rem 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.loading .spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 0.8rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error {
  text-align: center;
  padding: 2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--accent);
  font-size: 0.9rem;
}

.next-race-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem 1rem 1.4rem;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.4s ease both;
}

.next-race-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent);
  border-radius: 2px 0 0 2px;
}

.next-race-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.45rem;
  text-transform: uppercase;
}

.next-race-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
  letter-spacing: -0.01em;
}

.next-race-circuit {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.next-race-date {
  font-size: 0.78rem;
  color: var(--fg);
  opacity: 0.75;
}

.badge-sprint {
  display: inline-block;
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.5rem;
  vertical-align: middle;
  line-height: 1.5;
}

.season-complete {
  border-color: var(--accent);
  background: linear-gradient(
    145deg,
    var(--card) 60%,
    rgba(225, 6, 0, 0.06) 100%
  );
  text-align: center;
  padding: 1.2rem 1.1rem;
}

.season-complete::before {
  width: 100%;
  height: 3px;
  top: auto;
  bottom: 0;
  left: 0;
  border-radius: 0 0 10px 10px;
}

.champion-name {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.1rem;
}

.champion-team {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.champion-points {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.champion-points small {
  font-size: 0.55rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 0.2rem;
  letter-spacing: 0.05em;
}

.champion-badge {
  display: inline-block;
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--bg);
  background: var(--accent);
  padding: 0.12rem 0.45rem;
  border-radius: 3px;
  margin-left: 0.45rem;
  vertical-align: middle;
  line-height: 1.5;
}

.live-results {
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--border);
}

.live-results-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(225, 6, 0, 0.55);
  }

  70% {
    box-shadow: 0 0 0 7px rgba(225, 6, 0, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(225, 6, 0, 0);
  }
}

.live-chips {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.live-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.live-chip-pos {
  color: var(--accent);
  font-size: 0.68rem;
}

ol.standings {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

li.driver {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  align-items: center;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  transition:
    border-color 0.2s,
    transform 0.15s;
  animation: fadeUp 0.4s ease both;
}

li.driver:hover {
  border-color: var(--accent);
  transform: translateX(4px);
}

li.driver:nth-child(1) {
  animation-delay: 0.05s;
}

li.driver:nth-child(2) {
  animation-delay: 0.1s;
}

li.driver:nth-child(3) {
  animation-delay: 0.15s;
}

li.driver:nth-child(4) {
  animation-delay: 0.2s;
}

li.driver:nth-child(5) {
  animation-delay: 0.25s;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pos {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
}

li.driver:nth-child(1) .pos {
  color: var(--accent);
}

.info {
  min-width: 0;
}

.name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.points {
  font-size: 1.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.points small {
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--muted);
  margin-left: 0.15rem;
}

.accordion {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
  animation: fadeUp 0.4s ease both;
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  background: none;
  border: none;
  color: var(--fg);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.2s;
}

.accordion-header:hover {
  background: rgba(255, 255, 255, 0.025);
}

.accordion-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.accordion-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.accordion-header .label-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-upcoming {
  flex-shrink: 0;
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(225, 6, 0, 0.12);
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
}

.accordion-header .chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.3s ease;
}

.accordion.open .chevron {
  transform: rotate(180deg);
}

.accordion-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}

.accordion.open .accordion-body {
  grid-template-rows: 1fr;
}

.accordion-content {
  overflow: hidden;
}

.accordion-inner {
  padding: 0 1.1rem 1rem;
}

.results-table {
  display: flex;
  flex-direction: column;
}

.result-row {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.result-row:last-child {
  border-bottom: none;
}

.result-pos {
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.result-pos.p1 {
  color: var(--accent);
}

.result-pos.p2 {
  color: #c0c0c0;
}

.result-pos.p3 {
  color: #cd7f32;
}

.result-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.result-name {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-team {
  font-size: 0.62rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-time {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

.sprint-section {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border);
}

.sprint-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.45rem;
  text-transform: uppercase;
}

.no-data {
  padding: 0.8rem 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

footer {
  margin-top: 1.2rem;
  text-align: right;
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.6;
}

footer a {
  text-decoration: none;
  color: var(--muted);
}

footer a:hover {
  color: var(--accent);
}

.synced {
  margin-top: 0.35rem;
  font-size: 0.68rem;
  color: var(--muted);
  opacity: 0.55;
  text-align: right;
}

/* ── Pit Lane chatbot launcher (placeholder until the real thing ships) ── */

.pitlane-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.1rem 0.7rem 0.8rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(225, 6, 0, 0.35);
  transition:
    transform 0.15s,
    box-shadow 0.15s;
  animation: fadeUp 0.4s ease 0.4s both;
}

.pitlane-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(225, 6, 0, 0.45);
}

.pitlane-fab:active {
  transform: translateY(0);
}

.pitlane-fab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.pitlane-fab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  animation: pulse 1.6s ease-out infinite;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 14px;
  padding: 1.6rem 1.5rem 1.5rem;
  text-align: center;
  transform: translateY(10px) scale(0.97);
  transition: transform 0.25s ease;
}

.modal-overlay.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    color 0.15s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--fg);
}

.modal-icon {
  font-size: 1.8rem;
  margin-bottom: 0.6rem;
}

.modal-card h2 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}

.modal-card p {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0.3rem;
}

.modal-tag {
  display: inline-block;
  margin-top: 0.9rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

@media (max-width: 420px) {
  body {
    padding: 1.1rem 0.9rem 5.5rem;
    align-items: flex-start;
  }

  .pitlane-fab span.fab-label {
    display: none;
  }

  .pitlane-fab {
    padding: 0.75rem;
    bottom: 1.1rem;
    right: 1.1rem;
  }
}
