:root {
  --bg: #f7eff2;
  --bg-soft: #fcf6f8;
  --surface: rgba(255, 255, 255, 0.74);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --text: #2a2026;
  --muted: #735f68;
  --border: rgba(42, 32, 38, 0.14);
  --accent: #e15767;
  --accent-strong: #c23949;
  --bg-layer-1: radial-gradient(circle at 0 0, #fff3f5 0%, rgba(255, 243, 245, 0) 35%);
  --bg-layer-2: radial-gradient(circle at 100% 0, rgba(247, 197, 207, 0.56) 0%, rgba(247, 197, 207, 0) 39%);
  --bg-layer-3: linear-gradient(180deg, #f9e8ec 0%, var(--bg) 42%, var(--bg-soft) 100%);
  --glass-bg: rgba(255, 255, 255, 0.68);
  --glass-border: rgba(255, 255, 255, 0.9);
  --glass-hover: rgba(255, 255, 255, 0.75);
  --menu-bg: rgba(255, 255, 255, 0.96);
  --topbar-shadow: 0 10px 24px rgba(77, 20, 30, 0.1);
  --shadow-soft: 0 24px 48px rgba(77, 20, 30, 0.1);
  --shadow-card: 0 16px 30px rgba(77, 20, 30, 0.11);
  --max-width: 1120px;
}

.dark {
  --bg: #251c21;
  --bg-soft: #1f171c;
  --surface: rgba(58, 41, 48, 0.72);
  --surface-strong: rgba(67, 47, 55, 0.9);
  --text: #fbeef2;
  --muted: #ccb0b8;
  --border: rgba(199, 165, 176, 0.24);
  --accent: #ff7e8d;
  --accent-strong: #e76473;
  --bg-layer-1: radial-gradient(circle at 0 0, rgba(146, 84, 95, 0.28) 0%, rgba(146, 84, 95, 0) 38%);
  --bg-layer-2: radial-gradient(circle at 100% 0, rgba(223, 91, 114, 0.24) 0%, rgba(223, 91, 114, 0) 40%);
  --bg-layer-3: linear-gradient(180deg, #37242b 0%, var(--bg) 42%, var(--bg-soft) 100%);
  --glass-bg: rgba(52, 35, 42, 0.72);
  --glass-border: rgba(199, 165, 176, 0.24);
  --glass-hover: rgba(84, 63, 71, 0.74);
  --menu-bg: rgba(62, 43, 50, 0.96);
  --topbar-shadow: 0 12px 24px rgba(4, 8, 14, 0.34);
  --shadow-soft: 0 22px 48px rgba(3, 6, 13, 0.44);
  --shadow-card: 0 16px 32px rgba(3, 6, 13, 0.36);
}

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

html {
  scroll-behavior: smooth;
  overscroll-behavior-y: none;
  background-color: #251c21;
}

body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  line-height: 1.58;
  min-height: 100dvh;
  background-color: var(--bg);
  background:
    radial-gradient(circle at 0 0, #fff3f5 0%, rgba(255, 243, 245, 0) 35%),
    radial-gradient(circle at 100% 0, rgba(247, 197, 207, 0.56) 0%, rgba(247, 197, 207, 0) 39%),
    linear-gradient(180deg, #f9e8ec 0%, var(--bg) 42%, var(--bg-soft) 100%);
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.light body {
  background-color: #f7eff2;
  background:
    radial-gradient(circle at 0 0, #fff3f5 0%, rgba(255, 243, 245, 0) 35%),
    radial-gradient(circle at 100% 0, rgba(247, 197, 207, 0.56) 0%, rgba(247, 197, 207, 0) 39%),
    linear-gradient(180deg, #f9e8ec 0%, #f7eff2 42%, #fcf6f8 100%);
}

.dark body {
  background-color: #251c21;
  background:
    radial-gradient(circle at 0 0, rgba(146, 84, 95, 0.28) 0%, rgba(146, 84, 95, 0) 38%),
    radial-gradient(circle at 100% 0, rgba(223, 91, 114, 0.24) 0%, rgba(223, 91, 114, 0) 40%),
    linear-gradient(180deg, #37242b 0%, #251c21 42%, #1f171c 100%);
}

.light {
  background-color: #f7eff2;
}

.dark {
  background-color: #251c21;
}

@supports (-webkit-touch-callout: none) {
  @media (pointer: coarse) {
    .dark body {
      background-image: none;
    }
  }
}

a {
  color: inherit;
  text-decoration: none;
}

.site-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(1px);
}

.orb-one {
  width: 360px;
  height: 360px;
  top: -120px;
  right: -90px;
  background: radial-gradient(circle, rgba(230, 90, 110, 0.2), rgba(230, 90, 110, 0));
}

.orb-two {
  width: 280px;
  height: 280px;
  top: 45vh;
  left: -100px;
  background: radial-gradient(circle, rgba(174, 102, 116, 0.12), rgba(174, 102, 116, 0));
}

.orb-three {
  width: 280px;
  height: 280px;
  bottom: -100px;
  right: 18%;
  background: radial-gradient(circle, rgba(206, 69, 89, 0.16), rgba(206, 69, 89, 0));
}

.topbar {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + 0.7rem);
  z-index: 20;
  width: min(var(--max-width), 94vw);
  margin: 1rem auto 0;
  padding: 0.62rem 0.84rem;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  box-shadow: var(--topbar-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.62rem;
  min-width: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand img {
  width: 1.95rem;
  height: 1.95rem;
  border-radius: 0.6rem;
  border: 0;
  background: transparent;
  object-fit: cover;
}

.topnav {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 700;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.topnav a[aria-current="page"],
.topnav a:hover {
  color: var(--text);
  background: var(--glass-hover);
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--glass-bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  min-width: 4.1rem;
  font-size: 0.79rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--glass-hover);
  transform: translateY(-1px);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(225, 87, 103, 0.22);
}

.menu-toggle {
  display: none;
  position: relative;
  border: 1px solid var(--border);
  background: var(--glass-bg);
  color: var(--muted);
  border-radius: 0.72rem;
  width: 2.15rem;
  height: 2.15rem;
  align-items: center;
  justify-content: center;
  overflow: visible;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.menu-toggle:hover {
  background: var(--glass-hover);
}

.menu-toggle span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.9rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center;
  transition: transform 0.24s ease, opacity 0.2s ease;
}

.menu-toggle span:nth-child(1) {
  transform: translate(-50%, -0.32rem);
}

.menu-toggle span:nth-child(2) {
  transform: translate(-50%, -50%);
}

.menu-toggle span:nth-child(3) {
  transform: translate(-50%, 0.2rem);
}

.menu-toggle.open span:nth-child(1) {
  transform: translate(-50%, -50%) rotate(45deg);
}

.menu-toggle.open span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.open span:nth-child(3) {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.mobile-menu {
  display: none;
}

main {
  width: min(var(--max-width), 94vw);
  margin: 1.2rem auto 0;
  padding: 0.2rem 0 0;
  flex: 1 0 auto;
}

.page-hero {
  text-align: center;
  padding: 1.15rem 1rem;
  border: 1px solid var(--border);
  border-radius: 1.3rem;
  background: var(--surface);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
}

.page-hero-tight {
  padding: 1rem 1rem;
}

h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.5rem, 2vw + 0.9rem, 2.35rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.subtitle {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 1rem;
}

.home-grid-wrap,
.data-shell {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 1.3rem;
  background: var(--surface);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
  padding: 1rem;
}

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

.card {
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(225, 87, 103, 0.36);
  box-shadow: 0 18px 28px rgba(122, 36, 52, 0.22);
}

.card img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  background: #f7e8ed;
}

.card h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.08rem;
  padding: 0.85rem 0.9rem 0.28rem;
}

.card p {
  color: var(--muted);
  font-size: 0.92rem;
  padding: 0 0.9rem 0.9rem;
  margin-top: auto;
}

#driver-list,
#team-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.driver-card,
.team-card {
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  padding: 0.95rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 106px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.driver-card:hover,
.team-card:hover {
  transform: translateY(-2px);
  border-color: rgba(225, 87, 103, 0.36);
  box-shadow: 0 14px 22px rgba(122, 36, 52, 0.18);
}

.driver-position,
.team-position {
  min-width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(249, 230, 236, 0.86);
  display: grid;
  place-items: center;
  position: relative;
  font-weight: 800;
  color: var(--text);
}

.driver-position.gold,
.team-position.gold {
  background: #ffd767;
  border-color: #efbd34;
}

.driver-position.silver,
.team-position.silver {
  background: #d8dde4;
  border-color: #b8c1ce;
}

.driver-position.bronze,
.team-position.bronze {
  background: #d99a63;
  border-color: #b9783d;
  color: #fff;
}

.position-number {
  font-size: 1.16rem;
}

.position-emoji {
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: 1rem;
}

.driver-info,
.team-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.driver-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.driver-name,
.team-name {
  font-size: 1.02rem;
  color: var(--accent-strong);
  font-weight: 800;
  line-height: 1.2;
}

.driver-points,
.team-points {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 700;
}

.driver-team-name {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.team-logo {
  height: 38px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
  flex-shrink: 0;
  filter: saturate(1.04);
}

.team-logo-wrap {
  min-width: 118px;
  height: 44px;
  border-radius: 0.7rem;
  border: 1px solid rgba(68, 35, 44, 0.35);
  background: linear-gradient(180deg, #382127 0%, #26161b 100%);
  box-shadow: inset 0 1px 0 rgba(255, 214, 223, 0.14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.6rem;
}

.team-logo-fallback {
  min-width: 118px;
  height: 44px;
  border-radius: 0.7rem;
  border: 1px solid rgba(68, 35, 44, 0.35);
  background: linear-gradient(180deg, #382127 0%, #26161b 100%);
  box-shadow: inset 0 1px 0 rgba(255, 214, 223, 0.14);
  color: #ffe7ed;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.driver-team-logo-wrap {
  width: 64px;
  min-width: 64px;
  height: 26px;
  border-radius: 0.5rem;
  border: 1px solid rgba(68, 35, 44, 0.35);
  background: linear-gradient(180deg, #382127 0%, #26161b 100%);
  box-shadow: inset 0 1px 0 rgba(255, 214, 223, 0.14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.22rem 0.32rem;
}

.driver-team-logo {
  max-width: 54px;
  max-height: 16px;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: saturate(1.04);
}

.team-logo.logo-invert,
.driver-team-logo.logo-invert {
  filter: brightness(0) invert(1);
}

.driver-team-logo-fallback {
  width: 64px;
  min-width: 64px;
  height: 26px;
  border-radius: 0.5rem;
  border: 1px solid rgba(68, 35, 44, 0.35);
  background: linear-gradient(180deg, #382127 0%, #26161b 100%);
  box-shadow: inset 0 1px 0 rgba(255, 214, 223, 0.14);
  color: #ffe7ed;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.2rem;
}

.stats-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 0.7rem;
}

.stat-item {
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  padding: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.stat-icon {
  font-size: 1.3rem;
}

.stat-content {
  min-width: 0;
}

.stat-item .stat-label,
.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-item .stat-value,
.stat-value {
  display: block;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 800;
  margin-top: 0.2rem;
}

.loading-indicator {
  grid-column: 1 / -1;
  border-radius: 1rem;
  border: 1px dashed var(--border);
  background: var(--surface-strong);
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(164, 89, 100, 0.25);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

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

.loading-indicator p {
  color: var(--muted);
  font-size: 0.95rem;
}

.error-banner {
  grid-column: 1 / -1;
  border-radius: 1rem;
  border: 1px solid rgba(204, 90, 106, 0.45);
  background: rgba(242, 116, 137, 0.13);
  padding: 1.1rem;
  text-align: center;
}

.error-banner h3 {
  color: #9d364d;
  margin-bottom: 0.35rem;
}

.error-banner p {
  color: #6e4350;
}

.error-banner button {
  margin-top: 0.65rem;
  border: 1px solid rgba(166, 56, 76, 0.4);
  background: rgba(255, 255, 255, 0.78);
  color: #8a2e42;
  border-radius: 0.68rem;
  padding: 0.52rem 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.predictions-shell {
  padding-top: 0.9rem;
}

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

.control-card {
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  padding: 0.85rem;
}

.control-card label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--accent-strong);
  margin-bottom: 0.5rem;
}

.label-icon {
  font-size: 1rem;
}

select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #fdf7f9;
  color: var(--text);
  font-size: 0.92rem;
  padding: 0.62rem 0.7rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(225, 87, 103, 0.2);
}

#stats-container {
  margin-top: 0.9rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.7rem;
}

.stat-card {
  border-radius: 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  text-align: center;
  padding: 0.85rem;
}

.stat-value.chaser-name {
  color: var(--accent-strong);
}

.results-section {
  margin-top: 0.9rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  padding: 0.8rem;
}

#result-text {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.scenarios-header {
  border-radius: 0.86rem;
  border: 1px solid var(--border);
  background: rgba(255, 236, 241, 0.86);
  padding: 0.8rem;
}

.scenarios-header h3 {
  font-size: 0.98rem;
  text-align: center;
  color: var(--accent-strong);
}

.scenario-card {
  border-radius: 0.86rem;
  border: 1px solid var(--border);
  background: #fff9fa;
  padding: 0.8rem;
}

.scenario-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.52rem;
  margin-bottom: 0.6rem;
}

.scenario-number {
  display: inline-flex;
  border-radius: 0.55rem;
  background: rgba(225, 87, 103, 0.16);
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 0.84rem;
  padding: 0.18rem 0.58rem;
}

.points-gain-header {
  color: var(--muted);
  font-size: 0.84rem;
}

.points-gain-header strong {
  color: var(--text);
}

.scenario-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.scenario-detail {
  border-radius: 0.68rem;
  border: 1px solid var(--border);
  background: rgba(255, 242, 246, 0.92);
  padding: 0.55rem 0.62rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-size: 0.88rem;
}

.scenario-detail.dnf {
  border-left: 3px solid #d96b81;
  background: rgba(245, 219, 227, 0.72);
}

.scenario-detail .driver-name {
  font-size: 0.9rem;
  font-weight: 800;
}

.scenario-detail .driver-name.chaser {
  color: #cf4053;
}

.scenario-detail .driver-name.leader {
  color: #ce7e3e;
}

.position-badge,
.dnf-badge,
.equality-badge,
.winner-badge {
  border-radius: 0.5rem;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.2rem 0.56rem;
}

.position-badge {
  background: rgba(76, 43, 53, 0.14);
  color: var(--text);
}

.dnf-badge {
  background: #d96b81;
  color: #fff;
}

.equality-badge {
  background: #e0a769;
  color: #fff;
}

.winner-badge {
  background: #48a476;
  color: #fff;
}

.total-points {
  color: var(--muted);
}

.scenario-points {
  margin-top: 0.45rem;
  border-top: 1px solid var(--border);
  padding-top: 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: right;
}

.points-gain {
  color: var(--accent-strong);
}

.error-message {
  border-radius: 0.95rem;
  border: 1px solid rgba(204, 90, 106, 0.45);
  background: rgba(242, 116, 137, 0.13);
  padding: 1rem;
  text-align: center;
}

.error-message h4 {
  color: #9d364d;
  font-size: 1rem;
}

.error-details {
  color: #6e4350;
  margin-top: 0.3rem;
}

.no-scenarios {
  border-radius: 0.95rem;
  border: 1px dashed var(--border);
  background: rgba(255, 242, 246, 0.82);
  padding: 1rem;
  text-align: center;
  color: var(--muted);
}

.notification {
  position: fixed;
  top: 18px;
  right: -320px;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  padding: 0.7rem 0.9rem;
  box-shadow: var(--shadow-card);
  z-index: 120;
  transition: right 0.24s ease;
  min-width: 240px;
}

.notification.show {
  right: 18px;
}

.notification.success {
  border-left: 4px solid #49a574;
}

.notification.error {
  border-left: 4px solid #d96b81;
}

.notification.warning {
  border-left: 4px solid #d29a57;
}

.notification.info {
  border-left: 4px solid var(--accent);
}

.dark .card img {
  background: #2b1f24;
}

.dark .driver-position,
.dark .team-position {
  background: rgba(109, 78, 88, 0.72);
}

.dark .team-logo-wrap,
.dark .team-logo-fallback,
.dark .driver-team-logo-wrap,
.dark .driver-team-logo-fallback {
  border-color: rgba(255, 211, 220, 0.3);
  background: linear-gradient(180deg, #311d23 0%, #1f1317 100%);
  box-shadow: inset 0 1px 0 rgba(255, 214, 223, 0.12);
}

.dark select {
  background: #2b2025;
  color: var(--text);
}

.dark .scenarios-header {
  background: rgba(108, 62, 74, 0.38);
}

.dark .scenario-card {
  background: #2a1f24;
}

.dark .scenario-detail {
  background: rgba(79, 55, 64, 0.72);
}

.dark .position-badge {
  background: rgba(199, 165, 176, 0.24);
}

.dark .error-banner h3,
.dark .error-message h4 {
  color: #ffb5c5;
}

.dark .error-banner p,
.dark .error-details {
  color: #e8b8c4;
}

.dark .error-banner button {
  background: rgba(90, 46, 57, 0.6);
  border-color: rgba(226, 146, 167, 0.45);
  color: #ffdbe3;
}

.dark .notification {
  background: rgba(49, 34, 40, 0.96);
  color: var(--text);
}

footer {
  width: min(var(--max-width), 94vw);
  margin: 1.9rem auto calc(2rem + env(safe-area-inset-bottom, 0px));
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

footer a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(194, 121, 135, 0.45);
  text-underline-offset: 0.15em;
}

.dark footer a {
  text-decoration-color: rgba(199, 165, 176, 0.35);
}

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

@media (max-width: 860px) {
  .topbar {
    top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
    border-radius: 999px;
    gap: 0.45rem;
    padding: 0.48rem 0.56rem;
    position: sticky;
    overflow: visible;
  }

  .brand {
    gap: 0.46rem;
    font-size: 0.9rem;
    flex-shrink: 0;
  }

  .brand img {
    width: 1.78rem;
    height: 1.78rem;
  }

  .topnav {
    display: none;
  }

  .topbar-actions {
    margin-left: auto;
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 0.34rem;
  }

  .theme-toggle {
    min-width: auto;
    padding: 0.36rem 0.58rem;
    font-size: 0.74rem;
    line-height: 1.1;
  }

  .menu-toggle {
    display: inline-flex;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
  }

  .mobile-menu {
    display: flex;
    position: absolute;
    top: calc(100% + 0.48rem);
    right: 0;
    width: min(16.8rem, calc(100vw - 1.2rem));
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.38rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    background: var(--menu-bg);
    backdrop-filter: blur(14px) saturate(120%);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    box-shadow: var(--topbar-shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 30;
  }

  .mobile-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .mobile-menu a {
    display: flex;
    align-items: center;
    padding: 0.55rem 0.68rem;
    border-radius: 0.76rem;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
    transition: color 0.2s ease, background-color 0.2s ease;
  }

  .mobile-menu a:hover,
  .mobile-menu a[aria-current="page"] {
    color: var(--text);
    background: var(--glass-hover);
  }

  body.menu-open {
    overflow: hidden;
  }

  main {
    margin-top: 0.85rem;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .controls-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .scenario-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .notification {
    right: -340px;
    top: 12px;
    min-width: 210px;
    max-width: min(88vw, 300px);
  }

  .notification.show {
    right: 12px;
  }

  footer {
    margin: 1.3rem auto calc(0.8rem + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 560px) {
  .home-grid-wrap,
  .data-shell,
  .page-hero {
    border-radius: 1.05rem;
    padding: 0.82rem;
  }

  h1 {
    font-size: clamp(1.26rem, 7vw, 1.68rem);
  }

  .subtitle {
    font-size: 0.9rem;
  }

  .driver-card,
  .team-card {
    padding: 0.78rem;
    gap: 0.72rem;
  }

  .team-logo {
    max-width: 90px;
    height: 32px;
  }

  .team-logo-wrap,
  .team-logo-fallback {
    min-width: 98px;
    height: 38px;
  }

  .driver-header {
    gap: 0.36rem;
  }

  .scenario-card {
    padding: 0.68rem;
  }
}
