* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0a0a0a;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    z-index: 10;
}

#ui-layer div {
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
}

#total-games {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: normal;
    text-shadow: none;
    margin-top: 15px;
}

#total-games-count {
    color: rgba(255, 255, 255, 0.7);
    font-weight: bold;
}

.close-button {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    left: 20px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    transition: all 0.3s ease;
    z-index: 200;
}

.close-button:hover {
    color: rgba(255, 255, 255, 1);
    transform: scale(1.2);
}

#game-over-close-btn {
    display: none;
}

#game-over-screen:not(.hidden) + #game-over-close-btn {
    display: flex;
}

.pause-button {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    right: 20px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 20px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    transition: all 0.3s ease;
    z-index: 200;
}

.pause-button:hover {
    color: rgba(255, 255, 255, 1);
    transform: scale(1.2);
}

.resume-btn {
    background: linear-gradient(135deg, #00ffff, #0088ff);
    border: none;
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    color: #000;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.resume-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.leaderboard-replay {
    width: 100%;
    margin-top: 15px;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 136, 255, 0.2));
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 25px;
    color: #00ffff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: opacityPulse 1s ease-in-out infinite;
}

.leaderboard-replay:hover {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.4), rgba(0, 136, 255, 0.4));
    border-color: #00ffff;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.how-to-play-link {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    text-decoration: underline;
    cursor: pointer;
    margin: 10px 0;
    padding: 5px 10px;
    box-shadow: none;
    text-transform: none;
}

.how-to-play-link:hover {
    color: #00ffff;
    transform: none;
    box-shadow: none;
}

/* New start screen styling */
.game-tagline {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    margin: 10px 0 30px;
    text-align: center;
    letter-spacing: 2px;
}

.start-screen-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}

.play-main-btn {
    background: linear-gradient(135deg, #00ffff, #0088ff);
    border: none;
    padding: 20px 60px;
    font-size: 28px;
    font-weight: bold;
    color: #000;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.4);
    transition: all 0.3s ease;
    text-transform: uppercase;
    animation: opacityPulse 1.5s ease-in-out infinite;
}

.play-main-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.6);
}

.secondary-buttons {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.info-btn, button.info-btn, a.info-btn {
    background: transparent;
    border: 2px solid rgba(0, 255, 255, 0.4);
    padding: 12px 25px;
    font-size: 14px;
    font-weight: 600;
    color: #00ffff;
    border-radius: 25px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: none;
    outline: none;
    height: auto;
    line-height: 1.2;
    font-family: inherit;
    margin: 0;
    vertical-align: middle;
}

.info-btn:hover, button.info-btn:hover, a.info-btn:hover {
    background: rgba(0, 255, 255, 0.1);
    border-color: #00ffff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 255, 255, 0.2);
}

@media (max-width: 480px) {
    .play-main-btn {
        padding: 18px 50px;
        font-size: 24px;
    }
    
    .secondary-buttons {
        flex-direction: row;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .info-btn, button.info-btn, a.info-btn {
        padding: 8px 14px;
        font-size: 11px;
        border-radius: 20px;
        border-width: 1px;
    }
}

.modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.9);
    z-index: 30;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 15px;
    padding: 30px 40px;
    max-width: 350px;
    width: 90%;
    text-align: center;
    position: relative;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.3);
}

.modal-content h2 {
    color: #00ffff;
    font-size: 24px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.modal-close-x {
    position: absolute;
    top: 10px;
    right: 15px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: auto;
    height: auto;
    box-shadow: none;
}

.modal-close-x:hover {
    color: #fff;
    transform: scale(1.2);
    box-shadow: none;
}

.instructions {
    margin: 20px 0;
}

.instructions p {
    color: #ccc;
    font-size: 14px;
    margin: 10px 0;
    line-height: 1.5;
}

.modal-ok {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 136, 255, 0.2));
    border: 2px solid rgba(0, 255, 255, 0.5);
    padding: 10px 30px;
    font-size: 16px;
    color: #00ffff;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.modal-ok:hover {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.4), rgba(0, 136, 255, 0.4));
    border-color: #00ffff;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

@keyframes opacityPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    z-index: 20;
    backdrop-filter: blur(5px);
    padding: 20px;
    overflow-y: auto;
}

.screen.hidden {
    display: none;
}

.screen h1 {
    font-size: 36px;
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff, 0 0 40px #00ffff;
    margin-bottom: 20px;
    letter-spacing: 4px;
}

.screen p {
    color: #ccc;
    font-size: 16px;
    margin: 5px 0;
    text-align: center;
}

#start-btn {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 136, 255, 0.2));
    border: 2px solid rgba(0, 255, 255, 0.5);
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    color: #00ffff;
    border-radius: 30px;
    cursor: pointer;
    margin-top: 30px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
    transition: all 0.3s ease;
    text-transform: uppercase;
    animation: opacityPulse 1s ease-in-out infinite;
}

#start-btn:hover {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.4), rgba(0, 136, 255, 0.4));
    border-color: #00ffff;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

button {
    background: linear-gradient(135deg, #00ffff, #0088ff);
    border: none;
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    color: #000;
    border-radius: 30px;
    cursor: pointer;
    margin-top: 30px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    transition: all 0.3s ease;
    text-transform: uppercase;
}

button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.8);
}

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

.button-group {
    display: flex;
    gap: 20px;
}

#exit-btn {
    background: linear-gradient(135deg, #ff4444, #ff0088);
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
}

#exit-btn:hover {
    box-shadow: 0 0 30px rgba(255, 68, 68, 0.8);
}

#final-stats {
    display: flex;
    flex-direction: row;
    gap: 15px;
    margin: 10px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    min-width: 90px;
}

.stat-label {
    color: #888;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    color: #00ffff;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

#leaderboard {
    margin: 15px 0;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    max-width: 280px;
    width: 100%;
}

#leaderboard h3 {
    color: #00ffff;
    font-size: 16px;
    margin-bottom: 10px;
    text-align: center;
    letter-spacing: 2px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
}

.leaderboard-entry:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    color: #888;
    width: 30px;
}

.leaderboard-score {
    color: #ffff00;
    font-weight: bold;
}

.leaderboard-player {
    color: #ccc;
    font-size: 14px;
    flex: 1;
    text-align: center;
}

.leaderboard-entry.current {
    background: rgba(0, 255, 255, 0.1);
    margin: 0 -10px;
    padding: 8px 10px;
    border-radius: 5px;
}

@media (max-width: 600px) {
    .screen h1 {
        font-size: 28px;
        margin: 15px 0 10px 0;
    }
    
    button {
        padding: 10px 25px;
        font-size: 16px;
    }
    
    #ui-layer {
        padding: 10px 15px;
    }
    
    #ui-layer div {
        font-size: 14px;
    }
    
    #final-stats {
        gap: 10px;
    }
    
    .stat {
        padding: 8px 15px;
        min-width: 75px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    #leaderboard {
        padding: 10px 15px;
        max-width: 250px;
    }
    
    #total-games {
        font-size: 12px;
        margin-top: 10px;
    }
    
    .leaderboard-replay {
        padding: 10px 20px;
        font-size: 14px;
        margin-top: 10px;
    }
}

