/* Stunts Championship - Main Styles */

:root {
  --primary-color: #ff6b00;
  --primary-dark: #e55a00;
  --secondary-color: #2c3e50;
  --background: #1a1a2e;
  --surface: #16213e;
  --surface-light: #1f2937;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --success: #28a745;
  --error: #dc3545;
  --warning: #ffc107;
  --border-radius: 8px;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary-color);
}

a:hover {
  color: var(--primary-dark);
}

/* Navigation */
.navbar {
  background-color: var(--surface);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.nav-brand a {
  color: var(--primary-color);
  font-size: 1.5rem;
  font-weight: bold;
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.3s;
}

.nav-links a:hover {
  color: var(--primary-color);
}

.user-info {
  color: var(--text-secondary);
  margin-right: 1rem;
}

.btn-logout {
  background-color: var(--error);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
}

.btn-logout.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Main Container */
.container {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 4rem 2rem;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-light) 100%);
  border-radius: var(--border-radius);
  margin-bottom: 3rem;
}

.hero h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.hero h1 .gradient-text {
  color: var(--primary-color);
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero h1 .gradient-text {
    background: linear-gradient(135deg, var(--primary-color), #ffb347);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

.tagline {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* Features */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.feature {
  background-color: var(--surface);
  padding: 2rem;
  border-radius: var(--border-radius);
  text-align: center;
  transition: transform 0.3s;
}

.feature:hover {
  transform: translateY(-5px);
}

a.feature {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

a.feature:hover {
  color: inherit;
  background-color: var(--surface-light);
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.feature h3 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

/* How It Works */
.how-it-works {
  background-color: var(--surface);
  padding: 3rem 2rem;
  border-radius: var(--border-radius);
}

.how-it-works h2 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--primary-color);
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}

.step {
  text-align: center;
}

.step-number {
  width: 50px;
  height: 50px;
  background-color: var(--primary-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  margin: 0 auto 1rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
}

/* Colored buttons keep white text on hover (beats the global a:hover rule). */
a.btn-primary,
a.btn-register,
a.btn-logout {
  color: white;
}

a.btn-primary:hover,
a.btn-register:hover,
a.btn-logout:hover {
  color: white;
}

.btn-secondary {
  background-color: var(--surface-light);
  color: var(--text-primary);
  border: 1px solid var(--text-secondary);
}

.btn-secondary:hover {
  background-color: var(--text-secondary);
  color: var(--background);
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.875rem;
}

.btn-register {
  background-color: var(--success);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
}

/* Forms */
.auth-container {
  max-width: 500px;
  margin: 2rem auto;
  background-color: var(--surface);
  padding: 2rem;
  border-radius: var(--border-radius);
}

.auth-container h2 {
  text-align: center;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--text-secondary);
  border-radius: var(--border-radius);
  background-color: var(--surface-light);
  color: var(--text-primary);
  font-size: 1rem;
}

.form-group select[multiple] {
  height: 200px;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-group .hint {
  display: block;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.form-help {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.form-help.warning {
  color: var(--warning-color);
  font-style: italic;
}

.required {
  color: var(--error);
}

.championship-status {
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

.championship-status .checking {
  color: var(--warning);
}

.championship-status .valid {
  color: var(--success);
}

.championship-status .invalid {
  color: var(--error);
}

.auth-links {
  text-align: center;
  margin-top: 1.5rem;
}

.auth-links a {
  color: var(--primary-color);
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

.alert-error {
  background-color: rgba(220, 53, 69, 0.2);
  border: 1px solid var(--error);
  color: var(--error);
}

.alert-success {
  background-color: rgba(40, 167, 69, 0.2);
  border: 1px solid var(--success);
  color: var(--success);
}

/* Championship Selection */
.championship-select h2 {
  text-align: center;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.championship-select .subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.championship-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.championship-card {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--surface-light);
}

.championship-header {
  margin-bottom: 1rem;
}

.championship-header h3 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.track-badge {
  background-color: var(--surface-light);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.championship-details {
  margin-bottom: 1.5rem;
}

.championship-details p {
  margin-bottom: 0.25rem;
  color: var(--text-secondary);
}

.championship-actions {
  display: flex;
  gap: 0.5rem;
}

.no-championships {
  text-align: center;
  padding: 3rem;
  background-color: var(--surface);
  border-radius: var(--border-radius);
}

/* Game Page */
.game-container {
  max-width: 900px;
  margin: 0 auto;
}

.game-header {
  text-align: center;
  margin-bottom: 1rem;
}

.game-header h2 {
  color: var(--primary-color);
}

.game-info {
  display: flex;
  justify-content: center;
  gap: 2rem;
  color: var(--text-secondary);
}

.game-stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-bottom: 1rem;
}

.stat {
  text-align: center;
}

.stat-label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary-color);
  font-family: monospace;
}

.track-preview-section {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--border-radius);
}

.track-preview-section h4 {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

#trackPreviewFrame {
  display: block;
  margin: 0 auto;
  border: none;
  background: #000;
}

.dos-container {
  width: 100%;
  aspect-ratio: 4.75 / 3;
  background-color: #000;
  border-radius: var(--border-radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.dos-container-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
}

.dos-container-wrapper:fullscreen {
  width: 100vw;
  height: 100vh;
}

.dos-container-wrapper:fullscreen {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
  width: 40px;
  height: 40px;
  background-color: rgba(0, 0, 0, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s, background-color 0.2s;
}

.fullscreen-btn:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.9);
}

.dos-container-wrapper:fullscreen .fullscreen-btn {
  display: none;
}

.championship-tracks {
  background-color: var(--surface);
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

.championship-tracks h4 {
  margin-bottom: 0.75rem;
  color: var(--primary-color);
}

.track-selection {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.track-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--surface-light);
  color: #cccccc;
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s;
}

.track-btn:hover {
  border-color: var(--primary-color);
}

.track-btn.active {
  background-color: var(--primary-color);
  color: white;
}

.track-btn .track-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: bold;
}

.track-btn.active .track-number {
  background-color: white;
  color: var(--primary-color);
}

.track-btn .track-name {
  font-weight: 500;
}

.track-btn .track-time {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.track-btn.active .track-time {
  color: rgba(255, 255, 255, 0.8);
}

.compound-time {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background-color: var(--surface-light);
  border-radius: var(--border-radius);
}

.compound-label {
  font-weight: 500;
}

.compound-value {
  font-family: monospace;
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--primary-color);
}

.compound-status {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.compound-status.success {
  color: var(--success-color);
}

.compound-status.incomplete {
  color: var(--warning-color);
}

.game-controls {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

.controls-info h4 {
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

kbd {
  background-color: var(--surface-light);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--text-secondary);
  font-family: monospace;
}

.help-section {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

.help-section h4 {
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.expandable-heading {
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--primary-color);
  list-style-position: inside;
}

details[open] > .expandable-heading {
  margin-bottom: 1rem;
}

.help-steps {
  margin: 0;
  padding-left: 1.5rem;
}

.help-steps li {
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.help-steps em {
  color: var(--primary-color);
  font-style: normal;
}

.rules-section {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  border-left: 4px solid var(--warning-color);
}

.rules-section h4 {
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.rules-list {
  margin: 0;
  padding-left: 1.5rem;
}

.rules-list li {
  margin-bottom: 1rem;
  line-height: 1.5;
}

.rules-list em {
  color: var(--primary-color);
  font-style: normal;
  font-weight: 500;
}

.rules-list a {
  color: var(--primary-color);
}

.rules-list a:hover {
  text-decoration: underline;
}

.download-section {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

.download-section h4 {
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.download-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.saved-replays-list {
  margin-top: 1rem;
}

.replay-download-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.replay-download-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

.upload-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background-color: var(--surface);
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

.upload-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--surface-light);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.last-result {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  text-align: center;
}

.last-result h4 {
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.result-details {
  display: flex;
  justify-content: center;
  gap: 2rem;
  align-items: center;
}

.time {
  font-size: 2rem;
  font-weight: bold;
  font-family: monospace;
  color: var(--text-primary);
}

.status {
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
}

.status.success {
  background-color: rgba(40, 167, 69, 0.2);
  color: var(--success);
}

.status.error {
  background-color: rgba(220, 53, 69, 0.2);
  color: var(--error);
}

/* Leaderboard */
.leaderboard-page h2,
.leaderboard-detail h2 {
  text-align: center;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.leaderboard-page .subtitle,
.leaderboard-detail .track-info {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.championships-list {
  max-width: 600px;
  margin: 0 auto;
}

.championship-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

.championship-info h3 {
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.championship-info p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.championship-tracks-info {
  background-color: var(--surface);
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1.5rem;
}

.championship-tracks-info h4 {
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.championship-tracks-info .track-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.championship-tracks-info .compound-notice {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

.leaderboard-table-container {
  background-color: var(--surface);
  border-radius: var(--border-radius);
  overflow-x: auto;
  margin-bottom: 2rem;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--surface-light);
}

.leaderboard-table th {
  background-color: var(--surface-light);
  color: var(--primary-color);
  font-weight: 600;
  white-space: nowrap;
}

.leaderboard-table .position {
  font-weight: bold;
  font-size: 1.25rem;
}

.leaderboard-table .time {
  font-family: monospace;
  font-weight: bold;
}

.leaderboard-table .time.no-time {
  color: var(--text-secondary);
  opacity: 0.5;
}

.leaderboard-table .time .attempts-count {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: normal;
}

.leaderboard-table .replay-btn {
  display: inline-block;
  margin-left: 4px;
  text-decoration: none;
  font-size: 0.9rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.leaderboard-table .replay-btn:hover {
  opacity: 1;
}

.leaderboard-table .total-time {
  color: var(--primary-color);
  font-size: 1.1rem;
}

.leaderboard-table .partial-indicator {
  display: block;
  font-size: 0.7rem;
  color: var(--warning-color);
  font-weight: normal;
}

.leaderboard-table .status {
  font-size: 0.85rem;
}

.leaderboard-table .status-complete {
  color: var(--success-color);
  font-weight: bold;
}

.leaderboard-table .status-partial {
  color: var(--warning-color);
}

.leaderboard-table .incomplete {
  opacity: 0.7;
}

.leaderboard-table .first-place {
  background-color: rgba(255, 215, 0, 0.1);
}

.leaderboard-table .second-place {
  background-color: rgba(192, 192, 192, 0.1);
}

.leaderboard-table .third-place {
  background-color: rgba(205, 127, 50, 0.1);
}

.no-data {
  text-align: center;
  padding: 3rem;
  background-color: var(--surface);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
}

.leaderboard-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* Admin Dashboard */
.admin-dashboard h2 {
  color: var(--primary-color);
  margin-bottom: 2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  text-align: center;
}

.stat-card .stat-value {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.stat-card .stat-label {
  color: var(--text-secondary);
}

.admin-actions {
  margin-bottom: 2rem;
}

.admin-table {
  width: 100%;
  background-color: var(--surface);
  border-radius: var(--border-radius);
  overflow: hidden;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--surface-light);
}

.admin-table th {
  background-color: var(--surface-light);
  color: var(--primary-color);
}

.register-link-input {
  width: 200px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: var(--surface-light);
  border: 1px solid var(--text-secondary);
  border-radius: 4px;
  color: var(--text-primary);
  margin-left: 0.5rem;
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
}

.status-badge.active {
  background-color: rgba(40, 167, 69, 0.2);
  color: var(--success);
}

.status-badge.inactive {
  background-color: rgba(108, 117, 125, 0.2);
  color: var(--text-secondary);
}

.championships-section {
  margin-top: 2rem;
}

.championships-section h3 {
  margin-bottom: 1rem;
  color: var(--text-primary);
}

/* Admin Form */
.admin-page h2 {
  color: var(--primary-color);
  margin-bottom: 2rem;
}

.admin-form {
  max-width: 600px;
  background-color: var(--surface);
  padding: 2rem;
  border-radius: var(--border-radius);
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.success-message {
  background-color: rgba(40, 167, 69, 0.2);
  border: 1px solid var(--success);
  color: var(--success);
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 2rem;
}

.championship-secret {
  background-color: var(--surface);
  padding: 2rem;
  border-radius: var(--border-radius);
  margin-bottom: 2rem;
}

.championship-secret h3 {
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.secret-box {
  display: flex;
  gap: 1rem;
  align-items: center;
  background-color: var(--surface-light);
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

.secret-box code {
  flex: 1;
  font-family: monospace;
  font-size: 1.1rem;
  color: var(--primary-color);
  word-break: break-all;
}

.secret-instructions {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.championship-summary {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-bottom: 2rem;
}

.championship-summary h4 {
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.championship-summary ul {
  list-style: none;
}

.championship-summary li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

/* Error Page */
.error-page {
  text-align: center;
  padding: 4rem 2rem;
}

.error-page h2 {
  color: var(--error);
  margin-bottom: 1rem;
}

/* Footer */
.footer {
  background-color: var(--surface);
  text-align: center;
  padding: 1.5rem;
  margin-top: auto;
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    gap: 1rem;
  }
  
  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .hero h1 {
    font-size: 2rem;
  }
  
  .hero-actions {
    flex-direction: column;
  }
  
  .game-info {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .championship-item {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
}

/* Virtual Keypad for Mobile */
.virtual-keypad {
  display: none;
  background-color: var(--surface);
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-top: 1rem;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.keypad-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.key-btn {
  width: 70px;
  height: 70px;
  border: 2px solid var(--surface-light);
  border-radius: var(--border-radius);
  background-color: var(--surface-light);
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.key-btn:active,
.key-btn.pressed {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  transform: scale(0.95);
}

.key-btn.action-key {
  background-color: var(--surface-light);
  font-size: 0.9rem;
}

.key-btn.space-key {
  width: 200px;
  font-size: 1rem;
}

.keypad-toggle {
  text-align: center;
  margin-top: 0.5rem;
}

.keypad-toggle button {
  background-color: transparent;
  border: 1px solid var(--text-secondary);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.875rem;
}

.keypad-toggle button:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Virtual Keypad - Always visible below game */
.virtual-keypad {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--surface);
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.desktop-controls {
  display: none;
}

/* Mobile adjustments */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  .dos-container {
    /* aspect-ratio handled by base rule */
  }
  
  .key-btn {
    width: 60px;
    height: 60px;
    font-size: 1.25rem;
  }
  
  .key-btn.space-key {
    width: 160px;
  }
}

/* Smaller screens */
@media (max-width: 480px) {
  .key-btn {
    width: 55px;
    height: 55px;
    font-size: 1.1rem;
  }
  
  .key-btn.space-key {
    width: 140px;
    font-size: 0.9rem;
  }
}

/* Manual Upload Section */
.manual-upload-section {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-top: 1.5rem;
  border: 1px solid var(--surface-light);
}

.manual-upload-section h4 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.upload-hint {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.upload-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.selected-file {
  margin-top: 0.75rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-style: italic;
}

/* Upload Status */
.upload-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background-color: var(--surface);
  border-radius: var(--border-radius);
  margin: 1rem 0;
}

.upload-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--surface-light);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Manual Protection Words Section */
.manual-words-section {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-top: 1.5rem;
  border: 1px solid var(--surface-light);
}

.manual-words-section h4 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
  text-align: center;
}

.manual-hint {
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-align: center;
  margin-bottom: 1rem;
}

.manual-words-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.word-btn {
  background-color: var(--surface-light);
  border: 2px solid var(--surface-light);
  color: var(--text-primary);
  padding: 0.75rem 0.5rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: monospace;
  transition: all 0.15s;
  text-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.word-btn:hover {
  border-color: var(--primary-color);
  background-color: var(--surface);
}

.word-btn:active,
.word-btn.pressed {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  transform: scale(0.95);
}

.manual-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--surface-light);
}

.manual-controls .key-btn {
  width: auto;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* Responsive manual words */
@media (max-width: 768px) {
  .manual-words-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .word-btn {
    font-size: 0.8rem;
    padding: 0.6rem 0.3rem;
  }
}

@media (max-width: 480px) {
  .manual-words-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* JS-DOS File Browser */
.file-browser-section {
  background-color: var(--surface);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-top: 1.5rem;
  border: 1px solid var(--surface-light);
}

.file-browser-section h4 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.browser-hint {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

#refreshFileBrowser {
  margin-bottom: 1rem;
}

.file-list {
  margin-top: 1rem;
}

.no-files {
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  padding: 2rem;
}

.loading {
  color: var(--text-secondary);
  text-align: center;
  padding: 1rem;
}

.file-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--surface-light);
  padding: 1rem;
  border-radius: var(--border-radius);
  border: 1px solid var(--surface-light);
  transition: all 0.2s;
}

.file-item:hover {
  border-color: var(--primary-color);
}

.file-item.uploaded {
  opacity: 0.6;
  background-color: rgba(40, 167, 69, 0.1);
}

.file-name {
  font-family: monospace;
  font-size: 0.95rem;
  color: var(--text-primary);
  word-break: break-all;
  margin-right: 1rem;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  white-space: nowrap;
}

/* Debug Log Section */
.debug-log-section {
  background-color: #1a1a1a;
  border: 2px solid #ff6b00;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1.5rem;
}

.debug-log-section h4 {
  color: #ff6b00;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.debug-log-content {
  background-color: #000;
  border-radius: 4px;
  padding: 0.75rem;
  max-height: 150px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.75rem;
}

.log-entry {
  color: #00ff00;
  margin: 0.25rem 0;
  word-break: break-all;
}

.log-entry.log-error {
  color: #ff4444;
}

.log-entry.log-warn {
  color: #ffaa00;
}

.log-entry.log-info {
  color: #00aaff;
}

/* Debug Panel (Play Page) */
.debug-panel {
  background-color: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background-color: #161b22;
  border-bottom: 1px solid #30363d;
}

.debug-header span {
  color: #58a6ff;
  font-family: monospace;
  font-size: 0.875rem;
  font-weight: 600;
}

.debug-clear,
.debug-btn {
  background-color: transparent;
  border: 1px solid #30363d;
  color: #8b949e;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

.debug-clear:hover,
.debug-btn:hover {
  background-color: #21262d;
  color: #c9d1d9;
}

.debug-content {
  max-height: 200px;
  overflow-y: auto;
  padding: 0.75rem;
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  line-height: 1.4;
}

.debug-entry {
  color: #c9d1d9;
  padding: 0.25rem 0;
  border-bottom: 1px solid #21262d;
}

.debug-entry:last-child {
  border-bottom: none;
}

.debug-entry.debug-info {
  color: #58a6ff;
}

.debug-entry.debug-warn {
  color: #d29922;
}

.debug-entry.debug-error {
  color: #f85149;
}

/* Track List Section */
.track-list-section {
  background-color: var(--surface);
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  border: 1px solid var(--surface-light);
}

.track-list-section h4 {
  color: var(--primary-color);
  margin-bottom: 0.75rem;
}

.track-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.track-list .loading,
.track-list .no-tracks {
  color: var(--text-secondary);
  font-style: italic;
}

.track-badge {
  background-color: var(--surface-light);
  color: var(--text-primary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: monospace;
}

.track-upload {
  border-top: 1px solid var(--surface-light);
  padding-top: 0.75rem;
}

.save-button {
  visibility: hidden;
}

/* ============================================================
   Tighter layout: reduce whitespace, keep text readable
   ============================================================ */
.container { max-width: 1400px; padding: 1rem 1.25rem; }
.navbar { padding: 0.5rem 1rem; }
.nav-brand a { font-size: 1.2rem; }
.nav-links { gap: 1rem; }

.hero { padding: 1.5rem 1rem; margin-bottom: 1rem; }
.hero h1 { font-size: 2rem; margin-bottom: 0.4rem; }
.tagline { font-size: 1.05rem; margin-bottom: 0.8rem; }
.features { gap: 1rem; margin-bottom: 1rem; }
.feature { padding: 1rem; }

h1 { font-size: 1.7rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.35rem; margin-bottom: 0.4rem; }
h3 { font-size: 1.15rem; margin-bottom: 0.3rem; }
h4 { font-size: 1.02rem; margin-bottom: 0.3rem; }
p { margin-bottom: 0.5rem; }
ol, ul { margin: 0.4rem 0 0.4rem 1.2rem; }
li { margin: 0.1rem 0; }

.game-container { max-width: 1400px; }
.game-header { margin-bottom: 0.5rem; }
.game-header h2 { font-size: 1.3rem; }
.game-stats { gap: 1.5rem; margin-bottom: 0.6rem; }
.stat-value { font-size: 1.25rem; }

.championship-tracks, .championship-tracks-info,
.track-preview-section, .help-section, .rules-section,
.download-section, .manual-upload-section, .track-list-section,
.upload-status, .last-result, .leaderboard-section {
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.7rem;
}
.track-preview-section h4, .help-section h4, .rules-section h4,
.download-section h4, .championship-tracks h4,
.championship-tracks-info h4 { margin-bottom: 0.4rem; }
.help-steps, .rules-list { margin-left: 1.1rem; }
#trackPreviewFrame { max-width: 480px; min-height: 480px; }

.dos-container-wrapper { max-width: 960px; margin: 0 auto 0.7rem; }

.leaderboard-table-container { overflow-x: auto; }
.leaderboard-table th, .leaderboard-table td { padding: 0.35rem 0.6rem; }
.leaderboard-detail h2 { margin-bottom: 0.3rem; }
.leaderboard-detail .car-info { margin-bottom: 0.5rem; }
.leaderboard-actions { margin-top: 0.8rem; }
.track-standings-block { margin-bottom: 0.5rem; }
.attempt-row { padding: 0.15rem 0; }

.footer { padding: 0.6rem; font-size: 0.85rem; }

/* Race Feed */
.activity-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.activity-feed.compact { gap: 0.35rem; }
.activity-item {
  background: var(--surface);
  border-left: 3px solid var(--primary-color);
  border-radius: var(--border-radius);
  padding: 0.55rem 0.9rem;
  font-size: 0.95rem;
  line-height: 1.5;
}
.activity-item .time {
  font-family: monospace;
  font-weight: bold;
  color: var(--primary-color);
}
.activity-item .muted, .activity-item small.muted {
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.activity-replay { border-left-color: #28a745; }
.activity-championship { border-left-color: #ffc107; }
.activity-signup { border-left-color: #17a2b8; }
.activity-upload { border-left-color: #9c27b0; }
.activity-item .replay-btn { margin-left: 0.4rem; }
.race-feed-widget {
  background: var(--surface);
  border-radius: var(--border-radius);
  padding: 0.8rem 1rem;
  margin: 1rem 0;
}
.race-feed-widget h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.race-feed-widget h2 small { font-size: 0.8rem; font-weight: normal; }
/* Global audio preferences (Settings page) */
.audio-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.audio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* Cars tab */
.cars-page { max-width: 1400px; }
.cars-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-light) 100%);
  border-radius: var(--border-radius);
  padding: 1.3rem 1.5rem;
  margin-bottom: 1.2rem;
}
.cars-hero h1 { font-size: 2rem; margin-bottom: 0.35rem; }
.cars-hero p { color: var(--text-secondary); max-width: 62ch; margin: 0; }
.cars-hero-note { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; text-align: right; }
.cars-kicker {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--primary-color);
}
#carsCount { color: var(--text-secondary); font-size: 0.82rem; }

.cars-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.9fr);
  gap: 1.2rem;
  align-items: start;
}
.cars-layout > * { min-width: 0; }

.cars-stage-wrap { position: sticky; top: 1rem; }
.cars-stage {
  position: relative;
  height: 540px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at 50% 30%, rgba(56, 84, 140, 0.55) 0%, rgba(18, 25, 45, 0.9) 55%, #0a0f1a 100%);
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.6);
  cursor: grab;
  touch-action: none;
}
.cars-stage:active { cursor: grabbing; }
.cars-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cars-stage-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ffcf9b;
  background: rgba(10, 15, 26, 0.72);
  border: 1px solid rgba(255, 107, 0, 0.4);
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  pointer-events: none;
}
.cars-stage-hint {
  position: absolute;
  right: 14px;
  bottom: 10px;
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.72rem;
  pointer-events: none;
}
.cars-stage-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}
.cars-stage-loading.hidden { display: none; }

.cars-chart-block--stage {
  margin-top: 0.8rem;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius);
  padding: 0.8rem 1rem 0.6rem;
}
.cars-stage-under {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 0.75rem 0.25rem 0;
}
.cars-paint { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.cars-paint-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: var(--swatch);
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.cars-paint-swatch:hover { transform: translateY(-2px); }
.cars-paint-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.6);
}
.cars-stage-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.cars-stage-actions .btn { padding: 0.38rem 0.7rem; line-height: 1; }

.cars-panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius);
  padding: 1rem 1.1rem;
}
.cars-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; }
.cars-panel-head h2 { font-size: 1.5rem; margin: 0; }
.cars-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.cars-desc { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.55rem 0 1rem; }
.cars-desc-line {
  font-size: 0.76rem;
  color: #ffd7b0;
  background: rgba(255, 107, 0, 0.12);
  border: 1px solid rgba(255, 107, 0, 0.22);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}
.cars-chart-block { margin-bottom: 1rem; }
.cars-chart-block h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}
.cars-radar {
  display: block;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}
.cars-curve { display: block; width: 100%; aspect-ratio: 620 / 240; }
.cars-chart-note {
  font-size: 0.7rem;
  color: rgba(160, 160, 160, 0.7);
  text-align: center;
  margin: 0.15rem auto 0;
  max-width: 34ch;
}
.cars-legend {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}
.cars-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.cars-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.cars-swatch.torque { background: #ff8a2b; }
.cars-swatch.power { background: #54d6ff; }
.cars-legend-extra { margin-left: auto; color: #54d6ff; }

.cars-specs { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 0.4rem; }
.cars-spec-row {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 0.75rem;
  padding: 0.32rem 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.055);
}
.cars-spec-row:last-child { border-bottom: 0; }
.cars-spec-label { color: var(--text-secondary); font-size: 0.83rem; }
.cars-spec-value { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.cars-spec-hint {
  grid-column: 1 / -1;
  text-align: right;
  font-size: 0.68rem;
  color: rgba(160, 160, 160, 0.65);
  margin-top: -0.1rem;
}

.cars-gallery-section { margin-top: 1.6rem; }
.cars-gallery-head { display: flex; align-items: baseline; gap: 0.8rem; margin-bottom: 0.7rem; }
.cars-gallery-head h3 { margin: 0; }
.cars-gallery-note { color: var(--text-secondary); font-size: 0.8rem; }
.cars-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem;
}
.cars-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s;
}
.cars-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 107, 0, 0.5);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
}
.cars-card.active { border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.35); }
.cars-card-img {
  display: block;
  aspect-ratio: 12 / 7;
  background: radial-gradient(circle at 50% 40%, #223253 0%, #10162a 70%, #0a0f1a 100%);
}
.cars-card-img img { display: block; width: 100%; height: 100%; object-fit: contain; }
.cars-card-body { display: block; padding: 0.55rem 0.7rem 0.65rem; }
.cars-card-name { display: block; font-weight: 600; font-size: 0.94rem; margin-bottom: 0.2rem; }
.cars-card-meta {
  display: flex;
  gap: 0.55rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.cars-card-meta b {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #ffb066;
  font-weight: 700;
}

@media (max-width: 980px) {
  .cars-layout { grid-template-columns: minmax(0, 1fr); }
  .cars-stage-wrap { position: static; }
  .cars-stage { height: 420px; }
}
@media (max-width: 768px) {
  .cars-hero { flex-direction: column; align-items: flex-start; }
  .cars-hero-note { align-items: flex-start; text-align: left; }
  .cars-stage { height: 340px; }
  .cars-gallery { grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); }
}

/* Cars page: per-car records boards */
.cars-records-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin-top: 1.6rem;
}
.cars-records-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius);
  padding: 0.85rem 1rem;
}
.cars-records-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}
.cars-records-head h3 { margin: 0; font-size: 1.02rem; }
.cars-records-head small { color: var(--text-secondary); font-size: 0.74rem; }
.cars-records-head select {
  background: var(--surface-light);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 0.18rem 0.4rem;
  font-size: 0.78rem;
}
.cars-records-body { max-height: 320px; overflow-y: auto; }
.cars-muted { color: var(--text-secondary); font-size: 0.82rem; margin: 0.2rem 0; }
.cars-records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.cars-records-table th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.cars-records-table td {
  padding: 0.27rem 0.4rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}
.cars-records-table td:nth-child(2) { font-variant-numeric: tabular-nums; text-align: right; }
.cars-records-table td:last-child { text-align: right; width: 1.4rem; }
.cars-records-table a { color: #ffb066; text-decoration: none; }
.cars-records-table a:hover { text-decoration: underline; }
@media (max-width: 980px) {
  .cars-records-section { grid-template-columns: minmax(0, 1fr); }
}

/* Track library filters + championship exports */
.track-list-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.track-list-controls input[type="search"] {
  flex: 1;
  min-width: 120px;
  background: var(--surface-light);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  font-size: 0.82rem;
}
.track-list-controls select {
  background: var(--surface-light);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  font-size: 0.8rem;
}
.track-list-count { color: var(--text-secondary); font-size: 0.72rem; white-space: nowrap; }
.export-actions { display: flex; gap: 0.5rem; margin: 0.6rem 0; flex-wrap: wrap; }

/* Track viewer: ghost race */
.track-ghost {
  margin-top: 0.8rem;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--border-radius);
  padding: 0.7rem 0.9rem;
}
.track-ghost h4 { margin: 0 0 0.4rem; }
.track-ghost-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
}
.track-ghost-controls select {
  background: var(--surface-light);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 0.22rem 0.35rem;
  font-size: 0.8rem;
  max-width: 190px;
}

/* Cars page: laps per car on the gallery cards */
.cars-card-meta { flex-wrap: wrap; }
.cars-card-laps { color: #ffb066; }
#carsCount a { color: #ffb066; }
