:root {
    --bg-deep: #0b0d1f;
    --bg-panel: rgba(20, 23, 56, 0.85);
    --accent-purple: #a855f7;
    --accent-pink: #ec4899;
    --accent-gold: #fbbf24;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-blue: #3b82f6;
    --star-white: #f8fafc;
    --font-main: 'Nunito', sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    background: var(--bg-deep);
    color: var(--star-white);
}

body {
    position: relative;
}

#game-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.game-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    padding: 16px;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 700px;
    padding: 14px 18px;
    background: var(--bg-panel);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

.question-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.question-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 1px;
}

#question-text {
    font-size: 1.1rem;
    font-weight: 900;
}

.game-level {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-purple);
    letter-spacing: 1px;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.score-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 1px;
}

.shield-bar {
    display: flex;
    gap: 4px;
}

.shield-segment {
    width: 18px;
    height: 18px;
    background: var(--accent-blue);
    border-radius: 4px;
    opacity: 0.2;
    transition: opacity 0.3s ease;
}

.shield-segment.lit {
    opacity: 1;
    box-shadow: 0 0 12px var(--accent-blue);
}

.score-text {
    font-size: 0.9rem;
    font-weight: 700;
}

/* Asteroid stage */
.asteroid-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    max-width: 700px;
    margin-bottom: 20px;
}

.asteroid {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: floatAsteroid 3s ease-in-out infinite;
}

.asteroid-img {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(168, 85, 247, 0.6));
    user-select: none;
    -webkit-user-drag: none;
}

.asteroid-number {
    position: relative;
    font-size: 3.5rem;
    font-weight: 900;
    color: white;
    -webkit-text-stroke: 2px #111827;
    paint-order: stroke fill;
    text-shadow: 0 3px 8px rgba(0, 0, 0, 0.95);
    z-index: 1;
}

.asteroid.shake {
    animation: shake 0.4s ease-in-out;
}

.asteroid.pop {
    animation: pop 0.4s ease-out;
}

@keyframes floatAsteroid {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Sort buttons */
.sort-buttons {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 700px;
    justify-content: center;
    margin-bottom: 20px;
}

.sort-btn {
    flex: 1;
    max-width: 220px;
    padding: 22px 20px;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-family: var(--font-main);
    font-size: 1.8rem;
    font-weight: 900;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.odd-btn {
    background: rgba(168, 85, 247, 0.3);
    border-color: rgba(168, 85, 247, 0.6);
}

.odd-btn:hover {
    background: rgba(168, 85, 247, 0.5);
    transform: scale(1.05);
}

.even-btn {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.6);
}

.even-btn:hover {
    background: rgba(59, 130, 246, 0.5);
    transform: scale(1.05);
}

/* Message */
.message {
    min-height: 32px;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    color: var(--accent-gold);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Burst particles */
.burst-particle {
    position: fixed;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-gold);
    pointer-events: none;
    z-index: 999;
    will-change: transform, opacity;
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 13, 31, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: rgba(20, 23, 56, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 32px 28px;
    text-align: center;
    max-width: 520px;
    width: calc(100% - 32px);
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.3);
    max-height: 92vh;
    overflow-y: auto;
}

.overlay-asteroid {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 20px rgba(168, 85, 247, 0.5));
}

.overlay-content h1 {
    font-size: 2.2rem;
    font-weight: 900;
    margin: 0 0 12px;
    color: var(--accent-gold);
}

.game-desc {
    font-size: 1rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 20px;
}

.choose-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 12px;
}

.difficulty-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.diff-btn {
    padding: 14px 22px;
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 900;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 110px;
}

.diff-btn:hover {
    transform: scale(1.08);
    background: rgba(255, 255, 255, 0.15);
}

.diff-btn span {
    display: block;
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.8;
}

.win-rocket {
    margin: 20px 0;
    animation: launch 2s ease-in-out infinite;
}

.win-rocket img {
    width: 80px;
    height: 80px;
}

@keyframes launch {
    0%, 100% { transform: translateY(6px) rotate(-10deg); }
    50% { transform: translateY(-20px) rotate(-10deg); }
}

.launch-btn {
    padding: 12px 28px;
    border-radius: 24px;
    border: none;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 900;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-right: 10px;
}

.launch-btn:hover {
    transform: scale(1.08);
}

.home-btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 24px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    transition: all 0.2s ease;
}

.home-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Exit button */
.exit-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 50;
    padding: 8px 16px;
    border-radius: 24px;
    background: rgba(10, 10, 30, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.15);
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.exit-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.08);
}

/* Responsive */
@media (max-width: 600px) {
    .game-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 14px;
    }

    .score-box {
        order: -1;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        width: 100%;
        gap: 8px;
    }

    .shield-bar {
        width: 100%;
    }

    .shield-segment {
        flex: 1;
        width: auto;
        height: 15px;
    }

    .question-box {
        width: 100%;
    }

    #question-text {
        font-size: 0.95rem;
    }

    .asteroid {
        width: 130px;
        height: 130px;
    }

    .asteroid-number {
        font-size: 2.8rem;
    }

    .sort-btn {
        padding: 18px 14px;
        font-size: 1.5rem;
    }

    .exit-btn {
        bottom: 12px;
        right: 12px;
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}

@media (max-width: 360px) {
    .asteroid {
        width: 110px;
        height: 110px;
    }

    .asteroid-number {
        font-size: 2.2rem;
    }
}

/* Short landscape screens (Nest Hub, landscape phones, small tablets) */
@media (max-height: 640px) {
    .game-container {
        padding: 8px;
    }

    .game-header {
        padding: 8px 14px;
        margin-bottom: 8px;
    }

    .message {
        margin-bottom: 6px;
        min-height: 22px;
        font-size: 0.95rem;
    }
}
