/* =========================================================
   Cube Escape — mise en page
   Le jeu vit dans un carre/rectangle centre (#stage).
   Tout le reste est de l'habillage (menus, HUD).
   ========================================================= */

/* Police du titre d'accueil — Ranchers (SIL OFL, licence dans assets/fonts/Ranchers-OFL.txt).
   font-display:swap -> le fallback s'affiche tout de suite, remplace par Ranchers une fois charge. */
@font-face {
  font-family: "Ranchers";
  src: url("assets/fonts/Ranchers-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #f2fbff;
  --ink-dim: #bfe0ec;
  --accent: #57c8e8;
  --cube-blue: #4fb2ea; /* le bleu du glaçon (meme valeur que la flaque de game over) */
  --bg: #07222e;
  --panel: rgba(10, 44, 58, 0.58);
  --title-ink: #f2fbff; /* titre d'accueil : blanc */
  --title-shadow: 56, 150, 210; /* ombre du titre : bleu ciel (au lieu de noir) — en RGB pour l'alpha */
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  /* empeche le navigateur mobile de scroller / zoomer sur les gestes du jeu */
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Scene centree, format portrait facon smartphone.
   Sur grand ecran on plafonne la largeur, sur mobile ca remplit tout. */
#stage {
  position: relative;
  width: 100vw;
  height: 100dvh;
  max-width: min(520px, calc(100dvh * 0.62));
  margin: 0 auto;
  overflow: hidden;
  background: #0a2a38;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 3; /* au-dessus de l'overlay ECLIPSE (z-index 2), sous les ecrans (5) */
  padding: max(14px, env(safe-area-inset-top)) 16px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

#score { font-size: clamp(20px, 6vw, 30px); letter-spacing: 0.5px; }
#pickup-count { margin-left: auto; font-size: clamp(15px, 4.5vw, 20px); color: var(--accent); }

#melt-wrap {
  flex: 1;
  max-width: 42%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}
#melt-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ef0ff, #4ea8ff);
  transition: width 0.12s linear, background 0.3s linear;
}
/* joker ECLIPSE actif : la jauge est GELEE -> halo givre qui pulse */
#melt-wrap.eclipse {
  animation: eclipse-pulse 1.1s ease-in-out infinite;
}
@keyframes eclipse-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(190, 224, 255, 0.45), 0 0 6px rgba(150, 200, 255, 0.45); }
  50%      { box-shadow: inset 0 0 0 1px rgba(210, 235, 255, 0.75), 0 0 15px rgba(175, 215, 255, 0.9); }
}

/* ---------- Ecrans (menu / game over) ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px;
  text-align: center;
  background: radial-gradient(120% 80% at 50% 18%, rgba(255, 214, 150, 0.16), var(--panel) 72%);
  backdrop-filter: blur(1.5px);
  z-index: 5;
}

/* L'accueil : le verre 3D est le 1er plan, l'UI se superpose par-dessus en semi-transparent */
#menu {
  justify-content: flex-end;
  gap: 13px;
  padding-bottom: max(38px, env(safe-area-inset-bottom));
  /* juste un leger voile en bas pour garder le texte lisible sur le verre */
  background: linear-gradient(to top, rgba(6, 30, 40, 0.5) 0%, rgba(6, 30, 40, 0) 28%);
  backdrop-filter: none;
}
#menu h1 {
  position: absolute;
  top: 6%;
  left: 0;
  right: 0;
  color: var(--title-ink);
  /* halo bleu ciel (glace) + petites ombres noires DERRIERE pour asseoir le texte
     (le bleu seul faisait trop luminescent) */
  text-shadow:
    0 3px 12px rgba(var(--title-shadow), 0.5),
    0 4px 0 rgba(var(--title-shadow), 0.24),
    0 1px 3px rgba(0, 0, 0, 0.42),
    0 3px 5px rgba(0, 0, 0, 0.26);
}
#menu .tagline { display: none; } /* le visuel du verre remplace le texte */

/* bouton "JOUER" : cadre au bleu du glaçon, texte blanc, gros dans le cadre, memes ombres que le titre */
#menu .btn {
  text-transform: uppercase;
  font-family: "Ranchers", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(24px, 7vw, 32px);
  padding: 9px 30px;
  background: var(--cube-blue);
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  color: var(--ink);
  /* memes caracteristiques d'ombre que le titre : halo bleu ciel + petites ombres noires derriere */
  text-shadow:
    0 3px 12px rgba(var(--title-shadow), 0.5),
    0 4px 0 rgba(var(--title-shadow), 0.24),
    0 1px 3px rgba(0, 0, 0, 0.42),
    0 3px 5px rgba(0, 0, 0, 0.26);
}
#menu .best,
#menu .controls { text-shadow: 0 2px 7px rgba(0, 0, 0, 0.75); }

h1 {
  font-family: "Ranchers", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(38px, 13vw, 68px);
  line-height: 0.92;
  letter-spacing: 3px;
  display: flex;
  flex-direction: column;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
}
h1 span { color: var(--title-ink); } /* ESCAPE : meme blanc bleute que ICE (avant : var(--accent) bleu) */

h2 {
  font-size: clamp(34px, 11vw, 58px);
  letter-spacing: 4px;
  color: #ff8fa0;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
}

.tagline { max-width: 22ch; color: var(--ink-dim); line-height: 1.5; }
.result { font-size: clamp(20px, 6vw, 28px); font-weight: 700; }
.sub { color: var(--ink-dim); font-size: 15px; }
.best { color: var(--ink-dim); font-size: 15px; }

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  letter-spacing: 1px;
  font-size: clamp(18px, 5vw, 22px);
  color: #04121e;
  background: linear-gradient(180deg, #9fe9ff, var(--accent));
  padding: 14px 40px;
  border-radius: 999px;
  box-shadow: 0 8px 0 #2f7fa8, 0 14px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #2f7fa8, 0 6px 14px rgba(0, 0, 0, 0.35); }

.controls {
  list-style: none;
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.9;
}
.controls b { color: var(--ink); }

.hidden { display: none !important; }
