:root {
  --bg: #f3efe2;
  --bg-strong: #e2d8bb;
  --surface: rgba(255, 249, 235, 0.88);
  --surface-strong: #fffaf0;
  --ink: #191919;
  --muted: #6d675d;
  --line: rgba(25, 25, 25, 0.12);
  --accent: #b43f25;
  --accent-dark: #892e1a;
  --success: #2f7d32;
  --track: #ece5cf;
  --track-fill: #d63c2b;
  --team-red: #c81d25;
  --team-turquoise: #20c5c6;
  --team-navy: #1d2d7a;
  --team-orange: #f58b1f;
  --team-white: #f6f6f6;
  --team-yellow: #d2b304;
  --team-green: #28844b;
  --team-magenta: #c91d9a;
  --team-gray: #90959f;
  --team-sky: #6db7f2;
  --team-black: #222222;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 30%),
    linear-gradient(135deg, #f7f3e8, var(--bg) 45%, var(--bg-strong));
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.hero,
.screen,
.modal-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 40px rgba(44, 33, 15, 0.08);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  margin-bottom: 20px;
}

.hero h1,
.section-head h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

.intro,
.race-subtitle,
.modal-note,
#step-status,
.score-card p {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-status,
.start-actions,
.game-actions,
.panel-head,
.modal-actions,
.game-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-status {
  align-self: flex-start;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill,
.driver-badge,
.player-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.screen {
  display: none;
  padding: 24px;
}

.screen.active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.driver-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.driver-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--card-accent) 22%, white), rgba(255, 255, 255, 0.8));
}

.driver-index {
  position: absolute;
  top: 12px;
  right: 14px;
  font-weight: 700;
}

.driver-meta,
.driver-stats {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.driver-original {
  font-weight: 700;
}

.driver-badge.active {
  background: rgba(47, 125, 50, 0.14);
  color: var(--success);
}

.driver-input {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.92);
}

.ghost-button,
.primary-button,
.icon-button,
.bet-option {
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  transition: 160ms ease;
}

.primary-button,
.ghost-button,
.icon-button {
  padding: 11px 16px;
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost-button,
.icon-button {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
}

th,
td {
  padding: 5px 6px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-strong);
}

.pos-cell {
  font-weight: 700;
  width: 56px;
}

.name-tag {
  display: grid;
  gap: 0;
  padding: 5px 8px;
  border-radius: 10px;
  color: white;
  background: linear-gradient(135deg, var(--tag-color), color-mix(in srgb, var(--tag-color) 70%, black));
}

.track-cell {
  position: relative;
  overflow: hidden;
  min-width: 42px;
  text-align: center;
  background: var(--track);
  transition: background 220ms ease;
}

.track-cell.filled {
  color: white;
  font-weight: 700;
}

.track-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: linear-gradient(180deg, #f46d5e, var(--track-fill));
}

.track-label {
  position: relative;
  z-index: 1;
}

.track-cell.filled .track-fill {
  background: linear-gradient(180deg, #f46d5e, var(--track-fill));
}

.side-panel {
  display: grid;
  gap: 16px;
  align-content: start;
}

.info-card {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
}

.info-card.hidden,
.modal.hidden {
  display: none;
}

.scores-list {
  display: grid;
  gap: 12px;
}

.score-card {
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--score-color) 18%, white), rgba(255, 255, 255, 0.86));
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 18, 14, 0.5);
}

.modal-card {
  width: min(900px, 100%);
  padding: 20px;
}

.bet-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  max-height: 50vh;
  overflow: auto;
  margin: 18px 0;
}

.bet-option {
  display: grid;
  gap: 6px;
  text-align: left;
  padding: 14px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--option-color) 16%, white), rgba(255, 255, 255, 0.86));
  border-color: transparent;
}

.bet-option.selected {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

@media (max-width: 960px) {
  .hero,
  .section-head,
  .game-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .start-actions,
  .game-actions {
    justify-content: stretch;
  }

  .start-actions button,
  .game-actions button {
    flex: 1;
  }
}
