/* ========================================================
   RESET & SETUP BASE (ANTI-TAGLIO SCHERMO & SAFE AREAS)
   ======================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
  font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
  font-size: 11px;
  background-color: #0b0e14;
}

.kit-download-banner {
  background-color: #f1f5f9;
  border-bottom: 2px solid #0284c7;
  padding: 1rem 1.5rem;
  margin-bottom: 2rem;
}

.kit-download-banner .banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.kit-download-banner p {
  margin: 0;
  color: #0f172a;
  font-size: 0.95rem;
}

.kit-download-banner .button-download {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background-color: #0284c7;
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.kit-download-banner .button-download:hover,
.kit-download-banner .button-download:focus {
  background-color: #0369a1;
}

/* ========================================================
   DESKTOP SCREEN & SFONDO BLISS/DARK XP
   ======================================================== */
.desktop-screen {
  position: relative;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 20%, #152542 0%, #0d1627 60%, #05080f 100%);
  overflow: hidden;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ========================================================
   LOGO "BACK IN THE 90'S" (STILE RITORNO AL FUTURO)
   ======================================================== */
.bttf-header {
  width: 100%;
  max-width: 100%;
  padding: 8px 10px 4px 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(10,15,30,0.5) 80%, transparent 100%);
  overflow: hidden;
  flex-shrink: 0;
}

.bttf-logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}

.bttf-logo {
  position: relative;
  display: flex;
  align-items: baseline;
  transform: skew(-14deg) scale(0.95);
  font-family: 'Russo One', 'Impact', sans-serif;
  line-height: 0.9;
  text-transform: uppercase;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.9)) drop-shadow(0 0 14px rgba(255, 90, 0, 0.65));
}

.bttf-line-top {
  font-size: 40px;
  color: #ff9900;
  background: linear-gradient(180deg, #fff275 0%, #ff8c00 45%, #cc1100 85%, #880000 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 1.5px #ffffff;
  letter-spacing: 2px;
  margin-right: 6px;
}

.bttf-arrow-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 4px;
}

.bttf-in {
  font-size: 13px;
  color: #00e5ff;
  letter-spacing: 1px;
  font-weight: 900;
  text-shadow: 0 0 8px #00b0ff;
  -webkit-text-stroke: 0.5px #003366;
}

.bttf-arrow {
  font-size: 13px;
  color: #ff3300;
  letter-spacing: -2px;
  transform: translateY(-2px);
  text-shadow: 0 0 6px #ffcc00;
}

.bttf-line-bottom {
  font-size: 46px;
  color: #ff3b00;
  background: linear-gradient(180deg, #ffff99 0%, #ff4500 50%, #b30000 85%, #4a0000 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 1.5px #ffffff;
  letter-spacing: 2px;
}

.bttf-subtitle {
  margin-top: 2px;
  color: #00ffff;
  font-family: 'Courier New', Courier, monospace;
  font-weight: bold;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-align: center;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.8), 0 0 16px rgba(0, 255, 255, 0.4);
}

/* ========================================================
   FINESTRA WINDOWS XP LUNA & CONTROLLI
   ======================================================== */
.xp-window {
  position: absolute;
  top: 72px;
  left: max(12px, env(safe-area-inset-left, 12px));
  right: max(12px, env(safe-area-inset-right, 12px));
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  background-color: #ece9d8;
  border: 3px solid #0055ea;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75), 0 0 20px rgba(0, 85, 234, 0.3);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: transform 0.15s ease, opacity 0.15s ease;
  overflow: hidden;
}

.xp-window.minimized {
  transform: translateY(120vh) scale(0.6);
  opacity: 0;
  pointer-events: none;
}

/* Barra del titolo */
.window-titlebar {
  height: 30px;
  min-height: 30px;
  background: linear-gradient(180deg, #0058ee 0%, #3593ff 4%, #288eff 6%, #0060ee 8%, #0052e0 14%, #085ee5 68%, #0045c7 79%, #0036a5 86%, #003099 100%);
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 0 8px;
  color: #ffffff;
  font-weight: bold;
  letter-spacing: 0.3px;
  text-shadow: 1px 1px 1px #0f2b60;
  cursor: default;
  overflow: hidden;
}

.titlebar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
}

.ie-logo-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  background: #0070e0;
  color: #ffca28;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-size: 13px;
  font-weight: 900;
  border-radius: 50%;
  box-shadow: inset 1px 1px 2px #fff;
  flex-shrink: 0;
}

.window-title {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.titlebar-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.win-btn {
  width: 21px;
  height: 21px;
  border: 1px solid #ffffff;
  border-radius: 3px;
  color: #ffffff;
  font-weight: bold;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
  background: linear-gradient(180deg, #429aff 0%, #1572e8 60%, #0056cc 100%);
}

.win-btn.win-close {
  background: linear-gradient(180deg, #e76744 0%, #d83b19 50%, #ae1d00 100%);
}

/* Barra Menu */
.ie-menubar {
  display: flex;
  background: #ece9d8;
  border-bottom: 1px solid #d4d0c8;
  padding: 1px 4px;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.menu-item {
  padding: 3px 6px;
  cursor: pointer;
  color: #000;
  flex-shrink: 0;
}

.menu-item:hover {
  background-color: #316ac5;
  color: #fff;
}

/* Toolbar */
.ie-toolbar {
  display: flex;
  align-items: center;
  background: #ece9d8;
  border-top: 1px solid #fff;
  border-bottom: 1px solid #999484;
  padding: 2px 4px;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid transparent;
  padding: 2px 5px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  flex-shrink: 0;
  white-space: nowrap;
}

.tool-btn:hover {
  border: 1px solid #7f9db9;
  background: linear-gradient(180deg, #ffffff 0%, #e2eaf5 100%);
}

.tool-btn:active, .tool-btn.active {
  border: 1px solid #0a246a;
  background: #c2d5f2;
}

.tool-icon {
  font-size: 14px;
}

.toolbar-sep {
  width: 1px;
  height: 22px;
  background: #aca899;
  border-right: 1px solid #fff;
  margin: 0 3px;
  flex-shrink: 0;
}

.toolbar-flex-space {
  flex: 1;
  min-width: 8px;
}

.spinning-globe {
  width: 26px;
  height: 26px;
  border: 2px inset #ffffff;
  background: #001f3f;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 2px;
  flex-shrink: 0;
}

.throbber-inner {
  color: #ffcf40;
  font-family: 'Georgia', serif;
  font-style: italic;
  font-weight: 900;
  font-size: 16px;
}

.spinning-globe.spinning .throbber-inner {
  animation: spinThrobber 1s infinite linear;
}

@keyframes spinThrobber {
  from { transform: rotate(0deg) scale(1.1); }
  to { transform: rotate(360deg) scale(1.1); }
}

/* Barra Indirizzi */
.ie-addressbar {
  display: flex;
  align-items: center;
  background: #ece9d8;
  border-top: 1px solid #fff;
  border-bottom: 1px solid #aca899;
  padding: 3px 6px;
  gap: 5px;
  max-width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.address-label {
  color: #333;
  font-weight: bold;
  flex-shrink: 0;
}

.address-input-wrapper {
  flex: 1;
  min-width: 130px;
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid #7f9db9;
  padding: 2px 5px;
  box-shadow: inset 1px 1px 1px rgba(0,0,0,0.15);
}

.address-icon {
  font-size: 13px;
  margin-right: 4px;
  flex-shrink: 0;
}

.address-input {
  width: 100%;
  border: none;
  outline: none;
  font-family: Tahoma, Arial, sans-serif;
  font-size: 12px;
  user-select: text;
}

.go-button {
  background: linear-gradient(180deg, #ffffff 0%, #e1e9f4 100%);
  border: 1px solid #0055ea;
  border-radius: 3px;
  padding: 3px 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-weight: bold;
  color: #003399;
  flex-shrink: 0;
}

.go-arrow {
  color: #107c10;
  font-size: 12px;
}

.address-presets {
  flex-shrink: 0;
}

.address-presets select {
  padding: 2px 4px;
  font-size: 11px;
  border: 1px solid #7f9db9;
  border-radius: 2px;
  max-width: 170px;
}

/* Barra Gialla ActiveX */
.activex-bar {
  background: #ffffe1;
  border-top: 1px solid #e1c000;
  border-bottom: 1px solid #d0ad00;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.activex-text {
  flex: 1;
  color: #333;
}

.activex-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: bold;
  color: #666;
}

/* ========================================================
   VIEWPORT IFRAME & SCORRIMENTO TOUCH VERTICALE ABILITATO
   ======================================================== */
.ie-viewport {
  flex: 1;
  position: relative;
  background: #ffffff;
  border: 2px inset #808080;
  width: 100%;
  height: 100%;
  overflow: hidden !important; /* Impedisce la comparsa della seconda scrollbar esterna */
  -webkit-overflow-scrolling: touch;
}

.ie-viewport iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
  display: block;
}

/* Scanlines CRT */
.scanline-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.28) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 5;
}

.scanline-overlay.active {
  opacity: 1;
}

/* Barra di Stato */
.ie-statusbar {
  height: 22px;
  min-height: 22px;
  background: #ece9d8;
  border-top: 1px solid #999484;
  display: flex;
  align-items: center;
  padding: 0 4px;
  gap: 4px;
  overflow: hidden;
}

.status-zone {
  border-top: 1px solid #999;
  border-left: 1px solid #999;
  border-right: 1px solid #fff;
  border-bottom: 1px solid #fff;
  height: 16px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  font-size: 11px;
  white-space: nowrap;
}

.status-message {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-progress {
  width: 90px;
  background: #fff;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #308014, #44b01e);
  transition: width 0.2s ease;
}

.status-security {
  width: 130px;
  justify-content: center;
  flex-shrink: 0;
}

/* ========================================================
   TASKBAR WINDOWS XP
   ======================================================== */
.xp-taskbar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: calc(30px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #1f2f86 0%, #3165c4 3%, #245edb 10%, #1941a5 90%, #1941a5 100%);
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
  padding-left: max(0px, env(safe-area-inset-left, 0px));
  padding-right: max(0px, env(safe-area-inset-right, 0px));
  z-index: 100;
  overflow: hidden;
}

.start-btn {
  height: 28px;
  background: linear-gradient(180deg, #388e3c 0%, #2e7d32 10%, #1b5e20 90%);
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 14px;
  color: #fff;
  font-style: italic;
  font-weight: 900;
  font-size: 13px;
  box-shadow: 2px 0 5px rgba(0,0,0,0.4);
  cursor: pointer;
  flex-shrink: 0;
}

.start-flag {
  color: #ff9800;
  font-style: normal;
  font-size: 15px;
}

.taskbar-tasks {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 6px;
  overflow: hidden;
}

.task-btn {
  background: linear-gradient(180deg, #3878dd 0%, #205cbe 50%, #1945a0 100%);
  border: 1px solid #14357c;
  border-radius: 3px;
  padding: 2px 8px;
  height: 22px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
  overflow: hidden;
}

.task-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-btn.active {
  background: linear-gradient(180deg, #1b4594 0%, #153c84 50%, #0d2960 100%);
  border-color: #0b1f49;
}

.taskbar-tray {
  background: linear-gradient(180deg, #0c59b9 0%, #139eee 10%, #1085cf 20%, #0e61b9 90%);
  border-left: 1px solid #0f4a9b;
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 6px;
  color: #fff;
  flex-shrink: 0;
}

/* ========================================================
   FINESTRE DI DIALOGO & MODALI
   ======================================================== */
.xp-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 10px;
}

.xp-dialog {
  max-width: 440px;
  width: 95%;
  background: #ece9d8;
  border: 3px solid #0055ea;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  box-shadow: 4px 6px 20px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
}

.dialog-titlebar {
  height: 26px;
  background: linear-gradient(180deg, #0058ee 0%, #085ee5 70%, #0036a5 100%);
  color: #fff;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 0 8px;
}

.dialog-close {
  background: #d83b19;
  border: 1px solid #fff;
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 2px;
  cursor: pointer;
}

.dialog-body {
  padding: 16px;
  display: flex;
  gap: 14px;
}

.dialog-icon {
  font-size: 30px;
}

.dialog-message {
  font-size: 11px;
  line-height: 1.4;
  user-select: text;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  background: #ece9d8;
  border-top: 1px solid #d4d0c8;
}

.xp-btn {
  min-width: 75px;
  padding: 4px 12px;
  background: linear-gradient(180deg, #ffffff 0%, #ece9d8 100%);
  border: 1px solid #003c74;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
}

.xp-btn:hover {
  background: linear-gradient(180deg, #eef5ff 0%, #d8e5f8 100%);
}

.notepad-dialog {
  width: 680px;
  max-width: 95%;
  height: 440px;
}

.notepad-menubar {
  display: flex;
  gap: 12px;
  background: #ece9d8;
  border-bottom: 1px solid #999;
  padding: 2px 8px;
}

#notepadText {
  flex: 1;
  width: 100%;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  border: 1px inset #808080;
  padding: 8px;
  resize: none;
  outline: none;
  background: #ffffff;
  user-select: text;
}

/* ========================================================
   GESTIONE MOBILE, OVERLAY "BIFF" & ACCESSIBILITÀ
   ======================================================== */
.mobile-rotate-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 15px;
}

.rotate-dialog {
  max-width: 380px;
  width: 92%;
}

.rotate-phone-anim {
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulsePhone 1.5s infinite alternate ease-in-out;
}

@keyframes pulsePhone {
  0% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(-15deg); }
  100% { transform: scale(1) rotate(-90deg); }
}

@media screen and (max-width: 768px) and (orientation: portrait) {
  .mobile-rotate-overlay {
    display: flex;
  }

  .xp-window {
    top: 64px;
    left: 4px;
    right: 4px;
    bottom: 34px;
  }

  .bttf-line-top, .bttf-line-bottom {
    font-size: 26px;
  }

  .bttf-subtitle {
    font-size: 9px;
  }
}

/* ========================================================
   LANDSCAPE MOBILE (SAFE AREA + ALTEZZE MINIMIZZATE)
   ======================================================== */
@media screen and (max-height: 550px) and (orientation: landscape) {
  .bttf-header {
    padding: 1px 0 2px 0;
    height: 32px;
  }
  .bttf-logo {
    transform: skew(-8deg) scale(0.55);
  }
  .bttf-subtitle {
    display: none;
  }
  
  .xp-window {
    top: 34px;
    left: max(8px, env(safe-area-inset-left, 8px));
    right: max(8px, env(safe-area-inset-right, 8px));
    bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    border-width: 2px;
  }

  .window-titlebar {
    height: 24px;
    min-height: 24px;
    padding: 0 4px;
  }
  .window-title {
    font-size: 11px;
  }
  .win-btn {
    width: 18px;
    height: 18px;
  }
  .ie-menubar {
    padding: 0 2px;
  }
  .menu-item {
    padding: 2px 4px;
    font-size: 10px;
  }
  .ie-toolbar {
    padding: 1px 2px;
    gap: 1px;
  }
  .tool-btn {
    padding: 1px 4px;
    font-size: 10px;
  }
  .tool-icon {
    font-size: 12px;
  }
  .spinning-globe {
    width: 22px;
    height: 22px;
  }
  .throbber-inner {
    font-size: 13px;
  }
  .ie-addressbar {
    padding: 2px 4px;
    gap: 3px;
  }
  .go-button {
    padding: 2px 8px;
    font-size: 10px;
  }
  .address-presets select {
    max-width: 120px;
    font-size: 10px;
  }
  .ie-statusbar {
    height: 18px;
    min-height: 18px;
    font-size: 10px;
  }
  .status-zone {
    height: 14px;
    padding: 0 4px;
    font-size: 10px;
  }
  .status-progress {
    width: 60px;
  }
  .status-security {
    width: 100px;
  }

  .xp-taskbar {
    height: calc(26px + env(safe-area-inset-bottom, 0px));
  }
  .start-btn {
    height: 24px;
    padding: 0 10px;
    font-size: 12px;
  }
  .taskbar-tray {
    height: 24px;
    padding: 0 8px;
    font-size: 10px;
  }
}

/* Rotazione forzata dello schermo via CSS */
body.force-landscape {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

body.force-landscape #desktop {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100dvh;
  height: 100dvw;
  max-width: 100dvh;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center center;
}

body.force-landscape .xp-window {
  top: 36px !important;
  left: max(8px, env(safe-area-inset-left, 8px)) !important;
  right: max(8px, env(safe-area-inset-right, 8px)) !important;
  bottom: calc(30px + env(safe-area-inset-bottom, 0px)) !important;
}

body.force-landscape .bttf-header {
  padding: 1px 0 !important;
  height: 32px !important;
}

body.force-landscape .bttf-logo {
  transform: skew(-8deg) scale(0.55) !important;
}

body.force-landscape .bttf-subtitle {
  display: none !important;
}