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

body {
    font-family: "Courier New", Courier, monospace;
    background-color: #000;
    color: #fff;
    min-height: 100vh;
    padding: 10px;
    line-height: 1.4;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    border: 1px solid #fff;
    padding: 15px;
}

h1 {
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
    font-size: 1.2rem;
    border-bottom: 1px solid #fff;
    padding-bottom: 10px;
}

h2, h3 {
    text-transform: uppercase;
    margin-bottom: 10px;
    font-size: 1rem;
    border-bottom: 1px dashed #333;
    padding-bottom: 5px;
    color: #ccc;
}

/* Video Section */
.video-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto 15px;
    border: 1px solid #333;
    background: #000;
}

#webcam {
    width: 100%;
    height: auto;
    display: block;
    transform: scaleX(-1); /* Mirror the video */
    filter: grayscale(100%) contrast(1.2);
}

#output-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: scaleX(-1); /* Mirror the canvas */
}

/* Status Bar */
.status-bar {
    text-align: center;
    margin-bottom: 15px;
    border: 1px solid #333;
    padding: 5px;
    font-family: monospace;
    font-size: 0.8rem;
}

#status {
    display: inline-block;
    font-weight: bold;
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.collection-section,
.training-section,
.prediction-section,
.audio-section,
.preset-section,
.network-section {
    border: 1px solid #333;
    padding: 10px;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.gesture-control {
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: space-between;
}

/* Buttons */
button {
    font-family: "Courier New", Courier, monospace;
    background: #000;
    color: #fff;
    border: 1px solid #fff;
    padding: 8px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

button:hover:not(:disabled) {
    background: #fff;
    color: #000;
}

button:active:not(:disabled) {
    background: #ccc;
}

button:disabled {
    border-color: #333;
    color: #333;
    cursor: not-allowed;
}

.collect-btn {
    flex: 1;
    min-width: 0; /* Allows flex item to shrink below content size */
}

/* Highlight specific buttons implicitly by class if needed, but keeping it minimal */
.collect-btn.collecting {
    background: #fff;
    color: #000;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.count {
    font-family: monospace;
    min-width: 80px;
    text-align: right;
    font-size: 0.8rem;
}

/* Prediction Display */
.prediction-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.prediction-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gesture-label {
    min-width: 50px;
    font-size: 0.8rem;
}

.confidence-bar {
    flex: 1;
    height: 12px;
    border: 1px solid #333;
    background: #000;
    position: relative;
}

.confidence-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.1s linear;
}

.probability {
    min-width: 40px;
    text-align: right;
    font-family: monospace;
    font-size: 0.8rem;
}

.predicted-label {
    text-align: center;
    font-size: 1rem;
    font-weight: bold;
    border: 1px solid #fff;
    padding: 10px;
    margin-top: 5px;
    text-transform: uppercase;
}

/* Audio Section */
.audio-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.audio-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.audio-btn, .randomize-btn {
    flex: 1;
    min-width: 120px;
}

.audio-btn.active {
    background: #fff;
    color: #000;
}

.audio-status {
    padding: 5px;
    border: 1px solid #333;
    text-align: center;
    font-size: 0.7rem;
    margin-top: 5px;
}

/* Parameters & XY Pads */
.audio-parameters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.parameter-control {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.parameter-label {
    font-size: 0.7rem;
    text-transform: uppercase;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.parameter-slider {
    flex: 1;
    height: 2px;
    background: #333;
    -webkit-appearance: none;
    appearance: none;
}

.parameter-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    background: #000;
    border: 1px solid #fff;
    cursor: pointer;
}

.parameter-value {
    min-width: 35px;
    text-align: right;
    font-family: monospace;
    font-size: 0.7rem;
}

/* XY Pads */
.xy-pad-container {
    border: 1px solid #333;
    padding: 8px;
}

.xy-pad-label {
    text-align: center;
    margin-bottom: 5px;
    font-size: 0.7rem;
}

.xy-pad {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #000;
    border: 1px solid #fff;
    cursor: crosshair;
    touch-action: none;
}

.xy-pad::before,
.xy-pad::after {
    content: '';
    position: absolute;
    background: #333;
}

/* Crosshairs */
.xy-pad::before {
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
}

.xy-pad::after {
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
}

.xy-pad-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #fff;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.xy-pad-values {
    margin-top: 5px;
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #ccc;
}

/* Preset Section */
.preset-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.preset-state {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.preset-indicator {
    text-align: center;
    font-size: 0.7rem;
    color: #666;
    border: 1px solid #333;
    padding: 2px;
}

.preset-indicator.saved {
    color: #fff;
    border-color: #fff;
}

.interpolation-status {
    text-align: center;
    padding: 5px;
    font-size: 0.7rem;
    color: #666;
    margin-bottom: 8px;
    border: 1px solid transparent;
}

.interpolation-status.active {
    color: #fff;
    border-color: #fff;
}

.clear-presets-btn {
    margin-top: 8px;
    border-color: #666;
    color: #999;
    font-size: 0.7rem;
}

.clear-presets-btn:hover {
    border-color: #f00;
    color: #f00;
    background: transparent;
}

/* Network Status */
.network-status {
    text-align: center;
    padding: 5px;
    font-size: 0.7rem;
}

.network-status.connected { color: #fff; }
.network-status.disconnected { color: #666; }
.network-status.error { color: #fff; text-decoration: underline; }

.instructions {
    margin-top: 20px;
    border: 1px solid #333;
    padding: 10px;
    font-size: 0.8rem;
}

.instructions ol {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 5px;
}

/* Mode Toggle Section */
.mode-section {
    margin-bottom: 20px;
}

.mode-toggle-btn {
    width: 100%;
    padding: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: #111;
    border: 2px solid #0f0;
    color: #0f0;
    cursor: pointer;
    font-family: "Courier New", Courier, monospace;
    transition: all 0.2s ease;
}

.mode-toggle-btn:hover {
    background: #0a1a0a;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.mode-toggle-btn:active {
    background: #0f0;
    color: #000;
}

/* Mobile */
@media (max-width: 600px) {
    .container { border: none; padding: 10px; }
    .xy-pad-handle { width: 15px; height: 15px; } /* Larger touch target */
    button { font-size: 0.75rem; }
}
