:root {
  --bg-dark: #07080b;
  --card-bg: #0f1116;
  --card-border: #1e222a;
  --road-bg: #13171f;
  --road-border: #242a36;
  --accent-blue: #38bdf8;
  --accent-violet: #a78bfa;
  --text-main: #f3f4f6;
  --text-muted: #8b949e;
  --text-dim: #545d68;
  --success: #10b981;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 30px 16px 60px 16px;
}

.page-wrapper {
  max-width: 960px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--card-border);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  background: rgba(167, 139, 250, 0.12);
  color: var(--accent-violet);
  border: 1px solid rgba(167, 139, 250, 0.35);
  padding: 3px 10px;
  font-size: 0.72rem;
  border-radius: 9999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-title {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.github-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.github-link:hover {
  color: #fff;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: #14171f;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--card-border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

/* Showcase Container */
.showcase-container {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.showcase-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tab-group {
  display: flex;
  gap: 6px;
  background: #090a0d;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #20242e;
  color: #fff;
}

.tab-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.2s;
}

.link-btn:hover {
  color: #fff;
}

.question-headline {
  font-size: 1.45rem;
  font-weight: 500;
  color: #fff;
  letter-spacing: -0.01em;
}

/* Interactive Stage (Road & Bars) */
.interactive-stage {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 36px;
  background: #090b0f;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid #191d26;
  align-items: center;
}

@media (max-width: 768px) {
  .interactive-stage {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

.road-viewport {
  width: 280px;
  height: 460px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--road-border);
  background: var(--road-bg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

#roadCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Evaluation Panel */
.evaluation-panel {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Status Meta */
.status-meta {
  display: flex;
  background: #141720;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 12px 18px;
  justify-content: space-between;
}

.meta-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
}

.meta-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
}

.meta-value.highlight {
  color: var(--accent-blue);
}

/* Control Buttons */
.control-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-title {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
}

.button-row {
  display: flex;
  gap: 8px;
}

.action-btn {
  flex: 1;
  background: #1a202c;
  color: #cbd5e1;
  border: 1px solid #2d3748;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #252e3d;
  color: #ffffff;
  border-color: #4a5568;
}

.action-btn.active {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.6);
  color: #fca5a5;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.action-btn.secondary {
  background: #12151c;
}

/* Code Showcase Card (Matches OpenAI curl box) */
.code-showcase-card {
  background: #090a0d;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.code-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.copy-btn {
  background: #1e2430;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: #283040;
  color: #fff;
}

.code-content {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #7dd3fc;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
}

.status-dot.loading {
  background: #fbbf24;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.6);
}

.status-dot.ready {
  background: var(--success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.status-dot.failed {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero-lead {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 52rem;
}

.hero-lead code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  color: #c4b5fd;
  background: #14171f;
  padding: 2px 6px;
  border-radius: 4px;
}

.settings-bar {
  display: grid;
  grid-template-columns: minmax(240px, 340px) 1fr;
  gap: 20px;
  align-items: start;
  background: linear-gradient(145deg, #0a0c12 0%, #0d1018 100%);
  border: 1px solid #1a2030;
  border-radius: 14px;
  padding: 16px 20px;
}

@media (max-width: 768px) {
  .settings-bar {
    grid-template-columns: 1fr;
  }
}

.key-row-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.key-row-inline .field-input {
  flex: 1;
  min-width: 200px;
}

.settings-models-btn {
  background: #1a2030;
  border: 1px solid rgba(167, 139, 250, 0.45);
  color: #e9d5ff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  width: fit-content;
}

.settings-models-btn:hover {
  background: #252d42;
}

.selected-model-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.summary-pill {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: #141720;
  border: 1px solid #2a3140;
  color: var(--text-muted);
}

.summary-pill.free {
  border-color: rgba(16, 185, 129, 0.55);
  background: rgba(16, 185, 129, 0.1);
  color: #6ee7b7;
}

.summary-more {
  font-size: 0.72rem;
  color: var(--text-dim);
  align-self: center;
}

.settings-empty {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.nav-settings {
  padding: 5px 10px;
}

.hero.compact {
  gap: 6px;
}

.hero.compact .question-headline {
  font-size: 1.25rem;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(560px, 100%);
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  background: #0f1118;
  border: 1px solid #252b38;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid #1e222a;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}

.modal-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-close:hover {
  color: #fff;
}

.modal-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid #1a1f28;
}

.modal-search {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px !important;
  font-size: 0.85rem !important;
}

.modal-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 12px;
}

.modal-vendor {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-violet);
  font-weight: 700;
  padding: 12px 8px 6px;
}

.modal-model-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.modal-model-row:hover {
  background: #141820;
}

.modal-model-row.selected {
  background: rgba(167, 139, 250, 0.06);
  border-color: rgba(167, 139, 250, 0.25);
}

.modal-model-row.is-free {
  border-left: 3px solid rgba(16, 185, 129, 0.7);
  padding-left: 8px;
}

.modal-model-row.is-free.selected {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.35);
}

.modal-check {
  margin-top: 4px;
  accent-color: var(--accent-violet);
}

.modal-model-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.modal-model-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #f3f4f6;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-model-id {
  font-size: 0.68rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-dim);
  word-break: break-all;
}

.badge-free {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.45);
}

.modal-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid #1e222a;
}

.modal-footnote {
  font-size: 0.72rem;
  color: var(--text-dim);
  max-width: 240px;
  line-height: 1.4;
}

.modal-footnote code {
  font-size: 0.68rem;
}

.modal-footer-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.modal-apply {
  flex: 0 0 auto;
  min-width: 100px;
}

.setup-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: linear-gradient(145deg, #0a0c12 0%, #0d1018 100%);
  border: 1px solid #1a2030;
  border-radius: 14px;
  padding: 20px 22px;
}

.setup-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setup-row.models-row {
  gap: 12px;
}

.key-field {
  max-width: 420px;
}

.text-link {
  font-size: 0.8rem;
  color: var(--accent-violet);
  text-decoration: none;
  width: fit-content;
}

.text-link:hover {
  text-decoration: underline;
  color: #c4b5fd;
}

.models-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.models-row-actions {
  display: flex;
  gap: 8px;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.ghost-btn:hover {
  border-color: #3d4654;
  color: #fff;
}

.ghost-btn.primary {
  border-color: rgba(167, 139, 250, 0.45);
  color: #ddd6fe;
}

.ghost-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.model-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 2px;
}

.model-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  background: #12151c;
  border: 1px solid #252b38;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  min-width: 160px;
  transition: all 0.15s;
}

.model-chip:hover {
  border-color: #3d4654;
}

.model-chip.active {
  border-color: rgba(167, 139, 250, 0.65);
  background: rgba(167, 139, 250, 0.08);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.2);
}

.chip-vendor {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-violet);
  font-weight: 700;
}

.chip-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
}

.chip-id {
  font-size: 0.68rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-dim);
}

.setup-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.setup-hint code {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.lb-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.lb-pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: #1a2030;
  font-size: 0.72rem !important;
}

.lb-pill.bad {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.pg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.code-content.tall {
  max-height: 260px;
}

.engine-meta {
  margin-top: -18px;
}

.meta-col.wide {
  flex: 1;
}

.meta-value.small {
  font-size: 0.8rem;
  font-weight: 500;
}

.meta-value.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 400;
}

.model-note {
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-dim);
}

.model-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: #14171f;
  padding: 1px 5px;
  border-radius: 4px;
}

/* Playground tab */
.playground-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

#playgroundView {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#playgroundView[hidden] {
  display: none;
}

.playground-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #090b0f;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid #191d26;
}

.field-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
}

.field-label code {
  text-transform: none;
}

.field-input {
  background: #14171f;
  color: var(--text-main);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.field-input.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8rem;
}

.playground-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pg-submit {
  flex: 0 0 160px;
}

.pg-submit:disabled {
  opacity: 0.5;
  cursor: wait;
}

.pg-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pg-response {
  background: #090a0d;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 14px 16px;
  min-height: 80px;
}

/* Race mode */
.page-wrapper {
  max-width: 1280px;
}

.race-controls {
  background: #090b0f;
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid #191d26;
}

.race-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  min-height: 120px;
}

@media (max-width: 1020px) {
  .race-grid {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

.track-card {
  background: #090b0f;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #191d26;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 380px;
}

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

.track-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
}

.track-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.road-viewport.small {
  width: 100%;
  height: 380px;
}

.road-viewport.small canvas {
  width: 100%;
  height: 100%;
}

.key-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.key-row .field-input {
  font-size: 0.78rem;
  padding: 8px 10px;
}

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #090b0f;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid #191d26;
}

.lb-row {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.lb-name {
  color: var(--text-main);
  font-weight: 600;
  min-width: 170px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.lb-cell {
  white-space: nowrap;
}

#autoBtn.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
  box-shadow: none;
}
