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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0d1a;
  font-family: 'Segoe UI', system-ui, sans-serif;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  position: relative;
  width: 100%;
  max-width: 800px;
  /* Ratio 2:1 */
  aspect-ratio: 2 / 1;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(79,163,220,0.3), 0 0 0 1px rgba(255,255,255,0.08);
}

/* Sur mobile : on utilise toute la largeur, ratio 2:1 préservé */
@media (max-width: 820px) {
  body {
    align-items: center;
    justify-content: center;
    background: #0d0d1a;
  }
  #app {
    /* Remplit la largeur, la hauteur suit le ratio */
    width: 100vw;
    max-width: 100vw;
    /* Ratio 2:1 : height = 50vw */
    height: 50vw;
    aspect-ratio: 2 / 1;
    border-radius: 0;
  }
}

/* Paysage mobile : profiter de toute la hauteur */
@media (max-width: 820px) and (orientation: landscape) {
  #app {
    height: 100dvh;
    width: 200dvh;
    max-width: 100vw;
    aspect-ratio: unset;
  }
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── HUD ──────────────────────────────────────────────────────────── */
#hud {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 16px;
  pointer-events: none;
  z-index: 10;
}
#hud-score, #hud-hi {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: clamp(11px, 3vw, 14px);
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  letter-spacing: 0.03em;
}
#hud-speed {
  background: rgba(255,180,0,0.85);
  color: #1a0;
  font-size: clamp(10px, 2.5vw, 13px);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  animation: pulse 0.6s ease infinite alternate;
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }

/* ── BOUTON SAUT MOBILE ───────────────────────────────────────────── */
#jump-btn {
  display: none;
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(79,163,220,0.25);
  border: 3px solid rgba(79,163,220,0.6);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  z-index: 20;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.1s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
#jump-btn:active { background: rgba(79,163,220,0.5); transform: scale(0.92); }

@media (max-width: 820px), (pointer: coarse) {
  #jump-btn { display: flex; align-items: center; justify-content: center; }
}

/* ── OVERLAY SCREENS ──────────────────────────────────────────────── */
#menu-screen, #gameover-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(5,8,20,0.78);
  backdrop-filter: blur(3px);
  color: #fff;
  z-index: 15;
  padding: 20px;
  overflow-y: auto;
}
.hidden { display: none !important; }

/* Menu */
#menu-screen h1 {
  font-size: clamp(32px, 9vw, 56px);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  letter-spacing: -1px;
  text-transform: uppercase;
}
#menu-screen h1 span {
  font-size: clamp(22px, 6vw, 40px);
  font-weight: 400;
  color: #F5D78A;
  display: block;
}
.tagline {
  font-size: clamp(12px, 3vw, 15px);
  color: #a8c8e0;
  font-style: italic;
  margin-bottom: 4px;
  text-align: center;
}
#menu-record {
  font-size: clamp(12px, 3vw, 14px);
  color: #7de;
  background: rgba(0,100,180,0.3);
  padding: 4px 14px;
  border-radius: 20px;
}

/* Input nom joueur */
.name-input-wrap {
  width: 100%;
  max-width: 280px;
  margin: 4px auto;
}
#player-name {
  width: 100%;
  padding: 13px 18px;
  font-size: clamp(14px, 4vw, 16px);
  font-family: inherit;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(108,99,255,0.45);
  border-radius: 12px;
  color: #fff;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}
#player-name::placeholder { color: rgba(255,255,255,0.35); }
#player-name:focus {
  border-color: #6c63ff;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.25);
}

/* Game over */
#gameover-screen h2 {
  font-size: clamp(36px, 10vw, 54px);
  font-weight: 900;
  color: #ff6b6b;
}
.go-msg {
  font-size: clamp(12px, 3.5vw, 15px);
  color: #cce;
  font-style: italic;
  max-width: 380px;
  text-align: center;
  line-height: 1.4;
  background: rgba(255,255,255,0.05);
  padding: 8px 16px;
  border-radius: 8px;
}
.go-scores {
  display: flex;
  gap: clamp(16px, 6vw, 32px);
  text-align: center;
  font-size: clamp(10px, 2.5vw, 13px);
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.go-scores strong {
  display: block;
  font-size: clamp(26px, 8vw, 38px);
  color: #fff;
  font-weight: 800;
  letter-spacing: -1px;
}

/* Buttons */
button {
  padding: clamp(12px, 3vw, 14px) clamp(28px, 7vw, 40px);
  font-size: clamp(14px, 4vw, 16px);
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.04em;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  text-transform: uppercase;
  background: linear-gradient(135deg, #4FA3DC, #2e6fa8);
  color: #fff;
  box-shadow: 0 4px 20px rgba(79,163,220,0.4);
  min-width: 140px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:hover  { transform: translateY(-2px); box-shadow: 0 6px 26px rgba(79,163,220,0.55); }
button:active { transform: translateY(0);    box-shadow: 0 2px 10px rgba(79,163,220,0.3);  }

.hint {
  font-size: clamp(10px, 2.5vw, 12px);
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.06em;
  margin-top: 2px;
  text-align: center;
}

@media (pointer: coarse) {
  .hint { display: none; }
}
