html, body {
    margin: 0;
    padding: 0;
    background: #000;
    overflow: hidden;
	height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #fff;
}

/* CONTAINER JEU */
#gameContainer {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    background: radial-gradient(circle at top, #222 0%, #000 70%);
}

canvas {
    touch-action: none;
    display: block;
}

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 6px 10px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    text-shadow: 0 0 4px #000;
    z-index: 2000;
}

#hud .level { font-weight: 700; }
#hud .score { text-align: right; }

#bottomOverlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 10px;
    font-size: 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    text-align: center;
    z-index: 2000;
}

#touchHint {
    position: fixed;
    bottom: 50%;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 12px;
    opacity: 0.6;
    z-index: 2000;
}

/* GAME OVER */
#gameOverOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    align-items: center;          /* centre la carte */
    justify-content: center;      /* centre la carte */
    padding: 14px;
    box-sizing: border-box;
    z-index: 9000;

    /* IMPORTANT: autorise le scroll du contenu interne sur mobile */
    overscroll-behavior: contain;
}

#gameOverCard {
    width: min(520px, 96vw);
    max-height: calc(100vh - 28px);     /* IMPORTANT */
    overflow-y: auto;                   /* IMPORTANT */
    -webkit-overflow-scrolling: touch;  /* IMPORTANT (iOS/Android) */

    margin: 0 auto;
    background: rgba(0,0,0,0.5);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.15);
    padding: 16px;
    box-sizing: border-box;

    touch-action: pan-y; /* IMPORTANT: permet le scroll vertical dans la carte */
}

#gameOverOverlay h1 {
    margin: 0 0 10px;
    font-size: 22px;
    text-align: center;
}

#gameOverOverlay h2 {
    margin: 12px 0 6px;
    font-size: 18px;
}

#gameOverOverlay p { margin: 4px 0; }

.small { font-size: 0.9rem; opacity: 0.92; }

#gameOverOverlay button {
    margin-top: 12px;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
}
#gameOverOverlay button:active { transform: scale(0.96); }

/* FORMULAIRE */
#registerSection {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.15);
}

#registerForm label { display:block; margin-top:8px; font-weight:600; }

#registerForm input[type="text"],
#registerForm input[type="email"],
#registerForm input[type="tel"] {
    width:100%;
    padding:8px;
    border-radius:8px;
    border:1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.03);
    color:#fff;
    box-sizing:border-box;
    font-size:14px;
}
.error { color:#f66; }

/* LEADERBOARD */
#leaderboardSection {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.15);
}
#lbList { display: flex; flex-direction: column; gap: 6px; }

.lbMe {
    background: rgba(255, 216, 0, 0.16);
    border-color: rgba(255, 216, 0, 0.35);
    box-shadow: 0 0 0 1px rgba(255, 216, 0, 0.10) inset;
}

/* MENU + PRELOAD */
#menuScreen {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999;
}

#menuBg {
    position: absolute;
    inset: 0;
    background: url("/runner/assets/menu.png") center center / cover no-repeat;
    filter: saturate(1.05) contrast(1.02);
}

/* Bandeau bas centré */
#menuBottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    z-index: 2;
    padding: 0 14px;
    box-sizing: border-box;
}

#loadingWrapper {
    width: min(520px, 86vw);
    text-align: center;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(4px);
}

#loadingText {
    font-size: 16px;
    opacity: 0.92;
    margin-bottom: 8px;
}

#loadingBarOuter {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.08);
    overflow: hidden;
}

#loadingBarInner {
    width: 0%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #ffd800, #ff8c00);
    transition: width 0.15s linear;
}

#menuButtons {
    width: min(520px, 86vw);
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.menuBtn {
    padding: 12px 10px;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 12px;
    font-size: 18px;
    color: #fff;
    font-weight: 900;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.menuBtn:active { transform: scale(0.98); }

#btnPlay { display: none; } /* affiché quand preload terminé */

/* OPTIONS overlay */
#optionsOverlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    box-sizing: border-box;
    background: rgba(0,0,0,0.70);
    z-index: 3;
}

#optionsCard {
    width: min(640px, 92vw);
    max-height: min(80vh, 720px);
    overflow: auto;
    border-radius: 16px;
    background: rgba(0,0,0,0.72);
    border: 1px solid rgba(255,255,255,0.14);
    padding: 14px;
    box-sizing: border-box;
}

#optionsHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

#optionsHeader .title {
    font-size: 20px;
    font-weight: 900;
}

.iconBtn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.10);
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    font-weight: 900;
}

.iconBtn:active { transform: scale(0.98); }

.optionsSection {
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.12);
}

.optionsSection h3 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 900;
}

.optionsList {
    margin: 0;
    padding-left: 18px;
    line-height: 1.55;
}

.small { font-size: 0.9rem; opacity: 0.92; }

/* Leaderboard dans options (menu) */
#menuLbList {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
/* ===== Leaderboard (menu + game over) ===== */
.lbRow{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}

.lbRank{
  flex: 0 0 36px;
  opacity: .85;
  font-weight: 900;
  text-align: right;
}

.lbName{
  flex: 1 1 auto;
  min-width: 0;                 /* CRITIQUE: permet le shrink */
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lbBelt{
  flex: 0 1 auto;               /* peut rétrécir si besoin */
  max-width: 42vw;              /* évite d'écraser le score */
  padding: 4px 10px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.25);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;      /* troncature propre */
}

.lbScore{
  flex: 0 0 90px;
  text-align: right;
  font-weight: 900;
}

/* ===== Ceintures: lisibilité (marron/noir) ===== */
.lbBelt.belt-brown{
  background: rgba(0,0,0,0.45);
  border-color: rgba(255,255,255,0.55);
  color: #d2a679;
  text-shadow: 0 1px 0 rgba(0,0,0,0.95);
  box-shadow:
    0 0 0 2px rgba(139,69,19,0.35) inset,
    0 0 12px rgba(0,0,0,0.65);
}

.lbBelt.belt-black{
  background: rgba(0,0,0,0.60);
  border-color: rgba(255,255,255,0.70);
  color: #ffffff;
  text-shadow: 0 1px 0 rgba(0,0,0,0.95);
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.15) inset,
    0 0 12px rgba(0,0,0,0.75);
}

.lbBelt.belt-white  { background: rgba(255,255,255,0.16); color:#fff; border-color: rgba(255,255,255,0.55); }
.lbBelt.belt-yellow { background: rgba(255,216,0,0.22);   color:#ffd800; border-color: rgba(255,216,0,0.70); }
.lbBelt.belt-orange { background: rgba(255,140,0,0.22);   color:#ffb057; border-color: rgba(255,140,0,0.70); }
.lbBelt.belt-green  { background: rgba(0,176,80,0.20);    color:#2eea7c; border-color: rgba(0,176,80,0.70); }
.lbBelt.belt-blue   { background: rgba(0,112,192,0.20);   color:#6bb8ff; border-color: rgba(0,112,192,0.70); }
