@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;700&display=swap');

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

body {
    background-color: #08090c;
    background-image: radial-gradient(circle at 50% 50%, #11141b 0%, #08090c 100%);
    color: #00ff66;
    font-family: 'Fira Code', monospace;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Subtle Scanline CRT Effect */
body::after {
    content: " ";
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    aspect-ratio: auto;
    background-size: 100% 4px, 3px 100%;
    z-index: 99999;
    pointer-events: none;
}

/* Main Terminal Container */
.terminal-window {
    width: 1140px;
    max-width: 98%;
    background-color: #0c0d12;
    border: 1px solid #1f2430;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 255, 102, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Window Header Bar */
.terminal-header {
    background-color: #161821;
    border-bottom: 1px solid #1f2430;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    position: relative;
}

.terminal-dots {
    display: flex;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.dot.red { background-color: #ff5f56; }
.dot.yellow { background-color: #ffbd2e; }
.dot.green { background-color: #27c93f; }

.terminal-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: #6c7387;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Inner Layout */
.terminal-content {
    display: flex;
    flex-direction: row;
    height: 520px;
}

/* Common Panel Header */
.panel-header {
    width: 100%;
    color: #6c7387;
    font-size: 11px;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Left Panel: Input & Downscaled visual */
.left-panel {
    flex: 0 0 320px;
    border-right: 1px solid #1f2430;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-wrapper {
    position: relative;
    border: 2px solid #232834;
    border-radius: 6px;
    padding: 4px;
    background-color: #000;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
    transition: border-color 0.3s;
    margin-bottom: 8px;
    max-width: 100%;
}

.canvas-wrapper:hover {
    border-color: #00ff66;
}

#draw {
    display: block;
    cursor: crosshair;
    max-width: 100%;
    height: auto;
}

.scaled-canvas-wrapper {
    border: 2px solid #232834;
    border-radius: 6px;
    padding: 4px;
    background-color: #000;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

#scaled-canvas {
    width: 84px;
    height: 84px;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Center Panel: ASCII Array representation */
.center-panel {
    flex: 0 0 380px;
    border-right: 1px solid #1f2430;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.matrix-box {
    background-color: #07080b;
    border: 1px solid #1f2430;
    border-radius: 6px;
    flex: 1;
    width: 100%;
    padding: 12px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.9);
}

#ascii-matrix {
    font-family: 'Fira Code', monospace;
    font-size: 8px;
    line-height: 1.05;
    color: #00ff66;
    text-shadow: 0 0 3px rgba(0, 255, 102, 0.4);
    margin: 0;
    padding: 0;
    word-spacing: -2px;
    user-select: none;
}

/* Right Panel: Terminal Output Display */
.right-panel {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.console-box {
    background-color: #07080b;
    border: 1px solid #1f2430;
    border-radius: 6px;
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.9);
}

.console-line {
    font-size: 12px;
    margin-bottom: 4px;
    word-break: break-all;
}

.text-dim { color: #526070; }
.text-success { color: #00ff66; text-shadow: 0 0 4px rgba(0, 255, 102, 0.4); }
.text-warning { color: #ffbd2e; text-shadow: 0 0 4px rgba(255, 189, 46, 0.4); }
.text-error { color: #ff5f56; text-shadow: 0 0 4px rgba(255, 95, 86, 0.4); }

.separator {
    color: #1f2430;
    font-size: 11px;
    margin: 4px 0;
    user-select: none;
}

/* Dynamic predictions classes */
.predictions-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 4px 0;
}

.pred-row {
    display: flex;
    font-size: 12px;
    align-items: center;
    color: rgba(0, 255, 102, 0.6);
    transition: color 0.2s, font-weight 0.2s;
}

.pred-row.highlight {
    color: #00ff66;
    font-weight: bold;
    text-shadow: 0 0 6px rgba(0, 255, 102, 0.5);
}

.pred-label {
    width: 80px;
    flex-shrink: 0;
}

.pred-bar {
    font-family: monospace;
    margin-right: 12px;
    letter-spacing: 0.5px;
    user-select: none;
}

.pred-pct {
    margin-left: auto;
    width: 60px;
    text-align: right;
}

/* Most Confident */
.most-confident {
    font-size: 16px;
    font-weight: bold;
    color: #00ff66;
    text-shadow: 0 0 8px rgba(0, 255, 102, 0.4);
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-top: 1px dashed #1f2430;
    margin-top: 4px;
}

.highlight-val {
    color: #08090c;
    background-color: #00ff66;
    padding: 1px 8px;
    border-radius: 3px;
    margin: 0 8px;
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.5);
}

.pct-val {
    font-size: 13px;
    color: rgba(0, 255, 102, 0.8);
}

.controls {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-top: 8px;
}

/* Buttons style */
.btn {
    flex: 1;
    background: transparent;
    border: 1px solid #00ff66;
    color: #00ff66;
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    font-weight: 500;
    padding: 10px;
    cursor: pointer;
    border-radius: 4px;
    background-color: rgba(0, 255, 102, 0.02);
    transition: all 0.2s ease;
}

.btn:hover {
    background-color: rgba(0, 255, 102, 0.1);
    box-shadow: 0 0 12px rgba(0, 255, 102, 0.3);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 0 0 4px rgba(0, 255, 102, 0.2);
}

/* Cursor blink */
.blink {
    animation: blinker 1s linear infinite;
    font-weight: bold;
}

@keyframes blinker {
    50% { opacity: 0; }
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 992px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        padding: 16px 8px;
    }
    
    .terminal-window {
        width: 100%;
        max-width: 100%;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    }
    
    .terminal-content {
        flex-direction: column;
        height: auto;
    }
    
    .left-panel, .center-panel, .right-panel {
        flex: 1 1 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid #1f2430;
        padding: 24px 16px;
    }
    
    .right-panel {
        border-bottom: none;
    }
    
    .canvas-wrapper, .scaled-canvas-wrapper {
        margin-left: auto;
        margin-right: auto;
    }
    
    .matrix-box {
        padding: 24px 8px;
    }
    
    #ascii-matrix {
        font-size: 2.3vw; /* Scales dynamically with screen width on mobile */
        line-height: 1.05;
        letter-spacing: -0.5px;
    }
}

@media (max-width: 480px) {
    #ascii-matrix {
        font-size: 2.8vw; /* Slightly larger scale for very small viewports */
    }
    
    .pred-bar {
        display: none; /* Hide progress bar visual on extra small screens to save space */
    }
    
    .pred-row {
        justify-content: space-between;
    }
}
