/* ===================================================================
   FantaSanRocco — Mini-gioco «Corri San Rocco»
   Endless runner pixelato. Tema oro/notte, scoped sotto .gm-*.
   =================================================================== */

.gm-hero {
  text-align: center;
  padding: 4.5rem 1.5rem 2rem;
}
.gm-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 5.5rem);
  font-weight: 900; letter-spacing: .04em; line-height: 1;
  background: linear-gradient(120deg, #fffaee 0%, var(--gold-2) 30%, var(--gold) 55%, var(--amber) 100%);
  background-size: 250% auto;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: title-shimmer 9s linear infinite;
  margin-bottom: .6rem;
}
.gm-sub {
  font-family: var(--font-serif); font-style: italic;
  color: var(--text-2); font-size: clamp(.95rem, 2.2vw, 1.2rem);
  line-height: 1.6;
}

/* ── Cornice del gioco ──────────────────────────────────────────── */
.gm-stage-wrap {
  max-width: 760px; margin: 0 auto;
  padding: 0 1rem;
}
.gm-stage {
  position: relative;
  border-radius: 18px; overflow: hidden;
  border: 1px solid var(--border-gold);
  box-shadow: var(--shadow), 0 0 60px rgba(212,160,26,.12);
  background: #05060f;
  aspect-ratio: 3 / 2;
  max-height: 70vh; margin: 0 auto;
}
/* Niente selezione testo / menu nativo (incolla, copia…) sull'area di gioco e sui controlli */
.gm-stage, .gm-stage *, .gm-pad, .gm-pad * {
  -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.gm-canvas {
  display: block; width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* HUD punteggio/record sopra al canvas */
.gm-hud {
  position: absolute; top: 10px; left: 14px; right: 14px;
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none; z-index: 2;
  font-family: var(--font-heading); letter-spacing: .12em;
}
.gm-hud .gm-score { color: #fff; font-size: 1.1rem; font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,.8); }
.gm-hud .gm-best  { color: var(--gold-2); font-size: .78rem; font-weight: 600; text-shadow: 0 2px 8px rgba(0,0,0,.8); }

/* Overlay start / game over */
.gm-overlay {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .9rem; text-align: center; padding: 1.5rem;
  background: radial-gradient(ellipse at center, rgba(4,3,10,.55) 0%, rgba(4,3,10,.85) 100%);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  transition: opacity .3s var(--ease);
}
.gm-overlay.gm-hidden { opacity: 0; pointer-events: none; }
.gm-over-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 5vw, 2.6rem); font-weight: 900;
  color: var(--gold-2); text-shadow: 0 2px 20px rgba(0,0,0,.7);
}
.gm-over-score { color: #fff; font-family: var(--font-heading); font-size: 1.05rem; }
.gm-over-score b { color: var(--gold-2); }
.gm-hint { color: var(--text-2); font-size: .8rem; font-family: var(--font-body); }
.gm-hint kbd {
  font-family: var(--font-heading); font-size: .72rem;
  background: var(--glass); border: 1px solid var(--border-gold);
  border-radius: 6px; padding: .1rem .45rem; color: var(--text);
}
.gm-play-btn {
  margin-top: .3rem;
}

/* toast traguardi conquistati */
.gm-toast {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%) translateY(20px);
  z-index: 5; display: flex; flex-direction: column; gap: .4rem; align-items: center;
  opacity: 0; transition: opacity .35s var(--ease), transform .35s var(--spring);
  pointer-events: none; width: max-content; max-width: 90%;
}
.gm-toast.gm-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.gm-toast-item {
  display: flex; align-items: center; gap: .55rem;
  background: rgba(212,160,26,.16); border: 1px solid var(--border-gold);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-radius: 100px; padding: .4rem .9rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.gm-toast-item .ico { width: 16px; height: 16px; color: var(--gold-2); }
.gm-toast-item span { font-size: .82rem; color: #fff; font-weight: 600; }
.gm-toast-item b { color: var(--gold-2); }

/* ── Legenda bonus (con rarità) ─────────────────────────────────── */
.gm-bonus-legend {
  max-width: 760px; margin: 2.2rem auto 0; padding: 0 1rem;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: .8rem;
}
.gm-bonus {
  position: relative; display: flex; flex-direction: column; gap: .5rem;
  padding: .95rem 1rem; border-radius: 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  overflow: hidden;
}
.gm-bonus::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--bonus-col, var(--gold));
}
.gm-bonus-top { display: flex; align-items: center; gap: .55rem; }
.gm-bonus-ic {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  box-shadow: 0 0 12px var(--bonus-glow, rgba(245,200,66,.5));
}
.gm-bonus-ic.b-coin  { background: radial-gradient(circle at 35% 30%, #fff7d0, #f5c842 55%, #b8860b); }
.gm-bonus-ic.b-halo  { background: transparent; border: 3px solid #f5c842; box-shadow: 0 0 12px rgba(245,200,66,.6); }
.gm-bonus-ic.b-relic { background: linear-gradient(135deg, #e6caff, #b06bff 55%, #7a2dd6); border-radius: 4px; transform: rotate(45deg); }
.gm-bonus-ic.b-fw    { background: conic-gradient(#ff5a3c, #f5c842, #5ad1ff, #7bff9a, #ff8ad1, #ff5a3c); }
.gm-bonus-name { font-family: var(--font-heading); font-weight: 700; color: var(--text); font-size: .92rem; }
.gm-bonus-eff { color: var(--text-2); font-size: .78rem; line-height: 1.35; }
.gm-rarity {
  align-self: flex-start; font-family: var(--font-heading); font-weight: 700;
  font-size: .58rem; letter-spacing: .12em; text-transform: uppercase;
  padding: .2rem .5rem; border-radius: 100px;
  color: var(--bonus-col, var(--gold)); border: 1px solid currentColor;
  background: color-mix(in srgb, var(--bonus-col, var(--gold)) 12%, transparent);
}
.gm-bonus.r-comune     { --bonus-col: #f0b840; }
.gm-bonus.r-media      { --bonus-col: #f5c842; }
.gm-bonus.r-epica      { --bonus-col: #c98bff; --bonus-glow: rgba(190,120,255,.5); }
.gm-bonus.r-leggendaria{ --bonus-col: #ff7a3c; --bonus-glow: rgba(255,140,80,.55); }

/* ── Pannello traguardi ─────────────────────────────────────────── */
.gm-ach-subhead {
  font-family: var(--font-heading); font-weight: 700; letter-spacing: .04em;
  color: var(--gold-2); font-size: 1.05rem; margin: 2rem 0 1rem;
  display: flex; align-items: center; gap: .6rem;
}
.gm-ach-subhead::after { content: ''; flex: 1; height: 1px; background: var(--border-gold); }
.gm-ach-section { max-width: 760px; margin: 3.5rem auto 1rem; padding: 0 1.2rem; }
.gm-ach-head { text-align: center; margin-bottom: 1.8rem; }
.gm-ach-kicker { font-family: var(--font-heading); font-size: .7rem; letter-spacing: .24em; text-transform: uppercase; color: var(--gold-2); margin-bottom: .5rem; }
.gm-ach-title { font-family: var(--font-display); font-size: clamp(1.6rem, 5vw, 2.6rem); font-weight: 800; color: var(--text); }
.gm-ach-note { color: var(--text-2); font-family: var(--font-serif); font-style: italic; margin-top: .5rem; font-size: .95rem; }

.gm-ach-grid { display: grid; gap: .9rem; }
.gm-ach {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.2rem; border-radius: 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  transition: border-color .3s var(--ease), transform .3s var(--ease);
}
.gm-ach.is-done { border-color: rgba(46,204,113,.4); background: linear-gradient(120deg, rgba(46,204,113,.06), var(--bg-card)); }
.gm-ach-badge {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, rgba(243,198,75,.2), rgba(212,160,26,.04));
  border: 1px solid var(--border-gold); color: var(--gold-2);
}
.gm-ach.is-done .gm-ach-badge { background: linear-gradient(160deg, rgba(46,204,113,.22), rgba(46,204,113,.04)); border-color: rgba(46,204,113,.4); color: #43d17a; }
.gm-ach-badge .ico { width: 22px; height: 22px; }
.gm-ach-body { flex: 1; min-width: 0; }
.gm-ach-name { font-family: var(--font-heading); font-weight: 700; color: var(--text); font-size: 1rem; letter-spacing: .01em; }
.gm-ach-desc { color: var(--text-2); font-size: .82rem; margin-top: .15rem; }
.gm-ach-pts {
  flex: 0 0 auto; font-family: var(--font-heading); font-weight: 800;
  color: var(--gold-2); font-size: 1.05rem; white-space: nowrap;
}
.gm-ach.is-done .gm-ach-pts { color: #43d17a; }
.gm-ach-pts small { font-size: .62rem; opacity: .7; margin-left: 2px; }

.gm-login-note {
  text-align: center; max-width: 620px; margin: 1.5rem auto 0;
  padding: 1rem 1.2rem; border-radius: 14px;
  background: rgba(212,160,26,.08); border: 1px solid var(--border-gold);
  color: var(--text-2); font-size: .9rem;
}
.gm-login-note a { color: var(--gold-2); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .gm-title { animation: none; }
}


/* ── Controller mobile (tieni premuto per muoverti) ─────────────── */
.gm-pad { display: none; gap: 1rem; justify-content: center; margin-top: 1rem; }
.gm-pad-btn {
  flex: 1; max-width: 210px; min-height: 66px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px; cursor: pointer; color: var(--gold-2);
  background: linear-gradient(180deg, rgba(243,198,75,.16), rgba(212,160,26,.04));
  border: 1px solid var(--border-gold);
  box-shadow: 0 6px 18px rgba(0,0,0,.4), inset 0 1px 1px rgba(255,255,255,.1);
  -webkit-tap-highlight-color: transparent; touch-action: none;
  -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  transition: transform .1s var(--ease), background .2s var(--ease);
}
.gm-pad-btn .ico { width: 34px; height: 34px; }
.gm-pad-btn:active {
  transform: scale(.95);
  background: linear-gradient(180deg, rgba(243,198,75,.3), rgba(212,160,26,.08));
}

.gm-hint-touch { display: none; }
@media (pointer: coarse), (max-width: 760px) {
  .gm-pad { display: flex; }
  .gm-hint-desk { display: none; }
  .gm-hint-touch { display: inline; }
}


/* ── Messaggi stile arcade (VIA! / GAME OVER / BONUS!) ──────────── */
.gm-arcade-flash {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1.1rem, 5.2vw, 2.1rem);
  letter-spacing: .04em; text-align: center; padding: 0 1rem;
  color: #f5c842;
  text-shadow:
    3px 3px 0 #5a1a00, -1px -1px 0 #000, 1px 1px 0 #000,
    0 0 16px rgba(243,198,75,.7), 0 0 34px rgba(232,78,27,.5);
}
.gm-arcade-flash.show { animation: gm-arcade-pop 1.05s steps(60) forwards; }
@keyframes gm-arcade-pop {
  0%   { opacity: 0; transform: scale(.3) rotate(-4deg); }
  16%  { opacity: 1; transform: scale(1.22) rotate(2deg); }
  28%  { transform: scale(.96) rotate(0deg); }
  40%  { transform: scale(1.05); }
  70%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.18); }
}
@media (prefers-reduced-motion: reduce) {
  .gm-arcade-flash.show { animation: gm-arcade-fade 1s linear forwards; }
  @keyframes gm-arcade-fade { 0%{opacity:0} 12%{opacity:1} 75%{opacity:1} 100%{opacity:0} }
}

/* ===================================================================
   MENU 8-BIT — Main Menu (avvio / game over) + Pause Menu
   Bordo pixelato (border-image SVG), font Press Start 2P, oro su scuro.
   =================================================================== */
.gm-8card {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  gap: .8rem; text-align: center;
  width: min(360px, 88%);
  padding: 1.5rem 1.4rem 1.4rem;
  background: #0b0a16;
  color: #fff;
  border-style: solid; border-width: 6px;
  border-image-source: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='5'%3E%3Cpath d='M2 1h1v1H2z M1 2h1v1H1z M3 2h1v1H3z M2 3h1v1H2z' fill='%23f5c842'/%3E%3C/svg%3E");
  border-image-slice: 2; border-image-repeat: stretch;
  image-rendering: pixelated;
  box-shadow: 0 0 0 6px #0b0a16, 10px 10px 0 0 rgba(0,0,0,.5), 0 0 60px rgba(212,160,26,.18);
}
.gm-8card::after {                 /* scanline CRT */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.16) 0 2px, transparent 2px 4px);
  opacity: .55;
}

.gm-8kicker {
  font-family: 'Press Start 2P', monospace;
  font-size: .5rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold-2);
  animation: gm-blink 1.1s steps(1) infinite;
}
@keyframes gm-blink { 50% { opacity: .2; } }

.gm-8card .gm-over-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(.82rem, 3.2vw, 1.15rem); line-height: 1.55;
  font-weight: 400; color: var(--gold-2);
  text-transform: uppercase;
  text-shadow: 3px 3px 0 rgba(0,0,0,.85);
}
.gm-8card .gm-over-score {
  font-family: 'Press Start 2P', monospace;
  font-size: .5rem; line-height: 1.8; color: #d7d0e0;
}
.gm-8card .gm-over-score b { color: var(--gold-2); }
.gm-8card .gm-hint {
  font-family: 'Press Start 2P', monospace;
  font-size: .42rem; line-height: 1.8; color: var(--text-2);
}
.gm-8card .gm-hint kbd {
  font-family: inherit; background: #1a1430; color: #fff;
  padding: 1px 4px; border: 2px solid #3a2e5a;
}

.gm-8btns { display: flex; flex-direction: column; gap: .7rem; width: 100%; margin-top: .3rem; }
.gm-8btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  width: 100%;
  font-family: 'Press Start 2P', monospace;
  font-size: .6rem; letter-spacing: .03em; text-transform: uppercase;
  color: #1a1206; text-decoration: none;
  background: var(--gold);
  padding: .72rem .6rem;
  cursor: pointer;
  border-style: solid; border-width: 5px;
  border-image-source: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='5'%3E%3Cpath d='M2 1h1v1H2z M1 2h1v1H1z M3 2h1v1H3z M2 3h1v1H2z' fill='%231a1206'/%3E%3C/svg%3E");
  border-image-slice: 2; border-image-repeat: stretch;
  image-rendering: pixelated;
  filter: drop-shadow(3px 3px 0 rgba(0,0,0,.55));
  transition: background .12s steps(2), transform .06s var(--ease), filter .06s var(--ease);
}
.gm-8btn:hover { background: var(--gold-2); }
.gm-8btn:active { transform: translate(3px, 3px); filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
.gm-8btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.gm-8btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.gm-8btn-primary { background: linear-gradient(180deg, #fff2b0 0%, var(--gold-2) 45%, var(--gold) 100%); }
.gm-8btn-primary:hover { filter: drop-shadow(3px 3px 0 rgba(0,0,0,.55)) brightness(1.05); }

/* Pulsanti in alto a destra (mute + pausa): lascia spazio al "record" della HUD */
.gm-hud { right: 88px; }
.gm-pause-toggle {
  position: absolute; top: 9px; right: 50px; z-index: 4;
  width: 30px; height: 30px; padding: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(11,10,22,.9); color: var(--gold-2);
  border-style: solid; border-width: 4px;
  border-image-source: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='5'%3E%3Cpath d='M2 1h1v1H2z M1 2h1v1H1z M3 2h1v1H3z M2 3h1v1H2z' fill='%23f5c842'/%3E%3C/svg%3E");
  border-image-slice: 2; border-image-repeat: stretch;
  image-rendering: pixelated; cursor: pointer;
}
.gm-pause-toggle.is-on { display: inline-flex; }
.gm-pause-toggle:hover { background: rgba(212,160,26,.28); }
.gm-pause-toggle svg { width: 14px; height: 14px; }

/* Bottone mute della canzone del gioco — accanto alla pausa.
   z-index 2 (sotto l'overlay z-index 3): visibile solo durante il gioco,
   nascosto dietro al menu iniziale / game over / pausa. */
.gm-mute-toggle {
  position: absolute; top: 9px; right: 12px; z-index: 2;
  width: 30px; height: 30px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(11,10,22,.9); color: var(--gold-2);
  border-style: solid; border-width: 4px;
  border-image-source: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='5'%3E%3Cpath d='M2 1h1v1H2z M1 2h1v1H1z M3 2h1v1H3z M2 3h1v1H2z' fill='%23f5c842'/%3E%3C/svg%3E");
  border-image-slice: 2; border-image-repeat: stretch;
  image-rendering: pixelated; cursor: pointer;
}
.gm-mute-toggle:hover { background: rgba(212,160,26,.28); }
.gm-mute-toggle svg { width: 15px; height: 15px; }
.gm-mute-toggle .gm-ic-off { display: none; }
.gm-mute-toggle.is-muted { color: #c0554a; }
.gm-mute-toggle.is-muted .gm-ic-on { display: none; }
.gm-mute-toggle.is-muted .gm-ic-off { display: inline; }

@media (prefers-reduced-motion: reduce) {
  .gm-8kicker { animation: none; }
}

/* ── Menu 8-bit compatto su mobile (l'area di gioco è bassa: ~3/2) ── */
@media (max-width: 560px) {
  .gm-overlay { padding: .6rem; gap: .4rem; }
  .gm-8card {
    padding: .8rem .95rem; gap: .5rem; border-width: 4px;
    width: min(300px, 96%); max-height: 100%; overflow-y: auto;
  }
  .gm-8card::after { background-size: 100% 3px; }
  .gm-8kicker { font-size: .42rem; }
  .gm-8card .gm-over-title { font-size: .68rem; line-height: 1.4; text-shadow: 2px 2px 0 rgba(0,0,0,.85); }
  .gm-8card .gm-over-score { font-size: .42rem; line-height: 1.5; }
  .gm-8card .gm-hint { display: none; }            /* il comando è già scritto sotto al gioco */
  .gm-8btns { gap: .45rem; margin-top: .1rem; }
  .gm-8btn { font-size: .5rem; padding: .55rem .5rem; border-width: 4px; gap: .4rem; }
  .gm-8btn svg { width: 12px; height: 12px; }
}
