/* Couleur de fond aussi sur <html> : c'est elle qui apparaît sous la barre d'état */
html {
  background: #1c4fb5;
}

body {
  margin: 0;
  min-height: 100vh;
  box-sizing: border-box;
  /* Laisse la place à l'encoche et à la barre du bas de l'iPhone */
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  color: #fff;
  font-family: -apple-system, sans-serif;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  /* Pas de zoom, pas de scroll, pas de sélection : le doigt sert au jeu */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

/* Décor plein écran, derrière le jeu */
#scenery {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Level en haut à gauche, lignes en haut à droite */
#hud {
  position: absolute;
  top: env(safe-area-inset-top);
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  pointer-events: none;
}
.hud-item.right { text-align: right; }
#hud .label { font-size: 14px; margin-bottom: 2px; }
#hud .value { font-size: 28px; }

/* Le plateau seul est centré ; les panneaux dépassent à droite */
#game {
  position: relative; /* passe devant le décor */
  margin-top: 150px;  /* place pour les collines (144px) + un petit espace sous l'encoche */
}

/* Cadre du plateau : bord bleu arrondi, intérieur violet */
#frame {
  position: relative;
  z-index: 1; /* passe au-dessus des panneaux */
  padding: 12px;
  border-radius: 0 0 26px 26px; /* le haut, ce sont les collines */
  /* violet en haut (raccord avec les collines), bleu en bas */
  background: linear-gradient(#3e1366 0%, #37207a 45%, #1f4aa8 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#board {
  display: block;
  border-radius: 0 0 14px 14px;
  background: linear-gradient(#3e1366, #2a1f74);
}

/* Collines posées sur le plateau : recouvrent le bord haut du cadre */
#hills {
  position: absolute;
  left: 0;
  bottom: calc(100% - 12px);
  width: 100%;
  height: auto;
  aspect-ratio: 782 / 416;
  pointer-events: none;
}

#hold, #next {
  display: block;
  margin: 0 auto;
}

/* Colonnes de panneaux, glissées sous les bords du cadre */
.side {
  position: absolute;
  top: 30px; /* remonté d'environ 1,5 ligne du plateau */
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.side.right {
  left: 100%;
  margin-left: -14px;
}
.side.left {
  right: 100%;
  margin-right: -14px;
}

.panel {
  width: 44px;
  padding: 8px 0 8px 14px;
  border-radius: 0 14px 14px 0;
  text-align: center;
  background: linear-gradient(#10d6c2, #0aa3b8);
}
.side.left .panel {
  padding: 8px 14px 8px 0;
  border-radius: 14px 0 0 14px;
}
.panel.hold {
  background: #e5004f;
}

.label { font-size: 11px; margin-bottom: 6px; }
.value { font-size: 24px; }

/* Boutons ronds sous le plateau, toujours centrés (un seul ou deux côte à côte) */
#controls {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 10px;
}

#controls button {
  width: 54px;
  height: 54px;
  padding: 0;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
#controls button[hidden] { display: none; }
#controls svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

/* Une seule icône à la fois : Play, ou Pause pendant la partie */
#playBtn .icon-pause { display: none; }
#playBtn.playing .icon-play { display: none; }
#playBtn.playing .icon-pause { display: block; }

/* Hold : tout le panneau est un bouton */
.panel.hold {
  cursor: pointer;
  transition: transform 0.08s, filter 0.08s;
}
.panel.hold:active,
.panel.hold.pressed {
  transform: scale(0.94);
  filter: brightness(1.15);
}

/* ===== Menu d'accueil : au centre du plateau ===== */
#menu {
  position: absolute;
  inset: 12px; /* recouvre exactement le canvas */
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-radius: 0 0 14px 14px;
  background: rgba(30, 10, 70, 0.45);
}
#menu[hidden] { display: none; }

#menu button {
  border: none;
  padding: 0;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.menu-heading { font-size: 32px; text-align: center; }
.menu-sub { font-size: 13px; text-align: center; opacity: 0.8; margin-top: 2px; }

/* Gros bouton Play, pilule rose */
.menu-play {
  width: 150px;
  height: 52px;
  border-radius: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 20px !important;
  background: linear-gradient(#ff2f73, #e5004f);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.08s;
}
.menu-play svg { width: 22px; height: 22px; fill: #fff; }
.menu-play:active { transform: scale(0.95); }

/* Encadrés Level / Best, même style que les panneaux */
.menu-box {
  width: 150px;
  box-sizing: border-box;
  padding: 10px 0;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.menu-box.level-pick { background: linear-gradient(#10d6c2, #0aa3b8); }
.menu-box.best {
  background: rgba(255, 255, 255, 0.15);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.menu-box .unit { font-size: 11px; opacity: 0.8; }

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}
.stepper button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.25);
  transition: transform 0.08s;
}
.stepper button:active { transform: scale(0.9); }
.stepper button:disabled { opacity: 0.35; }
.stepper svg { width: 16px; height: 16px; fill: #fff; }
