/* Page du jeu. Couleurs de l'interface du jeu (UiPalette) : titre jaune, bouton orange, fond sombre.
   Le fond --bg est aussi celui du manifeste (background_color, theme_color) et de la balise theme-color. */
:root {
  --bg: #121419;
  --bg-glow: #1b2e21;
  --text: #f7f7fa;
  --muted: #b8bfcc;
  --accent: #ffc74d;
  --primary: #f59929;
  --primary-text: #1f1205;
}

html, body { height: 100% }
body { padding: 0; margin: 0; background: var(--bg); color: var(--text); overflow: hidden; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif }
[hidden] { display: none !important }

#unity-container { position: absolute }
#unity-container.unity-desktop { left: 50%; top: 50%; transform: translate(-50%, -50%) }
#unity-container.unity-mobile { position: fixed; width: 100%; height: 100% }
#unity-canvas { background: var(--bg) }
/* Commandes tactiles du jeu (stick virtuel, caméra, boutons, plusieurs doigts) : le navigateur ne fait ni défiler, ni zoomer, ni sélectionner, ni ouvrir de menu sur le canevas. */
#unity-canvas { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent }
.unity-mobile #unity-canvas { width: 100%; height: 100% }

/* Écrans de chargement et d'échec, par-dessus le canevas. La carte se centre par ses marges
   automatiques : sur un écran trop bas (téléphone en paysage), l'écran défile au lieu de couper. */
.screen {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 10;
  display: flex; overflow-y: auto; box-sizing: border-box; padding: 16px;
  background: radial-gradient(ellipse at 50% 38%, var(--bg-glow) 0%, var(--bg) 68%);
  -webkit-user-select: none; user-select: none;
  transition: opacity 0.35s ease;
}
.screen.is-done { opacity: 0; pointer-events: none }
.screen-card { margin: auto; width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: clamp(8px, 2.4vmin, 16px); text-align: center }
.screen-icon { width: clamp(56px, 20vmin, 132px); height: auto; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.45)) }
.screen-title { margin: 0; font-size: clamp(28px, 8vmin, 56px); line-height: 1.05; font-weight: 800; letter-spacing: 0.01em; color: var(--accent); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35) }

.loading-bar { width: min(360px, 72vw); height: 14px; margin-top: 4px; border-radius: 7px; background: rgba(255, 255, 255, 0.12); overflow: hidden }
.loading-bar-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 0.25s ease-out }
.is-starting .loading-bar-fill { animation: starting-pulse 1.2s ease-in-out infinite }
@keyframes starting-pulse { 50% { opacity: 0.5 } }
.loading-label { margin: 0; min-height: 1.3em; font-size: clamp(15px, 3.6vmin, 20px); color: var(--muted); font-variant-numeric: tabular-nums }

.failure-message { margin: 0; font-size: clamp(18px, 4.6vmin, 26px); font-weight: 700; color: var(--text) }
.failure-hint { margin: 0; font-size: clamp(15px, 3.6vmin, 19px); color: var(--muted) }
.reload-button {
  margin-top: 4px; min-height: 48px; padding: 12px 36px; border: 0; border-radius: 12px;
  font: inherit; font-size: clamp(17px, 4vmin, 21px); font-weight: 700;
  color: var(--primary-text); background: var(--primary); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.reload-button:hover { filter: brightness(1.08) }
.reload-button:active { transform: translateY(1px) }
.reload-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px }
.failure-detail { margin: 2px 0 0; max-width: 100%; font-size: 12px; color: rgba(184, 191, 204, 0.7); overflow-wrap: anywhere; -webkit-user-select: text; user-select: text }
.failure-detail:empty { display: none }

/* Avertissements passagers de Unity (5 s). */
#unity-warning { position: fixed; left: 50%; top: 12px; z-index: 30; transform: translateX(-50%); max-width: calc(100% - 32px); display: none }
.banner { margin-bottom: 6px; padding: 10px 14px; border-left: 4px solid var(--muted); border-radius: 10px; background: rgba(18, 20, 25, 0.94); color: var(--text); font-size: 14px }
.banner-warning { border-left-color: var(--accent) }

/* « Tourne ton téléphone », en CSS pur. Seulement si tout est vrai : écran plus haut que large,
   doigt comme pointeur principal et pas de survol (ni PC, ni souris), fenêtre et écran de moins
   de 600 px de large en portrait (seuil des tablettes d'Android ; un iPad fait au moins 744 px,
   même en fenêtre partagée, puisque device-width est la taille de l'écran). Disparaît dès le
   passage en paysage. Un navigateur qui ignorerait l'une de ces conditions n'affiche rien. */
#rotate-hint { display: none }
@media (orientation: portrait) and (hover: none) and (pointer: coarse) and (max-width: 599px) and (max-device-width: 599px) {
  #rotate-hint {
    position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 50;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    box-sizing: border-box; padding: 24px; text-align: center;
    background: radial-gradient(ellipse at 50% 42%, var(--bg-glow) 0%, var(--bg) 70%);
    -webkit-user-select: none; user-select: none;
  }
}
.rotate-phone { position: relative; box-sizing: border-box; width: 48px; height: 82px; margin-bottom: 18px; border: 4px solid var(--text); border-radius: 11px; animation: rotate-phone 2.6s ease-in-out infinite }
.rotate-phone::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 14px; height: 4px; margin-left: -7px; border-radius: 2px; background: currentColor }
@keyframes rotate-phone {
  0%, 25% { transform: rotate(0deg); border-color: var(--text); color: var(--text) }
  50%, 80% { transform: rotate(-90deg); border-color: var(--accent); color: var(--accent) }
  100% { transform: rotate(0deg); border-color: var(--text); color: var(--text) }
}
@media (prefers-reduced-motion: reduce) {
  .rotate-phone { animation: none; transform: rotate(-90deg); border-color: var(--accent); color: var(--accent) }
  .screen, .loading-bar-fill { transition: none }
  .is-starting .loading-bar-fill { animation: none }
}
.rotate-title { margin: 0; font-size: 26px; font-weight: 800; color: var(--accent) }
.rotate-text { margin: 0; font-size: 17px; color: var(--muted) }
