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

html, body {
    height: 100%;
    background: #0b0b1a;
    font-family: 'MySpaceFont', 'Segoe UI', system-ui, sans-serif;
    color: #aac;
    overflow: hidden;
}

body {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at 20% 30%, #1a1a3a 0%, #0b0b1a 80%);
    padding: 0;
}

.game-wrapper {
    max-width: 820px;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    background: #0f0f2a;
    border-radius: 0;
    box-shadow: none;
    border: none;
    padding: 8px 12px 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-nav {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 30px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    justify-content: center;
}
.main-nav a {
    color: #8899bb;
    text-decoration: none;
    font-size: 14px;
    padding: 4px 14px;
    border-radius: 30px;
    transition: all 0.2s ease;
    font-weight: 500;
}
.main-nav a:hover {
    background: #1e1e4a;
    color: #aaccff;
}
.main-nav a.active {
    background: #1e1e4a;
    color: #66aaff;
}

.info {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 30px;
    padding: 4px 14px;
    margin-bottom: 6px;
    font-size: 15px;
    color: #99aacc;
    border: 1px solid rgba(255, 255, 255, 0.05);
    gap: 6px 16px;
}
.info span {
    color: #66aaff;
    font-weight: bold;
    min-width: 20px;
    display: inline-block;
    text-align: center;
}

.canvas-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    overflow: hidden;
    background: #0a0a1a;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    background: #0a0a1a;
    border-radius: 12px;
    border: 1px solid #3a3a7a;
    touch-action: none;
    cursor: pointer;
    image-rendering: pixelated;
}

.controls {
    flex: 0 0 auto;
    text-align: center;
    padding: 4px 10px 2px;
    color: #556688;
    font-size: 13px;
    border-top: 1px solid #2a2a5a;
    margin-top: 6px;
}
.controls kbd {
    display: inline-block;
    background: #1a1a3a;
    border: 1px solid #3a3a7a;
    border-radius: 6px;
    padding: 0 10px;
    margin: 0 2px;
    color: #aaccff;
    font-family: inherit;
    font-size: 13px;
    box-shadow: 0 2px 0 #0a0a1a;
    min-width: 28px;
    text-align: center;
}

.theme-switcher {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px 10px;
    margin-top: 6px;
    color: #aac;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.03);
}
.theme-btn {
    background: none;
    border: 1px solid #3a3a7a;
    color: #bdf;
    padding: 2px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    min-width: 32px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
}
.theme-btn:hover {
    background: #2a2a6a;
    border-color: #66aaff;
}

.mobile-controls {
    display: none;
}
.desktop-controls {
    display: block;
}

#loadingOverlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(13, 13, 34, 0.9);
    border-radius: 16px;
    padding: 20px;
    gap: 10px;
    flex: 1;
}
#loadingOverlay > div:first-child {
    color: #aac;
    font-size: 1.1rem;
}
.progress-track {
    width: 80%;
    max-width: 300px;
    background: #222244;
    border-radius: 12px;
    height: 16px;
    overflow: hidden;
}
#progressBar {
    height: 100%;
    background: linear-gradient(90deg, #3af, #7cf);
    transition: width 0.3s ease;
}
#progressText {
    color: #667;
    font-size: 14px;
}

@media (max-width: 768px) {
    .main-nav a {
        font-size: 12px;
        padding: 3px 10px;
    }
    .info {
        font-size: 13px;
        padding: 3px 10px;
        gap: 4px 10px;
    }
    .controls {
        font-size: 12px;
        padding: 3px 6px;
    }
    .controls kbd {
        font-size: 12px;
        padding: 0 8px;
        min-width: 24px;
    }
    .theme-btn {
        font-size: 14px;
        min-width: 28px;
        min-height: 28px;
        padding: 1px 8px;
    }
    .desktop-controls {
        display: none !important;
    }
    .mobile-controls {
        display: block !important;
    }
}

@media (max-width: 400px) {
    .main-nav a {
        font-size: 10px !important;
        padding: 2px 8px !important;
    }
    .info {
        font-size: 11px;
        padding: 2px 8px;
    }
    .controls {
        font-size: 10px;
    }
    .controls kbd {
        font-size: 10px;
        padding: 0 6px;
        min-width: 20px;
    }
    .theme-btn {
        font-size: 12px !important;
        min-width: 24px;
        min-height: 24px;
        padding: 0 6px;
    }
}/* ============ РЕЙНДЖЕР: новые страницы и виджеты ============ */
.ranger-page { display: none; }
.ranger-page.active { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.ranger-panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px;
}
.ranger-panel-head {
    color: #7cf; font-size: 16px; font-weight: bold;
    margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}
.ranger-load { color: #667; padding: 12px; text-align: center; }

.ranger-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.ranger-grid-video { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }

.ranger-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 12px;
    display: flex; flex-direction: column; gap: 8px;
    min-width: 0;
}
.ranger-card-head { font-size: 14px; color: #cdf; display: flex; align-items: center; gap: 6px; }
.ranger-card-meta { color: #779; font-size: 12px; }
.ranger-watch {
    background: linear-gradient(135deg, #2a4a8a, #3af);
    border: none; color: #fff; border-radius: 20px; padding: 6px 16px;
    cursor: pointer; font-size: 13px; font-weight: bold;
}
.ranger-watch:hover { filter: brightness(1.2); }

.ranger-live-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #f33;
    display: inline-block; animation: ranger-pulse 1.2s ease-in-out infinite;
}
@keyframes ranger-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.ranger-live-viewer {
    background: #000; border-radius: 12px; padding: 8px; margin-bottom: 10px;
    border: 1px solid rgba(102, 170, 255, 0.3);
}
.ranger-live-viewer canvas { width: 100%; height: auto; border-radius: 8px; background: #0a0a1a; }
.ranger-viewer-note { color: #556; font-size: 11px; text-align: center; padding-top: 4px; }

.ranger-list { display: flex; flex-direction: column; gap: 6px; }
.ranger-lb-row {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,0.03); border-radius: 8px; padding: 6px 10px;
    font-size: 13px; color: #bcd;
}
.ranger-lb-idx { color: #7cf; font-weight: bold; min-width: 20px; text-align: center; }
.ranger-lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranger-lb-score { color: #ffcc44; font-weight: bold; }
.ranger-lb-wave { color: #667; font-size: 11px; }

.ranger-video { padding: 8px; }
.ranger-video-poster {
    height: 100px; background-size: cover; background-position: center;
    border-radius: 8px; border: 1px solid rgba(255,255,255,0.08);
}
.ranger-video-name { font-size: 12px; color: #cdf; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranger-video-meta { color: #667; font-size: 11px; }
.ranger-player { width: 100%; border-radius: 8px; background: #000; }

.ranger-drop {
    border: 2px dashed rgba(102, 170, 255, 0.4); border-radius: 14px;
    padding: 30px 20px; text-align: center; color: #99aacc; cursor: pointer;
    transition: all 0.2s ease;
}
.ranger-drop:hover, .ranger-drop.drag { border-color: #7cf; background: rgba(102,170,255,0.08); }
.ranger-drop-icon { font-size: 40px; margin-bottom: 8px; }
.ranger-drop-note { color: #667; font-size: 12px; margin-top: 6px; }
.ranger-upload-status { color: #7cf; font-size: 13px; margin-top: 8px; text-align: center; min-height: 18px; }

/* LIVE-плашка в шапке */
#liveStrip {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: rgba(255, 60, 60, 0.08);
    border: 1px solid rgba(255, 80, 80, 0.25);
    border-radius: 30px; padding: 4px 14px; margin-bottom: 6px;
    font-size: 12px; color: #c99;
}
.live-dot {
    width: 9px; height: 9px; border-radius: 50%; background: #f33;
    animation: ranger-pulse 1.2s ease-in-out infinite;
}
.live-label { color: #f66; font-weight: bold; letter-spacing: 1px; }
.live-item { color: #aac; }
.live-item b { color: #7cf; }
#liveCanvas { border-radius: 6px; border: 1px solid rgba(255,255,255,0.1); }

/* адаптив */
@media (max-width: 768px) {
    .ranger-grid, .ranger-grid-video { grid-template-columns: 1fr; }
    .ranger-panel { padding: 8px; }
}
