/* Commandes tactiles (ui/touch-controls.js) : joystick à gauche, boutons à droite. body.touch = appareil tactile. */
#scene { touch-action: none; -webkit-touch-callout: none; }
html, body { touch-action: pan-x pan-y; -webkit-tap-highlight-color: transparent; } /* pas de zoom de la page au pincer */

body.touch #help { display: none; }
/* Invite d'interaction : on la touche (pas de touche E sur un téléphone). */
body.touch .prompt { pointer-events: auto; cursor: pointer; touch-action: none; }
body.touch .prompt kbd { display: none; }
body.touch .prompt::before {
  content: ''; width: 22px; height: 22px; flex: none; background: var(--cyan);
  -webkit-mask: var(--tc-hand) center / contain no-repeat; mask: var(--tc-hand) center / contain no-repeat;
}
:root {
  --tc-hand: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 11V5.5a1.5 1.5 0 0 1 3 0V10m0-1.5V4.5a1.5 1.5 0 0 1 3 0V10m0-3.5a1.5 1.5 0 0 1 3 0v7.5a7 7 0 0 1-7 7h-.6a6 6 0 0 1-4.6-2.2L3.6 15a1.6 1.6 0 0 1 2.4-2.1L9 15.5'/%3E%3C/svg%3E");
}
body.touch .hud-gear { touch-action: manipulation; -webkit-touch-callout: none; } /* micro maintenu : pas de menu */
@media (hover: none) {
  .hud-gear:hover { background: var(--panel); transform: none; }
}

.tc-layer { position: absolute; inset: 0; pointer-events: none; -webkit-user-select: none; user-select: none; }

/* Joystick : au repos, une base pâle en bas à gauche ; le pouce posé, elle vient sous lui. */
.tc-stick {
  position: absolute; left: 104px; top: calc(100% - 104px);
  width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%;
  border: 2px solid var(--line);
  background: radial-gradient(circle, rgba(56, 232, 255, 0.04), rgba(8, 14, 34, 0.45) 70%);
  opacity: 0.45; transition: opacity 0.2s, border-color 0.2s;
}
.tc-stick.held { opacity: 1; transition: none; }
.tc-knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(223, 246, 255, 0.55), rgba(56, 232, 255, 0.35) 60%, rgba(56, 232, 255, 0.15));
  border: 2px solid var(--cyan); box-shadow: 0 0 16px rgba(56, 232, 255, 0.45);
}
.tc-stick.run { border-color: var(--amber); box-shadow: 0 0 22px rgba(255, 176, 46, 0.35); }
.tc-stick.run .tc-knob { border-color: var(--amber); box-shadow: 0 0 18px rgba(255, 176, 46, 0.6); }

/* Boutons : Sauter dans le coin, Interagir à sa gauche, raccourcis au-dessus. */
.tc-btn {
  pointer-events: auto; touch-action: none; -webkit-touch-callout: none;
  display: grid; place-items: center; padding: 0; border-radius: 50%;
  color: var(--cyan); background: var(--panel); border: 1.5px solid var(--line);
  backdrop-filter: blur(6px); box-shadow: 0 0 18px rgba(56, 232, 255, 0.15);
  transition: transform 0.08s, background 0.15s, opacity 0.2s;
}
.tc-btn svg { width: 46%; height: 46%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tc-btn.on { transform: scale(0.92); background: rgba(56, 232, 255, 0.28); }

.tc-pad { position: absolute; right: 22px; bottom: 22px; display: flex; align-items: flex-end; gap: 16px; }
.tc-jump { width: 80px; height: 80px; }
.tc-act { width: 66px; height: 66px; margin-bottom: 26px; }
.tc-act:disabled { opacity: 0.3; }
.tc-act.ready { color: #04121a; background: linear-gradient(135deg, var(--cyan), #7ff3ff); border-color: transparent; animation: tc-ready 1.6s ease-in-out infinite; }
.tc-act.ready.on { background: #fff; }
@keyframes tc-ready { 50% { box-shadow: 0 0 34px rgba(56, 232, 255, 0.75); } }

.tc-side { position: absolute; right: 22px; bottom: 120px; display: flex; flex-direction: row-reverse; gap: 10px; }
.tc-mini { width: 46px; height: 46px; }
.tc-mini svg { width: 50%; height: 50%; }
.tc-relic i { font-style: normal; font-size: 22px; line-height: 1; }

/* Téléphone à l'horizontale : peu de hauteur, tout se resserre. */
@media (max-height: 430px) {
  .tc-stick { left: 92px; top: calc(100% - 92px); }
  .tc-pad { right: 16px; bottom: 14px; gap: 12px; }
  .tc-jump { width: 72px; height: 72px; }
  .tc-act { width: 60px; height: 60px; margin-bottom: 22px; }
  .tc-side { right: 16px; bottom: 100px; }
  .tc-mini { width: 42px; height: 42px; }
  body.touch .prompt { bottom: 30%; }
}
@media (prefers-reduced-motion: reduce) { .tc-act.ready { animation: none; } }

/* Téléphone (vertical ou horizontal) : bandeau du haut resserré, il ne doit pas manger la vue (demande du
   propriétaire, 17/10) : carte du joueur, lieu (sans le secteur), boutons plus petits, tout à 8 px des bords. */
@media (max-width: 520px), (max-height: 430px) {
  .hud-card { padding: 5px 9px; border-radius: 8px; }
  .hud-player { top: 8px; left: 8px; gap: 7px; }
  .hud-avatar { width: 26px; height: 26px; border-width: 1.5px; }
  .hud-name { font-size: 12px; letter-spacing: 0.04em; }
  .hud-stats { gap: 8px; font-size: 11px; letter-spacing: 0.04em; }
  .hud-ox { gap: 3px; }
  .hud-ox b { font-size: 11px; }
  .ox-coin { width: 12px; height: 12px; font-size: 8px; }
  .hud-xp { height: 3px; margin-top: 3px; }
  .hud-right { top: 8px; right: 8px; gap: 6px; }
  .hud-gear { width: 34px; height: 34px; padding: 7px; border-radius: 8px; }
  .hud-loc-name { font-size: 10px; letter-spacing: 0.08em; }
  .hud-loc-sub { font-size: 0; letter-spacing: 0.04em; } /* sans les « · » : on n'y garde que joueurs en ligne et heure */
  .hud-loc-sub span { font-size: 10px; }
  #hud-loc-sector { display: none; }
  #hud-clock::before { content: ' · '; }
  .fps { top: 8px; font-size: 10px; padding: 3px 7px; }
  .hud-fx { top: 52px; left: 8px; max-width: calc(100vw - 16px); }
  #toasts { top: 64px; gap: 6px; }
  .toast { padding: 6px 12px; font-size: 14px; }
  #toasts .toast:nth-last-child(n + 3) { display: none; }
}
/* Téléphone à la verticale : l'invite au-dessus des raccourcis. Bandeau du haut (29/10, relevé par le bot : à 390 px, le
   solde passait sous le bouton de l'inventaire) : six boutons de 32 px (212 px en tout), la carte du joueur garde la place
   qui reste (8 + 212 + 8 + 6 px d'écart), le solde sans « OX » (la pièce le dit), le pseudo coupé par « … » s'il est
   trop long, et en dernier recours le solde passe sous le niveau. */
@media (max-width: 520px) {
  body.touch .prompt { bottom: 196px; max-width: calc(100vw - 32px); }
  .hud-right { gap: 4px; }
  .hud-gear { width: 32px; height: 32px; padding: 6.5px; }
  .hud-player { max-width: calc(100vw - 234px); }
  .hud-player > div { min-width: 0; }
  .hud-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hud-stats { flex-wrap: wrap; row-gap: 0; }
  .hud-ox-unit { display: none; }
}
/* Très petit téléphone (360 px) : la pastille de l'avatar laisse sa place au pseudo et au solde. */
@media (max-width: 374px) {
  .hud-avatar { display: none; }
}
