/* JoyBridge Remote Play — AMOLED dark theme */
:root {
    --bg: #000000;
    --surface: #111111;
    --surface2: #1A1A1A;
    --accent: #00E5FF;
    --success: #00E676;
    --warning: #FFD600;
    --error: #FF5252;
    --text: #E0E0E0;
    --text-dim: #757575;
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Landing Page (index.html) --- */
.landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 24px;
    padding: 24px;
}

.landing h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
}

.landing p {
    color: var(--text-dim);
    font-size: 1.1rem;
    max-width: 400px;
    text-align: center;
}

.code-input {
    display: flex;
    gap: 8px;
    align-items: center;
}

.code-input input {
    background: var(--surface);
    border: 2px solid var(--surface2);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.5rem;
    font-family: 'Cascadia Code', 'Consolas', monospace;
    letter-spacing: 0.3em;
    padding: 12px 20px;
    width: 200px;
    text-align: center;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.2s;
}

.code-input input:focus {
    border-color: var(--accent);
}

.code-input input::placeholder {
    color: var(--text-dim);
    letter-spacing: 0.1em;
}

.btn {
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: var(--radius);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn:hover { background: #00B8D4; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
}

.btn-outline:hover { background: rgba(0, 229, 255, 0.1); }

.error-msg {
    color: var(--error);
    font-size: 0.9rem;
    min-height: 1.2em;
}

/* --- Player Page (play.html) --- */
.player-page {
    width: 100%;
    max-width: 1200px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--surface);
    border-radius: var(--radius);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header h1 {
    font-size: 1.2rem;
    color: var(--accent);
    font-weight: 700;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: background 0.3s;
}

.status-dot.connecting { background: var(--warning); animation: pulse 1s infinite; }
.status-dot.connected { background: var(--success); }
.status-dot.error { background: var(--error); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-text {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.ping {
    font-size: 0.85rem;
    font-family: 'Cascadia Code', monospace;
    color: var(--text-dim);
    transition: color 0.3s;
}

.ping.ping-good { color: var(--success); }
.ping.ping-ok { color: var(--warning); }
.ping.ping-bad { color: var(--error); }

/* Floating ping overlay (visible in fullscreen) */
.ping-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: 'Cascadia Code', monospace;
    color: var(--text-dim);
    opacity: 0;
    pointer-events: none;
    transition: color 0.3s;
    z-index: 10;
}

.ping-overlay.ping-good { color: var(--success); }
.ping-overlay.ping-ok { color: var(--warning); }
.ping-overlay.ping-bad { color: var(--error); }

/* Video container */
.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    transition: opacity 0.3s;
}

.video-overlay.hidden { opacity: 0; pointer-events: none; }

.video-overlay p {
    font-size: 1.2rem;
    color: var(--text-dim);
}

.fullscreen-hint {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-dim);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.video-container:hover .fullscreen-hint { opacity: 1; }

/* Settings panel */
.settings-panel {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-group label {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.setting-group select,
.setting-group input[type="range"] {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

.setting-group select:focus,
.setting-group input:focus {
    border-color: var(--accent);
}

.setting-group select option {
    background: var(--surface2);
    color: var(--text);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #333; }

input[type="range"] {
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--surface2);
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.setting-value {
    font-size: 0.85rem;
    color: var(--accent);
    font-family: 'Cascadia Code', monospace;
    text-align: right;
}

/* Controller status */
.controller-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius);
}

.controller-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.controller-name {
    font-size: 0.9rem;
}

.controller-none {
    color: var(--text-dim);
    font-style: italic;
}

.btn-bar {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 16px;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* Fullscreen styles */
:fullscreen .player-page {
    max-width: 100%;
    padding: 0;
    gap: 0;
}

:fullscreen .header,
:fullscreen .settings-panel,
:fullscreen .controller-bar {
    display: none;
}

:fullscreen .video-container {
    border-radius: 0;
    height: 100vh;
}

:fullscreen .ping-overlay {
    opacity: 1;
}

/* Toggle checkbox */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: var(--surface2);
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-label input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: transform 0.2s, background 0.2s;
}

.toggle-label input[type="checkbox"]:checked {
    background: var(--accent);
}

.toggle-label input[type="checkbox"]:checked::after {
    transform: translateX(16px);
    background: var(--bg);
}

.toggle-text {
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* Video disabled state */
.video-container.video-disabled {
    aspect-ratio: auto;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-container.video-disabled video {
    display: none;
}

.video-container.video-disabled .fullscreen-hint {
    display: none;
}

.video-disabled-label {
    color: var(--text-dim);
    font-size: 0.9rem;
    display: none;
}

.video-container.video-disabled .video-disabled-label {
    display: block;
}

/* Responsive */
@media (max-width: 600px) {
    .settings-panel {
        grid-template-columns: 1fr;
    }
    .header {
        flex-wrap: wrap;
        gap: 8px;
    }
}
