:root {
  --bg: #02040a;
  --bg-2: #050816;
  --ink: #f7fbff;
  --text: rgba(247, 251, 255, 0.94);
  --soft: rgba(220, 232, 255, 0.72);
  --muted: rgba(187, 202, 230, 0.54);

  --glass: rgba(9, 14, 27, 0.64);
  --glass-strong: rgba(14, 20, 38, 0.78);
  --glass-soft: rgba(255, 255, 255, 0.045);

  --cyan: #45f6ff;
  --cyan-soft: rgba(69, 246, 255, 0.16);
  --violet: #9d7cff;
  --violet-soft: rgba(157, 124, 255, 0.16);
  --lime: #8dffb0;
  --lime-soft: rgba(141, 255, 176, 0.14);
  --amber: #ffd166;
  --amber-soft: rgba(255, 209, 102, 0.14);
  --red: #ff4d7d;
  --red-soft: rgba(255, 77, 125, 0.14);

  --edge: rgba(155, 211, 255, 0.16);
  --edge-strong: rgba(69, 246, 255, 0.35);

  --radius: 24px;
  --radius-sm: 14px;
  --radius-xs: 10px;

  --shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
  --glow-cyan: 0 0 32px rgba(69, 246, 255, 0.14);
  --glow-violet: 0 0 42px rgba(157, 124, 255, 0.15);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(69, 246, 255, 0.14), transparent 32%),
    radial-gradient(circle at 88% 6%, rgba(157, 124, 255, 0.18), transparent 34%),
    radial-gradient(circle at 78% 86%, rgba(255, 77, 125, 0.08), transparent 35%),
    linear-gradient(180deg, #050714 0%, #02040a 48%, #010207 100%);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(circle at 50% 20%, black, transparent 72%);
  opacity: 0.5;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent, rgba(69, 246, 255, 0.08), transparent),
    linear-gradient(180deg, transparent, rgba(157, 124, 255, 0.07), transparent);
  mix-blend-mode: screen;
  opacity: 0.42;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(100%, 1720px);
  margin: 0 auto;
  padding: 22px;
}

/* Header */

.topbar {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) auto;
  gap: 24px;
  align-items: start;
  margin-bottom: 22px;
}

.eyebrow {
  width: fit-content;
  margin: 0 0 10px;
  padding: 6px 10px;
  color: var(--cyan);
  background: rgba(69, 246, 255, 0.075);
  border: 1px solid rgba(69, 246, 255, 0.18);
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  font-weight: 850;
}

h1 {
  margin: 0;
  max-width: 820px;
  color: var(--ink);
  font-size: clamp(34px, 5vw, 72px);
  line-height: 0.9;
  letter-spacing: -0.075em;
  text-wrap: balance;
}

.subhead {
  max-width: 850px;
  margin: 16px 0 0;
  color: var(--soft);
  font-size: 15px;
  line-height: 1.55;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 10px;
  min-width: 610px;
}

.status-strip div {
  position: relative;
  overflow: hidden;
  padding: 13px 14px;
  border: 1px solid rgba(155, 211, 255, 0.14);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    rgba(5, 8, 18, 0.74);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
}

.status-strip div::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent, rgba(69, 246, 255, 0.12), transparent);
  transform: translateX(-120%);
  opacity: 0.7;
}

.status-strip div:hover::before {
  transform: translateX(120%);
  transition: transform 900ms ease;
}

.status-strip span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-strip strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Grid */

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.panel {
  position: relative;
  overflow: hidden;
  min-height: 110px;
  padding: 18px;
  border: 1px solid rgba(155, 211, 255, 0.13);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
    rgba(7, 11, 24, 0.68);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(22px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(125deg, rgba(69, 246, 255, 0.18), transparent 28%),
    linear-gradient(305deg, rgba(157, 124, 255, 0.14), transparent 30%);
  opacity: 0.45;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  padding: 1px;
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.race-setup {
  grid-column: 1 / -1;
  min-height: 0;
  padding: 16px 18px;
}

.hero {
  grid-column: 1 / -1;
}

.timing {
  grid-column: span 5;
}

.strategy {
  grid-column: span 7;
}

.controls {
  grid-column: span 4;
}

.services {
  grid-column: span 4;
}

.incidents {
  grid-column: span 4;
}

.deploy {
  grid-column: span 4;
}

.events {
  grid-column: span 4;
}

.report {
  grid-column: span 8;
}

.panel-header {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.panel-header.compact {
  margin-bottom: 13px;
}

h2 {
  margin: 0;
  color: var(--ink);
  font-size: 19px;
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: -0.045em;
}

h3 {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 18px;
  letter-spacing: -0.04em;
}

p {
  margin: 6px 0 0;
  color: var(--soft);
  font-size: 13.5px;
  line-height: 1.45;
}

.hint,
.muted {
  color: var(--muted);
  font-size: 12.5px;
}

/* Race setup */

.setup-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.setup-field {
  display: grid;
  gap: 7px;
}

.setup-field span {
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

select {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid rgba(155, 211, 255, 0.16);
  border-radius: 999px;
  outline: none;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
    rgba(3, 6, 14, 0.8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

select:focus {
  border-color: rgba(69, 246, 255, 0.52);
  box-shadow: 0 0 0 4px rgba(69, 246, 255, 0.11);
}

.setup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons */

button {
  position: relative;
  min-height: 40px;
  padding: 9px 15px;
  color: var(--ink);
  border: 1px solid rgba(69, 246, 255, 0.24);
  border-radius: 999px;
  background:
    radial-gradient(circle at 20% 0%, rgba(69, 246, 255, 0.22), transparent 38%),
    linear-gradient(135deg, rgba(69, 246, 255, 0.13), rgba(157, 124, 255, 0.09));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 22px rgba(69, 246, 255, 0.08);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
  transition:
    transform 130ms ease,
    border-color 130ms ease,
    filter 130ms ease,
    box-shadow 130ms ease;
}

button:hover {
  border-color: rgba(69, 246, 255, 0.56);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 28px rgba(69, 246, 255, 0.18);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.danger {
  color: #ffe4ec;
  border-color: rgba(255, 77, 125, 0.36);
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 77, 125, 0.28), transparent 38%),
    linear-gradient(135deg, rgba(255, 77, 125, 0.15), rgba(157, 124, 255, 0.08));
}

button.danger:hover {
  border-color: rgba(255, 77, 125, 0.68);
  box-shadow: 0 0 28px rgba(255, 77, 125, 0.17);
}

button.safe {
  color: #e7fff0;
  border-color: rgba(141, 255, 176, 0.34);
  background:
    radial-gradient(circle at 20% 0%, rgba(141, 255, 176, 0.26), transparent 38%),
    linear-gradient(135deg, rgba(141, 255, 176, 0.13), rgba(69, 246, 255, 0.08));
}

button.safe:hover {
  border-color: rgba(141, 255, 176, 0.64);
  box-shadow: 0 0 26px rgba(141, 255, 176, 0.15);
}

button.ghost {
  background: rgba(255, 255, 255, 0.035);
}

#startRaceBtn,
#resetRaceBtn {
  min-width: 124px;
}

#resetRaceBtn:disabled,
#startRaceBtn:disabled,
#trackSelect:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.button-row {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.button-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* Legend */

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--soft);
  font-size: 12px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: 0;
  box-shadow: 0 0 12px currentColor;
}

.dot.normal {
  color: var(--lime);
  background: var(--lime);
}

.dot.timing {
  color: var(--amber);
  background: var(--amber);
}

.dot.failed {
  color: var(--red);
  background: var(--red);
}

.dot.tyre {
  color: var(--cyan);
  background: var(--cyan);
}

.dot.pit {
  color: var(--violet);
  background: var(--violet);
}

/* Track */

.track-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
}

#trackCanvas {
  display: block;
  width: 100%;
  height: auto;
  min-height: 520px;
  border: 1px solid rgba(69, 246, 255, 0.16);
  border-radius: 30px;
  background:
    radial-gradient(circle at 50% 44%, rgba(69, 246, 255, 0.055), transparent 38%),
    radial-gradient(circle at 80% 75%, rgba(157, 124, 255, 0.08), transparent 36%),
    #03060e;
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, 0.7),
    inset 0 0 40px rgba(69, 246, 255, 0.055),
    0 0 70px rgba(69, 246, 255, 0.08);
}

.driver-card,
.deployment-card {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border: 1px solid rgba(155, 211, 255, 0.13);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.026)),
    rgba(3, 7, 16, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.driver-card::before,
.deployment-card::before {
  content: "";
  position: absolute;
  inset: auto 16px 0 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(69, 246, 255, 0.65), transparent);
}

.driver-card {
  min-height: 100%;
}

.driver-card h3 {
  font-size: 28px;
}

.driver-card p {
  margin-top: 8px;
  color: var(--soft);
}

.driver-actions {
  align-items: center;
  margin-top: 13px;
}

.driver-actions .hint {
  max-width: 790px;
}

/* Demo scenarios */

.demo-scenarios-compact {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 13px;
  border: 1px solid rgba(157, 124, 255, 0.16);
  border-radius: 24px;
  background:
    radial-gradient(circle at 0% 0%, rgba(157, 124, 255, 0.16), transparent 38%),
    rgba(255, 255, 255, 0.035);
}

.demo-scenarios-title {
  display: grid;
  gap: 3px;
}

.demo-scenarios-title strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 880;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.demo-scenarios-title span {
  color: var(--muted);
  font-size: 12px;
}

.demo-scenario-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.demo-scenario-buttons button {
  min-height: 32px;
  padding: 6px 11px;
  font-size: 12px;
}

.scenario-explainer {
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid rgba(69, 246, 255, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(69, 246, 255, 0.095), rgba(157, 124, 255, 0.07)),
    rgba(0, 0, 0, 0.14);
}

.scenario-explainer strong {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.scenario-explainer span {
  color: var(--soft);
  font-size: 13px;
}

.scenario-explainer small {
  color: var(--muted);
  font-size: 12px;
}

/* Tables */

.table-wrap {
  position: relative;
  z-index: 1;
  max-height: 520px;
  overflow: auto;
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.018)),
    rgba(3, 6, 14, 0.52);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th,
td {
  padding: 10px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  background: rgba(7, 12, 25, 0.94);
  font-size: 10.5px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  backdrop-filter: blur(14px);
}

td {
  color: var(--soft);
  border-top: 1px solid rgba(255, 255, 255, 0.055);
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(69, 246, 255, 0.055);
}

/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}

.badge.Healthy,
.badge.Normal {
  color: var(--lime);
  background: var(--lime-soft);
  box-shadow: inset 0 0 0 1px rgba(141, 255, 176, 0.18);
}

.badge.Degraded,
.badge.Warning,
.badge.Timing,
.badge.Medium {
  color: var(--amber);
  background: var(--amber-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 209, 102, 0.2);
}

.badge.Failed,
.badge.Critical,
.badge.Strategy,
.badge.Unavailable {
  color: #ff9eba;
  background: var(--red-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 77, 125, 0.22);
}

.badge.High {
  color: #ffb986;
  background: rgba(255, 142, 82, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 142, 82, 0.2);
}

.badge.Low {
  color: var(--cyan);
  background: var(--cyan-soft);
  box-shadow: inset 0 0 0 1px rgba(69, 246, 255, 0.2);
}

/* Strategy */

.strategy-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  min-height: 50px;
}

.strategy-card {
  position: relative;
  overflow: hidden;
  padding: 15px;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    rgba(5, 9, 19, 0.66);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 0 0 1px rgba(155, 211, 255, 0.11);
}

.strategy-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--cyan), var(--violet));
  opacity: 0.9;
}

.strategy-card-head {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.strategy-card-head strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.strategy-card-head small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
}

.strategy-card p {
  position: relative;
  z-index: 1;
  margin: 12px 0;
  color: var(--soft);
  font-size: 13.5px;
}

.strategy-metrics,
.strategy-factors {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.strategy-metrics {
  margin: 10px 0 9px;
}

.strategy-metrics span,
.strategy-factors span {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  color: var(--soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.052);
  box-shadow: inset 0 0 0 1px rgba(155, 211, 255, 0.095);
  font-size: 12px;
}

.strategy-factors span {
  color: var(--muted);
}

/* Services / incidents / events */

.service-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.service-card,
.incident,
.event {
  position: relative;
  overflow: hidden;
  padding: 13px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.062), rgba(255, 255, 255, 0.022)),
    rgba(2, 5, 13, 0.36);
  box-shadow: inset 0 0 0 1px rgba(155, 211, 255, 0.09);
}

.service-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 15px;
}

.service-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.incident-list,
.event-log {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 9px;
  max-height: 360px;
  overflow: auto;
}

.incident strong,
.event strong {
  display: block;
  color: var(--ink);
  font-size: 12.5px;
}

.incident span,
.event span {
  color: var(--muted);
  font-size: 12px;
}

.event-log {
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;
  font-size: 12px;
}

/* Report */

.report-output {
  position: relative;
  z-index: 1;
  min-height: 310px;
  max-height: 500px;
  overflow: auto;
  margin: 0;
  padding: 15px;
  color: rgba(230, 240, 255, 0.9);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(69, 246, 255, 0.045), rgba(157, 124, 255, 0.035)),
    rgba(0, 0, 0, 0.33);
  box-shadow: inset 0 0 0 1px rgba(155, 211, 255, 0.09);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.empty {
  color: var(--muted);
}

/* Scrollbars */

* {
  scrollbar-color: rgba(69, 246, 255, 0.28) transparent;
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(69, 246, 255, 0.24);
  background-clip: content-box;
}

/* Responsiveness */

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

  .status-strip {
    min-width: 0;
  }

  .timing,
  .strategy,
  .controls,
  .services,
  .incidents,
  .deploy,
  .events,
  .report {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .shell {
    padding: 16px;
  }

  .topbar {
    gap: 16px;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .track-layout,
  .setup-row,
  .demo-scenarios-compact {
    grid-template-columns: 1fr;
  }

  .track-layout {
    gap: 14px;
  }

  .driver-card {
    min-height: unset;
  }

  .panel-header {
    flex-direction: column;
  }

  #trackCanvas {
    min-height: 360px;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 12px;
  }

  h1 {
    font-size: 34px;
  }

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

  .panel {
    padding: 14px;
    border-radius: 20px;
  }

  .setup-actions,
  .button-row,
  .demo-scenario-buttons {
    flex-direction: column;
    width: 100%;
  }

  button,
  .demo-scenario-buttons button {
    width: 100%;
  }

  #trackCanvas {
    min-height: 300px;
    border-radius: 22px;
  }
}