@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400;700&family=Inter:wght@300;400;500;600;700&display=swap');

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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e9ecef;
    min-height: 100vh;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.header h1 {
    font-family: 'Courier Prime', monospace;
    font-size: 3rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 0 30px #00d4ff, 0 0 60px rgba(0, 212, 255, 0.3);
    margin-bottom: 10px;
    letter-spacing: -1px;
}

.header .subtitle {
    font-size: 1.2rem;
    color: #a8a8a8;
    font-weight: 400;
    margin-bottom: 20px;
}

.badge {
    position: absolute;
    top: 0;
    right: 0;
    background: linear-gradient(45deg, #00d4ff, #0099cc);
    border-radius: 25px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.4);
    transition: transform 0.3s ease;
}

.badge:hover {
    transform: translateY(-2px);
}

.badge a {
    color: #1a1a2e;
    text-decoration: none;
}

.drawing-status {
    text-align: center;
    font-family: 'Courier Prime', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.drawing-status.ready-to-draw {
    background: rgba(0, 212, 255, 0.2);
    color: #00d4ff;
}

.drawing-status.drawing {
    background: rgba(255, 215, 0, 0.2);
    color: #ffd700;
}

.drawing-status.analyzing {
    background: rgba(255, 87, 51, 0.2);
    color: #ff5733;
}

.drawing-status.classification-complete {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 450px;
    gap: 40px;
}

.left-panel, .right-panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Enhanced Canvas Section */
.canvas-section, .network-section, .prediction-section, .info-section, .tribute-section, .learning-section {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 28px;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 212, 255, 0.25);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.canvas-section.centerpiece {
    border: 2px solid #00d4ff;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.3);
}

.canvas-label {
    font-family: 'Courier Prime', monospace;
    font-size: 1.5rem;
    color: #00d4ff;
    text-align: center;
    margin-bottom: 20px;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.canvas-section h3, .network-section h3, .prediction-section h3, .info-section h3, .tribute-section h3, .learning-section h3 {
    font-family: 'Courier Prime', monospace;
    font-size: 1.4rem;
    color: #00d4ff;
    margin-bottom: 24px;
    text-align: center;
}

.canvas-container {
    position: relative;
    margin: 0 auto 30px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border: 3px solid #00d4ff;
    transition: all 0.3s ease;
    width: 420px;
    height: 420px;
}

.canvas-container.drawing-active {
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.6), 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: #ffd700;
}

#drawingCanvas, #gridCanvas {
    position: absolute;
    top: 0;
    left: 0;
    background: #000000;
    cursor: crosshair;
    border-radius: 13px;
    width: 420px;
    height: 420px;
}

#gridCanvas {
    pointer-events: none;
    z-index: 1;
}

#drawingCanvas {
    z-index: 2;
}

#networkCanvas {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 16px;
    width: 100%;
    height: 300px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

/* Enhanced Drawing Controls */
.drawing-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-large {
    padding: 18px 36px;
    font-size: 1.1rem;
    min-width: 220px;
}

.btn-danger {
    background: linear-gradient(45deg, #ff4757, #ff3838);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.4);
}

.btn-danger:hover {
    background: linear-gradient(45deg, #ff3838, #ff2e2e);
    box-shadow: 0 6px 20px rgba(255, 71, 87, 0.6);
    transform: translateY(-2px);
}

.btn-secondary {
    background: linear-gradient(45deg, #4dabf7, #339af0);
    color: white;
    box-shadow: 0 4px 15px rgba(77, 171, 247, 0.4);
}

.btn-secondary:hover {
    background: linear-gradient(45deg, #339af0, #228be6);
    box-shadow: 0 6px 20px rgba(77, 171, 247, 0.6);
    transform: translateY(-2px);
}

.btn-secondary.active {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #1a1a2e;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.5);
}

.grid-icon {
    margin-right: 8px;
    font-size: 1.2rem;
}

/* Brush Controls */
.brush-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(0, 212, 255, 0.3);
}

.brush-controls label {
    color: #c9c9c9;
    font-weight: 500;
}

.brush-controls input[type="range"] {
    width: 120px;
    height: 8px;
    border-radius: 4px;
    background: #333;
    outline: none;
    -webkit-appearance: none;
}

.brush-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #00d4ff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.5);
}

.brush-preview {
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    transition: all 0.3s ease;
}

#brushValue {
    font-family: 'Courier Prime', monospace;
    color: #00d4ff;
    font-weight: 600;
    min-width: 40px;
}

/* Auto-predict Toggle */
.auto-predict-control {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    color: #e9ecef;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #00d4ff;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Example Digits */
.example-digits {
    margin-top: 20px;
}

.example-digits h4 {
    color: #c9c9c9;
    margin-bottom: 15px;
    font-size: 1rem;
    text-align: center;
}

.digit-examples {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.example-digit {
    width: 36px;
    height: 36px;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid #00d4ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier Prime', monospace;
    font-weight: 700;
    font-size: 1.2rem;
    color: #00d4ff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.example-digit:hover {
    background: rgba(0, 212, 255, 0.3);
    transform: scale(1.1);
}

/* Enhanced Predictions */
.main-prediction {
    text-align: center;
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 212, 255, 0.05));
    border-radius: 16px;
    border: 1px solid rgba(0, 212, 255, 0.3);
}

.predicted-digit {
    font-family: 'Courier Prime', monospace;
    font-size: 5rem;
    font-weight: 700;
    color: #00d4ff;
    text-shadow: 0 0 30px #00d4ff;
    transition: transform 0.3s ease;
}

.confidence {
    font-size: 1.8rem;
    color: #ffffff;
    margin-top: 15px;
    font-weight: 600;
}

.top-predictions {
    margin-bottom: 25px;
}

.top-predictions h4 {
    color: #c9c9c9;
    margin-bottom: 15px;
    font-size: 1rem;
}

.top-prediction {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 3px solid transparent;
}

.top-prediction.rank-1 {
    border-left-color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
}

.top-prediction.rank-2 {
    border-left-color: #c9c9c9;
}

.top-prediction.rank-3 {
    border-left-color: #cd7f32;
}

.rank {
    font-size: 0.8rem;
    color: #a8a8a8;
    min-width: 25px;
}

.digit {
    font-family: 'Courier Prime', monospace;
    font-weight: 700;
    font-size: 1.2rem;
    color: #00d4ff;
    flex: 1;
    text-align: center;
}

.percentage {
    font-family: 'Courier Prime', monospace;
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}

.confidence-bars h4 {
    color: #c9c9c9;
    margin-bottom: 15px;
    font-size: 1rem;
}

.prediction-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.prediction-label {
    font-family: 'Courier Prime', monospace;
    font-weight: 600;
    color: #00d4ff;
    min-width: 20px;
}

.prediction-bar-bg {
    flex: 1;
    height: 10px;
    background: #333;
    border-radius: 5px;
    overflow: hidden;
}

.prediction-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00d4ff, #ffd700);
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border-radius: 5px;
}

.prediction-percentage {
    font-family: 'Courier Prime', monospace;
    color: #c9c9c9;
    min-width: 40px;
    font-size: 0.9rem;
    text-align: right;
}

.processing {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.neural-thinking {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #ffd700;
    font-weight: 600;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    background: #ffd700;
    border-radius: 50%;
    animation: thinking 1.4s ease-in-out infinite both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes thinking {
    0%, 80%, 100% {
        transform: scale(0);
    } 40% {
        transform: scale(1);
    }
}

/* Prediction History */
.prediction-history h4 {
    color: #c9c9c9;
    margin-bottom: 15px;
    font-size: 1rem;
}

.history-list {
    max-height: 150px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    margin-bottom: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    font-size: 0.9rem;
}

.history-digit {
    font-family: 'Courier Prime', monospace;
    font-weight: 700;
    color: #00d4ff;
    min-width: 20px;
}

.history-confidence {
    font-family: 'Courier Prime', monospace;
    color: #ffd700;
    min-width: 50px;
    text-align: center;
}

.history-time {
    color: #a8a8a8;
    font-size: 0.8rem;
}

/* Learning Features */
.learning-section {
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.learning-section h4 {
    color: #ffd700;
    margin-bottom: 12px;
    font-size: 1rem;
}

.drawing-tips {
    margin-bottom: 20px;
}

#currentTip {
    color: #e9ecef;
    font-style: italic;
    transition: opacity 0.3s ease;
    line-height: 1.4;
}

.accuracy-tracker {
    margin-bottom: 20px;
}

.accuracy-display {
    text-align: center;
}

#accuracyScore {
    font-family: 'Courier Prime', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffd700;
    display: block;
    margin-bottom: 8px;
}

.accuracy-bar {
    width: 100%;
    height: 8px;
    background: #333;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.accuracy-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4757, #ffd700, #2ecc71);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 4px;
}

#accuracyStats {
    color: #a8a8a8;
    font-size: 0.85rem;
}

.challenge-mode {
    color: #e9ecef;
}

#dailyChallenge {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid #ffd700;
    font-style: italic;
}

/* Info Sections */
.mnist-facts {
    margin-bottom: 20px;
    padding: 18px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    border-left: 4px solid #00d4ff;
}

.mnist-facts p {
    line-height: 1.6;
    color: #e9ecef;
    transition: opacity 0.3s ease;
}

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

.stat {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-label {
    color: #c9c9c9;
}

.stat-value {
    font-family: 'Courier Prime', monospace;
    color: #00d4ff;
    font-weight: 600;
}

.tribute-section blockquote {
    font-style: italic;
    font-size: 1rem;
    line-height: 1.6;
    color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #ffd700;
    transition: opacity 0.3s ease;
}

.network-info {
    margin-top: 16px;
}

.layer-info {
    display: flex;
    justify-content: space-around;
    font-size: 0.9rem;
    color: #c9c9c9;
}

.layer-label {
    text-align: center;
    font-family: 'Courier Prime', monospace;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .canvas-container {
        width: 350px;
        height: 350px;
    }
    
    #drawingCanvas, #gridCanvas {
        width: 350px;
        height: 350px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .badge {
        position: static;
        display: inline-block;
        margin-top: 15px;
    }
    
    .canvas-section, .network-section, .prediction-section, .info-section, .tribute-section, .learning-section {
        padding: 20px;
    }
    
    .canvas-container {
        width: 280px;
        height: 280px;
    }
    
    #drawingCanvas, #gridCanvas {
        width: 280px;
        height: 280px;
    }
    
    .brush-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .btn-large {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .drawing-controls {
        align-items: stretch;
    }
    
    .predicted-digit {
        font-size: 4rem;
    }
}

@media (max-width: 480px) {
    .canvas-container {
        width: 250px;
        height: 250px;
    }
    
    #drawingCanvas, #gridCanvas {
        width: 250px;
        height: 250px;
    }
    
    .header h1 {
        font-size: 1.7rem;
    }
    
    .predicted-digit {
        font-size: 3rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #00d4ff;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #00b8e6;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    .btn, .example-digit, .switch {
        min-height: 44px;
        min-width: 44px;
    }
    
    .brush-controls input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
}