/* Écran d'accueil : plein écran, la scène animée (héros + pouls) est dessinée sur le canvas
   derrière, dans la zone #heroStage. Disposition type « jeu mobile » : profil en haut à gauche,
   or et options en haut à droite, gros bouton JOUER sous le héros, modes sur les côtés. */
#mainMenu {
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: auto;
  overflow-y: auto;
  touch-action: pan-y;
}
/* base.css coupe tout ce qui déborde (* { overflow: hidden }) : ici on laisse respirer
   les lueurs, les badges et le titre qui bat. */
.home,
.home-top,
.home-title,
.home-title h1,
.home-side,
.home-play,
.home-dock,
button.home-tile,
.tile-text,
button.home-stage,
.home-hero-label {
  overflow: visible;
}
.home {
  display: grid;
  grid-template-columns: minmax(210px, 270px) 1fr minmax(210px, 270px);
  grid-template-rows: auto auto 1fr auto auto;
  grid-template-areas:
    "top top top"
    "title title title"
    "left stage right"
    "left play right"
    "dock dock dock";
  gap: 14px 28px;
  min-height: 100%;
  padding: max(16px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
}

/* --- Barre du haut --- */
.home-top {
  grid-area: top;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.home-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.home-level {
  flex-shrink: 0;
  width: 52px;
  height: 58px;
  display: grid;
  place-items: center;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: linear-gradient(160deg, #ffd700, #ff8a00);
  color: #1a0b00;
  font-family: "Press Start 2P";
  font-size: 15px;
  filter: drop-shadow(0 0 10px rgba(255, 200, 0, 0.6));
}
.home-id {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 210px;
  min-width: 0;
}
.home-pseudo {
  background: transparent;
  border: none;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.25);
  color: #fff;
  font-family: "Orbitron";
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 2px 0;
  width: 100%;
}
.home-pseudo:focus {
  outline: none;
  border-bottom-color: #00ffff;
}
.home-id .ac-bar-bg {
  height: 7px;
}
.home-xp {
  color: #aaa;
  font-size: 11px;
}
.home-res {
  display: flex;
  align-items: center;
  gap: 10px;
}
.home-gold {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 10px;
  border: 1px solid rgba(255, 215, 0, 0.5);
  border-radius: 999px;
  background: rgba(30, 20, 0, 0.6);
  color: #ffd700;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.2);
}
.home-gold .ico {
  font-size: 20px;
}
button.home-icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(20, 10, 35, 0.7);
  color: #ddd;
}
.home-icon-btn .ico {
  font-size: 22px;
}
/* Bouton « Se connecter » (devient « Compte » une fois connecté) */
button.home-login-btn {
  flex-shrink: 0;
  width: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 255, 136, 0.55);
  background: rgba(0, 40, 25, 0.7);
  color: #00ff88;
  font-size: 12px;
  letter-spacing: 1px;
  white-space: nowrap;
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.18);
}
.home-login-btn .ico {
  font-size: 18px;
}
button.home-login-btn.connected {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(20, 10, 35, 0.7);
  color: #ddd;
  box-shadow: none;
}

/* --- Titre --- */
.home-title {
  grid-area: title;
  text-align: center;
}
.home-title h1 {
  font-family: "Press Start 2P";
  font-size: clamp(26px, 5vw, 54px);
  color: #00ffff;
  letter-spacing: 4px;
  text-shadow:
    3px 0 0 rgba(255, 42, 109, 0.85),
    -3px 0 0 rgba(0, 120, 255, 0.6),
    0 0 24px rgba(0, 255, 255, 0.7);
  animation: heartbeat 1.1s infinite;
}
.home-tagline {
  margin-top: 10px;
  color: #ff7aa8;
  font-size: 12px;
  letter-spacing: 4px;
  text-transform: uppercase;
}
@keyframes heartbeat {
  0%,
  40%,
  100% {
    transform: scale(1);
  }
  12% {
    transform: scale(1.045);
  }
  24% {
    transform: scale(1.015);
  }
  30% {
    transform: scale(1.035);
  }
}

/* --- Zone du héros (vide : le héros est dessiné sur le canvas) --- */
button.home-stage {
  grid-area: stage;
  position: relative;
  min-height: 190px;
  width: 100%;
  padding: 0;
  background: none;
  border-radius: 20px;
}
.home-hero-label {
  position: absolute;
  left: 50%;
  top: min(calc(45% + 100px), calc(100% - 36px)); /* juste sous le héros dessiné sur le canvas */
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.home-hero-label b {
  font-size: 15px;
  letter-spacing: 3px;
  text-shadow: 0 0 10px currentColor;
}
.home-hero-label small {
  color: #999;
  font-size: 11px;
  font-weight: 400;
}
@media (hover: hover) {
  button.home-stage:hover:not(:disabled) {
    transform: none;
    filter: none;
    background: radial-gradient(closest-side, rgba(255, 255, 255, 0.05), transparent);
  }
}

/* --- Tuiles des modes --- */
.home-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}
.home-left {
  grid-area: left;
}
.home-right {
  grid-area: right;
}
button.home-tile {
  --tile: #00ccff;
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  text-align: left;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--tile) 45%, transparent);
  background: linear-gradient(
    120deg,
    color-mix(in srgb, var(--tile) 22%, transparent),
    rgba(10, 5, 20, 0.85)
  );
  box-shadow: inset 4px 0 0 var(--tile);
  color: #fff;
  z-index: 1; /* badge « ! » au-dessus des voisins */
}
.home-tile > .ico {
  font-size: 34px;
  flex-shrink: 0;
  color: var(--tile);
  filter: drop-shadow(0 0 6px var(--tile));
}
.tile-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.tile-text b {
  font-size: 15px;
  letter-spacing: 1px;
}
.tile-text small {
  color: #bbb;
  font-size: 11px;
  font-weight: 400;
  font-family: "Orbitron";
}
button.tile-daily {
  --tile: #ff2a6d;
}
button.tile-talents {
  --tile: #aa66ff;
}
button.tile-quests {
  --tile: #ffd700;
}
button.tile-shop {
  --tile: #00ff88;
}
button.tile-inv {
  --tile: #00ccff;
}
#btnShop.has-free .tile-text small,
#btnQuests.has-new .tile-text small {
  color: #00ff88;
}
#btnDaily.has-new::after,
#btnQuests.has-new::after {
  content: "!";
  position: absolute;
  top: -9px;
  right: -7px;
  width: 22px;
  height: 22px;
  line-height: 22px;
  border-radius: 50%;
  background: #ff2a6d;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 0 10px #ff2a6d;
  animation: bounceBadge 1s infinite;
}

/* --- Bouton JOUER --- */
.home-play {
  grid-area: play;
  display: flex;
  justify-content: center;
}
button.play-btn {
  width: min(100%, 380px);
  padding: 20px;
  font-size: 24px;
  letter-spacing: 4px;
  border-radius: 16px;
  color: #001018;
  background: linear-gradient(180deg, #7ffcff, #00d0ff);
  box-shadow:
    0 0 0 2px rgba(0, 255, 255, 0.35),
    0 0 30px rgba(0, 220, 255, 0.55);
  animation: playGlow 1.1s infinite;
}
.play-btn .ico {
  font-size: 24px;
  vertical-align: -3px;
}
@keyframes playGlow {
  0%,
  40%,
  100% {
    box-shadow:
      0 0 0 2px rgba(0, 255, 255, 0.35),
      0 0 30px rgba(0, 220, 255, 0.55);
  }
  12% {
    box-shadow:
      0 0 0 6px rgba(0, 255, 255, 0.25),
      0 0 45px rgba(0, 220, 255, 0.85);
  }
}

/* --- Barre du bas --- */
.home-dock {
  grid-area: dock;
  display: flex;
  justify-content: center;
  gap: 12px;
}
button.dock-btn {
  width: auto;
  padding: 11px 20px;
  font-size: 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(20, 10, 35, 0.75);
  color: #ccc;
}

.home-legal {
  grid-column: 1 / -1;
  justify-self: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 11px;
  text-decoration: none;
}
.home-legal:hover {
  color: #00ffff;
}

/* Pendant l'accueil, l'aide des touches ne doit pas gêner la barre du bas */
body[data-screen="mainMenu"] #controls {
  display: none;
}

/* --- Téléphone en portrait : une colonne --- */
@media (max-width: 760px) {
  .home {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto minmax(170px, 1fr) auto auto auto auto;
    grid-template-areas:
      "top top"
      "title title"
      "stage stage"
      "play play"
      "left right"
      "dock dock";
    gap: 12px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .home-id {
    width: auto;
    flex: 1;
  }
  .home-profile {
    flex: 1;
  }
  .home-level {
    width: 44px;
    height: 50px;
    font-size: 13px;
  }
  .home-gold {
    padding: 6px 12px 6px 8px;
    font-size: 14px;
  }
  /* Peu de place : le bouton de connexion ne garde que son icône */
  button.home-login-btn {
    width: 44px;
    padding: 0;
    justify-content: center;
  }
  #btnLoginLabel {
    display: none;
  }
  .home-login-btn .ico {
    font-size: 22px;
  }
  .home-title h1 {
    font-size: 28px;
    letter-spacing: 2px;
  }
  .home-tagline {
    font-size: 10px;
    margin-top: 6px;
  }
  .home-side {
    gap: 10px;
  }
  button.home-tile {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
  }
  .home-tile > .ico {
    font-size: 26px;
  }
  .tile-text b {
    font-size: 13px;
  }
  .tile-text small {
    font-size: 10px;
  }
  button.play-btn {
    width: 100%;
    padding: 16px;
    font-size: 20px;
  }
  .home-dock button.dock-btn {
    flex: 1;
    padding: 11px 8px;
    font-size: 12px;
  }
}

/* --- Petit téléphone en portrait (iPhone SE...) --- */
@media (max-width: 760px) and (max-height: 720px) {
  .home {
    grid-template-rows: auto auto minmax(140px, 1fr) auto auto auto auto;
    gap: 9px;
  }
  .home-title h1 {
    font-size: 22px;
  }
  .home-tagline {
    display: none;
  }
  button.home-tile {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px;
  }
  .home-tile > .ico {
    font-size: 22px;
  }
  .tile-text b {
    font-size: 11px;
  }
  button.play-btn {
    padding: 13px;
  }
}

/* --- Écran bas (téléphone en paysage) : tout plus compact --- */
@media (max-height: 520px) and (min-width: 761px) {
  .home {
    grid-template-columns: minmax(180px, 230px) 1fr minmax(180px, 230px);
    gap: 8px 18px;
  }
  .home-title h1 {
    font-size: 24px;
  }
  .home-tagline {
    display: none;
  }
  button.home-stage {
    min-height: 110px;
  }
  button.home-tile {
    padding: 10px 12px;
  }
  .home-tile > .ico {
    font-size: 26px;
  }
  button.play-btn {
    padding: 12px;
    font-size: 18px;
  }
  button.dock-btn {
    padding: 8px 16px;
  }
}
