:root {
    --bg-main: #0a0a0c;
    --bg-card: #151518;
    --bg-elevated: #1c1c22;
    --primary: #8b5cf6;
    --primary-hover: #a78bfa;
    --accent: #2dd4bf;
    --red: #ef4444;
    --red-glow: #e94560;
    --amber: #f59e0b;
    --green: #22c55e;
    --teal-glow: #2dd4bf;
    --purple-glow: #a78bfa;
    --text-primary: #f3f4f6;
    --text-muted: #9ca3af;
    --glass-border: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #0a0a0c;
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(45, 212, 191, 0.04) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 900px;
    padding: 2rem 1.5rem;
}

/* ── Header ──────────────────────────────────────────── */
header {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeIn 0.8s ease-out;
}

h1 {
    font-family: 'Press Start 2P', monospace;
    font-size: 2.8rem;
    margin: 0 0 0.6rem;
    background: linear-gradient(135deg, #fff 0%, #c4b5fd 50%, #2dd4bf 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.05em;
    text-shadow: 0 0 40px rgba(139, 92, 246, 0.3);
}

.tagline {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ── Cartridge Shelf ─────────────────────────────────── */
.cartridge-shelf {
    margin-bottom: 0.5rem;
    animation: slideUp 0.5s ease-out;
}

.shelf-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    color: #444;
    letter-spacing: 0.15em;
    margin-bottom: 0.8rem;
    padding-left: 0.5rem;
}

.cartridges {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.cartridge {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.cartridge:hover {
    transform: translateY(-40px) scale(2.2);
    z-index: 50;
    filter: drop-shadow(0 20px 40px rgba(0,0,0,0.8));
}

@media (hover: none) {
    .cartridge:hover {
        transform: translateY(-8px) scale(1.03);
        z-index: auto;
        filter: none;
    }
}

.cartridge.inserted {
    transform: translateY(30px) scale(0.95);
    opacity: 0.5;
    pointer-events: none;
}

.cartridge.inserted .cart-svg {
    filter: brightness(0.5) blur(1px);
}

.cart-svg {
    width: 140px;
    height: auto;
    transition: filter 0.3s;
}

.cart-status {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.45rem;
    color: #555;
    margin-top: 0.4rem;
    text-align: center;
    transition: color 0.3s;
}

.cartridge:hover .cart-status { color: #888; }
.cartridge.inserted .cart-status { color: var(--accent); }

/* ── Console Body ────────────────────────────────────── */
.console-body {
    position: relative;
    animation: fadeIn 0.6s ease-out 0.2s both;
}

.console-top-svg {
    width: 100%;
    height: 120px;
    display: block;
}

.console-screen {
    background: #111;
    border: 3px solid #222;
    border-top: none;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.screen-bezel {
    background: #0c0c0e;
    margin: 0 8px 8px;
    border-radius: 0 0 8px 8px;
    border: 2px solid #1a1a20;
    overflow: hidden;
    position: relative;
}

.screen-inner {
    min-height: 300px;
    position: relative;
}

/* ── Screen Off State ────────────────────────────────── */
.screen-off {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    position: relative;
    overflow: hidden;
}

.screen-off p {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.75rem;
    color: #333;
    animation: blink 1.5s infinite;
    z-index: 1;
}

.screen-static {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.01) 2px,
        rgba(255, 255, 255, 0.01) 4px
    );
    animation: scanlines 0.1s linear infinite;
    pointer-events: none;
}

/* CRT scanline overlay for active screen */
.screen-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
    pointer-events: none;
    z-index: 10;
}

/* ── Demo Panels (inside the screen) ─────────────────── */
.demo-panel {
    padding: 1.5rem;
    animation: screenOn 0.4s ease-out;
}

.demo-header {
    margin-bottom: 1rem;
}

.demo-header h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.85rem;
    margin: 0 0 0.5rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.demo-header p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.demo-stats {
    padding: 0.8rem 0 0;
    border-top: 1px solid rgba(255,255,255,0.05);
    color: var(--text-muted);
    font-family: monospace;
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
}

.demo-stats strong { color: var(--accent); font-weight: normal; }

/* ── Password Demo ───────────────────────────────────── */
.pw-field {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.pw-field input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.7rem 1rem;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    transition: border-color 0.2s;
}

.pw-field input:focus { outline: none; border-color: var(--red-glow); box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15); }

.pw-toggle {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0 0.7rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
}

.strength-meter { margin-bottom: 1rem; }

.meter-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.4rem;
}

.meter-fill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    transition: width 0.3s ease, background 0.3s ease;
    background: var(--red);
}

.meter-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.char-heatmap {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    min-height: 48px;
    align-items: flex-end;
}

.hm-char { display: flex; flex-direction: column; align-items: center; gap: 2px; }

.hm-bar {
    width: 22px;
    min-height: 4px;
    max-height: 40px;
    border-radius: 2px 2px 0 0;
    transition: height 0.2s, background 0.2s;
}

.hm-letter {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── Music Demo ──────────────────────────────────────── */
.music-controls {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.play-btn {
    background: var(--green);
    color: #000;
    border: none;
    padding: 0.55rem 1.2rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.play-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.play-btn:disabled { background: #2a2a35; color: #4b5563; cursor: not-allowed; transform: none; }

.stop-btn {
    background: var(--red);
    color: white;
    border: none;
    padding: 0.55rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.stop-btn:disabled { background: #2a2a35; color: #4b5563; cursor: not-allowed; }

.music-options {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.music-options label { display: inline-flex; align-items: center; gap: 0.3rem; }
.music-options input[type="range"] { width: 70px; accent-color: var(--primary); }
.music-options select { background: var(--bg-main); color: var(--text-primary); border: 1px solid var(--glass-border); border-radius: 4px; padding: 0.15rem 0.3rem; font-size: 0.75rem; }

.piano-roll {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    height: 150px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 6px;
}

.note-bar {
    width: 5px;
    border-radius: 2px 2px 0 0;
    background: var(--primary);
    transition: height 0.1s;
    opacity: 0.5;
}

.note-bar.playing {
    opacity: 1;
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
}

/* ── Shakespeare Demo ────────────────────────────────── */
.input-area { margin-bottom: 0.8rem; }

textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    resize: vertical;
    box-sizing: border-box;
    margin-bottom: 0.6rem;
}

textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15); }

.controls { display: flex; gap: 0.6rem; }

.controls button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.controls button:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
.controls button:disabled { background: #2a2a35; color: #4b5563; cursor: not-allowed; transform: none; }

.output-area {
    padding: 1rem;
    min-height: 150px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
}

#shk-output {
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
    color: #e2e8f0;
}

/* ── Footer ──────────────────────────────────────────── */
footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
}

footer p {
    font-family: 'Press Start 2P', monospace;
    color: #333;
    font-size: 0.5rem;
    letter-spacing: 0.05em;
}

/* ── Animations ──────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes scanlines {
    0% { background-position: 0 0; }
    100% { background-position: 0 4px; }
}

@keyframes screenOn {
    0% { opacity: 0; transform: scaleY(0.01) scaleX(0.8); }
    40% { opacity: 1; transform: scaleY(0.01) scaleX(0.8); }
    60% { transform: scaleY(1) scaleX(0.8); }
    100% { transform: scaleY(1) scaleX(1); }
}

/* Power LED glow when active */
.power-on { fill: #22c55e !important; filter: drop-shadow(0 0 6px #22c55e); }
