:root {
  --f1-red: #e10600;
  --f1-black: #15151e;
  --f1-dark: #0b0b0f;
  --f1-white: #ffffff;
  --f1-grey: #38383f;
  --f1-gold: #f2b84b;
  --f1-green: #00d2be;
  --f1-purple: #b62ad6;
  --f1-panel: rgba(21, 21, 30, 0.88);
}

* { box-sizing: border-box; }

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;700;900&display=swap');

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--f1-black);
  color: var(--f1-white);
  font-family: 'Outfit', sans-serif;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  background: radial-gradient(circle at 50% 40%, #1a252b, #000 75%);
}

/* F1 LEADERBOARD (Sidebar) */
.f1-leaderboard {
  position: fixed;
  top: 40px;
  left: 20px;
  width: 240px;
  background: var(--f1-panel);
  border-left: 4px solid var(--f1-red);
  backdrop-filter: blur(10px);
  box-shadow: 10px 0 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.f1-classification {
  position: fixed;
  top: 40px;
  right: 20px;
  width: 200px;
  background: var(--f1-panel);
  border-right: 4px solid var(--f1-white);
  backdrop-filter: blur(10px);
  box-shadow: -10px 0 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.f1-classification .f1-row {
  font-size: 12px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  justify-content: space-between;
}

.f1-classification .f1-row.empty {
  color: rgba(255,255,255,0.4);
  font-style: italic;
  font-size: 11px;
}

.f1-classification .time {
  font-family: 'Roboto Mono', monospace;
  font-weight: bold;
}

.f1-logo {
  background: var(--f1-red);
  color: white;
  font-weight: 900;
  padding: 6px 12px;
  font-size: 14px;
  letter-spacing: 2px;
}

.f1-row {
  display: flex;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  align-items: center;
  font-size: 13px;
  font-weight: 700;
}

.f1-row.header {
  background: rgba(255,255,255,0.05);
  font-size: 10px;
  color: rgba(255,255,255,0.5);
}

.f1-row.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--f1-gold);
}

.f1-row .pos { width: 30px; }
.f1-row .name { flex: 1; text-transform: uppercase; }
.f1-row .gap { width: 70px; text-align: right; font-family: monospace; }

.f1-lap-counter {
  background: var(--f1-grey);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 900;
}

.f1-checkpoint-info {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--f1-gold);
  font-weight: 700;
}

/* F1 DASHBOARD (Bottom Center) */
.f1-dashboard {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 30px;
  background: var(--f1-panel);
  padding: 15px 40px;
  pointer-events: none;
  z-index: 10;
  border-bottom: 4px solid var(--f1-red);
}

.f1-speed {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 2px solid rgba(255,255,255,0.1);
  padding-right: 30px;
}

.f1-speed span {
  font-size: 52px;
  font-weight: 900;
  line-height: 1;
}

.f1-speed small {
  font-size: 12px;
  color: var(--f1-gold);
  font-weight: 700;
}

.f1-time-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.f1-main-time {
  font-size: 38px;
  font-weight: 900;
  font-family: monospace;
  line-height: 1;
}

.f1-sector-delta {
  font-size: 16px;
  font-weight: 900;
  font-family: monospace;
  margin-top: 4px;
}

/* F1 TOP BUTTONS */
.f1-controls-top {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 20;
}

.f1-btn {
  background: var(--f1-panel);
  border: none;
  border-bottom: 2px solid var(--f1-red);
  color: white;
  padding: 8px 16px;
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.f1-btn:hover, .f1-btn.primary {
  background: var(--f1-red);
}

/* MENUS & PANELS */
.menuScreen {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(10px);
}

.menuCard {
  width: 500px;
  background: var(--f1-black);
  border-top: 6px solid var(--f1-red);
  padding: 40px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.8);
}

.f1Kicker { color: var(--f1-red); font-weight: 900; font-size: 14px; margin-bottom: 8px; }
.menuCard h1 { font-size: 48px; margin: 0 0 24px; text-transform: uppercase; font-weight: 900; }

.menuTabs { display: flex; gap: 4px; margin-bottom: 20px; }
.menuTabs button { flex: 1; background: var(--f1-grey); border: none; color: white; padding: 12px; font-weight: 700; cursor: pointer; }
.menuTabs button.primary { background: var(--f1-red); }

.menuPanel label { display: block; margin-bottom: 12px; font-size: 11px; font-weight: 700; color: #888; text-transform: uppercase; }
.menuPanel input, .menuPanel select { width: 100%; background: #222; border: 1px solid #444; color: white; padding: 12px; margin-top: 4px; }

.launch { width: 100%; background: var(--f1-red); border: none; color: white; padding: 16px; font-weight: 900; font-size: 18px; cursor: pointer; margin-top: 20px; }

.recordsList { background: #111; padding: 15px; border-radius: 4px; font-size: 13px; color: #aaa; }

.message {
  position: fixed; bottom: 130px; left: 50%; transform: translateX(-50%);
  background: var(--f1-panel); border-left: 4px solid var(--f1-gold);
  padding: 10px 24px; font-size: 14px; font-weight: 700;
  backdrop-filter: blur(10px); z-index: 50;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* MOBILE CONTROLS */
.mobileControls {
  position: fixed; bottom: 20px; right: 20px;
  display: grid; grid-template-columns: repeat(3, 70px); gap: 10px;
  z-index: 10;
}
.mobileControls button {
  height: 60px; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  color: white; font-size: 24px; backdrop-filter: blur(5px); border-radius: 8px;
}
[data-control="gas"] { grid-column: 2; grid-row: 1; }
[data-control="left"] { grid-column: 1; grid-row: 2; }
[data-control="brake"] { grid-column: 2; grid-row: 2; }
[data-control="right"] { grid-column: 3; grid-row: 2; }

.panel {
  position: fixed; top: 80px; right: 20px; width: 320px;
  background: var(--f1-panel); padding: 20px; border-top: 4px solid var(--f1-white);
  backdrop-filter: blur(10px);
  z-index: 20;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
}

.toolSection {
  margin-bottom: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.toolSectionTitle {
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.72);
  text-transform: uppercase;
}

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

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

#editorPanel .f1-btn {
  min-height: 38px;
  padding: 8px 10px;
  text-align: left;
  border-bottom-width: 3px;
  background: rgba(12, 12, 18, 0.85);
}

#editorPanel .f1-btn.active,
#editorPanel .f1-btn:hover {
  background: linear-gradient(135deg, rgba(225,6,0,0.92), rgba(255,118,72,0.92));
}

.search { display: flex; gap: 4px; margin-bottom: 10px; }
.search input { flex: 1; background: #222; border: 1px solid #444; color: white; padding: 8px; }
.search button { background: var(--f1-red); border: none; color: white; padding: 8px 12px; }

.trackWidthControl {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.75);
}

#trackWidthInput {
  width: 100%;
}

.check { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 10px; }

textarea { width: 100%; height: 120px; background: #000; color: var(--f1-green); border: 1px solid #333; font-family: monospace; padding: 10px; font-size: 11px; }

.hidden { display: none !important; }

@media (max-width: 800px) {
  .f1-leaderboard { top: 10px; left: 10px; width: 180px; transform: scale(0.85); transform-origin: top left; }
  .f1-dashboard { transform: translateX(-50%) scale(0.7); bottom: 10px; }
  .f1-controls-top { display: none; }
}
