/* Le jeu remplit la fenêtre ; la barre d'aide se fait discrète en bas et revient au survol. */
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #c8c8d8;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
body {
  display: flex;
  align-items: center;
  justify-content: center;
}
#cadre { line-height: 0; }
#ecran {
  /* la taille est posée par main.js : la plus grande qui tient dans la fenêtre en 16:9 */
  width: 100vw;
  height: 56.25vw;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  outline: none;
  display: block;
}
#pied {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 6px;
  font-size: 12px;
  background: rgba(8, 8, 20, 0.8);
  opacity: 0;
  transition: opacity 0.2s;
}
#pied:hover, #pied:focus-within { opacity: 1; }
#pied button {
  font: inherit;
  color: #fff;
  background: #2a2a44;
  border: 1px solid #55557a;
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
}
#pied button:hover { background: #3a3a5c; }
#pied button:focus-visible { outline: 2px solid #ffd23f; }

/* ---------- écran tactile ---------- */
html { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
/* encoches et bords arrondis : le jeu reste dans la zone sûre (main.js lit ces marges) */
body { box-sizing: border-box; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#pied p { flex-basis: 100%; margin: 0; text-align: center; font-size: 11px; line-height: 1.4; color: #a8a8c0; }
html.tactile #pied { display: none; }

#tactile { display: none; position: fixed; inset: 0; pointer-events: none; z-index: 5;
  --k: 1; --o: 0.5; --u: calc(min(17vh, 9.5vw) * var(--k));
  --g: calc(env(safe-area-inset-left) + 1.5vw); --d: calc(env(safe-area-inset-right) + 1.5vw); --b: calc(env(safe-area-inset-bottom) + 4vh);
  font: bold calc(var(--u) * 0.19) ui-monospace, Menlo, Consolas, monospace; color: #fff; text-align: center; }
html.tactile #tactile { display: block; }
#tactile > div { position: absolute; opacity: var(--o); box-sizing: border-box; }
#t-croix { left: var(--g); bottom: var(--b); width: calc(var(--u) * 2.5); height: calc(var(--u) * 2.5); border-radius: 50%;
  background: rgba(16, 16, 24, 0.55); border: calc(var(--u) * 0.05) solid #d8d8e0; }
#t-croix div { position: absolute; font-size: calc(var(--u) * 0.42); line-height: 1; color: #d8d8e0; }
#t-fleche0 { left: 50%; top: 4%; transform: translateX(-50%); }
#t-fleche1 { left: 50%; bottom: 4%; transform: translateX(-50%); }
#t-fleche2 { left: 5%; top: 50%; transform: translateY(-50%); }
#t-fleche3 { right: 5%; top: 50%; transform: translateY(-50%); }
#t-croix #t-pouce { left: 31%; top: 31%; width: 38%; height: 38%; border-radius: 50%; background: #d8d8e0; }
.t-bouton { width: var(--u); height: var(--u); border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--c); border: calc(var(--u) * 0.06) solid #101018; color: #101018; line-height: 1.05; padding: 0 calc(var(--u) * 0.06); }
.t-bouton.tenu { filter: brightness(1.5); transform: scale(0.92); }
#t-a  { right: calc(var(--d) + var(--u) * 2.35); bottom: calc(var(--b) + var(--u) * 0.15); }
#t-b  { right: calc(var(--d) + var(--u) * 1.2);  bottom: var(--b); }
#t-c  { right: calc(var(--d) + var(--u) * 0.05); bottom: calc(var(--b) + var(--u) * 0.45); }
#t-sp { right: calc(var(--d) + var(--u) * 1.8);  bottom: calc(var(--b) + var(--u) * 1.22); }
#t-su { right: calc(var(--d) + var(--u) * 0.65); bottom: calc(var(--b) + var(--u) * 1.5); }
/* le bouton du haut : Pause sous le chrono en combat, « ← RETOUR » en haut à gauche ailleurs */
#t-haut { display: flex; align-items: center; justify-content: center; white-space: nowrap;
  background: rgba(16, 16, 24, 0.75); border: calc(var(--u) * 0.04) solid #d8d8e0; border-radius: calc(var(--u) * 0.15); }
#tactile > #t-haut { opacity: max(var(--o), 0.7); }
#t-haut.tenu { background: #3048b0; }
#tactile[data-scene="combat"] #t-haut { width: calc(var(--u) * 0.85); height: calc(var(--u) * 0.5); font-size: calc(var(--u) * 0.26);
  left: calc(var(--ex) + var(--el) / 2); top: calc(var(--ey) + var(--eh) * 0.135); transform: translateX(-50%); }
#tactile:not([data-scene="combat"]) #t-haut { height: calc(var(--u) * 0.62); padding: 0 calc(var(--u) * 0.22); font-size: calc(var(--u) * 0.24);
  left: max(var(--g), calc(var(--ex) + 4px)); top: max(calc(env(safe-area-inset-top) + 4px), calc(var(--ey) + 4px)); }
/* croix et boutons : en combat seulement */
#tactile:not([data-scene="combat"]) .t-bouton, #tactile:not([data-scene="combat"]) #t-croix { display: none; }
/* téléphone tenu debout : on demande de le tourner */
#tourner { display: none; position: fixed; inset: 0; z-index: 10; background: #0c1230; color: #ffe060;
  flex-direction: column; align-items: center; justify-content: center; gap: 28px; text-align: center;
  font: bold 20px ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; line-height: 1.4; }
#tourner i { display: block; width: 54px; height: 96px; border: 5px solid #fff; border-radius: 10px; box-shadow: 6px 6px 0 #e03838, -6px -6px 0 #3a5ad0;
  animation: tourner 2.2s ease-in-out infinite; }
#tourner small { color: #c0c8f0; font-size: 13px; font-weight: normal; }
@keyframes tourner { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) { html.tactile #tourner { display: flex; } }
@media (prefers-reduced-motion: reduce) { #tourner i { animation: none; transform: rotate(-90deg); } }
#pied a { color: #ffe060; }
