/* Puzzle Smash — Accueil (scoped .app 420px, layout flex) */

.home-screen {
  position: absolute;
  inset: 0;
  z-index: 200;
  overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.home-screen[hidden] {
  display: none !important;
}

.home-bg {
  position: absolute;
  inset: 0;
}

.home-bg-vignette,
.scene-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.05) 0%,
    transparent 38%,
    rgba(0, 0, 0, 0.12) 100%
  );
}

.home-layout {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  padding: 10px 14px 0;
  box-sizing: border-box;
}

.home-logo {
  width: 82%;
  max-width: 300px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.3));
  animation: logoSway 4.5s ease-in-out infinite alternate;
  transform-origin: top center;
  flex-shrink: 0;
  margin-top: -15px;
}

@keyframes logoSway {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(3px) rotate(0.35deg); }
}

.home-score-panel {
  position: relative;
  width: 92%;
  max-width: 300px;
  min-height: 76px;
  margin-top: 10px;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.25));
}

.home-score-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.home-score-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 76px;
  width: 100%;
  padding: 6px 10px;
  box-sizing: border-box;
}

.home-avatar-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #e0b060;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.5);
  background: #4a2e12;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s ease;
}

.home-avatar-badge:active {
  transform: scale(0.92);
}

.home-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Sprite avatar — ici et non dans game.css, qui n'est chargé qu'au premier
   passage en jeu : l'avatar est un élément d'accueil, il doit être peint dès le
   départ. L'atlas est dans HOME_IMAGES pour que le loader l'attende. */
.avatar-sprite {
  background-image: url("assets/atlas/gameplay/avatars-atlas.png") !important;
  background-size: 300% 200% !important;
  background-repeat: no-repeat !important;
}

.avatar-0 { background-position: 0% 0%; }
.avatar-1 { background-position: 50% 0%; }
.avatar-2 { background-position: 100% 0%; }
.avatar-3 { background-position: 0% 100%; }
.avatar-4 { background-position: 50% 100%; }
.avatar-5 { background-position: 100% 100%; }

.home-score-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1 1 0;
  min-width: 0;
}

.home-score-label {
  font-size: var(--text-label);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #5c3d1e;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  white-space: nowrap;
}

.home-score-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: var(--text-hud-value);
  font-weight: 900;
  color: #3d2812;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
  font-variant-numeric: tabular-nums;
  max-width: 100%;
}

.home-score-value > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-coin-icon,
.home-medal-icon {
  width: 17px;
  height: 17px;
  object-fit: contain;
  flex-shrink: 0;
}

.home-play-area {
  width: 74%;
  max-width: 280px;
  position: relative;
  top: -20px;
  z-index:-1;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35));
  animation: hangingBounce 3.2s ease-in-out infinite alternate;
  transform-origin: top center;
  flex-shrink: 0;
}

@keyframes hangingBounce {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(5px) rotate(0.4deg); }
  100% { transform: translateY(-2px) rotate(-0.4deg); }
}

.home-play-area:hover {
  animation-play-state: paused;
  transform: scale(1.02);
}

.home-play-area:active {
  animation-play-state: paused;
  transform: scale(0.96);
}

.home-play-framed-img {
  width: 100%;
  height: auto;
  display: block;
}

.home-spacer {
  flex: 1 1 auto;
  min-height: 8px;
}

.home-nav-wrap {
  width: 88%;
  max-width: 320px;
  margin-bottom: 22vh;
  flex-shrink: 0;
  position: relative;
  z-index: 4;
}

.home-nav-line {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 3px;
  background: #7a6344;
  border-bottom: 1px solid #c4b18c;
  transform: translateY(-50%);
  opacity: 0.75;
}

.home-nav {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  justify-items: center;
}

.home-nav-btn {
  width: clamp(42px, 10.5vw, 52px);
  height: clamp(42px, 10.5vw, 52px);
  border: none;
  background-color: transparent;
  padding: 0;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.home-nav-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gift-badge-notify {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  background: #e74c3c;
  border: 2px solid #fff8ee;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: pulseBadge 1.8s ease-in-out infinite;
  display: none;
}

.home-nav-btn.has-notification .gift-badge-notify {
  display: block;
}

@keyframes pulseBadge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

.home-nav-btn:active {
  transform: scale(0.92);
}

.home-fg {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.home-block-pile {
  position: absolute;
  left: 50%;
  bottom: -100px;
  transform: translateX(-50%);
  width: 94%;
  max-width: 340px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
}

.home-leaves-left,
.home-leaves-right {
  position: absolute;
  bottom: 0;
  width: 32%;
  max-height: 24vh;
  object-fit: contain;
  object-position: bottom;
  z-index: 4;
}

.home-leaves-left { left: -1%; }
.home-leaves-right { right: -2%; }

/* #overlaySettings et #overlayShop sont des enfants directs de .app (même niveau que #overlayHome) :
   les boutons de l'accueil ouvrent ces modales, elles doivent rester
   visibles même quand home-active masque le reste (HUD, plateau, etc.). */
body.home-active .app > :not(#overlayHome, #overlaySettings, #overlayRateUs, #overlayAvatar, #overlayDailyBonus, #overlayShop, #overlayAuth) {
  visibility: hidden;
}

body.home-active #overlayHome {
  visibility: visible;
}

@media (max-height: 700px) {
  .home-logo { width: 76%; }
  .home-play-area { width: 68%; margin-top: 6px; }
  .home-nav-wrap { margin-bottom: 18vh; }
}

/* —— Boot / chargement initial —— */
.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  /* Teintes relevées sur l'accueil TEL QU'AFFICHÉ (capture du fond seul), pas sur
     forest-bg.png : le rendu passe par saturate(1.08) brightness(1.03), une
     vignette et un calque de teinte, donc les couleurs du fichier ne sont pas
     celles de l'écran. Le haut doit rester une canopée sombre (#416e26) — avec une
     brume claire en haut, les vignes du logo pendaient dans le vide. On garde un
     dégradé plutôt que l'image : même compressée elle pèse 780 Ko, or cet écran
     doit peindre au premier frame. */
  background: linear-gradient(
    180deg,
    #416e26 0%,
    #78a649 9%,
    #74b0ab 27%,
    #8cc3b1 41%,
    #5f9c64 57%,
    #3c681c 74%,
    #244e15 100%
  );
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: #fff;
  text-align: center;
  padding: 24px;
}

body.boot-active .boot-loader {
  display: flex;
}

body.boot-active .app {
  visibility: hidden;
}

/* Démo : accueil visible tout de suite, pas d'écran boot dans la vidéo. */
html.demo-mode body.boot-active .boot-loader {
  display: none !important;
}

html.demo-mode body.boot-active .app {
  visibility: visible;
}

/* Même vignette que l'accueil : creuse un peu le dégradé plat. */
.boot-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.05) 0%,
    transparent 38%,
    rgba(0, 0, 0, 0.12) 100%
  );
}

/* Plus petit que .home-logo (82% / 300px) : ici le logo est seul et centré, donc
   à taille égale il écrase l'écran, alors que sur l'accueil il est équilibré par
   le panneau, le bouton et la nav. width/height sont sur la balise : pas de
   reflow quand l'image arrive. */
.boot-logo {
  position: relative;
  width: 66%;
  max-width: 240px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.3));
  animation: logoSway 4.5s ease-in-out infinite alternate;
  transform-origin: top center;
  flex-shrink: 0;
}

.boot-bar {
  width: min(240px, 70vw);
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.boot-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffeaa7, #fdcb6e);
  transition: width 0.25s ease;
}

.boot-label {
  margin: 0;
  font-size: var(--text-body);
  font-weight: 700;
  opacity: 0.92;
}

.home-play-area.is-loading {
  pointer-events: none;
  opacity: 0.65;
  filter: grayscale(0.2);
}

.home-play-area.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: bootSpin 0.8s linear infinite;
}

@keyframes bootSpin {
  to { transform: rotate(360deg); }
}

/* Auth Gate Parchment Overlay */
#overlayAuth {
  z-index: 10000;
  background: rgba(15, 23, 42, 0.65);
}
body.auth-active #overlayHome {
  visibility: hidden !important;
  display: none !important;
}
.overlay-card.auth-card {
  width: min(90%, 330px);
  margin: 0 auto;
  text-align: center;
  padding: 28px 22px !important;
  background: linear-gradient(180deg, #fdf6e2 0%, #f7e6c4 100%) !important;
  border: 3px solid #5c3e23 !important;
  border-radius: 20px !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55) !important;
  border-image-source: none !important;
}
.auth-title {
  font-size: var(--text-title);
  font-weight: 800;
  color: #3b2314;
  margin: 0 0 12px 0;
}
.auth-subtitle {
  font-size: var(--text-body);
  font-weight: 600;
  color: #5c3e23;
  margin: 0 0 16px 0;
}
.auth-desc {
  font-size: var(--text-body);
  color: #6b4f38;
  margin: 0 0 10px 0;
}
.auth-hint {
  font-size: var(--text-meta);
  line-height: 1.4;
  color: #8a664c;
  margin: 0 0 18px 0;
}
.btn-google {
  background: #ffffff !important;
  border-image-source: none !important;
  border: 2px solid #5c3e23 !important;
  border-radius: 999px !important;
  color: #202124 !important;
  text-shadow: none !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18) !important;
  height: 48px !important;
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  font-size: var(--text-btn);
  background: #f8f9fa !important;
}
.btn-google:active {
  transform: scale(0.97);
}
.google-icon {
  flex-shrink: 0;
}
.auth-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(59, 35, 20, 0.2);
  border-top-color: #3b2314;
  border-radius: 50%;
  animation: bootSpin 0.8s linear infinite;
  margin: 12px auto;
}
.auth-badge-wait {
  display: inline-block;
  padding: 4px 12px;
  background: #fff3cd;
  color: #856404;
  border-radius: 12px;
  font-size: var(--text-caption);
  font-weight: 700;
  margin-bottom: 12px;
}
