:root {
  --rouge: #e0001b;
  --rouge-fonce: #a50014;
  --noir: #14080a;
  --creme: #fff3e6;
}

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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--noir);
  color: var(--creme);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  touch-action: none;
  user-select: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  padding: env(safe-area-inset-top) 12px 0;
  pointer-events: none; z-index: 5;
}
#hud-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; font-size: clamp(16px, 4vw, 22px);
  font-weight: bold; text-shadow: 0 2px 4px #000;
}
#hp-hearts { letter-spacing: 1px; }
#timer, #kills { background: rgba(0,0,0,.35); padding: 2px 10px; border-radius: 999px; }
#xp-bar {
  position: relative; margin: 8px auto 0; max-width: 700px; height: 16px;
  background: rgba(0,0,0,.5); border: 2px solid var(--rouge);
  border-radius: 999px; overflow: hidden;
}
#xp-fill {
  position: absolute; inset: 0; width: 0%;
  background: linear-gradient(90deg, #ffd000, #ff7b00);
  transition: width .12s linear;
}
#level-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: bold; text-shadow: 0 1px 2px #000;
}

/* Loadout (armes + passifs avec niveaux) */
#loadout {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 6px auto 0; max-width: 700px;
  justify-content: flex-start;
}
.lo-item {
  display: inline-flex; align-items: center; gap: 1px;
  background: rgba(0,0,0,.4); border-radius: 8px; padding: 2px 5px;
  font-size: 16px; line-height: 1;
}
.lo-item b { font-size: 11px; color: #ffd000; }
.lo-item.lo-pass { background: rgba(224,0,27,.3); }
.lo-item.lo-pass b { color: #7df9ff; }
.lo-sep { width: 2px; align-self: stretch; background: rgba(255,255,255,.25); margin: 0 3px; border-radius: 2px; }

/* ---------- Joystick ---------- */
#joystick {
  position: fixed; width: 130px; height: 130px; z-index: 6;
  border-radius: 50%; background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.25);
  transform: translate(-50%, -50%); pointer-events: none;
}
#joystick-knob {
  position: absolute; top: 50%; left: 50%; width: 56px; height: 56px;
  border-radius: 50%; background: rgba(224,0,27,.75);
  border: 2px solid var(--creme);
  transform: translate(-50%, -50%);
}

/* ---------- Écrans ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  background: radial-gradient(circle at 50% 35%, rgba(224,0,27,.35), rgba(20,8,10,.96) 70%);
  backdrop-filter: blur(2px);
}
.screen h1 { font-size: clamp(38px, 11vw, 80px); line-height: .95; letter-spacing: 2px; }
.screen h1 .accent { color: var(--rouge); }
.screen h2 { font-size: clamp(30px, 9vw, 56px); color: var(--rouge); margin-bottom: 6px; }
.subtitle { margin: 14px 0 6px; opacity: .9; font-size: clamp(14px, 3.5vw, 18px); }
.pick { margin: 18px 0 10px; font-weight: bold; opacity: .85; }
.hint { margin-top: 16px; max-width: 460px; font-size: 13px; opacity: .65; line-height: 1.4; }
.record { margin-top: 14px; font-size: 15px; }

.big-btn {
  margin-top: 18px; padding: 14px 38px; font-size: 22px; font-weight: bold;
  color: var(--creme); background: var(--rouge); border: none; border-radius: 999px;
  cursor: pointer; box-shadow: 0 6px 0 var(--rouge-fonce); transition: transform .08s;
  font-family: inherit;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--rouge-fonce); }

/* Sélecteur de héros */
#hero-picker { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.hero-card {
  width: 96px; padding: 12px 8px; border-radius: 16px; cursor: pointer;
  background: rgba(255,255,255,.06); border: 3px solid transparent; transition: .12s;
}
.hero-card.sel { border-color: var(--rouge); background: rgba(224,0,27,.22); }
.hero-card .emoji { font-size: 40px; display: block; }
.hero-card .name { font-size: 12px; font-weight: bold; margin-top: 4px; }
.hero-card .desc { font-size: 10px; opacity: .7; margin-top: 2px; }

/* Cartes d'upgrade */
#upgrade-cards { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; max-width: 640px; }
.up-card {
  width: 150px; padding: 18px 12px; border-radius: 16px; cursor: pointer;
  background: rgba(255,255,255,.06); border: 3px solid rgba(255,255,255,.15);
  transition: .12s;
}
.up-card:active { transform: scale(.96); }
.up-card:hover { border-color: var(--rouge); background: rgba(224,0,27,.18); }
.up-card .emoji { font-size: 46px; display: block; }
.up-card .name { font-size: 15px; font-weight: bold; margin-top: 8px; }
.up-card .desc { font-size: 12px; opacity: .75; margin-top: 4px; line-height: 1.3; }
.up-card .tag { font-size: 10px; opacity: .6; margin-top: 6px; text-transform: uppercase; letter-spacing: 1px; }

#go-stats { font-size: clamp(18px, 5vw, 26px); line-height: 1.6; margin: 10px 0; }
#go-stats .big { color: var(--rouge); font-weight: bold; }
