/* ── Tsunami Mini Game Styles ───────────────────────────────────────── */

.mg-body {
  overflow: hidden;
  background: #0d2a4f;
}

.mg-main {
  position: fixed;
  top: var(--nav-h, 64px);
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  background: #0d2a4f;
}

#mg-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  cursor: default;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

/* ── Mobile touch zones ─────────────────────────────────────────────── */
.mg-touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}

@media (pointer: coarse) {
  .mg-touch { display: block; }
}

.mg-touch__jump,
.mg-touch__shoot {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  display: flex;
  align-items: flex-end;
  /* Ergonomia: cerchi negli ANGOLI. 20 ago (Oliver): ALZATI sopra la barra
     armi — prima coprivano la prima e l'ultima cella prodotto rendendole
     imperscelte. vmin = lato corto fisico = altezza del gioco anche in
     modalità ruotata. La zona di tocco resta l'intera metà schermo. */
  padding-bottom: clamp(48px, 26vmin - 38px, 132px);
  touch-action: none;
}

.mg-touch__jump  { left: 0;  justify-content: flex-start; padding-left:  clamp(18px, 4vw, 44px); }
.mg-touch__shoot { right: 0; justify-content: flex-end;   padding-right: clamp(18px, 4vw, 44px); }

/* Visible touch buttons — only render on coarse pointers (parent is display:none otherwise) */
.mg-touch__jump::after,
.mg-touch__shoot::after {
  width: 76px; height: 76px;
  border-radius: 50%;
  /* Molto discreti a riposo: si intuiscono senza coprire la barra potenziamenti.
     Alla pressione (sotto) tornano ben visibili → feedback chiaro. */
  background: rgba(8, 20, 50, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.13);
  box-shadow: none;
  display: flex; align-items: center; justify-content: center;
  font: 700 13px/1 -apple-system, system-ui, sans-serif;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.38);
  text-shadow: 0 1px 3px rgba(0,0,0,0.45);
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.mg-touch__jump::after  { content: 'SALTA'; }
.mg-touch__shoot::after { content: 'SPARA'; }

/* ── FRECCE MOVIMENTO (20 ago, Oliver): visibili SOLO nelle arene boss in cui
   ci si sposta con S/D — sopra i cerchi SALTA/SPARA. Design IDENTICO a
   SALTA/SPARA (stessi colori, bordo, transizione e stato attivo); l'icona
   e' un CHEVRON SVG disegnato, mai un glifo testuale (su iOS \25C0/\25B6
   venivano resi come EMOJI). ── */
.mg-touch__mleft,
.mg-touch__mright {
  position: absolute;
  width: 76px; height: 76px;
  /* 20 ago (Oliver): alzate — non devono mai lambire la testa dei cerchi
     SALTA/SPARA (a loro volta alzati sopra la barra armi) */
  bottom: calc(clamp(48px, 26vmin - 38px, 132px) + clamp(88px, 20vmin, 128px));
  touch-action: none;
  display: none;
  pointer-events: auto;
  border-radius: 50%;
  background: rgba(8, 20, 50, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.13);
  box-shadow: none;
  color: rgba(255, 255, 255, 0.38);
  z-index: 5;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.mg-touch__mleft  { left:  clamp(18px, 4vw, 44px); }
.mg-touch__mright { right: clamp(18px, 4vw, 44px); }
.mg-touch--move .mg-touch__mleft,
.mg-touch--move .mg-touch__mright { display: flex; }
.mg-touch__mleft svg,
.mg-touch__mright svg {
  pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.45));
}
/* Area di tocco ESTESA (20 ago: "più precisi"): +16px invisibili attorno */
.mg-touch__mleft::before,
.mg-touch__mright::before {
  content: '';
  position: absolute;
  inset: -16px;
  border-radius: 50%;
}
.mg-touch__mleft:active,
.mg-touch__mright:active {
  transform: scale(0.90);
  background: rgba(0, 206, 209, 0.28);
  border-color: rgba(0, 206, 209, 0.55);
  color: rgba(255, 255, 255, 0.92);
}
.mg-touch__jump:active::after,
.mg-touch__shoot:active::after {
  transform: scale(0.90);
  background: rgba(0, 206, 209, 0.28);
  border-color: rgba(0, 206, 209, 0.55);
  color: rgba(255, 255, 255, 0.92);
}


/* ── Pause button — touch only, top-right ───────────────────────────────── */
.mg-touch__pause {
  position: absolute;
  top: 6px;
  right: 8px;
  /* Stesso linguaggio glass dei pulsanti audio/fullscreen → controlli coerenti */
  background: rgba(8, 20, 50, 0.72);
  border: none;
  border-radius: 10px;
  width: 36px; height: 36px;
  color: rgba(255,255,255,0.82);
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  box-shadow: 0 2px 14px rgba(0,0,0,0.38),
              inset 0 1px 0 rgba(255,255,255,0.06),
              0 0 8px rgba(0,206,209,0.10);
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s, transform 0.10s;
}
.mg-touch__pause:active { background: rgba(0,206,209,0.25); transform: scale(0.90); }
@media (pointer: coarse) { .mg-touch__pause { display: flex; } }

/* Tap target 44px (standard iOS/Android): area di hit estesa via pseudo-elemento,
   icona e visuale invariati. In piena azione i tap mancati finivano sul canvas. */
.mg-touch__pause::before,
.mg-audio-btn::before {
  content: '';
  position: absolute;
  inset: -4px;   /* 36px + 4+4 = 44px di zona cliccabile */
}

/* ── Audio control panel ────────────────────────────────────────────────── */
.mg-audio-panel {
  position: absolute;
  right: 10px;
  top: 58px; /* overridden by JS based on BU */
  display: flex;
  flex-direction: column;
  align-items: center; /* 18 ago: gruppo SEMPRE centrato sull'asse orizzontale */
  gap: 10px; /* >= 9px: le aree di hit estese a 44px (::before) non si sovrappongono */
  z-index: 12;
  pointer-events: none; /* children re-enable */
}

.mg-audio-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
}

/* ── Audio button ───────────────────────────────────────────────────────── */
.mg-audio-btn {
  /* 18 ago: MINIMALISTI — via la casella blu, resta la sola icona con
     un'ombra morbida per staccare dal fondo; l'area di hit resta 36px. */
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.55));
  transition: transform 0.10s, color 0.18s, filter 0.18s, background 0.15s;
  position: relative;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}
.mg-audio-btn:hover { color: #FFFFFF; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.55)) drop-shadow(0 0 6px rgba(0,206,209,0.45)); }
.mg-audio-btn:active { transform: scale(0.90); }

.mg-audio-btn--on {
  color: rgba(255,255,255,0.92);
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.55)) drop-shadow(0 0 5px rgba(0,206,209,0.30));
}

.mg-audio-btn--off {
  background: transparent;
  color: rgba(255,255,255,0.30);
}

/* ── Volume popup ───────────────────────────────────────────────────────── */
.mg-vol-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scaleY(0);
  transform-origin: top center;
  width: 36px;
  padding: 8px 0 10px;
  background: rgba(8, 20, 50, 0.86);
  border: 1.5px solid rgba(0,206,209,0.28);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  box-shadow: 0 6px 22px rgba(0,0,0,0.48),
              0 0 12px rgba(0,206,209,0.14);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.30s cubic-bezier(0.34,1.56,0.64,1),
              opacity   0.22s ease;
  z-index: 20;
}

.mg-vol-popup.mg-vol-open {
  transform: translateX(-50%) scaleY(1);
  opacity: 1;
  pointer-events: auto;
}

/* ── Vertical range input ──────────────────────────────────────────────── */
.mg-vol-range {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 20px;
  height: 88px;
  cursor: pointer;
  accent-color: #F0B429;
  background: transparent;
  outline: none;
  border: none;
  padding: 0;
}
/* WebKit track + thumb */
.mg-vol-range::-webkit-slider-runnable-track {
  width: 4px;
  background: rgba(0,206,209,0.22);
  border-radius: 3px;
}
.mg-vol-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #F0B429;
  box-shadow: 0 0 6px rgba(240,180,41,0.55);
  cursor: grab;
  margin-left: -5px; /* center on track (half of thumb - half of track = (14-4)/2 = 5) */
}
.mg-vol-range::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.15); }
/* Firefox */
.mg-vol-range::-moz-range-track {
  width: 4px;
  background: rgba(0,206,209,0.22);
  border-radius: 3px;
}
.mg-vol-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #F0B429;
  border: none;
  box-shadow: 0 0 6px rgba(240,180,41,0.55);
  cursor: grab;
}

/* ── Nav game link special style ────────────────────────────────────── */
.nav__link--game {
  color: var(--wave, #0EA5C8) !important;
  font-weight: 700;
}

.nav__link--game:hover {
  color: #fff !important;
}

.nav-drawer__link--game {
  color: var(--wave, #0EA5C8) !important;
  font-weight: 700;
}

/* ── Fullscreen mobile ──────────────────────────────────────────────────
   Il pulsante condivide il design dei bottoni audio (.mg-audio-btn).
   .mg-fs        = fullscreen attivo (nativo o pseudo) → il gioco copre tutto
   .mg-fs-rotate = telefono verticale senza orientation-lock → gioco ruotato 90° */

/* Icona: expand a riposo, compress in fullscreen */
.mg-fs-ico { display: block; }
.mg-fs-ico--exit { display: none; }
.mg-fs-on .mg-fs-ico--enter { display: none; }
.mg-fs-on .mg-fs-ico--exit  { display: block; }

/* Fullscreen (nativo o pseudo): il gioco occupa l'intero schermo, sopra la nav */
.mg-fs .mg-main {
  top: 0;
  z-index: 1000;
}
/* Notch / bordi arrotondati: i controlli non finiscono sotto la curvatura
   (attivo davvero ora che la meta viewport dichiara viewport-fit=cover) */
.mg-fs .mg-touch__pause  { right: max(8px,  env(safe-area-inset-right)); }
.mg-fs .mg-audio-panel   { right: max(10px, env(safe-area-inset-right)); }
/* Home indicator iPhone: i cerchi SALTA/SPARA non finiscono sotto la barra */
.mg-fs .mg-touch__jump,
.mg-fs .mg-touch__shoot {
  padding-bottom: calc(clamp(48px, 26vmin - 38px, 132px) + env(safe-area-inset-bottom, 0px));
}

/* ── Invito fullscreen (prima partita mobile): pulse breve sul bottone ── */
@keyframes mg-fs-pulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 2px 14px rgba(0,0,0,0.38), 0 0 8px  rgba(0,206,209,0.10); }
  50%      { transform: scale(1.14); box-shadow: 0 2px 14px rgba(0,0,0,0.38), 0 0 20px rgba(0,206,209,0.70); }
}
.mg-fs-hint { animation: mg-fs-pulse 0.9s ease-in-out 3; }
@media (prefers-reduced-motion: reduce) {
  .mg-fs-hint { animation: none; }
}

/* Telefono tenuto verticale: il gioco ruota di 90° → si gioca in orizzontale.
   Dimensioni di layout scambiate (offsetWidth/Height: il motore le legge già
   in modo transform-safe); i controlli touch ruotano insieme al contenitore. */
.mg-fs-rotate .mg-main {
  top: 0; left: 0; right: auto; bottom: auto;
  width: 100vh; height: 100vw;
  width: 100dvh;
  height: 100dvw;
  transform: rotate(90deg) translateY(-100%);
  transform-origin: top left;
}

/* ── Tooltip cel sui bottoni della colonna (13 ago): appare restando col
   cursore sull'icona (~0.45s), sparisce uscendo dal bottone o cliccando
   (classe .tip-off dal JS). Solo puntatori fini: su touch non c'e' hover. ── */
@media (hover: hover) and (pointer: fine) {
  .mg-audio-btn[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%) translateX(4px);
    background: rgba(13, 33, 62, 0.96);
    border: 2px solid rgba(7, 20, 46, 0.96);
    box-shadow: 0 3px 10px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
    color: #EAF7FF;
    font-family: 'Baloo 2', 'Fredoka One', sans-serif;
    font-weight: 700;
    font-size: 12px;
    line-height: 1;
    padding: 8px 11px;
    border-radius: 9px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 50;
  }
  .mg-audio-btn[data-tip]:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    transition-delay: 0.45s;
  }
  .mg-audio-btn.tip-off::after { opacity: 0 !important; transition-delay: 0s !important; }
}


/* audit mobile 18 ago: pseudo-fullscreen iPhone in LANDSCAPE (niente FS API) */
body.mg-fs-max #mg-main {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  z-index: 9990;
  background: #061428;
}
