:root {
  color-scheme: dark;
  --bg: #030712;
  --surface: #07101b;
  --surface-soft: #0c1624;
  --surface-raised: #101b2a;
  --text: #f7fbff;
  --muted: #7f8ea3;
  --line: #1d2a3a;
  --line-strong: #2d4058;
  --accent: #18b7ff;
  --accent-strong: #66d9ff;
  --blue: #3182ff;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #a855f7;
  --error: #ef4444;
  --code: #020617;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -20%, rgba(24, 183, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #06101d 0%, var(--bg) 42%, #02050d 100%);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}

.shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 520px);
  gap: 20px;
  align-items: end;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  font-weight: 750;
}

h2 {
  font-size: 17px;
  font-weight: 750;
}

.eyebrow,
.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-line {
  margin-top: 7px;
  color: var(--muted);
}

.game-meta {
  display: grid;
  justify-self: end;
  min-width: min(100%, 260px);
}

.fixed-game {
  display: grid;
  gap: 5px;
}

.fixed-game strong {
  min-height: 42px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 10px 12px;
}

button {
  border-radius: 6px;
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #00111d;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--accent-strong);
  color: #00111d;
}

.errors {
  margin: 0 0 16px;
  border-left: 4px solid var(--error);
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.11);
  color: #fecaca;
  padding: 12px 14px;
}

.view-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.view-tab {
  min-height: 38px;
  margin-bottom: -1px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  color: var(--muted);
  font-weight: 750;
}

.view-tab.active {
  border-color: var(--line);
  border-bottom-color: var(--surface);
  background: var(--surface);
  color: var(--accent-strong);
}

.config-stack {
  display: grid;
  gap: 14px;
}

.config-row,
.config-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.config-stack input[type="text"],
.config-stack input[type="password"],
.config-stack input[type="url"] {
  min-width: min(100%, 240px);
  flex: 1;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

.config-stack button {
  color: var(--text);
  background: rgba(24, 183, 255, 0.16);
  border: 1px solid rgba(24, 183, 255, 0.38);
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.overview {
  display: grid;
  grid-template-columns: minmax(280px, 440px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.hero-visual,
.panel,
.raw-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.hero-visual {
  position: relative;
  min-height: 300px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, rgba(24, 183, 255, 0.2), var(--surface-soft));
}

.hero-visual img {
  width: 100%;
  height: 100%;
  min-height: 300px;
  object-fit: cover;
  display: block;
}

.hero-placeholder {
  height: 100%;
  min-height: 300px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 46px;
  font-weight: 800;
}

.overview-body {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.game-heading,
.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

#gameTitle {
  font-size: 26px;
}

#gameSubtitle {
  margin-top: 5px;
  color: var(--muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--surface-raised), var(--surface-soft));
  padding: 13px;
  min-height: 92px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  line-height: 1.1;
}

.metric small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.progress-block {
  margin-top: 18px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #101827;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  transition: width 180ms ease;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  gap: 16px;
}

.panel,
.raw-panel {
  padding: 16px;
}

.panel-large {
  grid-row: span 2;
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-heading {
  margin-bottom: 12px;
}

.badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  padding: 4px 9px;
}

.badge.ok {
  border-color: rgba(34, 197, 94, 0.7);
  color: #86efac;
}

.badge.warn {
  border-color: rgba(245, 158, 11, 0.7);
  color: var(--amber);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-item strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.achievement-list {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.achievement-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.achievement-row img,
.achievement-icon-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-raised);
}

.achievement-icon-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.achievement-row h3 {
  margin: 0;
  font-size: 15px;
}

.achievement-row p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.achievement-score {
  color: var(--accent-strong);
  font-weight: 800;
  white-space: nowrap;
}

.definition-list {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.definition-list dt {
  color: var(--muted);
  font-size: 13px;
}

.definition-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.raw-panel {
  margin-top: 16px;
}

.raw-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.raw-tab {
  min-height: 34px;
  padding: 0 12px;
}

.raw-tab.active {
  border-color: var(--blue);
  color: var(--blue);
  font-weight: 750;
}

.live-view {
  display: grid;
  gap: 16px;
}

.live-cockpit {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.2fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: stretch;
}

.definition-list.compact {
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 6px 10px;
}

.live-status-panel,
.live-tire-panel {
  min-height: 176px;
}

.live-gauge-panel {
  display: grid;
  grid-row: span 2;
  grid-template-rows: 42px minmax(300px, 1fr) auto;
  gap: 12px;
  min-height: 620px;
  overflow: hidden;
}

.speed-gauge {
  display: grid;
  place-items: center;
  min-height: 300px;
  overflow: hidden;
}

.gauge-svg {
  width: min(100%, 520px);
  height: 100%;
  max-height: 410px;
}

.gauge-track,
.gauge-rpm,
.gauge-redline {
  fill: none;
  stroke-width: 20;
  stroke-linecap: round;
}

.gauge-track {
  stroke: #142033;
}

.gauge-rpm {
  stroke: var(--accent);
  transition: stroke-dasharray 60ms linear, stroke 120ms ease;
}

.gauge-rpm.danger,
.gauge-gear.danger,
.gauge-gear-box.danger,
.gauge-tick.danger {
  stroke: var(--red);
  color: var(--red);
  fill: var(--red);
}

.gauge-redline {
  stroke: rgba(239, 68, 68, 0.18);
}

.gauge-tick {
  stroke: var(--line-strong);
  stroke-linecap: round;
}

.gauge-speed {
  fill: var(--text);
  font-size: 68px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.gauge-unit,
.gauge-rpm-text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.gauge-gear-box {
  fill: var(--surface-raised);
  stroke: var(--line-strong);
  stroke-width: 2;
}

.gauge-gear {
  fill: var(--accent-strong);
  font-size: 34px;
  font-weight: 900;
}

.compass-strip {
  position: relative;
  min-height: 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--code);
}

.compass-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.compass-cardinal {
  stroke: var(--accent);
  stroke-width: 1.5;
}

.compass-minor {
  stroke: var(--line-strong);
}

.compass-label,
.compass-degree {
  fill: var(--muted);
  font-size: 7px;
  font-weight: 700;
}

.compass-label.cardinal {
  fill: var(--text);
  font-size: 9px;
}

.compass-pointer {
  fill: var(--accent-strong);
}

.heading-readout {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}

.heading-readout strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.heading-readout span {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.live-dynamics-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
}

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

.steering-wheel,
.attitude-indicator,
.g-force-meter {
  min-height: 150px;
  display: grid;
  justify-items: center;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.steer-svg,
.attitude-svg {
  width: min(100%, 112px);
  height: 112px;
  overflow: visible;
}

.steer-rim {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 8;
}

.steer-spoke {
  stroke: var(--line-strong);
  stroke-width: 4;
  stroke-linecap: round;
}

.steer-hub {
  fill: var(--surface-raised);
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.steer-marker,
.steer-notch,
.adi-pointer,
.adi-wing-dot {
  fill: var(--accent);
}

.adi-bezel {
  fill: var(--surface);
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.adi-sky {
  fill: #0a2338;
}

.adi-ground {
  fill: #21180f;
}

.adi-horizon,
.adi-rung,
.adi-wing,
.adi-ring {
  stroke: var(--text);
  stroke-linecap: round;
}

.adi-horizon {
  stroke-width: 1.2;
}

.adi-rung {
  stroke: var(--line-strong);
}

.adi-wing {
  stroke-width: 2.5;
}

.adi-ring {
  fill: none;
  stroke: var(--line-strong);
}

.g-force-meter {
  align-content: center;
  gap: 8px;
}

.g-meter-face {
  position: relative;
  width: 104px;
  aspect-ratio: 1;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: radial-gradient(circle, var(--surface-raised), var(--surface));
}

.g-ring,
.g-axis,
.g-dot {
  position: absolute;
}

.g-ring {
  border: 1px solid var(--line);
  border-radius: 50%;
  inset: 25%;
}

.g-ring.two {
  inset: 12%;
}

.g-axis.horizontal {
  left: 8%;
  right: 8%;
  top: 50%;
  height: 1px;
  background: var(--line);
}

.g-axis.vertical {
  top: 8%;
  bottom: 8%;
  left: 50%;
  width: 1px;
  background: var(--line);
}

.g-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.8);
  transform: translate(-50%, -50%);
  transition: left 60ms linear, top 60ms linear;
}

.mini-readout {
  display: flex;
  gap: 6px;
  align-items: baseline;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mini-readout strong {
  color: var(--accent-strong);
}

.live-chart-panel {
  grid-column: span 2;
  min-height: 330px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.chart-card {
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.chart-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.chart-head strong {
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.chart-svg {
  width: 100%;
  height: 62px;
  margin-top: 9px;
  overflow: visible;
}

.chart-zero {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.live-map-panel {
  display: grid;
  grid-row: span 2;
  grid-template-rows: auto minmax(360px, 1fr);
  gap: 8px;
  min-height: 620px;
}

.live-map-panel .panel-heading {
  margin-bottom: 0;
}

#liveMap {
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 620;
  align-self: start;
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #08111d;
}

.input-grid {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.input-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 54px;
  gap: 10px;
  align-items: center;
}

.input-row span,
.tire-cell span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.input-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #101827;
}

.input-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 120ms linear;
}

.steer-track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: #101827;
}

.steer-track::before {
  content: "";
  position: absolute;
  inset: 2px auto 2px 50%;
  width: 1px;
  background: var(--line-strong);
}

.steer-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent);
  transform: translate(-50%, -50%);
  transition: left 120ms linear;
}

.tire-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tire-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--surface-raised), var(--surface-soft));
  padding: 10px;
}

.tire-cell strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.tire-cell small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.live-raw {
  grid-column: 1 / -1;
  margin-top: 0;
}

pre {
  max-height: 520px;
  overflow: auto;
  margin: 0;
  border-radius: 6px;
  background: var(--code);
  color: #e5f4ff;
  padding: 12px;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
}

@media (max-width: 1100px) {
  .overview,
  .dashboard-grid,
  .live-cockpit {
    grid-template-columns: 1fr;
  }

  .panel-large,
  .panel-wide {
    grid-row: auto;
    grid-column: auto;
  }

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

  .live-map-panel {
    grid-template-rows: auto minmax(320px, 1fr);
  }

  .live-gauge-panel,
  .live-map-panel,
  .live-chart-panel {
    grid-column: auto;
    grid-row: auto;
  }

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

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 20px, 720px);
    padding-top: 14px;
  }

  .topbar,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .game-meta {
    justify-self: stretch;
  }

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

  .view-tabs {
    overflow-x: auto;
  }

  .input-row {
    grid-template-columns: 76px minmax(0, 1fr) 46px;
  }

  .tire-grid,
  .chart-grid,
  .dynamics-grid {
    grid-template-columns: 1fr;
  }

  .achievement-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .achievement-score {
    grid-column: 2;
  }
}
