/* ================================================================
 *  KyntroxGames — Stili giochi giroscopio
 *  Mobile-first, dark theme, responsive, animazioni fluide.
 * ================================================================ */

/* ---- Arena di gioco ---- */
.game-arena {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: #111;
  z-index: 1000;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- HUD (Head-Up Display) ---- */
.game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1010;
  pointer-events: none;
  padding: env(safe-area-inset-top, 8px) 12px 0;
}

.game-hud-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  pointer-events: auto;
}

.game-pill {
  background: rgba(255,255,255,0.1);
  border: 0.5px solid rgba(255,255,255,0.15);
  color: #fff;
  padding: 6px 14px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: system-ui, -apple-system, sans-serif;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}

.game-score {
  min-width: 50px;
  text-align: center;
}

.game-timer {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.game-pause-btn {
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}
.game-pause-btn:active {
  transform: scale(0.92);
}

.game-status {
  text-align: center;
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  padding: 4px;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

/* ---- Overlay schermate (avvio, pausa, vittoria, game over) ---- */
.game-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1020;
  animation: gameOverlayIn 0.3s ease;
  padding: 20px;
}

@keyframes gameOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.game-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.game-overlay-logo {
  max-width: 80px;
  max-height: 80px;
  border-radius: 16px;
}

.game-overlay-title {
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  font-family: system-ui, -apple-system, sans-serif;
}

.game-overlay-desc {
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  line-height: 1.5;
  max-width: 280px;
}

.game-overlay-hint {
  color: rgba(255,255,255,0.35);
  font-size: 12px;
}

.game-overlay-score {
  color: #FFD700;
  font-size: 20px;
  font-weight: 700;
}

/* ---- Pulsanti ---- */
.game-btn-primary {
  background: #378ADD;
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, background 0.2s;
  width: 100%;
  max-width: 280px;
  font-family: system-ui, -apple-system, sans-serif;
}
.game-btn-primary:active {
  transform: scale(0.96);
  background: #2a6fb5;
}

.game-btn-secondary {
  background: transparent;
  color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px;
  padding: 10px 24px;
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-family: system-ui, -apple-system, sans-serif;
}
.game-btn-secondary:active {
  background: rgba(255,255,255,0.05);
}

.game-btn-cta {
  display: inline-block;
  background: #34c759;
  color: #fff;
  border-radius: 14px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  width: 100%;
  max-width: 280px;
  font-family: system-ui, -apple-system, sans-serif;
}

/* ---- Banner marketing tra livelli ---- */
.game-banner {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 12px;
  width: 100%;
  max-width: 300px;
}

.game-banner-img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 8px;
}

.game-banner-text {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  line-height: 1.4;
}

/* ---- Form lead capture (reward modal) ---- */
.game-reward-emoji {
  font-size: 48px;
  line-height: 1;
}

.game-reward-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}

.game-input {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 12px 14px;
  color: #fff;
  font-size: 15px;
  font-family: system-ui, -apple-system, sans-serif;
  outline: none;
  transition: border-color 0.2s;
}
.game-input:focus {
  border-color: #378ADD;
}
.game-input::placeholder {
  color: rgba(255,255,255,0.3);
}

/* ---- Statistiche finali ---- */
.game-final-stats {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.game-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.game-stat-val {
  color: #FFD700;
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.game-stat-lbl {
  color: rgba(255,255,255,0.4);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- Popup punti flottante "+10" ---- */
.game-score-popup {
  position: absolute;
  color: #FFD700;
  font-size: 22px;
  font-weight: 800;
  font-family: system-ui, -apple-system, sans-serif;
  pointer-events: none;
  z-index: 1015;
  text-shadow: 0 2px 6px rgba(0,0,0,0.7);
  transform: translate(-50%, -50%);
  animation: scorePopup 0.85s ease-out forwards;
}

.game-score-popup-negative {
  color: #FF4444;
}

@keyframes scorePopup {
  0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  15%  { transform: translate(-50%, -60%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -120%) scale(1); opacity: 0; }
}

/* ---- Hub giochi (lista card) ---- */
.games-hub {
  padding: 20px;
  max-width: 600px;
  margin: 0 auto;
}

.games-hub-title {
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.games-hub-subtitle {
  color: rgba(255,255,255,0.5);
  font-size: 14px;
  margin-bottom: 20px;
}

.games-hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.game-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.game-card:active {
  transform: scale(0.98);
}
.game-card:hover {
  border-color: rgba(55,138,221,0.4);
}

.game-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.game-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(55,138,221,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.game-card-title {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.game-card-mode {
  color: rgba(255,255,255,0.3);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.game-card-desc {
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  line-height: 1.4;
}

/* ---- Empty state ---- */
.games-empty {
  text-align: center;
  padding: 60px 20px;
  color: rgba(255,255,255,0.4);
}
.games-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.games-empty-text {
  font-size: 15px;
}

/* ---- Loading spinner ---- */
.games-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}
.games-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: #378ADD;
  border-radius: 50%;
  animation: gameSpin 0.8s linear infinite;
}
@keyframes gameSpin {
  to { transform: rotate(360deg); }
}

/* ---- Responsive (tablet+) ---- */
@media (min-width: 600px) {
  .games-hub-grid {
    grid-template-columns: 1fr 1fr;
  }
  .game-card {
    padding: 20px;
  }
}

/* ---- Animazioni gioco in-game (stile codice originale) ---- */

/* Pulsazione target (come originale) */
@keyframes gpulse {
  0%,100% { transform: translate(-50%,-50%) scale(1); }
  50%     { transform: translate(-50%,-50%) scale(1.1); }
}
@keyframes gring {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.4; }
}

/* Popup punti flottante "+10" */
@keyframes gfloat {
  0%   { transform: translate(-50%,-50%) scale(0.5); opacity: 0; }
  15%  { transform: translate(-50%,-70%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%,-140%) scale(1); opacity: 0; }
}

/* Esplosione particelle raccolta (come originale) */
@keyframes gpop {
  0%   { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(3); opacity: 0; }
}

/* ---- Racing game — volantino e HUD specifico ---- */

#race-arena canvas {
  image-rendering: auto;
}

#race-wheel-zone {
  background: linear-gradient(to top, rgba(0,0,0,0.35) 0%, transparent 100%);
}

#race-wheel {
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  -webkit-tap-highlight-color: transparent;
}

#race-hud {
  background: linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, transparent 100%);
}

/* ---- Prefers reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .game-overlay,
  .game-card {
    animation: none;
    transition: none;
  }
}
