body {
    margin: 0;
    overflow: hidden;
    overflow-x: hidden;
    background: #000;
    /* Fallback */
    font-family: 'Varela Round', 'Segoe UI', sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

#bg-video, #bg-image {
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -1;
    transform: translate3d(-50%, -50%, 0);
    will-change: transform;
    object-fit: cover;
}

#ui-layer {
    position: absolute;
    top: 20px;
    left: 0;
    width: 100%;
    pointer-events: none;
    text-align: center;
    color: #5d4037;
    z-index: 10;
}

#game-logo {
    max-width: min(300px, 70%);
    height: auto;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}

#score-display {
    font-size: 56px;
    font-weight: 700;
    margin-top: -15px;
    color: #5d4037;
    text-shadow: 2px 2px 0px rgba(255, 255, 255, 0.5);
}

/* Ad Button */
#ad-button {
    position: absolute;
    top: 77%;
    left: 20px;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    max-width: 48px;
    max-height: 48px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 2.5px solid #FF8C00;
    box-shadow: 0 3px 10px rgba(255, 140, 0, 0.4), 0 0 0 1.5px rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 15;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    pointer-events: auto;
    transform: translateY(-50%); /* Center vertically on the 72% mark */
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

#ad-button:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 5px 13px rgba(255, 140, 0, 0.6), 0 0 0 2.5px rgba(255, 255, 255, 0.4);
}

#ad-button:active {
    transform: translateY(-50%) scale(0.95);
}

#ad-button.hidden {
    display: none;
}

.ad-icon {
    font-size: 22px;
    line-height: 1;
    margin-bottom: -2px;
}

.ad-badge {
    font-size: 8px;
    font-weight: bold;
    color: #fff;
    background: #FF4500;
    padding: 1.5px 5px;
    border-radius: 6px;
    line-height: 1;
    margin-top: -3px;
    box-shadow: 0 1.5px 3px rgba(0, 0, 0, 0.3);
}

/* Leaderboard Button */
#leaderboard-button {
    position: absolute;
    top: 77%;
    right: 20px;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    max-width: 48px;
    max-height: 48px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: linear-gradient(135deg, #4A90E2, #357ABD);
    border: 2.5px solid #2E5C8A;
    box-shadow: 0 3px 10px rgba(74, 144, 226, 0.4), 0 0 0 1.5px rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 15;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    pointer-events: auto;
    transform: translateY(-50%); /* Center vertically on the 72% mark */
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

#leaderboard-button:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 5px 13px rgba(74, 144, 226, 0.6), 0 0 0 2.5px rgba(255, 255, 255, 0.4);
}

#leaderboard-button:active {
    transform: translateY(-50%) scale(0.95);
}

#leaderboard-button.hidden {
    display: none;
}

.leaderboard-icon {
    font-size: 22px;
    line-height: 1;
    margin-bottom: -2px;
}

.leaderboard-badge {
    font-size: 8px;
    font-weight: bold;
    color: #fff;
    background: #1E3A5F;
    padding: 1.5px 5px;
    border-radius: 6px;
    line-height: 1;
    margin-top: -3px;
    box-shadow: 0 1.5px 3px rgba(0, 0, 0, 0.3);
}

/* Shake animation */
@keyframes adShake {
    0%, 100% {
        transform: translateY(-50%) translateX(0) rotate(0deg);
    }
    25% {
        transform: translateY(-50%) translateX(-3px) rotate(-5deg);
    }
    75% {
        transform: translateY(-50%) translateX(3px) rotate(5deg);
    }
}

#ad-button.shake {
    animation: adShake 0.5s ease-in-out;
}

/* Ad Popup Overlay */
.ad-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ad-popup-overlay.hidden {
    display: none;
}

.ad-popup-image {
    max-width: 90%;
    max-height: 90%;
    width: auto;
    height: auto;
    object-fit: contain;
    pointer-events: none; /* Prevent image from blocking clicks */
    user-select: none;
}

#level-indicator {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0; /* Will be set dynamically by JavaScript */
    background: rgba(255, 179, 0, 0.9);
    color: #5d4037;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    font-family: 'Varela Round', sans-serif;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    white-space: nowrap; /* Prevent text wrapping */
    text-align: center;
}

#level-indicator.hidden {
    display: none;
}

/* Level splash removed - no longer used */

#victory-text {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FFD700;
    font-size: 64px;
    font-weight: bold;
    font-family: 'Varela Round', sans-serif;
    text-align: center;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
    z-index: 10001;
    pointer-events: none;
}

#victory-text.hidden {
    display: none;
}

#defeat-text {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FF6B6B;
    font-size: 64px;
    font-weight: bold;
    font-family: 'Varela Round', sans-serif;
    text-align: center;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
    z-index: 10001;
    pointer-events: none;
}

#defeat-text.hidden {
    display: none;
}

/* Leaderboard Screen */
#leaderboard-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-width: 100vw;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10002;
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

#leaderboard-screen.hidden {
    display: none;
}

.leaderboard-content {
    padding: 40px 20px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-x: hidden;
    min-height: 0;
    box-sizing: border-box;
}

.leaderboard-header {
    text-align: center;
    margin-bottom: 30px;
}

.leaderboard-header h2 {
    margin: 0 0 20px 0;
    font-size: 42px;
    color: #5d4037;
    text-shadow: 2px 2px 0px rgba(255, 255, 255, 0.5);
}

.leaderboard-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    margin-bottom: 20px;
    min-height: 0; /* Allows flex item to shrink below content size */
    width: 100%;
    box-sizing: border-box;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 50px 30px 1fr 60px 90px;
    gap: 10px;
    padding: 12px 15px;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    align-items: center;
}

.leaderboard-row-header {
    display: grid;
    grid-template-columns: 50px 30px 1fr 60px 90px;
    gap: 10px;
    padding: 12px 15px;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    align-items: center;
    font-weight: bold;
    font-size: 16px;
    color: #5d4037;
}

.leaderboard-row.rank-1 {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #5d4037;
    font-weight: bold;
}

.leaderboard-row.rank-2 {
    background: linear-gradient(135deg, #C0C0C0 0%, #A0A0A0 100%);
    color: #5d4037;
    font-weight: bold;
}

.leaderboard-row.rank-3 {
    background: linear-gradient(135deg, #CD7F32 0%, #B87333 100%);
    color: #fff;
    font-weight: bold;
}

.leaderboard-row.rank-4 {
    background: rgba(200, 200, 200, 0.3);
    color: #5d4037;
    font-weight: bold;
}

.leaderboard-row.rank-5 {
    background: rgba(180, 180, 180, 0.3);
    color: #5d4037;
    font-weight: bold;
}

.leaderboard-row-divider {
    height: 2px;
    background: rgba(0, 0, 0, 0.2);
    margin: 12px 15px;
    border-radius: 1px;
    width: calc(100% - 30px);
}

body.dark-mode .leaderboard-row-divider {
    background: rgba(255, 255, 255, 0.3);
}

.leaderboard-row.self-row {
    background: rgba(255, 183, 0, 0.3);
    border: 2px solid #ffb300;
}

.leaderboard-row.focus-animation {
    animation: pulse 1s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.leaderboard-row .rank {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
}

.leaderboard-row .trophy {
    font-size: 20px;
    text-align: center;
}

.leaderboard-row .name {
    font-size: 18px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-row .level {
    font-size: 16px;
    text-align: center;
    color: #666;
}

.leaderboard-row .score {
    font-size: 18px;
    font-weight: bold;
    text-align: right;
}

.empty, .error, .loader {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 18px;
}

.leaderboard-reassurance {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    margin-top: 10px;
}

/* Name Input Screen - Styled like pause menu */
#name-input-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10003;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#name-input-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

#name-input-screen .pause-content {
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#name-input-screen.hidden .pause-content {
    transform: scale(0.8);
}

#name-input-field {
    color: #333;
    background: #fff;
}

#name-input-field::placeholder {
    color: #999;
}

#name-input-field:focus {
    outline: none;
    border-color: #ff8f00;
    box-shadow: 0 0 10px rgba(255, 183, 0, 0.3);
}

#name-input-error {
    color: #d32f2f;
    font-size: 14px;
    margin: 10px 0;
    min-height: 20px;
    text-align: center;
    font-weight: bold;
}

body.dark-mode #name-input-error {
    color: #ff6b6b;
}

/* Leaderboard Loading Screen - Styled like level splash */
#leaderboard-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 202, 40, 1.0), rgba(255, 143, 0, 1.0));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10004;
    opacity: 1;
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

#leaderboard-loading.hidden {
    display: none;
}

#leaderboard-loading .level-splash-title {
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* Dark mode support for leaderboard */
body.dark-mode #leaderboard-screen {
    background: rgba(30, 30, 30, 0.95);
    color: #e0e0e0;
}

body.dark-mode .leaderboard-header h2 {
    color: #ffb300;
}

body.dark-mode .leaderboard-row {
    background: rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
}

body.dark-mode .leaderboard-row-header {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

body.dark-mode .leaderboard-row.rank-1 {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #5d4037;
    font-weight: bold;
}

body.dark-mode .leaderboard-row.rank-2 {
    background: linear-gradient(135deg, #C0C0C0 0%, #A0A0A0 100%);
    color: #5d4037;
    font-weight: bold;
}

body.dark-mode .leaderboard-row.rank-3 {
    background: linear-gradient(135deg, #CD7F32 0%, #B87333 100%);
    color: #fff;
    font-weight: bold;
}

body.dark-mode .leaderboard-row.rank-4 {
    background: rgba(100, 100, 100, 0.3);
    color: #e0e0e0;
}

body.dark-mode .leaderboard-row.rank-5 {
    background: rgba(80, 80, 80, 0.3);
    color: #e0e0e0;
}

body.dark-mode .leaderboard-row .level {
    color: #aaa;
}

body.dark-mode #name-input-field {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border-color: #ffb300;
}

body.dark-mode .empty, 
body.dark-mode .error, 
body.dark-mode .loader {
    color: #aaa;
}

body.dark-mode .leaderboard-reassurance {
    color: #aaa;
}

/* Ensure leaderboard content fills available space */
#leaderboard-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    overflow-x: hidden;
    min-height: 0;
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

#level-slider {
    position: absolute;
    top: 77%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 60%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 20;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.9);
    padding: 5px 10px;
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    box-sizing: border-box;
}

#level-slider.hidden {
    display: none;
}

#level-slider-icon {
    font-size: 32px;
    line-height: 1;
    flex-shrink: 0;
}

#level-slider-progress {
    width: 200px;
    min-width: 100px;
    max-width: 200px;
    height: 12px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    flex-shrink: 1;
}

#level-slider-fill {
    height: 100%;
    background: linear-gradient(90deg, #FFB300, #FF8C00);
    border-radius: 6px;
    width: 0%;
    transition: width 0.3s ease;
}

#level-slider-text {
    font-size: clamp(12px, 2vw, 18px);
    font-weight: 700;
    color: #5d4037;
    font-family: 'Varela Round', sans-serif;
    min-width: 0;
    max-width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
}

/* Legacy locked-counter styles (deprecated - kept for migration) */
#locked-counter {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 28px;
    font-weight: 600;
    color: #5d4037;
    text-shadow: 2px 2px 0px rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 20;
    pointer-events: none;
    /* Positioned dynamically via JavaScript between grid and hand */
}

#locked-counter.hidden {
    display: none;
}

#locked-icon {
    font-size: 28px;
}

#locked-score {
    font-size: 28px;
    font-weight: 700;
}

#message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 40px 60px;
    border-radius: 24px;
    text-align: center;
    display: none;
    pointer-events: auto;
}

/* Fullscreen Button */
#fullscreen-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    border: 2px solid #ffb300;
    color: #ff8f00;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 0;
    margin: 0;
}

#fullscreen-btn:hover {
    background: #fff;
    transform: scale(1.1);
}

#fullscreen-btn:active {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.9);
}

/* Exit Button */
#exit-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    border: 2px solid #ffb300;
    color: #ff8f00;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 0;
    margin: 0;
}

#exit-btn:hover {
    background: #fff;
    transform: scale(1.1);
}

#exit-btn:active {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.9);
}

/* Rotate Prompt */
#rotate-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #1a1a1a;
    z-index: 100;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

.rotate-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: rotate 2s infinite;
}

.rotate-text {
    font-size: 24px;
    font-family: 'Segoe UI', sans-serif;
}

@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(90deg);
    }

    75% {
        transform: rotate(90deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

/* Splash Screen */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 202, 40, 0.95), rgba(255, 143, 0, 0.95));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

#splash-screen.hidden {
    transform: translateY(-100%);
}

.splash-title {
    font-size: 80px;
    color: #5d4037;
    text-shadow: 4px 4px 0px rgba(255, 255, 255, 0.4);
    margin-bottom: 20px;
    animation: bounceIn 1s ease-out;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 6px solid rgba(93, 64, 55, 0.2);
    border-top: 6px solid #5d4037;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

@media (max-width: 600px) {
    .splash-title {
        font-size: 48px;
        text-align: center;
        padding: 0 20px;
    }
    
    /* Leaderboard Mobile Adjustments */
    .leaderboard-content {
        padding: 8px 4px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    #leaderboard-content {
        padding: 6px 4px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .leaderboard-header {
        margin-bottom: 10px;
        padding: 0 4px;
    }
    
    .leaderboard-header h2 {
        font-size: 20px;
        margin-bottom: 8px;
    }
    
    .leaderboard-row {
        grid-template-columns: 28px 24px 1fr 35px 55px;
        gap: 3px;
        padding: 5px 6px;
        margin-bottom: 4px;
        box-sizing: border-box;
    }
    
    .leaderboard-row-header {
        grid-template-columns: 28px 24px 1fr 35px 55px;
        gap: 3px;
        padding: 5px 6px;
        margin-bottom: 4px;
        font-size: 11px;
    }
    
    .leaderboard-row .trophy {
        font-size: 14px;
    }
    
    .leaderboard-row .rank {
        font-size: 13px;
    }
    
    .leaderboard-row .name {
        font-size: 11px;
        min-width: 0;
    }
    
    .leaderboard-row .level {
        font-size: 9px;
    }
    
    .leaderboard-row .score {
        font-size: 11px;
    }
    
    .empty, .error, .loader {
        padding: 10px 4px;
        font-size: 12px;
    }
    
    .leaderboard-header .primary-btn {
        font-size: 13px;
        padding: 8px 12px;
        margin-top: 6px;
    }
    
    /* Ensure no horizontal overflow */
    #leaderboard-screen {
        overflow-x: hidden;
    }
    
    .leaderboard-list {
        overflow-x: hidden;
    }
    
    /* Level slider mobile adjustments */
    #level-slider {
        max-width: 80%;
        padding: 4px 8px;
        gap: 8px;
    }
    
    #level-slider-icon {
        font-size: 24px;
    }
    
    #level-slider-progress {
        width: 120px;
        min-width: 80px;
        max-width: 150px;
    }
    
    #level-slider-text {
        font-size: 14px;
    }
}

/* Pause Menu */
#pause-menu, #how-to-play-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#pause-menu.hidden, #how-to-play-menu.hidden {
    opacity: 0;
    pointer-events: none;
}

.pause-content {
    background: rgba(255, 255, 255, 0.9);
    padding: 40px;
    border-radius: 30px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: visible;
}

#pause-menu.hidden .pause-content, #how-to-play-menu.hidden .pause-content {
    transform: scale(0.8);
}

.pause-content h2 {
    margin: 0 0 30px 0;
    font-size: 42px;
    color: #5d4037;
    text-shadow: 2px 2px 0px rgba(255, 255, 255, 0.5);
}

.settings-group {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    padding: 20px;
    margin: 20px 0;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 18px;
    color: #5d4037;
    font-weight: bold;
}

.setting-row:last-child {
    margin-bottom: 0;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background-color: #ffb300;
}

input:focus+.slider {
    box-shadow: 0 0 1px #ffb300;
}

input:checked+.slider:before {
    transform: translateX(26px);
}
#pause-menu, #how-to-play-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#pause-menu.hidden, #how-to-play-menu.hidden {
    opacity: 0;
    pointer-events: none;
}

.pause-content {
    background: rgba(255, 255, 255, 0.9);
    padding: 40px;
    border-radius: 30px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.5);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: visible;
}

#pause-menu.hidden .pause-content, #how-to-play-menu.hidden .pause-content {
    transform: scale(0.8);
}

.pause-content h2 {
    margin: 0 0 30px 0;
    font-size: 42px;
    color: #5d4037;
    text-shadow: 2px 2px 0px rgba(255, 255, 255, 0.5);
}

.settings-group {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    padding: 20px;
    margin: 20px 0;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 18px;
    color: #5d4037;
    font-weight: bold;
}

.setting-row:last-child {
    margin-bottom: 0;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background-color: #ffb300;
}

input:focus+.slider {
    box-shadow: 0 0 1px #ffb300;
}

input:checked+.slider:before {
    transform: translateX(26px);
}

/* Button Variants */
button {
    background: linear-gradient(to bottom, #ffca28, #ffb300);
    border: none;
    padding: 12px 30px;
    color: #5d4037;
    font-size: 20px;
    border-radius: 50px;
    cursor: pointer;
    margin-top: 20px;
    font-weight: bold;
    font-family: 'Varela Round', sans-serif;
    box-shadow: 0 4px 0 #ff8f00, 0 4px 15px rgba(255, 179, 0, 0.4);
    transition: transform 0.1s, box-shadow 0.1s, filter 0.2s;
}

button:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #ff8f00, 0 6px 20px rgba(255, 179, 0, 0.4);
}

button:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #ff8f00, 0 0 5px rgba(255, 179, 0, 0.4);
}

.primary-btn {
    width: 100%;
    font-size: 24px;
    padding: 15px;
    margin-top: 10px;
}

.primary-btn:active {
    transform: translateY(4px);
    margin-top: 10px;
    box-shadow: 0 0 0 #ff8f00, 0 0 5px rgba(255, 179, 0, 0.4);
}

.secondary-btn {
    width: 100%;
    background: #e0e0e0;
    color: #757575;
    box-shadow: 0 4px 0 #bdbdbd;
    font-size: 18px;
    margin-top: 10px;
}

.secondary-btn:active {
    transform: translateY(4px);
    margin-top: 10px;
    box-shadow: 0 0 0 #bdbdbd, 0 0 5px rgba(189, 189, 189, 0.4);
}

.secondary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 4px 0 #bdbdbd !important;
}

.danger-btn {
    width: 100%;
    background: linear-gradient(to bottom, #ef5350, #e53935);
    color: white;
    font-size: 18px;
    margin-top: 10px;
    box-shadow: 0 4px 0 #c62828, 0 4px 15px rgba(229, 57, 53, 0.4);
}

.danger-btn:hover {
    box-shadow: 0 6px 0 #c62828, 0 6px 20px rgba(229, 57, 53, 0.4);
}

.danger-btn:active {
    transform: translateY(4px);
    margin-top: 10px;
    box-shadow: 0 0 0 #c62828, 0 0 5px rgba(229, 57, 53, 0.4);
}

/* Dark Mode Overrides */
body.dark-mode {
    background: #121212;
}

body.dark-mode #pause-menu .pause-content, body.dark-mode #how-to-play-menu .pause-content {
    background: #1e1e1e;
    color: #e0e0e0;
    border-color: #333;
}

body.dark-mode .pause-content h2 {
    color: #ffb300;
    text-shadow: none;
}

body.dark-mode .setting-row {
    color: #e0e0e0;
}

body.dark-mode .settings-group {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .secondary-btn {
    background: linear-gradient(to bottom, #555, #444);
    color: #e0e0e0;
    box-shadow: 0 4px 0 #333, 0 4px 15px rgba(51, 51, 51, 0.4);
}

body.dark-mode .secondary-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #333, 0 6px 20px rgba(51, 51, 51, 0.4);
}

body.dark-mode .secondary-btn:active {
    transform: translateY(4px);
    margin-top: 10px;
    box-shadow: 0 0 0 #333, 0 0 5px rgba(51, 51, 51, 0.4);
}

/* Hide Main Menu button */
#main-menu-btn {
    display: none;
}

/* Carousel Styles */
.carousel-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    overflow: visible;
    border-radius: 15px;
    padding-bottom: 15px;
}

.carousel-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel-slide {
    min-width: 100%;
    opacity: 0;
    transition: opacity 0.4s ease;
    display: none;
}

.carousel-slide.active {
    opacity: 1;
    display: block;
}

.carousel-image {
    width: 100%;
    height: auto;
    border-radius: 15px;
    display: block;
    max-width: 100%;
}

.carousel-arrow {
    position: absolute;
    bottom: 6px;
    transform: translateY(0);
    background: none;
    border: none;
    border-radius: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    color: #5d4037;
    box-shadow: none;
    padding: 0;
}

.carousel-arrow svg {
    width: 32px;
    height: 32px;
    stroke: #5d4037;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.carousel-arrow:hover {
    background: none;
    border: none;
    transform: translateY(0) scale(1.2);
    box-shadow: none;
}

.carousel-arrow:hover svg {
    stroke: #ff8f00;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

.carousel-arrow:active {
    transform: translateY(0) scale(1.0);
}

.carousel-arrow-left {
    left: -50px;
}

.carousel-arrow-right {
    right: -50px;
}

/* Position arrows relative to pause-content for how-to-play menu */
#how-to-play-menu .carousel-arrow {
    position: absolute;
}

#how-to-play-menu .carousel-arrow-left {
    left: -50px;
}

#how-to-play-menu .carousel-arrow-right {
    right: -50px;
}

.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 20px;
    margin-bottom: 15px;
    padding: 0 10px;
}

.carousel-dot {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(93, 64, 55, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: bold;
    color: #5d4037;
    font-family: 'Varela Round', sans-serif;
    padding: 8px;
}

.carousel-dot:hover {
    background: rgba(93, 64, 55, 0.5);
    transform: scale(1.1);
}

.carousel-dot.active {
    background: #5d4037;
    color: #ffffff;
    transform: scale(1.15);
    border-color: rgba(93, 64, 55, 0.5);
    box-shadow: 0 2px 8px rgba(93, 64, 55, 0.4);
}

/* Dark mode carousel styles */
body.dark-mode .carousel-arrow {
    background: none;
    border: none;
    color: #ffffff;
}

body.dark-mode .carousel-arrow svg {
    stroke: #ffffff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

body.dark-mode .carousel-arrow:hover {
    background: none;
    border: none;
}

body.dark-mode .carousel-arrow:hover svg {
    stroke: #ffb300;
    filter: drop-shadow(0 2px 6px rgba(255, 179, 0, 0.4));
}

body.dark-mode .carousel-dot {
    background: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

body.dark-mode .carousel-dot:hover {
    background: rgba(255, 255, 255, 0.5);
}

body.dark-mode .carousel-dot.active {
    background: #ffb300;
    color: #1e1e1e;
    border-color: rgba(255, 179, 0, 0.5);
    box-shadow: 0 2px 8px rgba(255, 179, 0, 0.4);
}

button:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #ff8f00, 0 0 5px rgba(255, 179, 0, 0.4);
}

.primary-btn {
    width: 100%;
    font-size: 24px;
    padding: 15px;
    margin-top: 10px;
}

.primary-btn:active {
    transform: translateY(4px);
    margin-top: 10px;
    box-shadow: 0 0 0 #ff8f00, 0 0 5px rgba(255, 179, 0, 0.4);
}

.secondary-btn {
    width: 100%;
    background: #e0e0e0;
    color: #757575;
    box-shadow: 0 4px 0 #bdbdbd;
    font-size: 18px;
    margin-top: 10px;
}

.secondary-btn:active {
    transform: translateY(4px);
    margin-top: 10px;
    box-shadow: 0 0 0 #bdbdbd, 0 0 5px rgba(189, 189, 189, 0.4);
}

.secondary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 4px 0 #bdbdbd !important;
}

.danger-btn {
    width: 100%;
    background: linear-gradient(to bottom, #ef5350, #e53935);
    color: white;
    font-size: 18px;
    margin-top: 10px;
    box-shadow: 0 4px 0 #c62828, 0 4px 15px rgba(229, 57, 53, 0.4);
}

.danger-btn:hover {
    box-shadow: 0 6px 0 #c62828, 0 6px 20px rgba(229, 57, 53, 0.4);
}

.danger-btn:active {
    transform: translateY(4px);
    margin-top: 10px;
    box-shadow: 0 0 0 #c62828, 0 0 5px rgba(229, 57, 53, 0.4);
}

