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

body {
    background: #000;
    overflow: hidden;
    cursor: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body.settings-open { cursor: default; }

#webcam {
    display: none;
}

#camera-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    z-index: 0;
    display: none;
    opacity: 0.35;
}

#projection-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

#debug-canvas {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 320px;
    height: 180px;
    border: 1px solid #333;
    display: none;
    z-index: 100;
}

#calibration-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 200;
    display: none;
}

/* ── Settings Panel ── */

#settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 500;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
#settings-overlay.open {
    display: flex;
}

#settings-panel {
    background: rgba(24, 24, 28, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 28px 32px 24px;
    width: min(440px, 90vw);
    max-height: 85vh;
    overflow-y: auto;
    color: #e0e0e0;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
}
#settings-panel::-webkit-scrollbar { width: 6px; }
#settings-panel::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

#settings-panel h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #888;
    margin: 20px 0 10px;
}
#settings-panel h2:first-child { margin-top: 0; }

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    gap: 12px;
}

.setting-row label {
    font-size: 14px;
    color: #ccc;
    flex-shrink: 0;
}

.setting-row .val {
    font-size: 13px;
    color: #888;
    min-width: 40px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}
.toggle .track {
    position: absolute;
    inset: 0;
    background: #333;
    border-radius: 12px;
    transition: background 0.2s;
    cursor: pointer;
}
.toggle .track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle input:checked + .track {
    background: #ff6644;
}
.toggle input:checked + .track::after {
    transform: translateX(20px);
}

/* Select */
.setting-row select {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    background: #222;
    color: #ccc;
    border: 1px solid #444;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}
.setting-row select:focus { border-color: #ff6644; }

/* Range Slider */
.setting-row input[type=range] {
    flex: 1;
    min-width: 0;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #333;
    border-radius: 2px;
    outline: none;
}
.setting-row input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #ff6644;
    border-radius: 50%;
    cursor: pointer;
}
.setting-row input[type=range]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #ff6644;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* Action buttons */
.setting-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.setting-actions button {
    flex: 1;
    padding: 10px 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #ccc;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.setting-actions button:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.setting-actions button.primary {
    background: #ff6644;
    border-color: #ff6644;
    color: #fff;
}
.setting-actions button.primary:hover {
    background: #e85530;
}

/* Ball color controls */
.ball-colors {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
}
.ball-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ball-color-row input[type=color] {
    width: 32px;
    height: 24px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #222;
    padding: 1px;
    cursor: pointer;
    flex-shrink: 0;
}
.ball-color-row input[type=color]::-webkit-color-swatch-wrapper { padding: 1px; }
.ball-color-row input[type=color]::-webkit-color-swatch { border: none; border-radius: 2px; }
.ball-color-toggle {
    position: relative;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
}
.ball-color-toggle input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}
.ball-color-toggle .mini-track {
    position: absolute;
    inset: 0;
    background: #333;
    border-radius: 9px;
    transition: background 0.2s;
}
.ball-color-toggle .mini-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.ball-color-toggle input:checked + .mini-track {
    background: #ff6644;
}
.ball-color-toggle input:checked + .mini-track::after {
    transform: translateX(14px);
}

/* Hint text */
.settings-hint {
    text-align: center;
    font-size: 11px;
    color: #555;
    margin-top: 12px;
}
