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

body {
    font-family: 'Outfit', sans-serif;
    background-color: #1a1a2e;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    padding: 10px;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 100%;
    max-width: 800px;
    margin: auto;
    position: relative;
}

#game-container {
    position: relative;
    width: 100%;
    max-height: calc(100vh - 180px);
    aspect-ratio: 4 / 3;
    background: linear-gradient(to bottom, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    overflow: hidden;
    touch-action: none;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.hidden {
    display: none !important;
}

/* HUD Styling */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: clamp(10px, 2.5vw, 15px) clamp(15px, 3.5vw, 20px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    color: white;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
    z-index: 5;
}

.hud-item {
    font-size: clamp(0.85rem, 2.5vw, 1.2rem);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: clamp(4px, 1.5vw, 8px);
}

.tension-meter-container {
    display: flex;
    align-items: center;
}

.tension-bar-bg {
    width: clamp(80px, 18vw, 150px);
    height: clamp(10px, 2vw, 15px);
    background-color: rgba(255, 255, 255, 0.3);
    border: 2px solid white;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

#tension-bar-fill {
    width: 0%;
    height: 100%;
    background-color: #00ff00;
    transition: width 0.1s linear, background-color 0.3s;
}

/* Overlay Screens */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    backdrop-filter: blur(4px);
    z-index: 10;
    padding: 20px;
}

.overlay h1 {
    font-size: clamp(2rem, 8vw, 4rem);
    margin-bottom: clamp(5px, 2vw, 10px);
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.8);
    background: -webkit-linear-gradient(#fff, #f0f0f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.overlay p {
    font-size: clamp(0.9rem, 2.8vw, 1.2rem);
    margin-bottom: clamp(10px, 3vw, 20px);
    max-width: 90%;
}

.controls-info {
    background: rgba(255, 255, 255, 0.1);
    padding: clamp(10px, 2.5vw, 15px) clamp(15px, 4vw, 30px);
    border-radius: 10px;
    margin-bottom: clamp(15px, 4vw, 30px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.controls-info p {
    margin-bottom: 5px;
    font-size: clamp(0.8rem, 2.2vw, 1rem);
}

.controls-info p:last-child {
    margin-bottom: 0;
}

button {
    padding: clamp(10px, 2.5vw, 15px) clamp(20px, 5vw, 40px);
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    color: #4facfe;
    background-color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

button:active {
    transform: scale(0.95);
}

/* Mobile Controls & Responsive Layout */
#mobile-controls {
    display: none;
    justify-content: space-between;
    width: 100%;
    padding: 0 10px;
    z-index: 20;
}

body.touch-device #mobile-controls {
    display: flex;
}

.control-group {
    display: flex;
    gap: 15px;
}

.ctrl-btn {
    width: clamp(55px, 15vw, 70px);
    height: clamp(55px, 15vw, 70px);
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.1s ease;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    margin: 0;
}

.ctrl-btn:active {
    background: rgba(255, 255, 255, 0.35);
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
    transform: scale(0.92);
}

.btn-label {
    font-size: clamp(8px, 1.8vw, 10px);
    text-transform: uppercase;
    opacity: 0.8;
    margin-bottom: 2px;
    pointer-events: none;
}

.btn-icon {
    font-size: clamp(1rem, 3.5vw, 1.3rem);
    pointer-events: none;
}

.instructions-hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: clamp(10px, 2.2vw, 12px);
    letter-spacing: 0.5px;
    margin-top: 5px;
    pointer-events: none;
    line-height: 1.5;
}

.instructions-hint strong {
    color: #00f2fe;
}

/* Visibility Classes */
.mobile-only {
    display: none !important;
}

.desktop-only {
    display: inline !important;
}

body.touch-device .desktop-only {
    display: none !important;
}

body.touch-device .mobile-only {
    display: inline !important;
}

/* Landscape overlay for mobile screens to maximize game viewport size */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 5px;
    }
    
    .game-wrapper {
        gap: 5px;
        max-width: 600px;
    }

    #game-container {
        max-height: 72vh;
    }

    #mobile-controls {
        position: absolute;
        bottom: 20px;
        left: 0;
        right: 0;
        padding: 0 20px;
        justify-content: space-between;
        pointer-events: none;
    }

    .control-group {
        pointer-events: auto;
        gap: 10px;
    }

    .ctrl-btn {
        width: 50px;
        height: 50px;
    }

    .btn-label {
        display: none;
    }
    
    .btn-icon {
        font-size: 1.1rem;
    }
    
    .instructions-hint {
        display: none;
    }
}