body {
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
}

.planetfall-topbar {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 25;
    display: flex;
    gap: 10px;
}

.planetfall-object-legend {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 12px;
    margin: 14px 0 16px;
}

.planetfall-object-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
}

.planetfall-object-svg {
    width: 72px;
    height: 72px;
}

.planetfall-object-item span {
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
}

@media (max-width: 820px) {
    .planetfall-object-legend {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
}

.game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: #1a1a2e;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    background: linear-gradient(180deg, #0f0f23 0%, #16213e 50%, #1a1a2e 100%);
    cursor: pointer;
}

.menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 10;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
}

.menu h1 {
    font-size: 4rem;
    font-size: max(0.5rem, 4rem * var(--screen-scale, 1));
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }     
}

.menu button {
    font-size: 1.5rem;
    font-size: max(0.5rem, 1.5rem * var(--screen-scale, 1));
    padding: 8px 14px;
    margin: 3px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.menu button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.hud {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    color: white;
    font-size: 1.5rem;
    font-size: max(0.5rem, 1.5rem * var(--screen-scale, 1));
    z-index: 5;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.hud button {
    font-size: 0.95rem;
    padding: 7px 10px;
    border: none;
    border-radius: 8px;
    background: rgba(16, 25, 48, 0.88);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

.hud button:hover {
    background: rgba(27, 42, 75, 0.95);
}

.instructions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    text-align: center;
    font-size: 1rem;
    font-size: max(0.5rem, 1rem * var(--screen-scale, 1));
    z-index: 5;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

#settingsMenu {
    position: fixed;
    inset: 0;
    transform: none;
    width: 100vw;
    height: 100dvh;
    display: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 72px 16px calc(120px + env(safe-area-inset-bottom));
    background: rgba(12, 18, 39, 0.88);
    border: none;
    border-radius: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-sizing: border-box;
    touch-action: pan-y;
    z-index: 20;
}

#settingsMenu:not(.hidden) {
    display: block;
}

#settingsMenu h2 {
    text-align: center;
    margin: 0 0 14px;
}

#settingsMenu > div {
    width: min(460px, 100%);
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

#settingsMenu > button {
    display: block;
    margin: 10px auto 0;
}

#settingsMenu label {
    display: block;
    white-space: normal;
    overflow-wrap: anywhere;
}

#settingsMenu input[type="range"] {
    max-width: 100%;
}

#settingsMenu::-webkit-scrollbar {
    width: 10px;
}

#settingsMenu::-webkit-scrollbar-track {
    background: rgba(50, 0, 0, 0.1);
    border-radius: 5px;
}

#settingsMenu::-webkit-scrollbar-thumb {
    background: rgba(100, 100, 200, 0.2);
    border-radius: 5px;
}

#settingsMenu::-webkit-scrollbar-thumb:hover {
    background: rgba(170, 170, 230, 0.3);
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 10;
    background: rgba(0,0,0,0.8);
    padding: 20px;
    border-radius: 20px;
    border: 2px solid #ff6b6b;
    width: 80%;
    line-height: 1;
    font-size: max(0.5rem, 1.2rem * var(--screen-scale, 1));
}

.game-over h2 {
    color: #ff6b6b;
    font-size: 3rem;
    font-size: max(1rem, 3rem * var(--screen-scale, 1));
    margin-bottom: 0.5rem;
}

.hidden {
    display: none;
}

/* Settings styles */
input[type="range"] {
    background: #374151;
    height: 8px;
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    cursor: pointer;
    border: none;
}

/* Table styles */
table th {
    background: rgba(255, 255, 255, 0.1);
}

table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 768px) {
    .planetfall-topbar {
        top: 10px;
        right: 10px;
        gap: 6px;
    }

    .planetfall-topbar .btn-small {
        font-size: 0.78rem;
        padding: 6px 8px;
    }

    .hud button {
        font-size: 0.85rem;
        padding: 6px 9px;
    }

    #settingsMenu {
        inset: 0;
        height: 100dvh;
        padding: 72px 10px calc(148px + env(safe-area-inset-bottom));
    }

    #settingsMenu > div {
        width: min(400px, 100%);
    }

    #settingsMenu label,
    #settingsMenu input,
    #settingsMenu button,
    #settingsMenu select {
        font-size: 13px;
    }

    #settingsMenu h2 {
        font-size: 1.9rem;
        line-height: 1.1;
    }
}