:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --accent: #00ff88;
    --accent-hover: #00cc6a;
    --error: #ff4444;
    --warning: #ffaa00;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 16px;
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--accent);
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

.header-info {
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.header-info a {
    color: var(--accent);
    text-decoration: none;
}

.header-info a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.controls {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.control-value {
    color: var(--accent);
    font-weight: 700;
    font-family: "Courier New", monospace;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    background: #444;
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="range"]:hover {
    background: #555;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 255, 136, 0.3);
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 255, 136, 0.3);
}

.canvas-container {
    position: relative;
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(0, 255, 136, 0.2);
}

canvas {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.canvas-container canvas:last-child {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0.9;
    cursor: crosshair;
    touch-action: none;
}

.instructions {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    margin-top: 16px;
    font-size: 14px;
    line-height: 1.6;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.instructions h3 {
    margin-top: 0;
    color: var(--accent);
    font-size: 1.1rem;
}

.instructions ul {
    margin: 12px 0;
    padding-left: 20px;
}

.instructions li {
    margin: 8px 0;
}

.instructions strong {
    color: var(--accent);
}

.instructions .tip {
    background: rgba(0, 255, 136, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
    border-left: 4px solid var(--accent);
}

.performance {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 12px;
    margin-top: 16px;
    font-family: "Courier New", monospace;
    font-size: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.performance h4 {
    margin-top: 0;
    color: var(--accent);
    font-family: inherit;
}

.perf-metric {
    display: flex;
    justify-content: space-between;
    margin: 6px 0;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

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

.error {
    background: rgba(255, 68, 68, 0.1);
    border: 2px solid var(--error);
    color: var(--error);
    padding: 16px;
    border-radius: 12px;
    margin-top: 16px;
    display: none;
}

.error strong {
    color: var(--error);
}

.warning {
    background: rgba(255, 170, 0, 0.1);
    border: 2px solid var(--warning);
    color: var(--warning);
    padding: 16px;
    border-radius: 12px;
    margin-top: 16px;
    display: none;
}

.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.loading-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 255, 136, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.footer {
    text-align: center;
    margin-top: 32px;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer a {
    color: var(--accent);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .controls {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px;
    }

    .instructions {
        padding: 16px;
    }

    .canvas-container {
        max-width: 100%;
    }

    h1 {
        font-size: 1.8rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner {
        animation: none;
    }

    input[type="range"]::-webkit-slider-thumb {
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #333333;
        --text-primary: #ffffff;
        --accent: #00ff00;
    }
}

/* Test page specific styles */
.test-container {
    margin: 20px 0;
    padding: 20px;
    border: 1px solid #555;
    border-radius: 8px;
    background: var(--bg-secondary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.test-container.success { 
    border-color: var(--accent); 
    background: rgba(0, 255, 136, 0.1); 
}

.test-container.error { 
    border-color: var(--error); 
    background: rgba(255, 68, 68, 0.1); 
}

.test-container.warning { 
    border-color: var(--warning); 
    background: rgba(255, 170, 0, 0.1); 
}

.test-container canvas {
    border: 1px solid #666;
    margin: 10px 0;
    width: 180px;
    height: 180px;
    image-rendering: pixelated;
}

.test-container button {
    padding: 10px 20px;
    margin: 5px;
    border: none;
    border-radius: 4px;
    background: var(--accent);
    color: var(--bg-primary);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.test-container button:hover { 
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.test-container button:disabled { 
    background: #666; 
    cursor: not-allowed;
    transform: none;
}

.test-container pre {
    background: var(--bg-primary);
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
    border: 1px solid #444;
} 