* {
    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;
    }
}