/* 🌍 Structure de base */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background-color: #111;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 🕹️ Conteneur de la borne arcade */
.arcade-wrapper {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  aspect-ratio: 9 / 16;
  max-height: 100vh;
  width: auto;
  overflow: hidden;
 --crt-top: 10.6%;                 /* ↓ remonte l’overlay */
  --crt-left: 13%;
  --crt-width: 75.6%;
  --crt-height: 66.9%;             /* ↑ allonge un peu pour couvrir la vitre */
}

#main-flex {
  display: flex;
  justify-content: center;
  align-items: stretch;
  width: 100vw;
  height: 100vh;
}

/* 🎮 Canvas Phaser */
#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
#game-container canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  outline: none;
  z-index: 1000;
}

.hud, #hud, #chicken, #score, .scorebar { 
  position: absolute; 
  z-index: 1;                               /* HUD en dessous de l’intro */
  pointer-events: none;
}

canvas {
  position: relative;
  z-index: 5000; /* supérieur au HUD / mp3-player */
}

/* 🖼️ Borne arcade */
.arcade-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2500;
  pointer-events: none;
}

/* 🧩 UI par-dessus (joystick etc.) */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3000;
  pointer-events: none !important;
}

/* 🕹️ Joystick */
#joystick-cage, #joystick-radius, #joystick-thumb, #joystick-stick {
  left: 70%;
  top: 84.5%;
  transform: translate(-50%, -50%);
}

#joystick-cage {
  position: absolute;
  width: 48px;
  height: 32px;
  pointer-events: none !important;
  z-index: 2;
}

#joystick-radius {
  position: absolute;
  width: 240px;
  height: 200px;
  pointer-events: none !important;
  z-index: 12;
}

#joystick-thumb {
  position: absolute;
  width: 60px;
  height: 58px;
  z-index: 14;
  pointer-events: none !important;
  filter: drop-shadow(10px 10px 10px rgba(0,0,0,0.5));
}

#joystick-stick {
  position: absolute;
  width: 16px;
  height: 120px;
  transform-origin: 50% 0%;
  z-index: 13;
  pointer-events: none !important;
  display: none;
  filter: drop-shadow(10px 10px 10px rgba(0,0,0,0.5));
}


#button-up, #button-down {
  position: absolute;
  width: 80px;
  height: 80px;
  left: 12%;
  right: auto;
  top: auto;
  bottom: 8%;
  transform: none;
  z-index: 101;
  pointer-events: auto;
  user-select: none;
  background: none;
  border: none;
  border-radius: 50%;
  touch-action: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
  filter: drop-shadow(10px 10px 10px rgba(0,0,0,0.5));

  /* outline: 2px solid red;
  background: rgba(255,0,0,0.08); */
}




/* ===== MP3 PLAYER (affichage en haut de la borne) ===== */

#mp3-player {
  position: absolute;
  top: 0.9%;
  left: 50%;
  transform: translateX(-50%);
  width: 70%;                 /* 70% de la largeur de la vitre */
  max-width: 620px;           /* garde un cap */
  z-index: 2600;              /* au-dessus du canvas, sous l’UI si besoin */
  pointer-events: none;       /* pas de boutons => pas d'interaction */
  font-family: 'Press Start 2P', monospace, Arial, sans-serif;
}

#mp3-player .player-bg {
  background: #0b0f12ee;      /* rectangle (pas d'angles arrondis) */
  border: 2px solid #00e5ff;
  border-radius: 0;           /* <= angles droits */
  padding: 10px 12px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.35), inset 0 0 0 2px #132a33;
}

#mp3-player .player-flex {
  display: grid;
  grid-template-columns: 1fr auto; /* titre qui prend la place, temps à droite */
  align-items: center;
  gap: 12px;
}

/* Conteneur du titre */
#mp3-player .mp3-title-box {
  position: relative;
  overflow: hidden;
  min-width: 0;
  pointer-events: none;
}

/* Piste qui défile (contient 2 copies pour un défilement continu) */
#mp3-player .mp3-track {
  display: inline-flex;
  white-space: nowrap;
  will-change: transform;
  animation-name: mp3-marquee;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

/* une copie de titre */
#mp3-player .mp3-title {
  color: #e6faff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.65);
  letter-spacing: 1.5px;
  line-height: 1;
  font-size: clamp(12px, 2.2vw, 18px); /* beaucoup plus lisible */
  padding-right: 4rem;                 /* espacement entre les copies */
}

/* Temps restant */
#mp3-player .mp3-time {
  color: #8ff7ff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  font-family: monospace;
  font-size: clamp(11px, 1.8vw, 17px);
  min-width: 54px;
  text-align: right;
}

/* L’anim fait défiler exactement une “demi-piste” (2 copies => boucle parfaite) */
@keyframes mp3-marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
  #mp3-player .mp3-track { animation: none; }
}



/* split animation styles */
:root {
  /* --split-angle: 28deg;
  --split-pos: 23; */
  --split-angle: 28deg;
  --split-pos: 22;
  --split-x: 2000px;
  --split-y: 2000px;
}

.startup-split {
  position: fixed;
  width: 1000px;
  height: 1000px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 9999;
}

.half {
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: url('./assets/img/benkomadfull.jpeg');
  background-size: cover;
  background-position: center;
}

.half.left {
  /* clip-path will be set dynamically by JS */
}

.half.right {
  /* clip-path will be set dynamically by JS */
}

.left.animate {
  animation: moveLeft var(--split-anim-duration, 2.5s) ease-in-out var(--split-anim-delay, 0s) forwards;
}

.right.animate {
  animation: moveRight var(--split-anim-duration, 2.5s) ease-in-out var(--split-anim-delay, 0s) forwards;
}

@keyframes moveLeft {
  to {
      transform: translate(var(--move-x), var(--move-y)) scale(10);
      opacity: 1;
  }
}

@keyframes moveRight {
  to {
      transform: translate(var(--move-x), var(--move-y)) scale(10);
      opacity: 1;
  }
}

#crt-overlay{
  position: absolute;
  top: var(--crt-top);
  left: var(--crt-left);
  width: var(--crt-width);
  height: var(--crt-height);
  z-index: 2200;             /* sous la frame (2500), au-dessus du canvas */
  display: flex;
  align-items: stretch;       /* IMPORTANT: l’enfant prend 100% en hauteur */
  justify-content: stretch;
  pointer-events: none;
  overflow: hidden;
  box-sizing: border-box;
  padding: 0;                 /* pas d’espace qui “mange” le haut */
  border-radius: 1.6vw;
}

/* Le panneau de texte remplit 100% de l’overlay */
#crt-message{
  width: 100%;
  height: 100%;               /* évite le “flottement” au milieu */
  margin: 0;
  padding: min(1.6vw, 12px);
  overflow: auto;             /* si le texte est long, on peut scroller */
  scrollbar-width: none;
  -ms-overflow-style: none;
  font-family: "Press Start 2P", monospace, Arial, sans-serif;
  font-size: clamp(13px, 1.9vw, 13px); /* plus stable */
  line-height: 1.35;
  color: #fff;
  text-shadow: 0 2px 0 #000, 0 0 12px rgba(0,229,255,.55);
  background: linear-gradient(180deg,#a83aa8 0%, #3b4ecf 100%);
  border-radius: inherit;
  position: relative;
  z-index: 1;
}
#crt-message::-webkit-scrollbar{ display:none; }

/* #crt-overlay::after{
  content:"";
  position:absolute; inset:0;
  outline:1px dashed rgba(255,0,0,.35);
  pointer-events:none;
} */

.crt-gradient{ position:absolute; inset:0; z-index:0; }
.crt-scanlines{ position:absolute; inset:0; mix-blend-mode:multiply; opacity:.45; z-index:2; }

/* Option: sur petits écrans, réduis un peu la taille */
@media (max-height: 700px){
  #crt-message{ font-size: clamp(11px, 1.6vw, 20px); }
}
.crt-off {
  animation: crt-off 0.6s cubic-bezier(.4,0,.2,1) forwards;
}

.crt-on {
  animation: crt-on 0.6s cubic-bezier(.4,0,.2,1) forwards;
}

@keyframes crt-off {
  0% { transform: scaleY(1); opacity: 1; }
  80% { transform: scaleY(0.05); opacity: 1; }
  100% { transform: scaleY(0); opacity: 0; }
}

@keyframes crt-on {
  0% { transform: scaleY(0); opacity: 0; }
  20% { transform: scaleY(0.05); opacity: 1; }
  100% { transform: scaleY(1); opacity: 1; }
}




#chicken-counter {
  position: absolute;
  left: 17%;
  bottom: 30%;
  display: flex;
  align-items: center;
  background: rgba(32,0,0,0.35);
  padding: 6px 12px;
  border-radius: 18px;
  z-index: 1800;
  font-family: 'Press Start 2P', monospace;
  font-size: 24px;
  color: #fff4c8;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.805);
}
#chicken-counter-img {
  width: 30px;
  height: 30px;
  margin-right: 12px;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.757));
}

/* cache tout HUD pendant l'écran d'intro */
.intro-active #chicken-counter,
.intro-active #hud,
.intro-active .hud {
  display: none !important;
}

#mp3-player, #hud, .arcade-overlay {
  z-index: 2000; /* plus bas que le canvas */
}


/* 🏆 Leaderboard styles */
#leaderboard-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: auto;
  min-width: unset;
  max-width: unset;
  position: relative;
  background: transparent;
  margin-left: 24px;
  border: none;
  border-radius: 0;
  z-index: 10;
  transition: opacity 0.3s, visibility 0.3s;
  opacity: 1;
  visibility: visible;
  box-shadow: none;
}

#leaderboard-crt-frame {
  position: absolute;
  left: 0;
  top: 0;
  height: 100vh;
  width: auto;
  max-width: none;
  max-height: none;
  object-fit: contain;
  transform: rotate(90deg);
  pointer-events: none;
  z-index: 1;
  display: block;
}

#leaderboard-content {
  position: relative;
  z-index: 2;
  width: 70%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 90%;
  color: #FFD700;
  font-family: 'Press Start 2P', 'VT323', 'monospace', Arial, sans-serif;
  text-shadow: 0 2px 8px #000c;
  background: transparent;
  overflow: auto;
}
