:root {
  --cyan: #22d3ee;
  --magenta: #e879f9;
  --gold: #fbbf24;
  --panel: rgba(10, 14, 32, 0.82);
  --stroke: rgba(255, 255, 255, 0.09);
  --font: "Segoe UI", system-ui, sans-serif;
}

html, body {
  margin: 0;
  height: 100%;
  background: #05070f;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-family: var(--font);
}

/* mobile : pas de zoom double-tap, pas de sélection ni de menu contextuel */
html { touch-action: manipulation; }
body {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input { user-select: text; -webkit-user-select: text; }

#stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: min(100vw, calc(100vh * 16 / 9));
}

/* dvh : tient compte de la barre d'adresse des navigateurs mobiles */
@supports (height: 100dvh) {
  #stage { width: min(100dvw, calc(100dvh * 16 / 9)); }
}

/* MOBILE EN PORTRAIT : au lieu de demander de tourner le téléphone, on PIVOTE
   automatiquement le jeu pour l'afficher en paysage plein écran. Le joueur
   tient son téléphone à l'horizontale et le jeu remplit l'écran, comme une app. */
/* MOBILE PAYSAGE : le jeu remplit TOUT l'écran, bord à bord (comme une app) */
@media (pointer: coarse) and (orientation: landscape) {
  #stage { width: 100vw; height: 100vh; aspect-ratio: auto; }
}
@supports (height: 100dvh) {
  @media (pointer: coarse) and (orientation: landscape) {
    #stage { width: 100dvw; height: 100dvh; }
  }
}
/* MOBILE PORTRAIT : on pivote le jeu en paysage ET on remplit tout l'écran */
@media (pointer: coarse) and (orientation: portrait) {
  #stage {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100vh;                 /* après rotation → occupe toute la hauteur écran */
    height: 100vw;                /* → occupe toute la largeur écran */
    aspect-ratio: auto;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
  }
}
@supports (height: 100dvh) {
  @media (pointer: coarse) and (orientation: portrait) {
    #stage { width: 100dvh; height: 100dvw; }
  }
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  cursor: pointer;
}

/* ---- surcouche UI : dimensionnée en 960×540 puis mise à l'échelle en JS ---- */
#ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 960px;
  height: 540px;
  transform-origin: 0 0;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(4, 6, 14, 0.72);
  backdrop-filter: blur(5px);
  pointer-events: auto;
}

.hidden { display: none !important; }

/* ---- typographie ---- */
.title {
  margin: 0;
  font-size: 58px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(34, 211, 238, 0.45));
}

.tagline {
  margin: -6px 0 4px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
}

h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
}

h2.over {
  color: #f43f5e;
  font-size: 34px;
  text-shadow: 0 0 24px rgba(244, 63, 94, 0.6);
}

.sub { color: rgba(255, 255, 255, 0.6); font-size: 14px; margin: 0; }
.hint { color: rgba(255, 255, 255, 0.45); font-size: 11.5px; margin: 6px 0 0; }

/* ---- choix de la tranche d'âge (écran du nom) ---- */
.age-label { margin-top: 4px; }
.age-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.age-btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.age-btn:hover { transform: translateY(-2px); border-color: var(--cyan); }
.age-btn.active {
  background: linear-gradient(135deg, #06b6d4, #2563eb);
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.4);
}
/* rappel « choisis un âge » si on valide sans avoir sélectionné */
.age-row.miss { animation: shake 0.35s; }
.age-row.miss .age-btn { border-color: #f43f5e; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ---- écran de consentement (conditions + politique) ---- */
.consent-links { display: flex; flex-direction: column; gap: 6px; margin: 2px 0; }
.consent-links a { color: var(--cyan); font-weight: 700; font-size: 14px; text-decoration: none; }
.consent-links a:hover { text-decoration: underline; }
.consent-check {
  display: flex; align-items: flex-start; gap: 8px; text-align: left;
  font-size: 13px; color: rgba(255, 255, 255, 0.75); max-width: 380px; cursor: pointer;
}
.consent-check input { margin-top: 3px; width: 18px; height: 18px; flex: 0 0 auto; accent-color: #06b6d4; }

/* ---- réglages du son (curseurs) ---- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; max-width: 320px; font-weight: 700; }
.set-row input[type="range"] { flex: 1; accent-color: #06b6d4; height: 22px; }

/* ---- liens légaux dans le menu ---- */
.menu-legal { margin-top: 8px; font-size: 12px; }
.menu-legal a { color: rgba(255, 255, 255, 0.6); text-decoration: none; }
.menu-legal a:hover { color: var(--cyan); text-decoration: underline; }
.menu-legal span { color: rgba(255, 255, 255, 0.35); margin: 0 4px; }

.big-score { font-size: 44px; font-weight: 900; color: #fff; }
.coins-line { color: var(--gold); font-weight: 700; }

.record {
  color: #fde047;
  font-weight: 900;
  font-size: 19px;
  text-shadow: 0 0 16px rgba(253, 224, 71, 0.7);
  animation: pop 0.5s ease;
}
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---- composants ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 30px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

/* ---- écran OPTIONS : onglets JEU / SON ---- */
.options-card {
  max-width: 560px;
  max-height: 82vh;
  overflow-y: auto;
  padding: 24px 28px;
}
.opt-tabs { display: flex; gap: 8px; width: 100%; max-width: 360px; }
.opt-tab {
  flex: 1;
  padding: 9px 0;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.7);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.opt-tab.active { background: rgba(34, 211, 238, 0.16); border-color: var(--cyan); color: #fff; }
.lang-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.lang-btn {
  padding: 12px 20px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.8);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.lang-btn:hover { border-color: var(--cyan); }
.lang-btn:active { transform: scale(0.95); }
.lang-btn.active { background: rgba(34, 211, 238, 0.16); border-color: var(--cyan); color: #fff; }
.opt-panel { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.howto {
  text-align: left;
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 14.5px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.82);
  max-width: 480px;
}
.howto b { color: #fff; }

.chips { display: flex; gap: 10px; }

/* ---- couverture du menu : HÉROS vs ENNEMI ---- */
.cover {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 4px 0 2px;
}
.cover img {
  height: 210px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.55));
}
/* le héros (à gauche) regarde déjà vers la droite → vers le centre (VS) */
.cover-enemy { transform: scaleX(-1); }   /* l'ennemi (à droite) se retourne vers le héros */
.vs {
  font-size: 62px;
  font-weight: 900;
  font-style: italic;
  color: #fff;
  letter-spacing: -2px;
  margin: 0 -6px;
  -webkit-text-stroke: 3px #b91c1c;
  text-shadow: 0 0 22px rgba(239, 68, 68, 0.8), 0 4px 8px rgba(0, 0, 0, 0.6);
  transform: rotate(-8deg);
  z-index: 2;
}

.menu-secondary { display: flex; align-items: center; gap: 10px; }
.menu-stats {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 700;
}

.chip {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 16px;
  font-family: var(--font);
}

.chip.clickable { cursor: pointer; transition: border-color 0.15s; }
.chip.clickable:hover { border-color: var(--cyan); }

.btn {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 26px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); background: rgba(255, 255, 255, 0.12); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn.primary {
  background: linear-gradient(135deg, #06b6d4, #2563eb);
  border: none;
  box-shadow: 0 6px 22px rgba(6, 182, 212, 0.35);
}
.btn.primary:hover:not(:disabled) { box-shadow: 0 8px 28px rgba(6, 182, 212, 0.5); }

.btn.revive {
  background: linear-gradient(135deg, #c026d3, #7c3aed);
  border: none;
  box-shadow: 0 6px 22px rgba(192, 38, 211, 0.4);
}

.btn.ad {
  background: linear-gradient(135deg, #16a34a, #15803d);
  border: none;
  box-shadow: 0 6px 22px rgba(22, 163, 74, 0.4);
}

/* écran de pub simulée */
.ad-tag {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 4px 12px;
}
.ad-visual { font-size: 72px; animation: pop 0.5s ease; }
.ad-count { font-size: 18px; font-weight: 800; color: #fff; }
.ad-count span { color: #4ade80; }

.btn.mini { padding: 7px 14px; font-size: 12.5px; border-radius: 9px; }
.big-btn { font-size: 17px; padding: 14px 34px; }
.btn-row { display: flex; gap: 12px; }

input {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 18px;
  width: 240px;
  outline: none;
}
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18); }

/* ---- écran ASSISTANCE ---- */
.support-card { width: 380px; max-width: 92vw; }
.support-card input,
.support-card textarea {
  width: 100%;
  max-width: 320px;
  box-sizing: border-box;
}
.support-card textarea {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 16px;
  outline: none;
  resize: vertical;
  text-align: left;
  line-height: 1.4;
}
.support-card textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18); }
.support-status { font-size: 13px; font-weight: 700; min-height: 18px; text-align: center; }

/* ---- classement mondial (top 100) ---- */
/* bandeau du haut : ton rang */
.lb-me {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 420px;
  max-width: 92vw;
  padding: 10px 16px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.18), rgba(34, 211, 238, 0.05));
  border: 1px solid rgba(34, 211, 238, 0.35);
}
.lb-me.out {  /* hors du top 100 : pas de rang mondial, ton record seulement */
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--stroke);
}
.lb-me-rank {
  font-size: 24px;
  font-weight: 900;
  color: var(--cyan);
  min-width: 58px;
}
.lb-me.out .lb-me-rank { color: rgba(255, 255, 255, 0.35); }
.lb-me-txt {
  flex: 1;
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-align: left;
}
.lb-me-score { font-size: 17px; font-weight: 800; color: #fff; }

/* la liste du top 100 */
.lb-list {
  width: 420px;
  max-width: 92vw;
  max-height: 250px;
  overflow-y: auto;
  padding: 4px 6px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--stroke);
}
.lb-wait {
  margin: 14px 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13.5px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 8px;
}
.lb-row:nth-child(even) { background: rgba(255, 255, 255, 0.03); }
.lb-row.me {
  color: var(--cyan);
  background: rgba(34, 211, 238, 0.14);
  font-weight: 800;
}
.lb-rank {
  min-width: 34px;
  text-align: left;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 700;
}
.lb-row.me .lb-rank { color: var(--cyan); }
.lb-name {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-score { font-weight: 800; }

/* ---- boutique ---- */
.shop-head { display: flex; align-items: center; gap: 18px; }

#shop-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 780px;
}

.bot-card {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color 0.15s;
}
.bot-card.selected { border-color: var(--cyan); box-shadow: 0 0 18px rgba(34, 211, 238, 0.25); }

.bot-prev {
  width: 40px;
  height: 54px;
  border-radius: 10px;
  position: relative;
}
.bot-prev i {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 9px;
  height: 13px;
  background: #0b1020;
  border-radius: 5px;
}
.bot-prev i::after {
  content: "";
  position: absolute;
  right: 3px;
  top: 4px;
  width: 6px;
  height: 5px;
  background: #fff;
  border-radius: 1px;
}

/* aperçu HÉROS dans le coffre (skin 'azur') : la vraie image, pas un swatch */
.bot-prev.hero-prev {
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
}
.bot-prev.hero-prev img {
  height: 54px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.6));
}

.bot-name { color: #fff; font-size: 13px; font-weight: 800; }

/* vraie icône de patins (l'emoji 🛼 ne s'affiche pas sur Windows 10) */
.emoji-patin {
  height: 1.25em;
  width: auto;
  vertical-align: -0.3em;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}
.stock { color: var(--cyan); font-weight: 800; }

.conso-prev {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.5));
}
.conso-prev img {
  height: 52px;
  width: auto;
  object-fit: contain;
}

/* ---- bouton pause (coin haut-gauche, tactile + souris) ---- */
.pause-btn {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(10, 14, 32, 0.6);
  border: 1px solid var(--stroke);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}
.pause-btn:hover { background: rgba(20, 26, 52, 0.8); }
.pause-btn:active { transform: scale(0.92); }
/* MOBILE : pas de bouton de pause à l'écran — la pause se fait par le geste
   « retour » du téléphone (voir trapBack dans game.js) */
@media (pointer: coarse) { .pause-btn { display: none !important; } }

/* BOUTON PATINS (coin bas-droite) : activation manuelle. Visible aussi sur
   MOBILE (c'est une commande de jeu, pas une redite de la pause). */
.patin-btn {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 68px;
  height: 68px;
  border-radius: 18px;
  background: rgba(251, 146, 60, 0.22);
  border: 2px solid #fb923c;
  box-shadow: 0 4px 18px rgba(251, 146, 60, 0.35);
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  animation: patinPulse 1.1s ease-in-out infinite;
}
.patin-btn img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  pointer-events: none;
}
.patin-btn #patin-count {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: #fb923c;
  color: #1a0e02;
  font-size: 13px;
  font-weight: 900;
  line-height: 22px;
  text-align: center;
  pointer-events: none;
}
.patin-btn:active { transform: scale(0.92); }
@keyframes patinPulse {
  0%, 100% { box-shadow: 0 4px 18px rgba(251, 146, 60, 0.35); }
  50%      { box-shadow: 0 4px 26px rgba(251, 146, 60, 0.7); }
}

/* ---- coffre : tuiles de ressources ---- */
.coffre-res {
  display: flex;
  gap: 12px;
}
.res-tile {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 84px;
}
.res-emoji { font-size: 26px; }
.res-val { font-size: 22px; font-weight: 900; color: #fff; }
.res-lbl { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: rgba(255, 255, 255, 0.5); }

#coffre-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 620px;
}
