* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
    user-select: none;
}

body {
    background-color: #1a1a1a;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 800px; /* Optional: Constrain on wide screens for better gameplay */
    max-height: 600px;
    background: #87CEEB; /* Fallback */
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border-radius: 12px;
    overflow: hidden;
}

@media (max-width: 800px) {
    #game-container {
        border-radius: 0;
        max-width: 100vw;
        max-height: 100vh;
    }
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    /* We'll handle the internal resolution in JS */
}

/* UI Overlay */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to canvas if needed */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

#ui-layer.hidden {
    display: none;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    font-size: 24px;
    font-weight: 900;
    color: white;
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.timer {
    background: rgba(0,0,0,0.3);
    padding: 5px 15px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

.score {
    background: rgba(0,0,0,0.3);
    padding: 5px 15px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

.hud-bottom {
    display: flex;
    justify-content: center;
    margin-bottom: 20px; /* Keep it above the bottom area where they build the bridge */
}

.progress-bar-container {
    width: 80%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid white;
    border-radius: 20px;
    height: 30px;
    position: relative;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    backdrop-filter: blur(5px);
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: 900;
    z-index: 2;
    text-shadow: 1px 1px 2px black;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.progress-bar {
    width: 100%;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
}

#bridge-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #FFD700, #FFA500);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Screens (Start, Win, Lose) */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 10;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

.screen.hidden {
    display: none !important;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    color: white;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90%;
    width: 400px;
}

.screen.active .glass-panel {
    transform: scale(1);
}

.glass-panel h1 {
    font-size: 48px;
    margin-bottom: 10px;
    background: linear-gradient(to bottom, #fff, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.glass-panel.success h1 {
    background: linear-gradient(to bottom, #fff, #4CAF50);
    -webkit-background-clip: text;
}

.glass-panel.failure h1 {
    background: linear-gradient(to bottom, #fff, #F44336);
    -webkit-background-clip: text;
}

.glass-panel h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    color: #FFD700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.glass-panel p {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.controls {
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 12px;
    margin-bottom: 25px;
    font-size: 14px;
    color: #e0e0e0;
}

button {
    background: linear-gradient(135deg, #FF9800, #F44336);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 20px;
    font-weight: 900;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.4);
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(244, 67, 54, 0.6);
}

button:active {
    transform: translateY(1px);
}

/* Phase 2 Additions */
.level-indicator {
    background: rgba(0,0,0,0.3);
    padding: 5px 15px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    color: #FFD700;
}

.highscore-display {
    font-size: 18px;
    font-weight: 900;
    color: #4CAF50;
    margin-bottom: 20px;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 12px;
}

.social-share {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.share-btn {
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 20px;
    box-shadow: none;
}

.share-btn.twitter {
    background: #1DA1F2; /* X/Twitter color */
}

.share-btn.twitter:hover {
    box-shadow: 0 4px 15px rgba(29, 161, 242, 0.4);
}

.share-btn.facebook {
    background: #4267B2; /* Facebook color */
}

.share-btn.facebook:hover {
    box-shadow: 0 4px 15px rgba(66, 103, 178, 0.4);
}

.level-title {
    font-size: 80px;
    color: white;
    text-transform: uppercase;
    text-shadow: 0 5px 15px rgba(0,0,0,0.5);
    animation: pulseScale 1s infinite alternate;
}

@keyframes pulseScale {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}
