* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; background: #06090b; overflow: hidden; }

/* ══════════════════════════════════════════
   MONITOR — tutto schermo, bordo minimo
══════════════════════════════════════════ */
#crt {
  --ph:       #35ff70;
  --ph-mid:   rgba(53,255,112,0.72);
  --ph-dim:   rgba(53,255,112,0.48);
  --ph-glow:  rgba(53,255,112,0.20);
  --ph-bg:    #051108;
  --ph-ink:   #04230e;

  position:      fixed;
  inset:         8px;
  border:        2px solid #35352f;
  border-radius: 12px;
  background:    radial-gradient(ellipse at 50% 38%, #0b1e10 0%, var(--ph-bg) 62%, #020703 100%);
  overflow:      hidden;
  font-family:   'JetBrains Mono', monospace;
  box-shadow:    inset 0 0 70px rgba(0,0,0,.85),
                 inset 0 0 8px rgba(0,0,0,.9),
                 0 0 42px rgba(53,255,112,.06);
  animation:     crtOn 2s ease-out both;
}
/* Accensione: puntino → riga → apertura → sfarfallio → stabile */
@keyframes crtOn {
  0%   { transform: scale(.004,.006); filter: brightness(0);   opacity: 0; }
  6%   { transform: scale(.004,.006); filter: brightness(5);   opacity: 1; }
  20%  { transform: scale(.004,.006); filter: brightness(4); }
  26%  { transform: scale(.06,.006);  filter: brightness(4.5); }
  46%  { transform: scale(1,.006);    filter: brightness(3); }
  56%  { transform: scale(1,.006);    filter: brightness(3.5); }
  70%  { transform: scale(1,1);       filter: brightness(1.7); }
  76%  { filter: brightness(.65); }
  82%  { filter: brightness(1.35); }
  88%  { filter: brightness(.85); }
  94%  { filter: brightness(1.12); }
  100% { transform: scale(1,1);       filter: brightness(1); }
}
#crt ::selection { background: var(--ph); color: var(--ph-ink); }

#crt::before {
  content: ''; position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background: repeating-linear-gradient(to bottom,
    rgba(0,0,0,0) 0 2px, rgba(0,0,0,.20) 2px 4px);
}
#crt::after {
  content: ''; position: absolute; inset: 0; z-index: 7; pointer-events: none;
  background: radial-gradient(ellipse at 26% 12%,
    rgba(255,255,255,.07) 0%, rgba(255,255,255,0) 40%);
}
.crt-roll {
  position: absolute; left: 0; right: 0; height: 22%; z-index: 5; pointer-events: none;
  background: linear-gradient(to bottom,
    rgba(53,255,112,0) 0%, rgba(53,255,112,.045) 50%, rgba(53,255,112,0) 100%);
  animation: crtRoll 6s linear infinite;
}
@keyframes crtRoll { 0% { top: -25%; } 100% { top: 120%; } }

/* ══════════════════════════════════════════
   VIEWPORT + LOG
══════════════════════════════════════════ */
#crt-view {
  position:   absolute;
  inset:      0 0 40px 0;
  overflow-y: auto;
  padding:    22px 26px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(53,255,112,.35) transparent;
}
#crt-view::-webkit-scrollbar { width: 8px; }
#crt-view::-webkit-scrollbar-thumb { background: rgba(53,255,112,.3); border-radius: 4px; }

#crt-log {
  color:       var(--ph-mid);
  font-size:   clamp(11px, 1.5vw, 14px);
  line-height: 1.5;
  letter-spacing: .04em;
  white-space: pre-wrap;
  word-break:  break-word;
  text-shadow: 0 0 4px var(--ph-glow), 0 0 9px var(--ph-glow);
  animation:   crtFlicker 4s steps(60) infinite;
  max-width:   1000px;
  margin:      0 auto;
}
#crt-log > div { min-height: 1.5em; }
@keyframes crtFlicker {
  0%,91%,94%,100% { opacity: 1; }
  92% { opacity: .85; }
  97% { opacity: .94; }
}

#crt-log .b   { color: var(--ph); font-weight: 700; }
#crt-log .d   { color: var(--ph-dim); }
#crt-log .inv {
  background: var(--ph); color: var(--ph-ink);
  font-weight: 700; text-shadow: none;
  display: inline-block; padding: 0 8px;
}
#crt-log a {
  color: var(--ph); text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer;
}
#crt-log a:hover { background: rgba(53,255,112,.12); }
#crt-log pre {
  font-family: inherit;
  color:       #23c452;
  font-size:   clamp(7px, 1.6vw, 13px);
  line-height: 1.18;
  overflow-x:  hidden;
  text-shadow: 0 0 4px var(--ph-glow);
}

/* menu orizzontale */
.crt-menu { letter-spacing: .04em; }
.crt-menu span {
  display: inline-block; margin-right: 6px; padding: 1px 6px;
  color: var(--ph); font-weight: 700; cursor: pointer;
}
.crt-menu span.sel {
  background: var(--ph); color: var(--ph-ink); text-shadow: none;
}

/* immagine dot-matrix */
.crt-img { text-align: center; }
.crt-img canvas {
  max-width: min(320px, 82%);
  image-rendering: pixelated;
  filter: contrast(1.05);
  opacity: .92;
}

/* cursore */
.crt-cur {
  display: inline-block; width: .62em; height: 1.05em;
  background: var(--ph); vertical-align: -0.15em; margin-left: 1px;
  box-shadow: 0 0 6px var(--ph-glow);
  animation: crtBlink .5s step-end infinite;
}
@keyframes crtBlink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* riga di comando (attiva e congelate nello storico) */
#cmdline, .cmdline-frozen { color: var(--ph); font-weight: 700; }
#cmdline .u, .cmdline-frozen .u { color: var(--ph-dim); font-weight: 400; }

/* input nascosto per la tastiera mobile */
#kbd {
  position: fixed; bottom: 0; left: 0;
  width: 1px; height: 1px;
  opacity: 0; border: 0; padding: 0;
  background: transparent; color: transparent;
  pointer-events: none;
}

/* ══════════════════════════════════════════
   BARRA DI STATO
══════════════════════════════════════════ */
#crt-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 40px; z-index: 8;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 14px;
  background: rgba(53,255,112,.10);
  border-top: 1px solid rgba(53,255,112,.3);
  font-size: clamp(8px, 1.2vw, 10px);
  letter-spacing: .08em;
  color: var(--ph-dim);
  text-shadow: 0 0 4px var(--ph-glow);
  overflow: hidden; white-space: nowrap;
}
#crt-bar .l { display: flex; gap: 16px; min-width: 0; overflow: hidden; }
#crt-bar .r { display: flex; gap: 8px; flex-shrink: 0; }
.crt-key {
  background: var(--ph); color: var(--ph-ink);
  border: none; cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: inherit; font-weight: 700; letter-spacing: .08em;
  padding: 4px 10px; text-shadow: none;
  transition: filter .15s;
}
.crt-key:hover { filter: brightness(1.2); }
.crt-key.off { background: rgba(53,255,112,.25); color: var(--ph); }

@media (prefers-reduced-motion: reduce) {
  #crt, #crt-log, .crt-roll, .crt-cur { animation: none; }
}
@media (max-width: 640px) {
  #crt { inset: 0; border-radius: 0; border-width: 0 0 0 0; }
  #crt-view { padding: 14px 12px 12px; }
  #crt-bar .hide-m { display: none; }
}
