* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: #0d1226;
  color: #fff;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  z-index: 10;
}

.screen.active {
  display: flex;
}

#screen-menu,
#screen-over {
  background: radial-gradient(ellipse at top, #1b2450 0%, #0d1226 70%);
}

#screen-menu {
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: calc(28px + env(safe-area-inset-top));
}

@media (max-height: 760px) {
  .logo {
    font-size: 42px;
  }

  .tagline {
    font-size: 13px;
    max-width: 280px;
  }

  #screen-menu {
    gap: 8px;
  }

  .btn {
    padding: 10px 22px;
    min-width: 200px;
    font-size: 15px;
  }

  .btn.big {
    padding: 12px 26px;
    font-size: 17px;
  }
}

#screen-levels,
#screen-shop {
  background: rgba(10, 14, 32, 0.96);
  justify-content: flex-start;
  overflow-y: auto;
  gap: 10px;
}

.overlay {
  background: rgba(5, 8, 20, 0.78);
  backdrop-filter: blur(4px);
  z-index: 30;
}

.logo {
  font-size: clamp(52px, 14vw, 84px);
  line-height: 0.95;
  text-align: center;
  letter-spacing: 4px;
  background: linear-gradient(180deg, #ffd54a, #ff8a3c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 6px 30px rgba(255, 138, 60, 0.25);
}

.tagline {
  max-width: 320px;
  text-align: center;
  color: #aeb8d8;
  font-size: 15px;
  margin-bottom: 4px;
}

.coins-display {
  font-size: 18px;
  font-weight: 700;
  color: #ffd54a;
  background: rgba(255, 213, 74, 0.1);
  border: 1px solid rgba(255, 213, 74, 0.35);
  padding: 6px 16px;
  border-radius: 999px;
}

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  color: #0d1226;
  background: linear-gradient(180deg, #ffd54a, #ffb020);
  border: none;
  border-radius: 14px;
  padding: 13px 28px;
  min-width: 220px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b97a10, 0 8px 18px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #b97a10, 0 4px 10px rgba(0, 0, 0, 0.4);
}

.btn.big {
  font-size: 20px;
  padding: 16px 34px;
}

.btn.secondary {
  background: #232c4d;
  color: #dfe6ff;
  box-shadow: 0 4px 0 #141a33, 0 8px 18px rgba(0, 0, 0, 0.4);
}

.btn.secondary:active {
  box-shadow: 0 1px 0 #141a33, 0 4px 10px rgba(0, 0, 0, 0.4);
}

.btn.small {
  min-width: 0;
  font-size: 14px;
  padding: 9px 14px;
  border-radius: 10px;
}

.btn.back {
  min-width: 0;
  padding: 8px 14px;
}

.topbar {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
}

.topbar h2 {
  font-size: 24px;
}

.cards {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 24px;
}

.card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1a2142;
  border: 1px solid #2c3560;
  border-radius: 16px;
  padding: 12px;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-weight: 700;
  font-size: 16px;
}

.card-sub {
  color: #9aa6cc;
  font-size: 13px;
  margin-top: 2px;
}

.card-best {
  color: #ffd54a;
  font-size: 13px;
  margin-top: 2px;
  min-height: 15px;
}

.card-theme {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  flex-shrink: 0;
}

.theme-autoroute { background: linear-gradient(180deg, #6fb9f2 40%, #3d4250 40%); }
.theme-ville { background: linear-gradient(180deg, #ffb46b 40%, #484d59 40%); }
.theme-desert { background: linear-gradient(180deg, #ff9e5e 40%, #6e6353 40%); }
.theme-neige { background: linear-gradient(180deg, #9fc6e8 40%, #8fa3bd 40%); }
.theme-nuit { background: linear-gradient(180deg, #070b1d 40%, #151824 40%); }

.shop-section-title {
  width: 100%;
  max-width: 560px;
  font-size: 16px;
  color: #aeb8d8;
  margin-top: 8px;
}

.shop-card .swatch {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.shop-card .swatch.fx {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: #232c4d;
}

.panel {
  width: min(92vw, 420px);
  background: #161d3d;
  border: 1px solid #2c3560;
  border-radius: 22px;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-height: 88vh;
  overflow-y: auto;
}

.panel h2 {
  font-size: 24px;
  text-align: center;
}

#over-score {
  font-size: 52px;
  font-weight: 800;
  color: #ffd54a;
  line-height: 1;
}

.score-label {
  color: #9aa6cc;
  font-size: 13px;
  margin-top: -8px;
}

.record {
  color: #7ee081;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}

.stats-grid > div {
  background: #10173a;
  border-radius: 12px;
  padding: 10px 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stats-grid b {
  font-size: 17px;
  color: #fff;
}

.stats-grid span {
  font-size: 11px;
  color: #9aa6cc;
}

.coins-earned {
  font-size: 18px;
  font-weight: 700;
  color: #ffd54a;
}

.help-text {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14.5px;
  line-height: 1.45;
  color: #dfe6ff;
}

#hud {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 20;
  pointer-events: none;
}

#hud-score {
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  min-width: 90px;
}

#hud-combo {
  font-size: 22px;
  font-weight: 800;
  color: #ffd54a;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

#hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

#hud-level {
  font-size: 13px;
  color: #dfe6ff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  max-width: 110px;
  text-align: right;
}

#hud-lives {
  font-size: 15px;
  letter-spacing: 2px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.overlay-sub {
  color: #aeb8d8;
  font-size: 15px;
  text-align: center;
}

#ad-countdown {
  font-size: 56px;
  font-weight: 800;
  color: #ffd54a;
}

.ad-note {
  color: #9aa6cc;
  font-size: 13px;
  text-align: center;
}

.picker-label {
  width: 100%;
  max-width: 560px;
  color: #aeb8d8;
  font-size: 13px;
  margin-top: 2px;
}

#difficulty-picker,
#lb-filter {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  flex-wrap: wrap;
}

.diff-btn {
  flex: 1;
  min-width: 0;
  background: #232c4d;
  color: #dfe6ff;
  box-shadow: 0 3px 0 #141a33;
}

.diff-btn.active {
  background: linear-gradient(180deg, #ffd54a, #ffb020);
  color: #0d1226;
  box-shadow: 0 3px 0 #b97a10;
}

.lb-source {
  color: #9aa6cc;
  font-size: 12px;
  width: 100%;
  max-width: 560px;
}

.lb-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 560px;
  flex-wrap: wrap;
}

.lb-optin {
  font-size: 13px;
  color: #dfe6ff;
  display: flex;
  gap: 6px;
  align-items: center;
}

.lb-row {
  gap: 10px;
}

.lb-rank {
  font-weight: 800;
  width: 30px;
  text-align: right;
  color: #ffd54a;
  flex-shrink: 0;
}

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

.lb-name.me {
  color: #54f0ff;
}

.lb-score {
  font-weight: 800;
}

.lb-level {
  color: #9aa6cc;
  font-size: 12px;
}

.ach-done {
  border-color: #ffd54a;
  background: #232047;
}

#pseudo-input {
  font: inherit;
  font-size: 17px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #3a4670;
  background: #10173a;
  color: #fff;
  width: 100%;
  text-align: center;
}

#btn-pause {
  font: inherit;
  font-size: 18px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: rgba(20, 26, 51, 0.8);
  color: #fff;
  cursor: pointer;
}

#toast {
  position: fixed;
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #232c4d;
  border: 1px solid #3a4670;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  pointer-events: none;
  white-space: nowrap;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
