/* 
 * T E X T R I S - Stylesheet
 * Responsive Retro-Cyberpunk, Synthwave & CRT Phosphor Terminal Styles
 */

/* ==========================================
   THEME VARIABLES
   ========================================== */

/* Synthwave Theme (Default) */
.theme-synthwave {
    --bg-color: #0b001a;
    --monitor-bezel-color: #1b122c;
    --monitor-border-color: #2b1d42;
    --text-color: #ffd2fc;
    --text-glow-color: rgba(255, 0, 160, 0.6);
    
    --accent-primary: #ff00a0;       /* Neon Pink */
    --accent-secondary: #00b8ff;     /* Cyan */
    --accent-tertiary: #ff9a00;      /* Sunset Orange */
    --accent-primary-rgb: 255, 0, 160;
    --accent-secondary-rgb: 0, 184, 255;
    
    --panel-bg: rgba(26, 9, 51, 0.55);
    --panel-border: rgba(255, 0, 160, 0.3);
    --grid-line-color: rgba(0, 184, 255, 0.15);
    --crt-flicker-opacity: 0.08;
    --scanline-opacity: 0.12;
    --bezel-glow: 0 0 30px rgba(255, 0, 160, 0.15);
}

/* Cyberpunk Theme */
.theme-cyberpunk {
    --bg-color: #0d0211;
    --monitor-bezel-color: #17181c;
    --monitor-border-color: #2f323a;
    --text-color: #00f0ff;
    --text-glow-color: rgba(0, 240, 255, 0.5);
    
    --accent-primary: #ff007f;       /* Hot Pink */
    --accent-secondary: #00f0ff;     /* Electric Cyan */
    --accent-tertiary: #fcee0a;      /* Cyberpunk Yellow */
    --accent-primary-rgb: 255, 0, 127;
    --accent-secondary-rgb: 0, 240, 255;
    
    --panel-bg: rgba(20, 1, 45, 0.6);
    --panel-border: rgba(0, 240, 255, 0.35);
    --grid-line-color: rgba(255, 0, 127, 0.18);
    --crt-flicker-opacity: 0.12;
    --scanline-opacity: 0.15;
    --bezel-glow: 0 0 35px rgba(0, 240, 255, 0.2);
}

/* Matrix Theme */
.theme-matrix {
    --bg-color: #000000;
    --monitor-bezel-color: #0a0d0a;
    --monitor-border-color: #161e16;
    --text-color: #00ff66;
    --text-glow-color: rgba(0, 255, 102, 0.6);
    
    --accent-primary: #00ff66;       /* Matrix Green */
    --accent-secondary: #008822;     /* Dark Green */
    --accent-tertiary: #a3ffc2;      /* Bright Matrix Green */
    --accent-primary-rgb: 0, 255, 102;
    --accent-secondary-rgb: 0, 136, 34;
    
    --panel-bg: rgba(0, 12, 3, 0.8);
    --panel-border: rgba(0, 255, 102, 0.3);
    --grid-line-color: rgba(0, 255, 102, 0.12);
    --crt-flicker-opacity: 0.06;
    --scanline-opacity: 0.22;
    --bezel-glow: 0 0 25px rgba(0, 255, 102, 0.12);
}

/* Amber Terminal Theme */
.theme-amber {
    --bg-color: #0d0702;
    --monitor-bezel-color: #1b1109;
    --monitor-border-color: #2d1e12;
    --text-color: #ffb000;
    --text-glow-color: rgba(255, 176, 0, 0.6);
    
    --accent-primary: #ffb000;       /* Phosphor Amber */
    --accent-secondary: #cc7e00;     /* Dark Amber */
    --accent-tertiary: #ffe3a3;      /* Light Amber */
    --accent-primary-rgb: 255, 176, 0;
    --accent-secondary-rgb: 204, 126, 0;
    
    --panel-bg: rgba(24, 12, 3, 0.7);
    --panel-border: rgba(255, 176, 0, 0.35);
    --grid-line-color: rgba(255, 176, 0, 0.15);
    --crt-flicker-opacity: 0.08;
    --scanline-opacity: 0.2;
    --bezel-glow: 0 0 25px rgba(255, 176, 0, 0.12);
}

/* ==========================================
   RESET & SYSTEM INITIALIZATION
   ========================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: #040108;
    color: var(--text-color);
    font-family: 'Share Tech Mono', monospace;
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ==========================================
   CRT DISPLAY SIMULATION
   ========================================== */
.crt-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.015) 0%, rgba(0, 0, 0, 0.45) 120%);
    pointer-events: none;
    z-index: 10;
}

.scanlines {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.22) 50%
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 9;
    opacity: var(--scanline-opacity);
}

.flicker {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(18, 16, 16, 0.12);
    opacity: 0;
    pointer-events: none;
    z-index: 8;
    animation: crt-flicker 0.15s infinite;
}

@keyframes crt-flicker {
    0% { opacity: calc(var(--crt-flicker-opacity) * 0.9); }
    50% { opacity: calc(var(--crt-flicker-opacity) * 1.1); }
    100% { opacity: calc(var(--crt-flicker-opacity) * 0.95); }
}

/* ==========================================
   RETRO COMPUTER HARDWARE CASE
   ========================================== */
.monitor-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 30px;
    box-sizing: border-box;
}

.monitor-bezel {
    position: relative;
    background: linear-gradient(135deg, var(--monitor-bezel-color) 0%, #0e0a16 100%);
    border: 14px solid var(--monitor-border-color);
    border-radius: 28px;
    padding: 20px 20px 15px 20px;
    box-shadow: 
        0 30px 60px -15px rgba(0, 0, 0, 0.85),
        inset 0 4px 10px rgba(255, 255, 255, 0.05),
        var(--bezel-glow);
    max-width: 1200px;
    width: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    border-bottom-width: 30px; /* Thick bottom border simulating structural casing */
    transition: all 0.3s ease;
}

.monitor-brand {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.25);
    text-align: center;
    margin-bottom: 12px;
    letter-spacing: 4px;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

.screen-container {
    position: relative;
    background: var(--bg-color);
    border: 6px solid #111;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.9);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    transform-origin: center;
}

/* Power Cutout Transition */
.screen-container.screen-off {
    transform: scaleY(0.005) scaleX(0);
    filter: brightness(0);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.85, 0, 0.15, 1), filter 0.2s linear, opacity 0.4s ease-out;
}

.screen-glass {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.9);
}

/* Simulated curved glass highlight */
.screen-glass::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0.3) 100%);
    pointer-events: none;
    z-index: 11;
}

/* ==========================================
   TERMINAL WINDOW LAYOUT
   ========================================== */
.terminal-window {
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 80vh;
}

/* Header */
.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: 12px;
    margin-bottom: 20px;
    text-shadow: 0 0 5px var(--text-glow-color);
}

.header-logo h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: 8px;
    color: var(--accent-primary);
    line-height: 1;
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--accent-secondary);
    letter-spacing: 1.5px;
    margin-top: 4px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-primary);
}

.status-dot.pulsing {
    animation: pulse-dot 1.5s infinite ease-in-out;
}

@keyframes pulse-dot {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 12px var(--accent-primary); }
    100% { transform: scale(0.8); opacity: 0.5; }
}

.badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border: 1px solid var(--accent-primary);
    border-radius: 4px;
    background: rgba(var(--accent-primary-rgb), 0.1);
}

/* ==========================================
   GRID LAYOUT (MAIN INTERFACE)
   ========================================== */
.terminal-grid {
    display: grid;
    grid-template-columns: 240px 1fr 240px;
    gap: 20px;
    flex-grow: 1;
}

/* Panels (Glassmorphism & CRT borders) */
.panel {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    box-shadow: inset 0 0 15px rgba(var(--accent-primary-rgb), 0.05),
                0 4px 15px rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    overflow: hidden;
    backdrop-filter: blur(2px);
    transition: border 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    border-color: var(--accent-primary);
    box-shadow: inset 0 0 20px rgba(var(--accent-primary-rgb), 0.1),
                0 0 15px rgba(var(--accent-primary-rgb), 0.15);
}

.panel-header {
    background: rgba(var(--accent-primary-rgb), 0.15);
    border-bottom: 1px solid var(--panel-border);
    padding: 6px 12px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-primary);
    text-shadow: 0 0 3px var(--text-glow-color);
}

.panel-body {
    padding: 15px;
    flex-grow: 1;
}

/* ==========================================
   LEFT SIDEBAR: GAME STATS & DATA
   ========================================== */
.next-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 140px;
}

#next-canvas {
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed var(--panel-border);
    border-radius: 4px;
}

.stats-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(var(--accent-secondary-rgb), 0.1);
    padding-bottom: 6px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--accent-secondary);
    letter-spacing: 1px;
}

.stat-value {
    font-family: 'VT323', monospace;
    font-size: 1.8rem;
    line-height: 1;
    color: var(--text-color);
    text-shadow: 0 0 5px var(--text-glow-color);
}

/* Current Word Buffer display */
.current-word-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
    padding: 8px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    color: var(--accent-tertiary);
    margin-bottom: 10px;
}

#word-buffer {
    color: var(--text-color);
    text-shadow: 0 0 5px var(--text-glow-color);
    letter-spacing: 2px;
}

.word-list {
    list-style: none;
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 5px;
}

.word-list::-webkit-scrollbar {
    width: 4px;
}

.word-list::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 2px;
}

.word-list li {
    padding: 4px 8px;
    background: rgba(var(--accent-secondary-rgb), 0.08);
    border-left: 2px solid var(--accent-secondary);
    font-family: 'Share Tech Mono', monospace;
    animation: slide-in 0.25s ease-out;
}

.empty-list-msg {
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
    border: none !important;
    background: transparent !important;
    font-style: italic;
    padding: 10px 0 !important;
}

@keyframes slide-in {
    from { transform: translateX(-15px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==========================================
   CENTER: MAIN TETRIS BOARD
   ========================================== */
.main-play-area {
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-board-wrapper {
    position: relative;
    padding: 6px;
    border: 2px solid var(--accent-primary);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 20px rgba(var(--accent-primary-rgb), 0.15);
    border-radius: 8px;
}

#game-canvas {
    display: block;
    background: rgba(0, 0, 0, 0.45);
    width: 300px;
    height: 600px;
    border-radius: 4px;
}

/* Sci-fi Decorative Brackets */
.bracket-tl, .bracket-tr, .bracket-bl, .bracket-br {
    position: absolute;
    width: 16px;
    height: 16px;
    border-color: var(--accent-secondary);
    border-style: solid;
    pointer-events: none;
}
.bracket-tl { top: -4px; left: -4px; border-width: 3px 0 0 3px; }
.bracket-tr { top: -4px; right: -4px; border-width: 3px 3px 0 0; }
.bracket-bl { bottom: -4px; left: -4px; border-width: 0 0 3px 3px; }
.bracket-br { bottom: -4px; right: -4px; border-width: 0 3px 3px 0; }

/* Overlays (Centering and styling) */
.game-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(var(--bg-color), 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    border-radius: 6px;
    padding: 20px;
}

.overlay-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.overlay-active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.overlay-content {
    text-align: center;
    width: 100%;
    max-width: 260px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.overlay-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--accent-primary);
    text-shadow: 0 0 10px var(--text-glow-color);
    letter-spacing: 4px;
}

.overlay-tagline {
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 5px;
}

/* Game Over overlay stats */
.game-over-stats {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.over-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.over-label {
    color: var(--accent-secondary);
}

.over-value {
    color: var(--accent-tertiary);
    font-weight: bold;
}

.leaderboard-submit-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 5px;
}

/* ==========================================
   RIGHT SIDEBAR: CONFIG & LEADERBOARD
   ========================================== */
.leaderboard-body ol {
    list-style: decimal-leading-zero;
    padding-left: 20px;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-body li {
    border-bottom: 1px dashed rgba(var(--accent-secondary-rgb), 0.1);
    padding-bottom: 4px;
}

.leaderboard-body li::marker {
    color: var(--accent-secondary);
    font-weight: bold;
}

.lb-name {
    margin-left: 8px;
    color: var(--text-color);
    font-weight: bold;
}

.lb-score {
    float: right;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    color: var(--accent-tertiary);
}

.settings-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.config-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.config-row label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-secondary);
    letter-spacing: 1.5px;
}

.vol-control {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Help Panel Keyboard styling */
.help-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.75rem;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.key {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--panel-border);
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--accent-primary);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* ==========================================
   INTERACTIVE RETRO COMPONENTS
   ========================================== */

/* Buttons */
.crt-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    transition: all 0.2s ease;
    outline: none;
    text-align: center;
}

.btn-primary {
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    box-shadow: 0 0 8px rgba(var(--accent-primary-rgb), 0.2);
    background: rgba(var(--accent-primary-rgb), 0.05);
}

.btn-primary:hover {
    background: var(--accent-primary);
    color: var(--bg-color);
    box-shadow: 0 0 15px var(--accent-primary);
}

.btn-secondary {
    color: var(--accent-secondary);
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.02);
}

.btn-secondary:hover {
    border-color: var(--accent-secondary);
    color: var(--text-color);
    box-shadow: 0 0 10px rgba(var(--accent-secondary-rgb), 0.2);
}

.btn-accent {
    color: var(--bg-color);
    background: var(--accent-tertiary);
    border: 1px solid var(--accent-tertiary);
    box-shadow: 0 0 8px rgba(255, 154, 0, 0.2);
}

.btn-accent:hover {
    background: transparent;
    color: var(--accent-tertiary);
    box-shadow: 0 0 15px var(--accent-tertiary);
}

/* Form Inputs */
.crt-input {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 4px;
    text-align: center;
    outline: none;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: border 0.2s ease;
}

.crt-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px rgba(var(--accent-primary-rgb), 0.2);
}

.crt-select {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
    padding: 6px 10px;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    text-transform: uppercase;
    transition: border 0.2s ease;
}

.crt-select:focus, .crt-select:hover {
    border-color: var(--accent-secondary);
    box-shadow: 0 0 8px rgba(var(--accent-secondary-rgb), 0.2);
}

.crt-select option {
    background: var(--bg-color);
    color: var(--text-color);
}

/* Volume Slider styling */
.crt-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.crt-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-secondary);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-secondary);
    transition: transform 0.1s ease;
}

.crt-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

/* ==========================================
   DIAGNOSTIC FOOTER
   ========================================== */
.terminal-footer {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--panel-border);
    padding-top: 10px;
    margin-top: 20px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
}

.diag-item {
    display: flex;
    gap: 4px;
}

.diag-label {
    color: var(--accent-secondary);
}

.text-green {
    color: var(--accent-primary);
}

/* ==========================================
   GLITCH ANIMATIONS
   ========================================== */
.glitch-text {
    position: relative;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
}

.glitch-text::before {
    left: 2px;
    text-shadow: -1px 0 #ff00c1;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch-text::after {
    left: -2px;
    text-shadow: -1px 0 #00ffe7, 0 1px #00ffe7;
    clip: rect(85px, 450px, 140px, 0);
    animation: glitch-anim2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% { clip: rect(15px, 9999px, 66px, 0); }
    10% { clip: rect(34px, 9999px, 55px, 0); }
    20% { clip: rect(78px, 9999px, 5px, 0); }
    30% { clip: rect(46px, 9999px, 60px, 0); }
    40% { clip: rect(90px, 9999px, 98px, 0); }
    50% { clip: rect(12px, 9999px, 34px, 0); }
    60% { clip: rect(76px, 9999px, 88px, 0); }
    70% { clip: rect(23px, 9999px, 67px, 0); }
    80% { clip: rect(54px, 9999px, 12px, 0); }
    90% { clip: rect(89px, 9999px, 43px, 0); }
    100% { clip: rect(10px, 9999px, 85px, 0); }
}

@keyframes glitch-anim2 {
    0% { clip: rect(65px, 9999px, 10px, 0); }
    11% { clip: rect(84px, 9999px, 30px, 0); }
    21% { clip: rect(12px, 9999px, 95px, 0); }
    31% { clip: rect(76px, 9999px, 20px, 0); }
    41% { clip: rect(34px, 9999px, 80px, 0); }
    51% { clip: rect(88px, 9999px, 44px, 0); }
    61% { clip: rect(10px, 9999px, 90px, 0); }
    71% { clip: rect(56px, 9999px, 15px, 0); }
    81% { clip: rect(23px, 9999px, 78px, 0); }
    91% { clip: rect(98px, 9999px, 53px, 0); }
    100% { clip: rect(45px, 9999px, 12px, 0); }
}

/* Pulsing title alert */
.neon-pulse-fast {
    animation: neon-pulse 1s infinite alternate;
}

@keyframes neon-pulse {
    from {
        text-shadow: 0 0 4px var(--text-glow-color),
                     0 0 10px var(--text-glow-color),
                     0 0 15px var(--accent-primary);
    }
    to {
        text-shadow: 0 0 8px var(--text-glow-color),
                     0 0 20px var(--text-glow-color),
                     0 0 30px var(--accent-primary);
    }
}

/* ==========================================
   BEZEL PHYSICAL BUTTONS & DIALS
   ========================================== */
.bezel-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 30px;
    padding-top: 15px;
    border-top: 2px solid rgba(255, 255, 255, 0.05);
    margin-top: 5px;
}

.bezel-dial-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.bezel-dial {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #444 0%, #222 100%);
    border: 2px solid #555;
    position: relative;
    cursor: pointer;
}

.dial-mark {
    position: absolute;
    top: 2px;
    left: calc(50% - 1px);
    width: 2px;
    height: 6px;
    background-color: #777;
    transform-origin: bottom center;
    transform: rotate(30deg); /* initial rotation pointer */
}

.bezel-dial-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.5rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 1.5px;
}

.power-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.led-light {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #300;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.5);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.led-light.active {
    background-color: #ff3300;
    box-shadow: 0 0 8px #ff3300, inset 0 1px 1px rgba(255,255,255,0.4);
}

.power-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 3px;
    border: 1px solid #444;
    background: linear-gradient(180deg, #3a3a3a 0%, #1a1a1a 100%);
    color: #888;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    outline: none;
    transition: all 0.1s ease;
}

.power-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* ==========================================
   RESPONSIVE DESIGN & SCALING
   ========================================== */

/* Tablet & Smaller Laptops */
@media (max-width: 1024px) {
    .monitor-bezel {
        border-width: 10px;
        border-bottom-width: 20px;
        border-radius: 20px;
        padding: 15px 15px 10px 15px;
    }
    
    .terminal-window {
        padding: 15px;
        min-height: 70vh;
    }
    
    .terminal-grid {
        grid-template-columns: 200px 1fr 200px;
        gap: 15px;
    }
    
    #game-canvas {
        width: 260px;
        height: 520px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}

/* Vertical / Single Column Layout for Mobile */
@media (max-width: 768px) {
    body {
        align-items: flex-start;
        padding: 10px 0;
    }
    
    .monitor-wrapper {
        padding: 5px;
    }
    
    .monitor-bezel {
        border-width: 6px;
        border-bottom-width: 12px;
        border-radius: 12px;
        padding: 10px 10px 8px 10px;
    }
    
    .terminal-window {
        padding: 10px;
        min-height: auto;
    }
    
    .terminal-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
        padding-bottom: 8px;
        margin-bottom: 12px;
    }
    
    .header-logo h1 {
        font-size: 1.6rem;
    }
    
    .header-status {
        align-self: flex-end;
    }
    
    .terminal-grid {
        grid-template-columns: 1fr;
        grid-template-areas: 
            "board"
            "left"
            "right";
        gap: 15px;
    }
    
    .left-hud {
        grid-area: left;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .left-hud .panel {
        margin-bottom: 0;
    }
    
    .right-hud {
        grid-area: right;
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .right-hud .panel {
        margin-bottom: 0;
    }
    
    .main-play-area {
        grid-area: board;
    }
    
    #game-canvas {
        width: 280px;
        height: 560px;
        max-height: 55vh;
    }
    
    .bezel-controls {
        gap: 15px;
        padding-top: 10px;
    }
}

/* Extra Small Mobile Devices */
@media (max-width: 480px) {
    .left-hud {
        grid-template-columns: 1fr;
    }
    
    #game-canvas {
        width: 240px;
        height: 480px;
    }
    
    .header-logo h1 {
        font-size: 1.4rem;
        letter-spacing: 4px;
    }
    
    .bezel-dial-group {
        display: none; /* Hide dials on tiny viewports to save space */
    }
}

/* ==========================================
   MOBILE CONTROLLER STYLING
   ========================================== */
.mobile-controls {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
    padding: 6px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px dashed var(--panel-border);
    border-radius: 6px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6);
}

@media (max-width: 768px) {
    .mobile-controls {
        display: grid;
    }
}

.ctrl-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 12px 6px;
    background: rgba(var(--accent-secondary-rgb), 0.08);
    border: 1px solid var(--panel-border);
    color: var(--accent-secondary);
    border-radius: 4px;
    text-align: center;
    cursor: pointer;
    text-shadow: 0 0 3px var(--text-glow-color);
    box-shadow: inset 0 0 5px rgba(var(--accent-secondary-rgb), 0.1);
    transition: all 0.1s ease;
    user-select: none;
    touch-action: manipulation;
    text-transform: uppercase;
}

.ctrl-btn:active {
    background: var(--accent-secondary);
    color: var(--bg-color);
    box-shadow: 0 0 12px var(--accent-secondary);
    border-color: var(--accent-secondary);
    transform: translateY(1px);
}

#textris-btn-left { grid-column: 1; }
#textris-btn-rotate { grid-column: 2; }
#textris-btn-right { grid-column: 3; }
#textris-btn-down { grid-column: 1 / span 2; }
#textris-btn-drop { grid-column: 3; }

