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

html, body {
    width: 100%; height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Share Tech Mono', monospace;
    user-select: none;
    overflow: hidden;
}

/* ── Stage: vertical flex column holding monitor + powerbar ── */
.skin-stage {
    display: flex;
    flex-direction: column;
    align-items: center;

    /* ── Theater-mode zoom ──
       Timing values are exposed as custom properties for easy tweaking.
       --theater-zoom-in  : duration when zooming INTO the screen  (slow, cinematic)
       --theater-zoom-out : duration when zooming OUT to full view  (quicker, snappy)
       --theater-ease-in  : easing curve for zoom-in
       --theater-ease-out : easing curve for zoom-out                              */
    --theater-zoom-in:  1.8s;
    --theater-zoom-out: 0.5s;
    --theater-ease-in:  cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --theater-ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);

    /* transform is applied by JS; transition starts with the zoom-in timing
       and is swapped to zoom-out timing via the .theater-out helper class. */
    transition: transform var(--theater-zoom-in) var(--theater-ease-in);
    will-change: transform;
}
/* When zooming OUT, swap to the faster duration/easing */
.skin-stage.theater-out {
    transition: transform var(--theater-zoom-out) var(--theater-ease-out);
}

/* ── Monitor layer ── */
.skin-monitor-wrap {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}
.skin-monitor-img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    /* SVG images bleed black bg — don't clip, let it show as dark room */
}

/* ── Screen area: absolutely positioned over the monitor's glass ── */
.skin-screen-area {
    position: absolute;
    overflow: hidden;
    /* Subtle perspective warp matching CRT curvature */
    transform: perspective(2400px) rotateX(0.35deg);
    transform-origin: 50% 50%;
}

/* ── DOM text stage ── */
.crt-stage {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 1;
    background: var(--crt-bg, #010a04);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;   /* bottom-anchored — Portal style (default) */
    overflow: hidden;
    contain: layout style paint;
    /* padding set via JS from SKIN config pad values */
}

.crt-stage.flow-top { justify-content: flex-start; }   /* canvas.stackFrom: "top" */

/* ── Zone container — positioned region within the stage ── */
.crt-zone {
    position: absolute;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    contain: layout style paint;
    /* padding/font inherited from stage */
}
.crt-zone.flow-bottom { justify-content: flex-end; }
.crt-zone.flow-top    { justify-content: flex-start; }

/* ── Individual text line ── */
.crt-line {
    font-family: 'VT323', monospace;
    font-size: var(--crt-font-size, 19px);
    line-height: var(--crt-line-height, 1.22);
    color: var(--crt-fg, #2aba7a);
    white-space: pre;
    min-height: 1em;
    min-height: 1lh;   /* blank lyric lines take exactly one line's height */
    text-shadow:
        0 0 8px  var(--crt-glow-near, rgba(42,186,122,0.6)),
        0 0 20px var(--crt-glow-mid,  rgba(42,186,122,0.15)),
        0 0 40px var(--crt-glow-far,  rgba(42,186,122,0.05));
    opacity: 1;
    transition: opacity 1.5s ease-out;
}

.crt-line.align-left   { text-align: left; }
.crt-line.align-center { text-align: center; }
.crt-line.align-right  { text-align: right; }

/* Age fading — oldest lines dim out */
.crt-line.age-01 { opacity: 0.85; }
.crt-line.age-02 { opacity: 0.65; }
.crt-line.age-03 { opacity: 0.45; }
.crt-line.age-04 { opacity: 0.30; }
.crt-line.age-05 { opacity: 0.18; }
.crt-line.age-06 { opacity: 0.14; }
.crt-line.age-07 { opacity: 0.11; }
.crt-line.age-08 { opacity: 0.08; }
.crt-line.age-09 { opacity: 0.05; }
.crt-line.age-10 { opacity: 0.00; }

/* Blinking cursor on the active streaming line */
.crt-cursor::after {
    content: '█';
    animation: cursor-blink 0.6s step-end infinite;
}
@keyframes cursor-blink {
    0%, 100% { opacity: 1; } 50% { opacity: 0; }
}

/* ── ASCII scroll overlay — sits above the stage, below CRT effects ── */
.crt-scroll-layer {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 1;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: hidden;
    contain: layout style paint;
    /* No background — reveal is managed by the content wrapper's clip-path */
    /* Padding is set by JS to match stageEl padding */
}
/* Content wrapper — carries the opaque background and the clip-path reveal.
   will-change promotes this to its own GPU compositing layer so clip-path
   animation runs on the compositor thread, not the main thread. */
.crt-scroll-content {
    background: transparent;
    will-change: clip-path;
    contain: layout style paint;
}
.crt-scroll-layer .crt-line {
    white-space: pre;
    opacity: 1 !important;
    /* Single glow layer instead of three — cuts text-shadow paint cost ~60%.
       The outer blurs (20px, 40px) are the expensive ones; one tight glow
       still reads as phosphor but at a fraction of the compositing work. */
    text-shadow: 0 0 8px var(--crt-glow-near, rgba(42,186,122,0.6));
}

/* CRT effect layers — promoted to GPU compositing layers via will-change
   so they are rasterized once and never re-painted when stage content changes */
.crt-scanlines {
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
            0deg,
            transparent, transparent 2px,
            rgba(0,0,0,0.13) 2px, rgba(0,0,0,0.13) 4px
    );
    pointer-events: none;
    z-index: 2;
    will-change: transform;
}
.crt-rgb {
    position: absolute; inset: 0;
    background-image: repeating-linear-gradient(
            90deg,
            rgba(255,80,80,0.022) 0px, rgba(255,80,80,0.022) 1px,
            rgba(80,255,80,0.022) 1px, rgba(80,255,80,0.022) 2px,
            rgba(80,80,255,0.022) 2px, rgba(80,80,255,0.022) 3px
    );
    pointer-events: none;
    z-index: 3;
    will-change: transform;
}
.crt-vignette {
    position: absolute; inset: 0;
    background: radial-gradient(
            ellipse at 50% 50%,
            transparent 50%,
            rgba(0,0,0,0.30) 78%,
            rgba(0,0,0,0.60) 100%
    );
    pointer-events: none;
    z-index: 4;
    will-change: transform;
}
.crt-glare {
    position: absolute;
    top: -25%; left: -15%;
    width: 55%; height: 55%;
    background: radial-gradient(
            ellipse at 35% 35%,
            rgba(255,255,255,0.018) 0%,
            transparent 65%
    );
    pointer-events: none;
    border-radius: 50%;
    z-index: 5;
    transform: rotate(-12deg);
}

/* ── Load overlay (inside screen area) ── */
.load-overlay {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: #010a04;
    z-index: 10;
    gap: 10px;
    padding: 16px;
    transition: opacity 0.6s ease;
}
.load-overlay.fading { opacity: 0; pointer-events: none; }
.load-overlay.gone   { display: none; }

.load-logo {
    font-family: 'VT323', monospace;
    font-size: clamp(20px, 4cqi, 52px);
    color: #2aba7a;
    text-shadow: 0 0 24px rgba(42,186,122,0.7);
    letter-spacing: 6px;
}
.load-sub {
    font-size: clamp(8px, 1.2cqi, 14px);
    color: #1a5a38;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.load-drop-row {
    display: flex; gap: 10px;
}
.load-drop {
    position: relative;
    border: 1px solid #1a3a28;
    border-radius: 4px;
    padding: clamp(6px, 2.5cqi, 14px) clamp(12px, 3cqi, 24px);
    cursor: pointer;
    transition: border-color 0.2s;
    text-align: center;
    background: rgba(42,186,122,0.02);
}
.load-drop:hover, .load-drop.drag-over { border-color: #2aba7a; }
.load-drop.has-file { border-color: #2aba7a; background: rgba(42,186,122,0.05); }
.load-drop input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.load-drop-icon { display: block; font-size: clamp(16px, 2.5cqi, 28px); color: #1a5a38; margin-bottom: 4px; }
.load-drop-label { font-size: clamp(8px, 1.1cqi, 12px); color: #2aba7a; letter-spacing: 1px; }
.load-drop-hint  { font-size: clamp(7px, 0.9cqi, 10px); color: #1a4a30; letter-spacing: 1px; margin-top: 2px; }
.load-status {
    font-size: clamp(7px, 1cqi, 11px);
    color: #1a5a38; letter-spacing: 2px; min-height: 14px;
}
.load-start-btn {
    background: transparent;
    border: 1px solid #2aba7a;
    color: #2aba7a;
    font-family: 'VT323', monospace;
    font-size: clamp(14px, 2.5cqi, 24px);
    letter-spacing: 3px;
    padding: clamp(3px, 0.7cqi, 8px) clamp(14px, 3cqi, 28px);
    cursor: pointer;
    display: none;
    transition: all 0.2s;
}
.load-start-btn:hover { background: rgba(42,186,122,0.1); }
.load-start-btn.visible { display: block; }

/* Phones: the screen glass is only ~300px wide, so trim the overlay down
   to the essentials and let it scroll rather than clip the Play button. */
.load-overlay { justify-content: safe center; overflow-y: auto; }
@media (max-width: 600px) {
    .load-overlay  { gap: 4px; padding: 6px; }
    .load-sub, .load-drop-hint, .load-drop-icon { display: none; }
    .load-logo     { letter-spacing: 3px; }
    .load-drop     { padding: 6px 8px; }
    .load-drop-row { gap: 6px; }
}

/* ── Power center layer ── */
.skin-powerbar-wrap {
    position: relative;
    flex-shrink: 0;
    /* Negative margin so it visually tucks under the monitor's bottom plastic lip */
    margin-top: -8.5%;
}
.skin-powerbar-img {
    display: block;
    width: 100%;
    height: auto;
    z-index: 1;
    pointer-events: none;
}

/* ── Controls: overlaid on the open strip recess ── */
.skin-controls-area {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 0 6px;
}

/* LED indicator */
.ctl-led {
    width: clamp(6px, 0.5vw, 9px);
    height: clamp(6px, 0.5vw, 9px);
    border-radius: 50%;
    background: #1a2a10;
    flex-shrink: 0;
    transition: all 0.3s;
}
.ctl-led.on {
    background: #7cd246;
    box-shadow: 0 0 5px rgba(124,210,70,0.9), 0 0 10px rgba(124,210,70,0.5);
    animation: led-breathe 3s ease-in-out infinite;
}
.ctl-led.paused {
    background: #e8a030;
    box-shadow: 0 0 5px rgba(232,160,48,0.9);
    animation: led-blink 1s step-end infinite;
}
@keyframes led-breathe { 0%,100%{opacity:1} 50%{opacity:0.45} }
@keyframes led-blink   { 0%,100%{opacity:1} 50%{opacity:0.05} }

/* Strip buttons */
.strip-btn {
    background: linear-gradient(180deg, #252318 0%, #151210 100%);
    border: 1px solid #080604;
    border-radius: 2px;
    box-shadow: 0 1px 0 #040302, inset 0 1px 0 rgba(255,255,255,0.05);
    color: #5a5030;
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(6px, 0.55vw, 10px);
    letter-spacing: 0.5px;
    padding: 1px 5px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 60ms;
    outline: none;
    line-height: 1.8;
}
.strip-btn:hover  { color: #b09848; border-color: #201c0e; }
.strip-btn:active { transform: translateY(1px); box-shadow: none; }
.strip-btn.lit {
    color: #7cd246;
    border-color: #253a12;
    box-shadow: 0 1px 0 #040302, 0 0 4px rgba(124,210,70,0.25);
}

/* Divider */
.strip-div {
    width: 1px; height: 55%;
    background: #181410;
    flex-shrink: 0;
    margin: 0 2px;
}

/* Progress strip */
.strip-progress {
    flex: 1;
    height: clamp(2px, 0.25vw, 4px);
    background: #080604;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    border: 1px solid #151210;
    min-width: 30px;
}
.strip-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2a3a18, #7cd246);
    border-radius: 2px;
    width: 0%;
    box-shadow: 0 0 3px rgba(124,210,70,0.4);
    transition: width 0.1s linear;
}

/* Time display */
.strip-time {
    font-family: 'VT323', monospace;
    font-size: clamp(10px, 1.1vw, 18px);
    color: #7cd246;
    letter-spacing: 2px;
    text-shadow: 0 0 5px rgba(124,210,70,0.6);
    background: #040602;
    border: 1px solid #161e0c;
    border-radius: 2px;
    padding: 0 4px;
    min-width: clamp(38px, 3.8vw, 64px);
    text-align: center;
    flex-shrink: 0;
}

/* Theater mode checkbox */
.strip-theater {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
}
.strip-theater input[type="checkbox"] {
    display: none;
}
.theater-check {
    font-family: 'VT323', monospace;
    font-size: clamp(10px, 1vw, 16px);
    color: #1a3a28;
    transition: color 0.2s;
}
.strip-theater input:checked ~ .theater-check {
    color: #7cd246;
    text-shadow: 0 0 4px rgba(124,210,70,0.5);
}
.theater-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(6px, 0.55vw, 10px);
    color: #5a5030;
    letter-spacing: 0.5px;
    transition: color 0.2s;
}
.strip-theater:hover .theater-text { color: #b09848; }

