:root {
    --theme-rgb: 255, 51, 51;
    --bg-color: #030000;
    --term-color: rgb(var(--theme-rgb));
    --term-glow: rgba(var(--theme-rgb), 0.6);
    --text-main: #f0f0f0;
    --panel-bg: rgba(15, 0, 0, 0.4);
    --panel-border: rgba(var(--theme-rgb), 0.25);
    --font-term: 'Fira Code', monospace;
    --font-ui: 'Inter', sans-serif;
}


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

body {
    background-color: color-mix(in srgb, rgb(var(--theme-rgb)) 1.2%, #000);
    color: var(--text-main);
    font-family: var(--font-ui);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 2rem;
    background-image: radial-gradient(circle at center, color-mix(in srgb, rgb(var(--theme-rgb)) 6.5%, #000) 0%, color-mix(in srgb, rgb(var(--theme-rgb)) 1.2%, #000) 100%);
}

.container {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
    width: 100%;
    max-width: 1600px;
    height: 100%;
}

.right-column {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 1.5rem;
    height: 100%;
}

/* Glassmorphism / borders */
.panel {
    background: linear-gradient(135deg, color-mix(in srgb, rgba(var(--theme-rgb), 0.4) 10%, rgba(0, 0, 0, 0.4)) 0%, color-mix(in srgb, rgba(var(--theme-rgb), 0.6) 2%, rgba(0, 0, 0, 0.6)) 100%);
    border: 1px solid rgba(var(--theme-rgb), 0.15);
    border-top: 1px solid rgba(var(--theme-rgb), 0.4);
    border-left: 1px solid rgba(var(--theme-rgb), 0.3);
    border-radius: 20px;
    backdrop-filter: blur(24px) saturate(150%);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.6),
        inset 0 1px 2px rgba(255, 255, 255, 0.1),
        inset 0 0 20px rgba(var(--theme-rgb), 0.05);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease;
    overflow: hidden;
}

/* Apple liquid glass glossy edge reflection */
.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 20px;
    padding: 2px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0) 70%, rgba(var(--theme-rgb), 0.3) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 5;
}

.panel:hover {
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.7),
        inset 0 1px 2px rgba(255, 255, 255, 0.2),
        inset 0 0 30px rgba(var(--theme-rgb), 0.1);
    transform: translateY(-2px);
}

/* Terminal Styles */
.terminal-panel {
    background: color-mix(in srgb, rgb(var(--theme-rgb)) 0.8%, #000);
    border-radius: 20px;
    font-family: var(--font-term);
    color: var(--term-color);
    text-shadow: 0 0 6px var(--term-glow);
    padding: 2rem;
    overflow: hidden;
    position: relative;
}

/* Global CRT toggle effect on panels */
.panel.crt-active {
    box-shadow: inset 0 0 6rem rgba(0, 0, 0, 0.95), 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* Apply flicker animation to text elements and the panel itself so it matches origin exactly */
.panel.crt-active,
.panel.crt-active h1,
.panel.crt-active p,
.panel.crt-active .panel-label,
.panel.crt-active #terminal-input {
    animation: textFlicker 0.12s infinite alternate;
}

/* Hide liquid glass edge highlight when CRT is active */
.panel.crt-active::before {
    display: none;
}

@keyframes textFlicker {
    0% {
        opacity: 0.95;
        text-shadow: 0 0 4px var(--term-glow);
    }

    100% {
        opacity: 1;
        text-shadow: 0 0 10px var(--term-glow), 0 0 2px rgba(255, 255, 255, 0.4);
    }
}

#global-scanlines {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(transparent 50%,
            rgba(0, 0, 0, 0.35) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 9999;
}

#global-scanlines::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, transparent 50%, rgba(0, 0, 0, 0.5) 150%);
    pointer-events: none;
}

#global-scanlines.active {
    display: block;
}

.terminal-content {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--theme-rgb), 0.5) transparent;
    z-index: 2;
    padding-right: 10px;
}

.terminal-content::-webkit-scrollbar {
    width: 6px;
}

.terminal-content::-webkit-scrollbar-thumb {
    background: rgba(var(--theme-rgb), 0.5);
    border-radius: 3px;
}

#terminal-output {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    /* Prevent mid-word splitting unless necessary */
    word-break: normal;
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.terminal-input-line {
    display: flex;
    align-items: center;
    margin-top: 5px;
}

.prompt {
    margin-right: 0.8rem;
    font-weight: bold;
}

#terminal-input {
    background: transparent;
    border: none;
    color: var(--term-color);
    font-family: var(--font-term);
    font-size: 1rem;
    flex-grow: 1;
    outline: none;
    text-shadow: 0 0 5px var(--term-glow);
    caret-color: var(--term-color);
}

/* About Panel */
.about-panel {
    padding: 2.5rem;
    justify-content: center;
    overflow: hidden;
}

.about-panel h1 {
    font-size: 2.2rem;
    margin-bottom: 1.2rem;
    color: var(--term-color);
    text-shadow: 0 0 8px var(--term-glow);
    font-family: var(--font-term);
    font-weight: 700;
}

.placeholder-text {
    line-height: 1.7;
    color: #e0e0e0;
    font-size: 1.15rem;
    font-weight: 300;
}

.glow-accent {
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(var(--theme-rgb), 0.2) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* Tesseract Panel */
.tesseract-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    /* Canvas will fill */
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
}

.panel-label {
    position: absolute;
    bottom: 1rem;
    right: 1.5rem;
    font-family: var(--font-term);
    color: rgba(var(--theme-rgb), 0.5);
    font-size: 0.85rem;
    pointer-events: none;
    letter-spacing: 2px;
}

/* Mobile Responsive Layout */
@media (max-width: 850px) {
    body {
        padding: 1rem;
        height: 100dvh;
        align-items: stretch;
        overflow: hidden;
    }

    .container {
        grid-template-columns: 1fr;
        grid-template-rows: 1.25fr 1fr;
        gap: 1rem;
    }

    .right-column {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr;
        gap: 1rem;
    }

    .terminal-panel {
        padding: 1.25rem;
    }

    .about-panel {
        padding: 1.25rem;
    }

    .about-panel h1 {
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
    }

    .placeholder-text {
        font-size: 0.6rem;
        line-height: 1.2;
    }

    #terminal-output,
    .prompt {
        font-size: 0.85rem;
    }

    #terminal-input {
        font-size: 16px;
        /* 16px prevents iOS auto-zoom on focus */
    }

    .panel-label {
        font-size: 0.5rem;
        bottom: 0.5rem;
        right: 0.5rem;
        text-align: right;
        max-width: 90%;
    }
}
