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

.hidden {
    display: none !important;
}

body {
    font-family: Arial, sans-serif;
    background: #1a1a2e;
    color: #eee;
    overflow: auto;
    min-height: 100vh;
    width: 100vw;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
}

#game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    height: 100%;
    width: 100%;
    /* max-width set via JavaScript from GAME_CONSTANTS.MAX_SCREEN_WIDTH */
}

#gameCanvas {
    background: #0f0f1e;
    border: none;
    border-radius: 0;
    flex-shrink: 0;
}

#ui {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 800px;
    flex-shrink: 0;
}

#stats {
    background: #16213e;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

#stats h4 {
    margin: 0 0 10px 0;
    color: #4ecca3;
    font-size: 18px;
}

#stats div {
    margin: 8px 0;
    font-size: 16px;
}

#upgrades {
    background: transparent;
    padding: 15px;
}

#upgrades h3 {
    margin-bottom: 15px;
    color: #4ecca3;
}

button {
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    background: #4ecca3;
    border: none;
    border-radius: 5px;
    color: #1a1a2e;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-text {
    text-align: left;
}

.btn-cost {
    text-align: right;
    font-weight: bold;
}

button:hover:not(:disabled) {
    background: #45b393;
}

button:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.5;
}

#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(22, 33, 62, 0.95);
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    border: 3px solid #e94560;
}

#game-over h2 {
    color: #e94560;
    margin-bottom: 15px;
}

#game-over p {
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

#dev-mode {
    background: #2d1b3d;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #8b5cf6;
}

#dev-mode h3 {
    margin-bottom: 10px;
    color: #8b5cf6;
}

.dev-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.dev-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dev-item label {
    font-size: 11px;
    color: #c4b5fd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dev-item input[type="number"] {
    width: 100%;
    padding: 4px 6px;
    background: #1a1a2e;
    border: 1px solid #8b5cf6;
    border-radius: 3px;
    color: #c4b5fd;
    font-size: 12px;
    text-align: center;
}

.dev-item input[type="number"]:focus {
    outline: none;
    border-color: #a78bfa;
}

#dev-toggle {
    background: #8b5cf6;
    margin-top: 10px;
}

#dev-toggle:hover {
    background: #7c3aed;
}

.dev-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.dev-btn {
    background: #8b5cf6;
    padding: 8px;
    margin: 0;
    font-size: 12px;
}

.dev-btn:hover {
    background: #7c3aed;
}

.dev-btn-small {
    background: #8b5cf6;
    padding: 8px;
    margin: 0;
    font-size: 12px;
}

.dev-btn-small:hover {
    background: #7c3aed;
}

.dev-stat {
    color: #c4b5fd;
}

.controls-title {
    font-size: 14px;
    font-weight: bold;
    color: #4ecca3;
    margin-bottom: 10px;
    text-align: center;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0;
    font-size: 13px;
}

.key {
    background: #4ecca3;
    color: #1a1a2e;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
    min-width: 60px;
    text-align: center;
}

#sound-icon-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(22, 33, 62, 0.9);
    border: 2px solid #4ecca3;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    backdrop-filter: blur(5px);
    z-index: 100;
}

#sound-icon-btn:hover {
    background: rgba(78, 204, 163, 0.3);
    transform: scale(1.1);
}

#sound-icon-btn:active {
    transform: scale(0.95);
}

#dev-icon-btn {
    position: fixed;
    top: 20px;
    right: 80px;
    width: 50px;
    height: 50px;
    background: rgba(22, 33, 62, 0.9);
    border: 2px solid #4ecca3;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: none; /* Hidden by default, shown via URL parameter */
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    backdrop-filter: blur(5px);
    z-index: 100;
}

#dev-icon-btn:hover {
    background: rgba(78, 204, 163, 0.3);
    transform: scale(1.1);
}

#dev-icon-btn:active {
    transform: scale(0.95);
}

#dev-icon-btn.active {
    background: rgba(78, 204, 163, 0.5);
    border-color: #e94560;
}

#controls-help {
    position: fixed;
    top: 80px;
    right: 20px;
    background: transparent;
    padding: 10px 15px;
    border-radius: 8px;
    z-index: 100;
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

#controls-help.fading-out {
    opacity: 0;
    transform: translateY(20px);
}

.control-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0;
    font-size: 14px;
    color: #4ecca3;
}

.control-item .key {
    background: #4ecca3;
    color: #1a1a2e;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 13px;
}

#level-display {
    display: none;
}

#level-transition {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    pointer-events: none;
}

#level-transition-text {
    font-size: 120px;
    font-weight: bold;
    color: #4ecca3;
    text-shadow: 
        0 0 20px rgba(78, 204, 163, 1),
        0 0 40px rgba(78, 204, 163, 0.8),
        0 0 60px rgba(78, 204, 163, 0.6);
    animation: levelTransition 2s ease-out forwards;
}

@keyframes levelTransition {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    20% {
        transform: scale(1.5);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    80% {
        transform: scale(1.3);
        opacity: 1;
    }
    100% {
        transform: scale(5);
        opacity: 0;
    }
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    #game-container {
        gap: 0;
    }

    #gameCanvas {
        max-width: 100vw;
        width: 100%;
        height: auto !important;
    }

    #ui {
        /* No max-height - allow full expansion */
    }

    #upgrades {
        padding: 10px;
    }

    #upgrades h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }

    button {
        padding: 8px;
        font-size: 14px;
    }

    #sound-icon-btn,
    #dev-icon-btn {
        display: none !important; /* Hide sound and dev buttons on mobile */
    }

    #controls-help {
        display: none !important; /* Hide keyboard controls on mobile */
    }

    #level-transition-text {
        font-size: 60px;
    }

    .dev-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
