/* ==========================================================================
   SILVO TV - MINIMAL IPHONE / SMARTPHONE APP STYLES
   Ottimizzato per mobile, PWA, touch controls e caricamento su FTP.
   ========================================================================== */

:root {
  --app-bg: #0b0c0f;
  --tv-chassis: #1a1c22;
  --tv-bezel: #101115;
  --tv-accent: #ffcc00;
  --tv-accent-glow: rgba(255, 204, 0, 0.45);
  --tv-green: #39ff14;
  --text-main: #ffffff;
  --text-sub: #9ca3af;
  --btn-bg: #22252e;
  --btn-border: #353945;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--app-bg);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  user-select: none;
}

/* Bagliore d'atmosfera */
.ambient-glow {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 90vw;
  max-width: 600px;
  height: 350px;
  background: radial-gradient(circle, rgba(255, 204, 0, 0.08) 0%, rgba(57, 255, 20, 0.04) 50%, transparent 75%);
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
}

/* Container principale stile App */
.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 680px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px)) 16px;
}

/* ==========================================================================
   HEADER MINIMALE
   ========================================================================== */

.app-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-home-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e5e5e5;
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  border-radius: 999px;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-home-link:hover, .btn-home-link:active {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
}

.tv-icon {
  font-size: 1.3rem;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #fff;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

.badge-total {
  background: rgba(255, 204, 0, 0.15);
  border: 1px solid rgba(255, 204, 0, 0.4);
  color: var(--tv-accent);
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 12px;
  letter-spacing: 0.5px;
}

/* Timer Countdown */
.header-timer {
  display: flex;
  align-items: center;
}

.timer-countdown {
  background: rgba(20, 22, 28, 0.85);
  border: 1px solid rgba(255, 204, 0, 0.4);
  border-radius: 18px;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--tv-accent);
  font-family: "Courier New", Courier, monospace;
  font-weight: 800;
}

.timer-countdown span {
  font-size: 0.95rem;
  min-width: 30px;
  text-align: right;
}

.timer-track {
  width: 50px;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
}

.timer-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ffcc00, #ff3b30);
  transition: width 0.95s linear;
}

/* ==========================================================================
   TELEVISORE RETRO MINIMALE
   ========================================================================== */

.tv-container {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 10px 0;
}

.retro-tv {
  position: relative;
  width: 100%;
  background: linear-gradient(160deg, #242730 0%, #16171d 100%);
  border-radius: 24px;
  padding: 14px 14px 12px 14px;
  border: 2px solid #363a46;
  box-shadow: 
    0 16px 40px rgba(0, 0, 0, 0.8),
    inset 0 1px 2px rgba(255, 255, 255, 0.15),
    inset 0 -2px 5px rgba(0, 0, 0, 0.6);
}

/* Antenne */
.tv-antenna {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 28px;
  pointer-events: none;
}

.tv-antenna .ant {
  width: 3px;
  height: 32px;
  background: linear-gradient(to top, #444, #aaa);
  border-radius: 2px;
  display: block;
}

.tv-antenna .ant-l { transform: rotate(-32deg); transform-origin: bottom center; }
.tv-antenna .ant-r { transform: rotate(32deg); transform-origin: bottom center; }

.tv-antenna .ant::after {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  background: #eee;
  border-radius: 50%;
  position: relative;
  top: -3px;
  left: -1.5px;
}

/* Cornice dello Schermo */
.tv-bezel {
  background: var(--tv-bezel);
  border-radius: 18px;
  padding: 6px;
  border: 1px solid #1f2229;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.9);
}

.tv-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.9);
}

.player-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#yt-player {
  width: 100%;
  height: 100%;
}

/* Scanlines leggere */
.scanlines {
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.22) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 4;
}

/* Canvas statica per zapping */
.static-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.05s ease;
}

.static-canvas.active {
  opacity: 1;
}

/* Badge Canale OSD */
.screen-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--tv-green);
  border: 1px solid rgba(57, 255, 20, 0.4);
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 6;
  text-shadow: 0 0 6px var(--tv-green);
}

/* Alert Solo Avanti */
.alert-solo-avanti {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(220, 20, 20, 0.95);
  color: #fff;
  border: 2px solid #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-align: center;
  box-shadow: 0 0 25px rgba(255, 0, 0, 0.85);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.alert-solo-avanti.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Box Titolo sotto allo schermo */
.video-info-box {
  margin-top: 12px;
  padding: 0 4px;
}

.video-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.video-meta {
  font-size: 0.78rem;
  color: var(--text-sub);
  font-family: monospace;
}

/* ==========================================================================
   BARRA CONTROLLI MINIMALE (SOLO PULSANTI BASE)
   ========================================================================== */

.bottom-controls {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.btn-ctrl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: #eee;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: all 0.15s ease;
}

.btn-ctrl:active {
  transform: scale(0.96);
}

/* Pulsante Muto / Audio */
.btn-audio {
  flex: 1;
}

.btn-audio.muted {
  background: #3b1d1d;
  border-color: #632e2e;
  color: #ff9999;
}

/* Pulsante Installa PWA */
.btn-pwa {
  flex: 1;
  background: #1c2233;
  border-color: #2e3a59;
  color: #8bb4ff;
}

/* Pulsante Primario AVANTI */
.btn-next {
  flex: 1.5;
  background: linear-gradient(180deg, #ffcc00 0%, #d4a000 100%);
  border: 1px solid #ffd633;
  color: #121316;
  font-weight: 900;
  letter-spacing: 1px;
  box-shadow: 0 6px 18px var(--tv-accent-glow);
}

.btn-next .btn-arrow {
  font-size: 1.1rem;
  transition: transform 0.15s;
}

.btn-next:hover .btn-arrow {
  transform: translateX(3px);
}

/* ==========================================================================
   CREDITI
   ========================================================================== */

.app-credits {
  margin-top: 10px;
  text-align: center;
  font-size: 0.74rem;
  color: #6c7382;
  line-height: 1.4;
}

.app-credits strong {
  color: var(--tv-accent);
}

.credits-hint {
  font-size: 0.68rem;
  margin-top: 2px;
  opacity: 0.8;
}

.credits-hint kbd {
  background: #1e2028;
  border: 1px solid #363a46;
  padding: 1px 4px;
  border-radius: 3px;
  color: #fff;
}

.credits-home-link {
  color: var(--tv-accent);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}

.credits-home-link:hover {
  text-decoration: underline;
  opacity: 0.85;
}

/* ==========================================================================
   MODAL POPUP PWA INSTALL (IPHONE / ANDROID)
   ========================================================================== */

.pwa-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.pwa-modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.pwa-modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: #1b1d24;
  border: 1px solid #333845;
  border-radius: 22px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
  transform: translateY(20px);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pwa-modal-backdrop.show .pwa-modal-card {
  transform: translateY(0);
}

.pwa-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: #272a34;
  border: none;
  color: #999;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.85rem;
  cursor: pointer;
}

.pwa-modal-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.pwa-modal-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}

.pwa-modal-desc {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.4;
  margin-bottom: 18px;
}

/* Guida iOS */
.pwa-ios-instructions {
  background: #14161b;
  border-radius: 14px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  font-size: 0.85rem;
  border: 1px solid #282c38;
}

.ios-step {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-num {
  background: var(--tv-accent);
  color: #000;
  font-weight: 900;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.ios-icon {
  font-size: 1.1rem;
}

/* Tasto Android */
.btn-pwa-install-now {
  width: 100%;
  background: linear-gradient(180deg, #ffcc00 0%, #d4a000 100%);
  border: none;
  color: #121316;
  padding: 14px;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 6px 16px var(--tv-accent-glow);
}
