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

html, body {
  height: 100%;
  background: #0b1020;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #1a2244 0%, #0b1020 100%);
}

canvas {
  display: block;
  background: #87ceeb;
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  image-rendering: pixelated;
}

/* HUD */
#hud {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(90%, 900px);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.hud-item {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
  font-weight: 600;
}

.hud-item .lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
  font-weight: 500;
}

.hud-item span:last-child {
  font-size: 20px;
  margin-top: 2px;
}

.fuel-wrap {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.fuel-wrap .lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
}

.fuel-bar {
  flex: 1;
  height: 12px;
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  overflow: hidden;
}

#fuel-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff5252 0%, #ffd740 40%, #69f0ae 100%);
  transition: width 0.15s linear;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 16, 32, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
  overflow-y: auto;
}

.overlay h1 {
  font-size: clamp(28px, 5vw, 48px);
  margin-bottom: 4px;
}

.overlay h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.7;
  margin-bottom: 10px;
  text-align: center;
}

.subtitle {
  opacity: 0.7;
  margin-bottom: 8px;
  text-align: center;
}

.section {
  width: min(92%, 720px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  width: 100%;
}

.card {
  background: rgba(255,255,255,0.06);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.card:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-2px);
}

.card.selected {
  border-color: #ffd740;
  background: rgba(255, 215, 64, 0.15);
}

.card .icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.card .name {
  font-weight: 600;
  font-size: 14px;
}

.card .stats {
  font-size: 11px;
  opacity: 0.65;
  margin-top: 4px;
}

.big-btn {
  background: linear-gradient(135deg, #ffd740 0%, #ff9100 100%);
  color: #0b1020;
  border: none;
  font-size: 20px;
  font-weight: 700;
  padding: 14px 40px;
  border-radius: 999px;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 8px 24px rgba(255, 145, 0, 0.4);
  transition: transform 0.15s ease;
}

.big-btn:hover {
  transform: translateY(-2px);
}

.big-btn:active {
  transform: translateY(0);
}

.ghost-btn {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.3);
  font-size: 16px;
  padding: 10px 28px;
  border-radius: 999px;
  cursor: pointer;
}

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

.controls-hint {
  margin-top: 12px;
  opacity: 0.6;
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}

.small { font-size: 11px; opacity: 0.8; }

.stats {
  display: flex;
  gap: 24px;
  margin: 16px 0;
}

.stats > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.06);
  padding: 12px 20px;
  border-radius: 12px;
  min-width: 100px;
}

.stats .lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.6;
}

.stats span:last-child {
  font-size: 22px;
  font-weight: 700;
  margin-top: 2px;
}

/* Touch controls */
#touch-controls {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  pointer-events: none;
}

.touch-btn {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.3);
  font-size: 32px;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.touch-btn:active {
  background: rgba(255, 215, 64, 0.4);
}

/* Auth */
.tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  padding: 4px;
}

.tab {
  background: transparent;
  border: none;
  color: #fff;
  padding: 8px 24px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  opacity: 0.6;
}

.tab.active {
  background: rgba(255, 215, 64, 0.2);
  opacity: 1;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(92%, 320px);
  margin-top: 4px;
}

.auth-form input {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}

.auth-form input:focus {
  border-color: #ffd740;
}

.auth-form input::placeholder {
  color: rgba(255,255,255,0.4);
}

.auth-error {
  color: #ff6b6b;
  font-size: 13px;
  min-height: 18px;
  text-align: center;
}

.auth-note {
  opacity: 0.5;
  text-align: center;
  margin-top: 8px;
}

/* User bar im Menü */
.user-bar {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,0.4);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
}

.small-btn {
  font-size: 12px;
  padding: 4px 12px;
}

/* Leaderboard */
.leaderboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}

.lb-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 10px;
  align-items: center;
  background: rgba(255,255,255,0.05);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.lb-row.me {
  background: rgba(255, 215, 64, 0.18);
  border: 1px solid rgba(255, 215, 64, 0.4);
}

.cheat-badge {
  display: inline-block;
  font-size: 13px;
  margin-left: 2px;
  background: rgba(255, 80, 80, 0.18);
  border: 1px solid rgba(255, 80, 80, 0.45);
  padding: 1px 5px;
  border-radius: 6px;
  cursor: help;
}

.cheat-badge.clean {
  background: rgba(105, 240, 174, 0.15);
  border-color: rgba(105, 240, 174, 0.45);
}

.cheat-badge.unknown {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  opacity: 0.6;
  font-size: 11px;
  letter-spacing: 1px;
}

.admin-banner {
  background: linear-gradient(135deg, rgba(255,215,64,0.25), rgba(255,145,0,0.18));
  border: 1px solid rgba(255, 215, 64, 0.4);
  padding: 6px 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #ffd740;
  letter-spacing: 0.5px;
}

.lb-row.clickable {
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}

.lb-row.clickable:hover {
  background: rgba(255, 215, 64, 0.22);
  transform: translateX(2px);
}

.lb-row.top1 { background: rgba(255, 215, 64, 0.25); }
.lb-row.top2 { background: rgba(200, 200, 200, 0.15); }
.lb-row.top3 { background: rgba(205, 127, 50, 0.15); }

.lb-rank {
  font-weight: 700;
  text-align: center;
  opacity: 0.8;
}

.lb-name {
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-meta {
  opacity: 0.55;
  font-size: 12px;
}

.lb-dist {
  font-weight: 700;
  color: #ffd740;
}

.lb-empty {
  opacity: 0.5;
  text-align: center;
  padding: 16px;
  font-size: 14px;
}

/* Replay-Leiste */
#replay-bar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  padding: 10px 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  border: 1px solid rgba(255, 215, 64, 0.3);
  z-index: 500;
}

#replay-bar .replay-label strong {
  color: #ffd740;
}

#replay-bar .small-btn {
  padding: 6px 14px;
}

/* Toast (Cheat-Hinweis & Co.) */
#toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 14px 28px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 1000;
  white-space: nowrap;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.hidden { display: none !important; }

@media (max-width: 600px) {
  .hud-item { min-width: 70px; padding: 6px 10px; }
  .hud-item span:last-child { font-size: 16px; }
  #touch-controls.show { display: flex; }
}
