/* ============================================================
   BITFOOT OS — CRT phosphor terminal v1.2
   Font: "Web IBM VGA 8x16" — The Ultimate Oldschool PC Font Pack
         (c) VileR, int10h.org — CC BY-SA 4.0
   Effetti CRT ispirati a CRTFilter.js di Ichiaka (MIT),
   ricreati in CSS/JS per funzionare sul DOM interattivo.
   Livelli effetto: body.fx-full / body.fx-soft / body.fx-off
   ============================================================ */

@font-face {
    font-family: 'IBM VGA';
    src: url('../fonts/WebPlus_IBM_VGA_8x16.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --font: 'IBM VGA', 'Courier New', monospace;
}

body.theme-green {
    --ph:      #33ff33;
    --ph-dim:  #1f9e1f;
    --ph-dark: #0c4d0c;
    --ph-bg:   #020a02;
    --glow:    rgba(51, 255, 51, 0.55);
    --glow-soft: rgba(51, 255, 51, 0.18);
    --err:     #ff5555;
}

body.theme-amber {
    --ph:      #ffb000;
    --ph-dim:  #b87a00;
    --ph-dark: #5c3d00;
    --ph-bg:   #0a0600;
    --glow:    rgba(255, 176, 0, 0.55);
    --glow-soft: rgba(255, 176, 0, 0.18);
    --err:     #ff5555;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: #000;
    overflow: hidden;
}

body {
    font-family: var(--font);
    color: var(--ph);
    cursor: text;
}

/* ---------- screen ---------- */

#crt {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, var(--ph-bg) 0%, #000 90%);
}

#screen {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: clamp(14px, 3vw, 40px);
    /* font bitmap 8x16: multipli interi = resa nitida */
    font-size: 16px;
    line-height: 1.25;
    text-shadow: 0 0 3px var(--glow-soft);
    scrollbar-width: thin;
    scrollbar-color: var(--ph-dark) transparent;
}
@media (min-width: 900px)  { #screen { font-size: 24px; } }
@media (min-width: 1600px) { #screen { font-size: 32px; } }

/* aberrazione cromatica (stile CRTFilter) — solo a livello full */
body.fx-full #screen {
    text-shadow:
        -1px 0 0 rgba(255, 0, 60, 0.28),
         1px 0 0 rgba(0, 180, 255, 0.22),
         0 0 4px var(--glow),
         0 0 14px var(--glow-soft);
}
body.fx-soft #screen {
    text-shadow:
        0 0 4px var(--glow),
        0 0 12px var(--glow-soft);
}
body.fx-off #screen { text-shadow: none; }
#screen::-webkit-scrollbar { width: 8px; }
#screen::-webkit-scrollbar-thumb { background: var(--ph-dark); }

#output { white-space: pre-wrap; word-break: break-word; }

/* ---------- CRT overlays (stack ispirato a CRTFilter.js) ---------- */

/* scanline più sottili e leggere */
.crt-scanlines {
    position: absolute; inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0,0,0,0)    0px,
        rgba(0,0,0,0)    2px,
        rgba(0,0,0,0.16) 2px,
        rgba(0,0,0,0.16) 3px
    );
    z-index: 5;
}
body.fx-soft .crt-scanlines { opacity: 0.6; }
body.fx-off  .crt-scanlines { display: none; }

/* retraceLines: la riga di refresh che scende (tipica CRT) */
.crt-retrace {
    position: absolute; left: 0; right: 0; top: -10%;
    height: 14vh;
    pointer-events: none;
    background: linear-gradient(to bottom,
        rgba(255,255,255,0) 0%,
        var(--glow-soft) 55%,
        rgba(255,255,255,0.06) 60%,
        rgba(255,255,255,0) 100%);
    z-index: 6;
    animation: retrace 7s linear infinite;
}
@keyframes retrace {
    0%   { top: -16%; }
    100% { top: 104%; }
}
body.fx-soft .crt-retrace,
body.fx-off  .crt-retrace { display: none; }

/* staticNoise: tela di rumore generata via JS */
#crt-noise {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    opacity: 0.05;
    z-index: 6;
    image-rendering: pixelated;
}
body.fx-soft #crt-noise { opacity: 0.025; }
body.fx-off  #crt-noise { display: none; }

/* flicker: instabilità di luminosità */
.crt-flicker {
    position: absolute; inset: 0;
    pointer-events: none;
    background: var(--glow-soft);
    opacity: 0.02;
    z-index: 7;
    animation: flicker 0.12s infinite;
}
body.fx-off .crt-flicker { display: none; }

/* vignette + illusione di curvatura del vetro */
.crt-vignette {
    position: absolute; inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at center,
            rgba(0,0,0,0) 58%, rgba(0,0,0,0.42) 100%),
        radial-gradient(ellipse at 50% -40%,
            rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 40%);
    border-radius: 2.2vw / 2.8vh;
    box-shadow: inset 0 0 12vw rgba(0,0,0,0.55);
    z-index: 8;
}
body.fx-off .crt-vignette { display: none; }

@keyframes flicker {
    0%   { opacity: 0.015; }
    50%  { opacity: 0.035; }
    100% { opacity: 0.02; }
}

@media (prefers-reduced-motion: reduce) {
    .crt-flicker, .crt-retrace { animation: none; display: none; }
    #crt-noise { display: none; }
    #cursor { animation: none !important; opacity: 1; }
}

/* ---------- input line ---------- */

#inputline { display: flex; flex-wrap: wrap; align-items: baseline; }
#prompt { color: var(--ph-dim); margin-right: 0.5ch; }
#typed { white-space: pre-wrap; word-break: break-all; }
#cursor {
    display: inline-block;
    width: 0.6em;
    height: 1em;
    background: var(--ph);
    vertical-align: text-bottom;
    box-shadow: 0 0 8px var(--glow);
    animation: blink 1.06s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* logo a blocchi: si scala da solo per stare nello schermo (55 colonne) */
.ascii-logo {
    display: block;
    font-size: min(1em, calc((100vw - 2 * clamp(14px, 3vw, 40px)) / 34));
    line-height: 1.0;
    letter-spacing: 0;
}
.ascii-logo .line { white-space: pre; }

#mobilekb {
    position: fixed;
    opacity: 0.01;
    height: 1px; width: 1px;
    top: -100px; left: -100px;
    border: 0; background: transparent; color: transparent;
    font-size: 16px; /* evita lo zoom automatico di iOS */
}

/* barra di comando: nascosta su desktop, visibile e usabile su mobile/touch */
#mobilebar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
    background: #000;
    border-top: 1px solid var(--ph-dim);
    box-shadow: 0 -6px 18px rgba(0,0,0,0.6);
}
#mobilebar-prompt {
    color: var(--ph);
    font-family: var(--font);
    font-size: 18px;
    text-shadow: 0 0 6px var(--glow);
}
#mobilebar #mobilekb {
    position: static;
    flex: 1;
    opacity: 1;
    height: auto; width: auto;
    top: auto; left: auto;
    background: #0a0a0a;
    border: 1px solid var(--ph-dim);
    color: var(--ph);
    font-family: var(--font);
    font-size: 18px;
    padding: 8px 10px;
    outline: none;
    caret-color: var(--ph);
}
#mobilebar #mobilekb::placeholder { color: var(--ph-dark); }
#mobilebar #mobilekb:focus { border-color: var(--ph); box-shadow: 0 0 8px var(--glow-soft); }
#mobilebar-send {
    background: var(--ph);
    color: #000;
    border: 0;
    font-family: var(--font);
    font-size: 18px;
    padding: 8px 14px;
    cursor: pointer;
    text-shadow: none;
}

/* su touch mostro la barra e lascio spazio in fondo allo schermo */
body.touch #mobilebar { display: flex; }
body.touch #screen { padding-bottom: 72px; }
body.touch #cursor { display: none; } /* su mobile il cursore vero è nella barra */

/* ---------- output elements ---------- */

.line          { display: block; }
.dim           { color: var(--ph-dim); }
.dark          { color: var(--ph-dim); opacity: 0.85; }
.err           { color: var(--err); text-shadow: 0 0 6px rgba(255,85,85,.5); }
.inv           { background: var(--ph); color: #000; text-shadow: none; padding: 0 0.4ch; }
.title-block   { color: var(--ph); }

a, .link {
    color: var(--ph);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
a:hover, .link:hover, .menu-item:hover {
    background: var(--ph);
    color: #000;
    text-shadow: none;
}
a:focus-visible, .link:focus-visible, .menu-item:focus-visible {
    outline: 2px solid var(--ph);
    outline-offset: 2px;
}

.menu-item { cursor: pointer; display: inline-block; }

/* chip comando in negativo: sfondo fosforo, testo nero */
.navchip {
    display: inline-block;
    background: var(--ph);
    color: #000;
    text-shadow: none;
    padding: 0 0.6ch;
    margin: 2px 1.2ch 2px 0;
    cursor: pointer;
    box-shadow: 0 0 8px var(--glow-soft);
}
.navchip:hover { background: var(--ph-dim); }
.navchip:focus-visible { outline: 2px solid var(--ph); outline-offset: 2px; }
.navhint { color: var(--ph-dim); opacity: 0.9; }

/* ---------- foto "scansione sci-fi" ---------- */

.scanframe {
    display: inline-block;
    border: 2px solid var(--ph-dim);
    padding: 6px;
    margin: 10px 0;
    position: relative;
    max-width: min(320px, 70vw);
    box-shadow: 0 0 18px var(--glow-soft), inset 0 0 18px var(--glow-soft);
}
.scanframe img {
    display: block;
    width: 100%;
    filter: grayscale(1) contrast(1.35) brightness(0.95);
    mix-blend-mode: screen;
}
body.theme-green .scanframe img { filter: grayscale(1) contrast(1.35) brightness(0.9) sepia(1) hue-rotate(70deg) saturate(4); }
body.theme-amber .scanframe img { filter: grayscale(1) contrast(1.35) brightness(0.9) sepia(1) hue-rotate(-10deg) saturate(4); }

.scanframe::after {
    content: '';
    position: absolute; inset: 6px;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0,0,0,0) 0 2px,
        rgba(0,0,0,0.35) 2px 3px
    );
    pointer-events: none;
}
.scanframe::before {
    content: '';
    position: absolute;
    left: 6px; right: 6px;
    height: 14px;
    background: linear-gradient(to bottom, transparent, var(--glow-soft), transparent);
    animation: scanpass 4s linear infinite;
    pointer-events: none;
    z-index: 2;
}
@keyframes scanpass {
    0%   { top: 6px; }
    100% { top: calc(100% - 20px); }
}
.scanlabel {
    display: block;
    font-size: 0.75em;
    color: var(--ph-dim);
    border-top: 1px dashed var(--ph-dark);
    margin-top: 6px;
    padding-top: 4px;
}

/* immagini dei lavori */
.workimg {
    display: block;
    max-width: min(560px, 88vw);
    margin: 12px 0;
    border: 2px solid var(--ph-dim);
    padding: 4px;
    filter: grayscale(0.15) contrast(1.08);
    box-shadow: 0 0 14px var(--glow-soft);
    cursor: zoom-in;
}

.videoframe {
    position: relative;
    max-width: min(640px, 90vw);
    aspect-ratio: 16 / 9;
    border: 2px solid var(--ph-dim);
    margin: 12px 0;
    box-shadow: 0 0 14px var(--glow-soft);
}
.videoframe iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* skill bars (riempite via JS coi caratteri █ e ░) */
.skillrow { display: block; }

/* ---------- ADMIN PANEL ---------- */

#adminpanel {
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.92);
    font-family: var(--font);
    color: var(--ph);
    padding: clamp(12px, 3vw, 36px);
    font-size: clamp(16px, 2vw, 20px);
    text-shadow: 0 0 4px var(--glow);
}

.adm-box {
    max-width: 880px;
    margin: 0 auto;
    border: 2px solid var(--ph);
    padding: 18px;
    background: var(--ph-bg);
    box-shadow: 0 0 24px var(--glow-soft);
}

.adm-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.adm-tab {
    border: 1px solid var(--ph-dim);
    padding: 4px 12px;
    cursor: pointer;
    background: transparent;
    color: var(--ph-dim);
    font-family: inherit;
    font-size: inherit;
}
.adm-tab.active, .adm-tab:hover { background: var(--ph); color: #000; text-shadow: none; }

#adminpanel label { display: block; margin: 12px 0 2px; color: var(--ph-dim); }
#adminpanel input[type=text],
#adminpanel input[type=password],
#adminpanel input[type=number],
#adminpanel input[type=email],
#adminpanel textarea,
#adminpanel select {
    width: 100%;
    background: #000;
    border: 1px solid var(--ph-dim);
    color: var(--ph);
    font-family: inherit;
    font-size: inherit;
    padding: 8px;
    outline: none;
}
#adminpanel textarea { min-height: 140px; resize: vertical; }
#adminpanel input:focus, #adminpanel textarea:focus { border-color: var(--ph); box-shadow: 0 0 8px var(--glow-soft); }

.adm-btn {
    background: var(--ph);
    color: #000;
    border: 0;
    font-family: inherit;
    font-size: inherit;
    padding: 8px 18px;
    margin: 14px 8px 0 0;
    cursor: pointer;
    text-shadow: none;
}
.adm-btn.ghost { background: transparent; color: var(--ph); border: 1px solid var(--ph-dim); }
.adm-btn.danger { background: transparent; color: var(--err); border: 1px solid var(--err); }
.adm-btn:hover { opacity: 0.85; }

.adm-list-item {
    border: 1px dashed var(--ph-dark);
    padding: 10px;
    margin: 10px 0;
}
.adm-thumb {
    width: 90px; height: 64px;
    object-fit: cover;
    border: 1px solid var(--ph-dim);
    margin: 4px 6px 0 0;
    vertical-align: top;
}
.adm-imgwrap { display: inline-block; position: relative; }
.adm-imgdel {
    position: absolute; top: 4px; right: 6px;
    background: #000; color: var(--err);
    border: 1px solid var(--err);
    cursor: pointer; font-family: inherit;
    line-height: 1; padding: 0 4px;
}
.adm-msg { margin-top: 10px; color: var(--ph-dim); min-height: 1.4em; }
.adm-msg.err { color: var(--err); }

/* lightbox immagini */
#lightbox {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(0,0,0,0.95);
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out;
}
#lightbox img { max-width: 94vw; max-height: 92vh; border: 2px solid var(--ph-dim); }

@media (max-width: 600px) {
    #screen { font-size: 16px; padding: 12px 10px; }
    .scanframe { max-width: 82vw; }
    .workimg { max-width: calc(100vw - 32px); }
    .videoframe { max-width: calc(100vw - 32px); }
    .adm-box { padding: 12px; }
    #adminpanel { padding: 8px; font-size: 16px; }
    .adm-tabs { gap: 5px; }
    .adm-tab { padding: 4px 8px; }
}

/* iOS: 100dvh evita il salto della barra del browser */
@supports (height: 100dvh) {
    #crt { height: 100dvh; }
}

/* ============================================================
   EASTER EGG MODES
   ============================================================ */

/* ---- COMMODORE 64: la mitica palette blu VIC-II ---- */
body.c64-mode {
    --ph:      #8688fb;
    --ph-dim:  #7c7ed4;
    --ph-dark: #4a4ca0;
    --glow:      rgba(134,136,251,0.5);
    --glow-soft: rgba(134,136,251,0.18);
    background: #3e31a4;
}
body.c64-mode #crt {
    background: #3e31a4;
}
body.c64-mode #screen {
    color: #7c7ed4;
    /* cornice azzurra come il bordo del C64 */
    box-shadow: inset 0 0 0 18px #7c7ed4;
}
body.c64-mode .crt-vignette,
body.c64-mode .crt-retrace,
body.c64-mode #crt-noise { display: none; }

/* ---- RITORNO AL FUTURO: flash bianco a 88 mph ---- */
body.timetravel #crt {
    animation: flash88 0.9s ease-out;
}
@keyframes flash88 {
    0%   { filter: brightness(1); }
    40%  { filter: brightness(1) hue-rotate(0deg); }
    55%  { filter: brightness(8) saturate(3) hue-rotate(180deg); }
    70%  { filter: brightness(12) invert(0.3); }
    100% { filter: brightness(1); }
}

/* ---- STRANGER THINGS: il Sottosopra ---- */
body.upside-down {
    --ph:      #ff2b2b;
    --ph-dim:  #b81d1d;
    --ph-dark: #5c0e0e;
    --glow:      rgba(255,43,43,0.55);
    --glow-soft: rgba(255,43,43,0.20);
}
body.upside-down #crt {
    transform: rotate(180deg);
    background: radial-gradient(ellipse at center, #1a0303 0%, #000 90%);
    transition: transform 2s cubic-bezier(.6,0,.4,1);
}
/* particelle di spore che fluttuano */
body.upside-down #screen::before {
    content: '';
    position: fixed; inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(2px 2px at 20% 30%, rgba(255,80,80,0.5), transparent),
        radial-gradient(1px 1px at 70% 60%, rgba(255,120,120,0.5), transparent),
        radial-gradient(2px 2px at 40% 80%, rgba(255,60,60,0.4), transparent),
        radial-gradient(1px 1px at 85% 25%, rgba(255,100,100,0.5), transparent);
    animation: spores 6s linear infinite;
    z-index: 4;
}
@keyframes spores {
    0%   { transform: translateY(0); opacity: 0.7; }
    100% { transform: translateY(-40px); opacity: 0.3; }
}

/* ---- SAMANTHA FOX: tinta fosforo sull'immagine luminanza->alpha ---- */
body.theme-green .scanframe img[src*="sam.png"],
body.theme-amber .scanframe img[src*="sam.png"],
.scanframe img[src*="sam.png"] {
    filter: none;
    width: min(360px, 78vw);
    height: auto;
    aspect-ratio: 320 / 200;
    background: var(--ph);
    -webkit-mask: url('../sam.png') center/contain no-repeat;
            mask: url('../sam.png') center/contain no-repeat;
    mix-blend-mode: normal;
    image-rendering: pixelated;
}

/* ---- MATRIX & time-travel canvas ---- */
#matrix-canvas {
    position: absolute; inset: 0;
    z-index: 4;
    pointer-events: none;
    opacity: 0.5;
}

@media (prefers-reduced-motion: reduce) {
    body.timetravel #crt { animation: none; }
    body.upside-down #crt { transition: none; }
    body.upside-down #screen::before { animation: none; }
}

/* ============================================================
   MINGO 9000 — overlay grafico (Demenza Artificiale)
   ============================================================ */
#mingo-overlay {
    position: fixed; inset: 0; z-index: 80;
    background: radial-gradient(ellipse at center, #1a0a00 0%, #000 75%);
    display: grid; place-items: center;
    font-family: var(--font);
    overflow: hidden;
}
#mingo-overlay.mingo-fade-in { animation: mingoFade 0.6s ease-out; }
@keyframes mingoFade { from { opacity: 0; } to { opacity: 1; } }

#mingo-stage {
    width: min(92vw, 560px);
    display: flex; flex-direction: column; align-items: center;
    gap: 18px; padding: 16px;
}
#mingo-face { width: min(60vw, 280px); will-change: transform; }
#mingo-svg { width: 100%; height: auto; display: block;
    filter: drop-shadow(0 0 24px rgba(255,120,0,0.35)); }

#mingo-caption {
    min-height: 4.5em;
    width: 100%;
    text-align: center;
    color: #ffcf6a;
    font-size: clamp(17px, 3.4vw, 24px);
    line-height: 1.4;
    text-shadow: 0 0 8px rgba(255,160,0,0.6);
    letter-spacing: 0.5px;
}
#mingo-caption.shout {
    color: #ff5a3c;
    font-weight: bold;
    text-shadow: 0 0 12px rgba(255,40,0,0.9);
    animation: mingoShout 0.12s steps(2) infinite;
}
@keyframes mingoShout {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

#mingo-form {
    display: flex; align-items: center; gap: 8px;
    width: 100%;
    border: 1px solid rgba(255,160,0,0.4);
    border-radius: 8px;
    padding: 8px 12px;
    background: rgba(20,8,0,0.6);
    box-shadow: 0 0 16px rgba(255,120,0,0.15) inset;
}
#mingo-prompt { color: #ff8a00; font-size: 14px; white-space: nowrap; }
#mingo-input {
    flex: 1; background: transparent; border: none; outline: none;
    color: #ffcf6a; font-family: var(--font); font-size: 18px;
}
#mingo-input::placeholder { color: rgba(255,160,0,0.4); }
#mingo-send {
    background: #ff8a00; color: #1a0a00; border: none;
    width: 38px; height: 34px; border-radius: 6px;
    font-size: 18px; cursor: pointer; font-family: var(--font);
}
#mingo-send:hover { background: #ffb000; }

#mingo-exit {
    background: none; border: none; color: rgba(255,160,0,0.55);
    font-family: var(--font); font-size: 14px; cursor: pointer;
    padding: 4px 10px;
}
#mingo-exit:hover { color: #ff8a00; }

/* mood tints sull'alone di fondo */
#mingo-overlay.mood-angry    { background: radial-gradient(ellipse at center, #2a0000 0%, #000 70%); }
#mingo-overlay.mood-blessing { background: radial-gradient(ellipse at center, #1a1200 0%, #000 75%); }

/* fallback senza GSAP: respiro via CSS */
.mingo-idle-css #mingo-glow { animation: mingoBreath 2.4s ease-in-out infinite; transform-origin: 200px 200px; }
@keyframes mingoBreath { 0%,100% { opacity: 0.6; transform: scale(1); } 50% { opacity: 0.95; transform: scale(1.12); } }
.mingo-idle-css.mood-angry #mingo-glow { animation: mingoBreath 0.18s steps(2) infinite; }

@media (prefers-reduced-motion: reduce) {
    #mingo-caption.shout { animation: none; }
    .mingo-idle-css #mingo-glow { animation: none; }
}

/* ============================================================
   EGG FX OVERLAYS (next-level)
   ============================================================ */
.egg-overlay {
    position: fixed; inset: 0; z-index: 85;
    display: grid; place-items: center; overflow: hidden;
    font-family: var(--font);
}
.egg-overlay canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.egg-close {
    position: fixed; top: 16px; right: 16px; z-index: 90;
    background: rgba(0,0,0,0.6); color: #fff;
    border: 1px solid rgba(255,255,255,0.3); border-radius: 6px;
    padding: 8px 14px; font-family: var(--font); font-size: 15px; cursor: pointer;
}
.egg-close:hover { background: rgba(255,255,255,0.15); }
.egg-fallback { text-align: center; color: #fff; z-index: 2; }
.egg-fallback h1 { font-size: clamp(28px,8vw,64px); }

/* BTTF */
.bttf-hud { position: fixed; bottom: 40px; left: 0; right: 0; text-align: center; z-index: 3; color: #ff7b00; pointer-events: none; }
.bttf-speed { font-size: clamp(48px,14vw,120px); font-weight: bold; text-shadow: 0 0 20px #ff5500; line-height: 1; }
.bttf-mph { font-size: 22px; letter-spacing: 4px; }
.bttf-dest { margin-top: 14px; color: #ff2200; font-size: 15px; letter-spacing: 2px; text-shadow: 0 0 10px #ff0000; }
.bttf-flash { position: fixed; inset: 0; background: #fff; z-index: 4; }
.bttf-flash-css { position: fixed; inset: 0; background: #fff; animation: bttfFlash 1.2s ease-out; }
@keyframes bttfFlash { 0%,60%{opacity:0;} 75%{opacity:1;} 100%{opacity:0;} }

/* Matrix */
.matrix-title { position: fixed; z-index: 3; color: #6f6; font-size: clamp(24px,6vw,52px);
    text-shadow: 0 0 16px #0f0; letter-spacing: 4px; pointer-events: none; }

/* Stranger Things */
.updown-txt { position: fixed; z-index: 3; color: #ff2233; font-size: clamp(28px,8vw,64px);
    font-weight: bold; letter-spacing: 6px; text-shadow: 0 0 20px #ff0033, 0 0 40px #ff0033; pointer-events: none;
    animation: updownFlicker 3s infinite; }
@keyframes updownFlicker { 0%,100%{opacity:1;} 48%{opacity:1;} 50%{opacity:0.4;} 52%{opacity:1;} }
.updown-fallback h1 { color: #ff2233; text-shadow: 0 0 20px #ff0033; font-size: clamp(28px,8vw,64px); }
body.upside-down-real #crt { transform: rotate(180deg); filter: hue-rotate(-30deg) saturate(1.4); transition: transform 1.5s; }

/* Jordan */
.jordan-hud { position: fixed; top: 20px; left: 0; right: 0; text-align: center; z-index: 3; color: #ff7733; font-size: 22px; pointer-events: none; }
.jordan-tip { font-size: 13px; color: #aaa; margin-top: 6px; }
.jordan-win { position: fixed; z-index: 5; text-align: center; color: #fff; background: rgba(0,0,0,0.8);
    padding: 30px 50px; border-radius: 14px; border: 2px solid #ff7733; }
.jordan-win h1 { font-size: clamp(30px,8vw,60px); color: #ff7733; }

/* C64 full screen */
#egg-c64 { background: #4036b5; padding: 6vmin; }
.c64-screen { width: 100%; max-width: 760px; aspect-ratio: 4/3; background: #4036b5;
    border: 8px solid #7c70d6; box-shadow: 0 0 0 4px #4036b5, 0 0 40px rgba(0,0,0,0.6);
    padding: 22px; overflow: hidden; }
.c64-inner { color: #a89fe6; font-size: clamp(13px,2.6vw,20px); line-height: 1.25; white-space: pre; }
.c64-cursor { display: inline-block; width: 0.7em; height: 1.05em; background: #a89fe6; animation: blink 0.7s steps(1) infinite; vertical-align: text-bottom; }

/* Sam Fox */
.samfox-wrap { text-align: center; color: #ffb000; }
.samfox-load { font-size: clamp(18px,4vw,28px); letter-spacing: 3px; margin-bottom: 18px; text-shadow: 0 0 10px #ff8a00; }
.samfox-img { width: min(80vw,420px); aspect-ratio: 320/200; margin: 0 auto;
    background: var(--ph, #ffb000);
    -webkit-mask: url('../sam.png') center/contain no-repeat; mask: url('../sam.png') center/contain no-repeat;
    image-rendering: pixelated; }
.samfox-cap { margin-top: 14px; font-size: 13px; color: rgba(255,176,0,0.6); letter-spacing: 2px; }

@media (prefers-reduced-motion: reduce) {
    body.upside-down-real #crt { transition: none; }
    .updown-txt { animation: none; }
}

/* ============================================================
   WINDOW MANAGER — finestre a fosfori dentro il CRT
   ============================================================ */
.bf-win {
    position: absolute;
    background: var(--ph-bg, #020a02);
    border: 2px solid var(--ph);
    box-shadow: 0 0 0 1px #000, 0 0 18px var(--glow-soft), inset 0 0 30px rgba(0,0,0,0.6);
    font-family: var(--font);
    color: var(--ph);
    display: flex; flex-direction: column;
    min-width: 220px; max-width: 96%;
    /* stato chiuso: collassato al centro, come un CRT che si accende */
    transform: scale(0.02, 0.001);
    opacity: 0;
    transform-origin: center center;
    will-change: transform, opacity;
}
.bf-win.bf-win-open {
    animation: bfWinOpen 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
}
@keyframes bfWinOpen {
    0%   { transform: scale(0.02, 0.001); opacity: 0; }
    45%  { transform: scale(1.0, 0.02);   opacity: 1; }   /* linea orizzontale */
    100% { transform: scale(1, 1);        opacity: 1; }
}
.bf-win.bf-win-closing {
    animation: bfWinClose 0.18s ease-in forwards;
}
@keyframes bfWinClose {
    0%   { transform: scale(1,1); opacity: 1; }
    55%  { transform: scale(1, 0.02); opacity: 1; }
    100% { transform: scale(0.02, 0.001); opacity: 0; }
}

.bf-win-bar {
    display: flex; align-items: center; gap: 6px;
    height: 26px; padding: 0 4px 0 8px;
    background: var(--ph);
    color: #000;
    cursor: grab;
    user-select: none;
    text-shadow: none;
    flex: none;
}
.bf-win-bar:active { cursor: grabbing; }
.bf-win-deco { font-size: 13px; opacity: 0.7; }
.bf-win-title {
    flex: 1; font-size: 14px; font-weight: bold;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    text-transform: uppercase; letter-spacing: 1px;
}
.bf-win-btns { display: flex; gap: 3px; }
.bf-win-btns button {
    width: 18px; height: 18px; line-height: 16px;
    background: var(--ph-bg, #020a02); color: var(--ph);
    border: 1px solid #000; font-family: var(--font); font-size: 12px;
    cursor: pointer; padding: 0; text-align: center;
}
.bf-win-btns button:hover { background: #000; color: var(--ph); }

.bf-win-body {
    flex: 1; overflow: auto; padding: 12px;
    font-size: clamp(14px, 1.8vw, 18px); line-height: 1.4;
    background:
        repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0,0,0,0.13) 2px 3px),
        var(--ph-bg, #020a02);
    scrollbar-width: thin; scrollbar-color: var(--ph-dark) transparent;
}
.bf-win-body::-webkit-scrollbar { width: 8px; }
.bf-win-body::-webkit-scrollbar-thumb { background: var(--ph-dark); }

.bf-win-rolled .bf-win-body { display: none; }
.bf-win-maxed {
    left: 6px !important; top: 6px !important;
    width: calc(100% - 12px) !important; height: calc(100% - 12px) !important;
}
.bf-win-maxed .bf-win-body { height: auto !important; }

/* contenuti tipici dentro le finestre */
.bf-win-body .wb-row { display: block; white-space: pre-wrap; }
.bf-win-body .wb-dim { color: var(--ph-dim); }
.bf-win-body .wb-center { text-align: center; }
.bf-win-body canvas { display: block; max-width: 100%; image-rendering: pixelated; }
.bf-win-body .wb-btn {
    display: inline-block; border: 1px solid var(--ph); padding: 3px 12px;
    margin: 4px 4px 0 0; cursor: pointer; background: transparent; color: var(--ph);
    font-family: var(--font); font-size: inherit;
}
.bf-win-body .wb-btn:hover { background: var(--ph); color: #000; }

@media (prefers-reduced-motion: reduce) {
    .bf-win.bf-win-open { animation: none; transform: scale(1,1); opacity: 1; }
    .bf-win.bf-win-closing { animation: none; opacity: 0; }
}

/* ============================================================
   EGG FX — stili dei contenuti DENTRO le finestre
   ============================================================ */
/* BTTF */
.bttf-win-hud { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center;
    color: var(--ph); font-size: 15px; text-shadow: 0 0 8px var(--glow); pointer-events: none; }
.bttf-win-hud .bttf-spd { font-size: 22px; }
.bttf-win-flash { position: absolute; inset: 0; background: var(--ph); opacity: 0; }

/* Jordan */
.jordan-win-hud { height: 22px; line-height: 22px; text-align: center; color: var(--ph);
    font-size: 13px; border-bottom: 1px solid var(--ph-dark); }

/* C64 window */
.c64-win { background: #3e31a4 !important; color: #b5a9ef !important; white-space: pre; }
.c64-win .wb-row { color: #b5a9ef; }
.c64-cur { display: inline-block; width: 0.7em; height: 1.05em; background: #b5a9ef;
    animation: blink 0.7s steps(1) infinite; vertical-align: text-bottom; }

/* Sam Fox */
.sf-wrap { text-align: center; color: var(--ph); padding: 14px; }
.sf-load { font-size: 18px; letter-spacing: 2px; margin-bottom: 14px; text-shadow: 0 0 8px var(--glow); }
.sf-img { width: 88%; aspect-ratio: 320/200; margin: 0 auto; background: var(--ph);
    -webkit-mask: url('../sam.png') center/contain no-repeat; mask: url('../sam.png') center/contain no-repeat;
    image-rendering: pixelated; }
.sf-cap { margin-top: 12px; font-size: 12px; color: var(--ph-dim); letter-spacing: 1px; }

/* CRT "infestato" per Stranger Things: il vetro stesso si distorce */
body.crt-haunted #screen { animation: crtHaunt 4s infinite; }
body.crt-haunted .crt-flicker { opacity: 0.08; }
@keyframes crtHaunt {
    0%,100% { filter: none; }
    47% { filter: none; }
    48% { filter: hue-rotate(-25deg) brightness(1.3) saturate(1.5); transform: translateX(2px); }
    50% { filter: hue-rotate(-40deg) brightness(0.8); transform: translateX(-3px); }
    52% { filter: none; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    body.crt-haunted #screen { animation: none; }
}

/* ============================================================
   MINGO 9000 — contenuto dentro la finestra (fosfori)
   ============================================================ */
.mingo-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; height: 100%; color: var(--ph); }
.mingo-face { width: 62%; max-width: 200px; color: var(--ph); }
.mingo-face #mingo-svg { width: 100%; height: auto; display: block;
    filter: drop-shadow(0 0 12px var(--glow-soft)); }
.mingo-caption { flex: 1; width: 100%; text-align: center; font-size: clamp(14px,3.2vw,18px);
    line-height: 1.4; min-height: 3em; text-shadow: 0 0 6px var(--glow); overflow-y: auto; }
.mingo-caption.shout { color: var(--err); font-weight: bold; text-shadow: 0 0 10px rgba(255,40,0,0.8);
    animation: mingoShout 0.12s steps(2) infinite; }
@keyframes mingoShout { 0%,100%{transform:scale(1);} 50%{transform:scale(1.04);} }
.mingo-form { display: flex; align-items: center; gap: 6px; width: 100%;
    border: 1px solid var(--ph-dim); padding: 5px 8px; }
.mingo-prompt { color: var(--ph-dim); }
.mingo-input { flex: 1; background: transparent; border: none; outline: none;
    color: var(--ph); font-family: var(--font); font-size: 16px; }
.mingo-input::placeholder { color: var(--ph-dark); }
.mingo-send { background: var(--ph); color: #000; border: none; width: 30px; height: 26px;
    cursor: pointer; font-family: var(--font); }
.mingo-angry { /* la finestra trema via GSAP */ }
@media (prefers-reduced-motion: reduce) { .mingo-caption.shout { animation: none; } }

/* ============================================================
   POWER-ON / POWER-OFF del monitor (ispirato al CRT TV pen)
   Si attiva aggiungendo .crt-powering al body al primo avvio.
   ============================================================ */
body.crt-powering #crt { animation: crtPowerOn 1.1s ease-out; }
@keyframes crtPowerOn {
    0%   { transform: scale(1, 0.002); filter: brightness(6); opacity: 1; }
    8%   { transform: scale(1, 0.002); filter: brightness(6); }
    18%  { transform: scale(1.04, 0.01); filter: brightness(4); }
    40%  { transform: scale(1, 0.7); filter: brightness(2); }
    100% { transform: scale(1, 1); filter: brightness(1); }
}
/* lampo orizzontale iniziale */
body.crt-powering #screen::after {
    content: ''; position: absolute; left: 0; right: 0; top: 50%;
    height: 3px; background: var(--ph); box-shadow: 0 0 30px 8px var(--glow);
    animation: crtScanline 0.5s ease-out forwards; z-index: 9; pointer-events: none;
}
@keyframes crtScanline {
    0% { opacity: 1; transform: scaleX(0.1); }
    40% { opacity: 1; transform: scaleX(1); }
    100% { opacity: 0; transform: scaleX(1); }
}
@media (prefers-reduced-motion: reduce) {
    body.crt-powering #crt { animation: none; }
    body.crt-powering #screen::after { animation: none; display: none; }
}
