:root {
  --bg: #0a0708;
  --bg-panel: #140d0f;
  --red: #c81e33;
  --red-dark: #7a0f1c;
  --steel: #c9ccd1;
  --steel-dim: #7d8189;
  --text: #eae6e6;
  --text-dim: #a79ea0;
  --ok: #4caf50;
  --radius: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

body {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(200, 30, 51, 0.18), transparent 60%),
    var(--bg);
}

#app {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.view { display: none; }
.view.active { display: block; }

/* Le jeu occupe tout l'écran restant et n'autorise pas le scroll de page */
body.game-mode { overflow: hidden; height: 100%; }
body.game-mode #view-game.active { display: flex; flex: 1; min-height: 0; }

/* ---------- Topbar ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(20, 13, 15, 0.95), rgba(10, 7, 8, 0.9));
  border-bottom: 1px solid var(--red-dark);
  z-index: 20;
}

#brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 1.1rem;
}
#brand-logo { height: 30px; width: 30px; object-fit: contain; border-radius: 6px; }
#brand .horde { color: var(--red); }

#topbar-actions { display: flex; gap: 8px; align-items: center; }
#topbar-actions #user-name { color: var(--text-dim); font-size: 0.85rem; margin-right: 6px; }

button, .btn {
  cursor: pointer;
  border: 1px solid var(--red-dark);
  background: #1b1113;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
button:hover, .btn:hover { background: var(--red-dark); border-color: var(--red); }
button:active, .btn:active { transform: scale(0.97); }
button.primary { background: var(--red); border-color: var(--red); font-weight: 700; }
button.primary:hover { background: #e03a4f; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Stage (jeu) ---------- */
#view-game { width: 100%; }
#stage {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-root { line-height: 0; }
#game-root canvas { display: block; margin: 0 auto; box-shadow: 0 0 60px rgba(200, 30, 51, 0.25); }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  z-index: 10;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}
#hud.active { display: block; }

.bar {
  height: 14px;
  border-radius: 7px;
  background: #26161a;
  border: 1px solid #3a1c22;
  overflow: hidden;
  flex: 1;
}
.bar-fill { height: 100%; transition: width 0.15s linear; }
.bar.hp .bar-fill { background: linear-gradient(90deg, var(--red-dark), var(--red)); }
.bar.xp .bar-fill { background: linear-gradient(90deg, #2b6ea8, #57b7f2); }
.bar.big { height: 20px; border-radius: 4px; border-width: 2px; box-shadow: inset 0 0 6px rgba(0,0,0,0.6); }

/* Chrono + vague, centré en haut */
#hud-topcenter {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  text-align: center;
}
#hud-timer { font-size: 1.4rem; font-weight: 800; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.8); letter-spacing: 1px; }
#hud-wave-label { font-size: 0.78rem; color: #e8c46a; text-transform: uppercase; letter-spacing: 2px; margin-top: 2px; }

/* Compteurs + minimap, en haut à droite */
#hud-topright {
  position: absolute; top: 12px; right: 12px;
  display: flex; align-items: center; gap: 12px;
}
.counter {
  display: flex; align-items: center; gap: 5px;
  background: rgba(10,7,8,0.7); border: 1px solid #3a1c22; border-radius: 20px;
  padding: 5px 12px; font-size: 0.85rem; color: #fff; font-weight: 700;
}
.counter-icon { font-size: 0.85rem; }
.counter-icon.gold { color: #e8c46a; }
#minimap {
  position: relative; width: 74px; height: 74px; border-radius: 50%;
  background: radial-gradient(circle, #1a1012, #0a0708 80%);
  border: 2px solid var(--red-dark);
}
#minimap-player {
  position: absolute; top: 50%; left: 50%; width: 6px; height: 6px;
  background: #fff; border-radius: 50%; transform: translate(-50%, -50%);
  box-shadow: 0 0 6px 2px rgba(255,255,255,0.7);
}
.minimap-dot {
  position: absolute; width: 4px; height: 4px; background: #ff2a2a; border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* Bas d'écran : avatar + barres + compétences */
#hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 14px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 0 14px;
}
#hud-avatar { position: relative; flex-shrink: 0; }
#hud-avatar-img {
  width: 52px; height: 52px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--red); background: #1a1012; display: block;
}
#hud-level-badge {
  position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
  background: var(--red); color: #fff; font-size: 0.68rem; font-weight: 800;
  border-radius: 8px; padding: 1px 6px; border: 1px solid #fff;
}
#hud-bars { display: flex; flex-direction: column; gap: 5px; width: min(360px, 42vw); }
.hud-bar-row { display: flex; align-items: center; gap: 8px; }
.bar-value { font-size: 0.68rem; color: var(--steel); white-space: nowrap; min-width: 64px; text-align: right; }

#hud-abilities { display: flex; gap: 6px; flex-shrink: 0; }
.ability-icon {
  position: relative; width: 40px; height: 40px; border-radius: 6px;
  background: #1a1012; border: 1px solid var(--red-dark);
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.ability-level {
  position: absolute; bottom: -3px; right: -3px; background: var(--bg-panel); color: #e8c46a;
  font-size: 0.6rem; font-weight: 800; border: 1px solid var(--red-dark); border-radius: 5px; padding: 0 3px;
}

/* Panneau de montée de niveau façon parchemin doré */
.panel.ornate {
  border: 2px solid #b3862c;
  box-shadow: 0 0 40px rgba(179,134,44,0.25), inset 0 0 20px rgba(179,134,44,0.08);
}
.panel.ornate h2 { color: #e8c46a; }

/* Bouton de compétence active premium (façon MOBA : recharge en balayage radial) */
#surge-btn {
  position: absolute;
  right: 16px;
  bottom: 92px;
  width: 58px; height: 58px;
  border-radius: 50%;
  background: #1a1012;
  border: 2px solid #e8c46a;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  overflow: visible;
  padding: 0;
  box-shadow: 0 0 16px rgba(232, 196, 106, 0.35);
}
#surge-btn.hidden { display: none; }
#surge-btn:disabled,
#surge-btn.on-cooldown { cursor: default; }
.surge-icon {
  position: relative; z-index: 2; font-size: 1.5rem; color: #fff;
  text-shadow: 0 0 8px #57b7f2, 0 0 2px #000;
}
.surge-cooldown-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(rgba(0,0,0,0.82) calc(var(--pct, 0) * 360deg), transparent 0);
  z-index: 1; pointer-events: none;
  transition: background 0.1s linear;
}
.surge-label {
  position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%);
  font-size: 0.58rem; color: var(--text-dim); white-space: nowrap;
}

@media (max-width: 640px) {
  #hud-bars { width: 46vw; }
  #hud-abilities { display: none; }
  #minimap { width: 56px; height: 56px; }
  #surge-btn { right: 10px; bottom: 76px; width: 50px; height: 50px; }
  .surge-label { display: none; }
}

/* ---------- Overlays / Modales ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 3, 4, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 20px;
  overflow-y: auto;
}
.overlay.active { display: flex; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--red-dark);
  border-radius: var(--radius);
  padding: 24px 26px;
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 0 80px rgba(200, 30, 51, 0.15);
}
.panel h2 {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--red);
}
.panel p.subtitle { color: var(--text-dim); margin: 0 0 18px; font-size: 0.9rem; }

/* Classes */
#class-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 14px 0 18px;
}
.class-card {
  border: 1px solid #2b1a1e;
  background: #180f11;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.class-card:hover { border-color: var(--red); }
.class-card.selected { border-color: var(--red); background: #231417; }
.class-card h3 { margin: 0 0 2px; font-size: 1rem; }
.class-card .role { color: var(--text-dim); font-size: 0.75rem; margin-bottom: 6px; }
.class-card .desc { font-size: 0.78rem; color: var(--steel-dim); }
.stat-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.stat-pill { font-size: 0.68rem; background: #241417; border: 1px solid #3a1c22; border-radius: 20px; padding: 2px 8px; color: var(--steel); }

/* Formulaires */
.field { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.78rem; color: var(--text-dim); }
.field input {
  background: #170f11;
  border: 1px solid #3a1c22;
  border-radius: 6px;
  color: var(--text);
  padding: 9px 10px;
  font-size: 0.9rem;
}
.field input:focus { outline: none; border-color: var(--red); }
.form-error { color: var(--red); font-size: 0.8rem; min-height: 1.1em; margin-top: -4px; margin-bottom: 8px; }
.row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.switch-link { color: var(--text-dim); font-size: 0.8rem; margin-top: 10px; }
.switch-link a { color: var(--red); cursor: pointer; text-decoration: underline; }

/* Level up */
#levelup-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.upgrade-card {
  border: 1px solid #2b1a1e;
  background: #180f11;
  border-radius: 8px;
  padding: 14px 12px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s, border-color 0.15s;
}
.upgrade-card:hover { border-color: var(--red); transform: translateY(-2px); }
.upgrade-card .icon { font-size: 1.8rem; margin-bottom: 6px; }
.upgrade-card h4 { margin: 0 0 4px; font-size: 0.9rem; }
.upgrade-card p { margin: 0; font-size: 0.75rem; color: var(--steel-dim); }

/* Leaderboard */
#leaderboard-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 10px; }
#leaderboard-table th, #leaderboard-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid #241417; }
#leaderboard-table th { color: var(--text-dim); text-transform: uppercase; font-size: 0.7rem; }
#leaderboard-table td.score { color: var(--red); font-weight: 700; }

/* Boutique */
#shop-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.shop-item { display: flex; justify-content: space-between; align-items: center; border: 1px solid #2b1a1e; border-radius: 8px; padding: 12px 14px; background: #150d0f; }
.shop-item h4 { margin: 0 0 2px; }
.shop-item p { margin: 0; font-size: 0.78rem; color: var(--steel-dim); }
.shop-price { font-weight: 700; color: var(--red); margin-right: 10px; white-space: nowrap; }
.owned-tag { color: var(--ok); font-size: 0.78rem; font-weight: 700; }

/* Game over */
#gameover-stats { display: flex; justify-content: space-around; margin: 18px 0; }
#gameover-stats .stat-big { text-align: center; }
#gameover-stats .stat-big .value { font-size: 1.8rem; font-weight: 800; color: var(--red); }
#gameover-stats .stat-big .label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; }

/* Start screen */
#start-panel { text-align: center; }
#start-panel .logo-word { font-size: 2rem; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; }
#start-panel .logo-word .horde { color: var(--red); display: block; }
#start-panel .tagline { color: var(--text-dim); margin: 6px 0 20px; }

.hint { font-size: 0.75rem; color: var(--text-dim); margin-top: 14px; text-align: center; }

.link-back {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0;
  margin-bottom: 12px;
  font-size: 0.8rem;
  text-decoration: underline;
}
.link-back:hover { background: none; color: var(--red); }

/* Portrait de personnage (carte de sélection + boutique) */
.class-portrait {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
  background: radial-gradient(circle at 50% 35%, var(--portrait-color, #3a1c22), #100a0b 75%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.class-portrait img { width: 100%; height: 100%; object-fit: contain; display: block; }
.class-portrait.no-portrait::after {
  content: "";
  width: 46%;
  height: 46%;
  border-radius: 50%;
  background: var(--portrait-color, var(--red-dark));
  border: 2px solid rgba(255,255,255,0.5);
}

/* ================= LANDING PAGE ================= */
body { overflow-x: hidden; }

#hero {
  position: relative;
  min-height: 92vh;
  background-size: cover;
  background-position: center 30%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}
.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(6,3,4,0.55) 0%, rgba(6,3,4,0.75) 55%, var(--bg) 100%);
}
.hero-content { position: relative; z-index: 1; max-width: 720px; }
.hero-logo { width: min(340px, 70vw); filter: drop-shadow(0 8px 40px rgba(200,30,51,0.5)); }
.hero-slogan { font-size: 0.95rem; letter-spacing: 3px; text-transform: uppercase; color: var(--steel); margin: 18px 0 2px; }
.hero-slogan .dot { color: var(--red); }
.hero-slogan .horde { color: var(--red); font-weight: 800; }
.hero-run { font-family: Georgia, serif; font-style: italic; font-size: 1.3rem; color: #fff; margin: 4px 0 14px; text-shadow: 0 2px 12px rgba(200,30,51,0.6); }
.hero-tagline { font-size: 1.05rem; color: var(--steel); margin: 0 0 26px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
button.big { padding: 14px 26px; font-size: 1rem; border-radius: 8px; }
.hero-content .hint { margin-top: 16px; }

section { padding: 60px 24px; max-width: 1080px; margin: 0 auto; }
section h2 { text-align: center; text-transform: uppercase; letter-spacing: 1px; font-size: 1.6rem; margin-bottom: 8px; }
.section-sub { text-align: center; color: var(--text-dim); margin: 0 0 30px; }

/* Bandeau "comment jouer" (4 icônes façon poster) */
#howto { padding-top: 30px; padding-bottom: 10px; }
.howto-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.howto-card { text-align: center; }
.howto-icon {
  width: 64px; height: 64px; margin: 0 auto 10px;
  border: 2px solid var(--red);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; background: radial-gradient(circle, rgba(200,30,51,0.15), transparent 70%);
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}
.howto-card h3 { margin: 0 0 2px; font-size: 0.95rem; text-transform: uppercase; }
.howto-card p { margin: 0; font-size: 0.78rem; color: var(--text-dim); }

#pitch p { max-width: 720px; margin: 0 auto 34px; text-align: center; color: var(--steel); line-height: 1.6; }

/* Vitrine à 3 panneaux (vagues / builds / héros) */
.showcase-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.showcase-card { background: var(--bg-panel); border: 1px solid var(--red-dark); border-radius: 10px; padding: 14px; }
.showcase-caption { text-align: center; margin: 12px 0 0; font-size: 0.85rem; color: var(--steel); text-transform: uppercase; letter-spacing: 0.5px; }

.mock-arena {
  position: relative; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #241417, #0d0708 75%);
  border: 1px solid #2b1a1e;
}
.mock-lv { position: absolute; top: 8px; left: 8px; font-size: 0.65rem; font-weight: 800; color: #fff; background: rgba(0,0,0,0.5); padding: 2px 6px; border-radius: 4px; }
.mock-hpbar { position: absolute; top: 8px; left: 40px; right: 8px; height: 6px; background: #3a1c22; border-radius: 3px; overflow: hidden; }
.mock-hpbar i { display: block; width: 70%; height: 100%; background: var(--red); }
.mock-rings span { position: absolute; top: 50%; left: 50%; border: 1px solid rgba(200,30,51,0.5); border-radius: 50%; transform: translate(-50%, -50%); }
.mock-rings span:nth-child(1) { width: 40%; height: 40%; }
.mock-rings span:nth-child(2) { width: 65%; height: 65%; opacity: 0.6; }
.mock-rings span:nth-child(3) { width: 90%; height: 90%; opacity: 0.3; }
.mock-player { position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; background: #fff; border-radius: 50%; box-shadow: 0 0 12px 4px rgba(255,255,255,0.5); transform: translate(-50%, -50%); }
.mock-mob { position: absolute; width: 8px; height: 8px; background: #8b0000; border-radius: 50%; box-shadow: 0 0 5px rgba(255,42,42,0.8); }
.mock-mob.m1 { top: 8%; left: 15%; } .mock-mob.m2 { top: 12%; left: 80%; } .mock-mob.m3 { top: 85%; left: 20%; }
.mock-mob.m4 { top: 90%; left: 75%; } .mock-mob.m5 { top: 50%; left: 4%; } .mock-mob.m6 { top: 50%; left: 95%; }
.mock-mob.m7 { top: 25%; left: 50%; } .mock-mob.m8 { top: 75%; left: 45%; }

.mock-levelup { display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: 4/3; gap: 6px; }
.mock-levelup-title { color: var(--red); font-weight: 800; text-transform: uppercase; font-size: 0.9rem; }
.mock-levelup-sub { color: var(--text-dim); font-size: 0.72rem; margin-bottom: 10px; }
.mock-levelup-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.mock-levelup-choices .upgrade-card { padding: 10px 6px; cursor: default; }
.mock-levelup-choices .upgrade-card:hover { transform: none; border-color: #2b1a1e; }
.mock-levelup-choices .upgrade-card .icon { font-size: 1.3rem; margin-bottom: 4px; }
.mock-levelup-choices .upgrade-card h4 { font-size: 0.68rem; }

.mock-heroes { display: flex; gap: 6px; aspect-ratio: 4/3; }
.showcase-hero {
  flex: 1; position: relative; border-radius: 6px; overflow: hidden;
  background: radial-gradient(circle at 50% 30%, var(--portrait-color, #3a1c22), #100a0b 75%);
  display: flex; align-items: flex-end;
}
.showcase-hero img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.showcase-hero span {
  position: relative; z-index: 1; width: 100%; text-align: center; font-size: 0.6rem;
  padding: 4px 2px; background: linear-gradient(0deg, rgba(0,0,0,0.85), transparent);
  color: #fff; text-transform: uppercase; letter-spacing: 0.3px;
}
.showcase-hero.no-portrait { background: radial-gradient(circle at 50% 40%, var(--portrait-color, var(--red-dark)), #100a0b 75%); }

/* Bandeau de features façon affiche, avec rubans rouges */
#feature-bar {
  max-width: none; padding: 34px 24px; margin: 20px 0 0;
  display: flex; align-items: center; justify-content: center; gap: 24px; flex-wrap: wrap;
  background: linear-gradient(180deg, transparent, rgba(122,15,28,0.12), transparent);
  border-top: 1px solid #241417; border-bottom: 1px solid #241417;
}
#feature-bar .ribbon {
  background: var(--red); color: #fff; font-weight: 800; text-transform: uppercase;
  font-size: 0.8rem; line-height: 1.3; padding: 12px 20px; border-radius: 4px;
  text-align: center; box-shadow: 0 4px 16px rgba(200,30,51,0.35);
}
.feature-icons { display: flex; gap: 26px; flex-wrap: wrap; justify-content: center; }
.feature-icons div { text-align: center; font-size: 0.75rem; color: var(--steel); max-width: 110px; }
.feature-icons span { display: block; font-size: 1.3rem; margin-bottom: 4px; }

.class-grid-preview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.class-grid-preview .class-card { cursor: default; }
.class-grid-preview .class-card:hover { border-color: #2b1a1e; }

#cta-final { text-align: center; }
#cta-final h2 { margin-bottom: 20px; }

#site-footer { text-align: center; padding: 24px; color: var(--text-dim); font-size: 0.8rem; border-top: 1px solid #241417; }

@media (max-width: 900px) {
  .class-grid-preview, .showcase-grid, .howto-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  #class-grid, #levelup-choices { grid-template-columns: 1fr; }
  .class-grid-preview, .showcase-grid, .howto-grid { grid-template-columns: 1fr; }
  #hero { min-height: 100vh; }
  #feature-bar { flex-direction: column; }
}
