/* --- CONFIGURAZIONE CORE STVFFO 2025 --- */
body, html {
  margin: 0;
  padding: 0;
  background: #010301; /* Nero profondissimo */
  color: #eef0ef; /* Verde Fosforo */
  font-family: 'Courier New', Courier, monospace;
  overflow: hidden;
  height: 100%;
  text-shadow: 0 0 5px rgba(237, 239, 237, 0.7), 0 0 10px rgba(233, 239, 235, 0.4);
}

/* 0. LIVELLO GIF SOTTO TUTTO */
.stvffo-gif-underlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  object-fit: cover;
  opacity: 0.3; /* Regola da 0.1 a 0.4 per la visibilità */
  /* Trasforma la GIF in una texture verde retro */
  filter: grayscale(1) brightness(0.3) contrast(1.2) sepia(1) hue-rotate(80deg) saturate(0);
  pointer-events: none;
}

/* 1. MOTORE DI MOVIMENTO (SFONDO) */
@keyframes stvffo-move {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.stvffo-bg {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 1; /* Sopra la GIF */
  opacity: 0.12;
  filter: blur(1.5px);
  pointer-events: none;
}

.stvffo-line {
  display: flex;
  white-space: nowrap;
  font-family: 'Arial Black', sans-serif;
  font-size: 110px;
  line-height: 0.85;
}

.stvffo-line span {
  display: inline-block;
  animation: stvffo-move 18s linear infinite;
  color: #f1f3f1;
}

.move-reverse span { animation-direction: reverse; animation-duration: 28s; }
.skewed { transform: skewY(-2.5deg); background: rgba(0, 255, 65, 0.05); }
.outline span { color: transparent; -webkit-text-stroke: 1px #18e94d; }

/* 2. INTERFACCIA PIP-BOY TERMINAL */
.pipboy-overlay {
  position: relative;
  z-index: 10; /* Sopra tutto */
  height: 100vh;
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
}

.menu-container {
  max-width: 600px;
}

.menu-item {
  display: block;
  font-size: 12px;
  text-decoration: none;
  color: #f7fbf8;
  margin-bottom: 25px;
  padding: 8px 20px;
  border-left: 4px solid transparent;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-transform: uppercase;
  letter-spacing: 3px;
  text-shadow: 0 0 8px rgba(245, 248, 246, 0.8);
}

.menu-item:hover {
  background: rgba(248, 249, 248, 0.2);
  border-left: 4px solid #f3f8f4;
  padding-left: 35px;
  text-shadow: 0 0 15px rgb(243, 245, 243), 0 0 25px rgba(241, 242, 241, 0.5);
  cursor: pointer;
}

/* HUD & EFFETTI SCHERMO */
.corner-frame {
  position: absolute;
  width: 60px;
  height: 60px;
  border: 2px solid #f4f6f5;
  opacity: 0.5;
}
.top-left { top: 30px; left: 30px; border-right: 0; border-bottom: 0; }
.top-right { top: 30px; right: 30px; border-left: 0; border-bottom: 0; }
.bottom-left { bottom: 30px; left: 30px; border-right: 0; border-top: 0; }
.bottom-right { bottom: 30px; right: 30px; border-left: 0; border-top: 0; }

.status-bar {
  border-top: 1px solid rgba(242, 246, 243, 0.2);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  letter-spacing: 2px;
}

.screen-flicker {
  position: fixed;
  inset: 0;
  background: rgba(241, 245, 242, 0.015);
  z-index: 100;
  pointer-events: none;
  animation: flicker 0.12s infinite;
}

@keyframes flicker {
  0% { opacity: 0.1; }
  50% { opacity: 0.13; }
  100% { opacity: 0.1; }
}

/* === TEMA COLORATO (UNLOCKED CON KONAMI CODE) === */
body.color-mode {
  color: #00ff41; /* Verde matrix */
  text-shadow: 0 0 5px rgba(0, 255, 65, 0.7), 0 0 10px rgba(0, 255, 65, 0.4);
}

body.color-mode .stvffo-gif-underlay {
  filter: brightness(0.7) contrast(1.3) saturate(1.5); /* GIF A COLORI! */
  opacity: 0.5;
}

body.color-mode .stvffo-bg {
  opacity: 0.15;
}

body.color-mode .stvffo-line span {
  color: #00ff41;
  text-shadow: 0 0 10px rgba(0, 255, 65, 0.8);
}

body.color-mode .outline span {
  -webkit-text-stroke: 1px #ff00ff; /* Magenta */
}

body.color-mode .menu-item {
  color: #00ff41;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.8);
  border-left-color: #00ff41;
}

body.color-mode .menu-item:hover {
  background: rgba(0, 255, 65, 0.1);
  border-left-color: #ff00ff;
  text-shadow: 0 0 15px #00ff41, 0 0 25px rgba(255, 0, 255, 0.5);
}

body.color-mode .corner-frame {
  border-color: #00ff41;
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.5);
}

body.color-mode .status-bar {
  border-top-color: rgba(0, 255, 65, 0.4);
  color: #00ff41;
}

body.color-mode .screen-flicker {
  background: rgba(0, 255, 65, 0.02);
}

/* ANIMAZIONE UNLOCK */
@keyframes colorUnlock {
  0% { 
    filter: hue-rotate(0deg) brightness(1);
    transform: scale(1);
  }
  20% { 
    filter: hue-rotate(180deg) brightness(1.5);
    transform: scale(1.05);
  }
  40% { 
    filter: hue-rotate(360deg) brightness(1);
    transform: scale(0.95);
  }
  60% { 
    filter: hue-rotate(180deg) brightness(1.3);
    transform: scale(1.02);
  }
  100% { 
    filter: hue-rotate(0deg) brightness(1);
    transform: scale(1);
  }
}

body.unlocking {
  animation: colorUnlock 2s ease-in-out;
}

/* NOTIFICA UNLOCK */
.unlock-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  padding: 40px 60px;
  background: rgba(0, 0, 0, 0.95);
  border: 4px solid #00ff41;
  color: #00ff41;
  font-size: 32px;
  letter-spacing: 8px;
  text-align: center;
  text-shadow: 0 0 30px rgba(0, 255, 65, 1);
  box-shadow: 0 0 60px rgba(0, 255, 65, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.unlock-notification.show {
  opacity: 1;
  animation: pulse 0.5s ease-in-out 3;
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.1); }
}

/* === LOADING SCREEN === */
.loading-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease-out;
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-screen img {
  width: 120px;
  height: auto;
  opacity: 1;
}

/* === NOISE/GRAIN OVERLAY === */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 101;
  pointer-events: none;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' /%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' /%3E%3C/svg%3E");
  animation: grain 0.5s steps(4) infinite;
}

@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-5%, -10%); }
  20% { transform: translate(-15%, 5%); }
  30% { transform: translate(7%, -25%); }
  40% { transform: translate(-5%, 25%); }
  50% { transform: translate(-15%, 10%); }
  60% { transform: translate(15%, 0%); }
  70% { transform: translate(0%, 15%); }
  80% { transform: translate(3%, 35%); }
  90% { transform: translate(-10%, 10%); }
}

/* Container per posizionare le gif nello stesso punto */
.container-sfondi {
  position: relative;
  width: 100%;
  height: 100vh; /* Altezza schermo intero */
  overflow: hidden;
}

.stvffo-gif-underlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* Adatta l'immagine allo schermo */
  opacity: 0; /* Tutte invisibili di base */
  animation: loopSfondi 6s infinite; /* Ciclo totale di 6 secondi */
}

/* Gestione dei ritardi (delay) per ogni immagine */
.stvffo-gif-underlay:nth-child(1) {
  animation-delay: 0s;
}
.stvffo-gif-underlay:nth-child(2) {
  animation-delay: 2s;
}
.stvffo-gif-underlay:nth-child(3) {
  animation-delay: 4s;
}

/* Definizione dell'animazione */
@keyframes loopSfondi {
  0% { opacity: 0; }
  5% { opacity: 1; }   /* Appare velocemente */
  33% { opacity: 1; }  /* Resta visibile per 1/3 del tempo (2s) */
  38% { opacity: 0; }  /* Scompare */
  100% { opacity: 0; }
}

/* ============================================ */
/* RESPONSIVE DESIGN - MOBILE OPTIMIZATION */
/* ============================================ */

@media (max-width: 768px) {
  /* RIDUZIONE PADDING GENERALE */
  .pipboy-overlay {
    padding: 20px !important;
    padding-top: 80px !important; /* Spazio per back button */
  }

  /* MENU ITEMS PIU' LEGGIBILI */
  .menu-item {
    font-size: 14px;
    margin-bottom: 20px;
    padding: 10px 15px;
    letter-spacing: 2px;
  }

  .menu-item:hover {
    padding-left: 25px;
  }

  /* CORNER FRAMES PIU' PICCOLI E VICINI AI BORDI */
  .corner-frame {
    width: 40px;
    height: 40px;
  }
  
  .top-left { top: 15px; left: 15px; }
  .top-right { top: 15px; right: 15px; }
  .bottom-left { bottom: 15px; left: 15px; }
  .bottom-right { bottom: 15px; right: 15px; }

  /* STATUS BAR - LAYOUT VERTICALE SU MOBILE */
  .status-bar {
    flex-direction: column;
    gap: 15px;
    padding-top: 30px;
    font-size: 12px;
    text-align: center;
  }

  .status-bar span {
    width: 100%;
    padding: 8px 0;
    border-top: 1px solid rgba(242, 246, 243, 0.2);
  }

  /* BACK LINK PIU' PICCOLO */
  .back-link {
    top: 20px !important;
    right: 20px !important;
    padding: 8px 16px !important;
    font-size: 10px !important;
    letter-spacing: 1px !important;
  }

  /* LETTERE BACKGROUND PIU' GRANDI E PIU' SPESSE */
  .stvffo-line {
    font-size: 90px;
    font-weight: 900;
    letter-spacing: 4px;
  }
}

@media (max-width: 480px) {
  /* PADDING ANCORA PIU' RIDOTTO SU SCHERMI MOLTO PICCOLI */
  .pipboy-overlay {
    padding: 15px !important;
    padding-top: 70px !important;
  }

  /* MENU ITEMS */
  .menu-item {
    font-size: 12px;
    letter-spacing: 1px;
  }

  /* STATUS BAR ANCORA PIU' COMPATTO */
  .status-bar {
    font-size: 11px;
    gap: 10px;
  }

  /* CORNER FRAMES ANCORA PIU' PICCOLI */
  .corner-frame {
    width: 30px;
    height: 30px;
  }

  .top-left { top: 10px; left: 10px; }
  .top-right { top: 10px; right: 10px; }
  .bottom-left { bottom: 10px; left: 10px; }
  .bottom-right { bottom: 10px; right: 10px; }

  /* LETTERE BACKGROUND PIU' GRANDI E SPESSE */
  .stvffo-line {
    font-size: 70px;
    font-weight: 900;
    letter-spacing: 3px;
  }
}