body {
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    overflow: hidden;
    color: white;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

h1 {
    color: #4ecca3;
    text-shadow: 0 0 20px rgba(78, 204, 163, 0.8);
    margin-bottom: 20px;
    font-size: 2.5em;
    text-align: center;
}

#game-canvas {
    background: linear-gradient(180deg, #232f3e, #0f3460);
    border: 3px solid #4ecca3;
    box-shadow: 0 0 30px rgba(78, 204, 163, 0.6);
    border-radius: 8px;
}

#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    font-size: 16px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #4ecca3;
    min-width: 200px;
}

.hud-item {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.hud-label {
    color: #4ecca3;
    font-weight: bold;
}

/* Lives display styling */
#lives-value {
    font-weight: bold;
    font-size: 18px;
    text-shadow: 0 0 5px currentColor;
    transition: color 0.3s ease;
}

.menu-screen {
    position: absolute;
    background: rgba(26, 26, 46, 0.95);
    width: 90%;
    max-width: 500px;
    max-height: 80vh; /* Limit height to 80% of viewport */
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    z-index: 20;
    color: white;
    display: none;
    border: 3px solid #4ecca3;
    box-shadow: 0 0 30px rgba(78, 204, 163, 0.5);
    overflow-y: auto; /* Enable vertical scrolling */
}

/* Custom scrollbar styling */
.menu-screen::-webkit-scrollbar {
    width: 8px;
}

.menu-screen::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.menu-screen::-webkit-scrollbar-thumb {
    background: #4ecca3;
    border-radius: 4px;
}

.menu-screen::-webkit-scrollbar-thumb:hover {
    background: #3db58a;
}

/* Scrollable molecule summary */
.molecule-summary-scrollable {
    max-height: 300px;
    overflow-y: auto;
    margin: 10px 0;
    padding: 10px;
    border: 1px solid #4ecca3;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.molecule-summary-scrollable::-webkit-scrollbar {
    width: 6px;
}

.molecule-summary-scrollable::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.molecule-summary-scrollable::-webkit-scrollbar-thumb {
    background: #4ecca3;
    border-radius: 3px;
}

.molecule-summary-scrollable::-webkit-scrollbar-thumb:hover {
    background: #3db58a;
}

.menu-screen.active {
    display: block;
}

.menu-screen h2 {
    color: #4ecca3;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(78, 204, 163, 0.7);
}

button {
    background: linear-gradient(135deg, #4ecca3, #3db58a);
    border: none;
    color: #1a1a2e;
    padding: 12px 25px;
    margin: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(78, 204, 163, 0.3);
}

button:hover {
    background: linear-gradient(135deg, #7efdd0, #4ecca3);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 204, 163, 0.5);
}

.collected-elements {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.element-chip {
    background: #4ecca3;
    color: #1a1a2e;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

/* Difficulty Menu Styles */
.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 30px 0;
    max-width: 600px;
}

.difficulty-option {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.difficulty-option:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(78, 204, 163, 0.7);
    transform: translateY(-2px);
}

.difficulty-option.selected {
    background: rgba(78, 204, 163, 0.2);
    border-color: #4ecca3;
    box-shadow: 0 0 20px rgba(78, 204, 163, 0.3);
}

.difficulty-option h3 {
    margin: 0 0 10px 0;
    font-size: 1.5em;
    color: #4ecca3;
}

.difficulty-option p {
    margin: 5px 0;
    color: #cccccc;
    font-size: 0.9em;
}

.difficulty-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
}

.difficulty-buttons button {
    padding: 12px 30px;
    font-size: 1.1em;
    min-width: 120px;
}

/* Pause indicator styles */
.pause-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: #4ecca3;
    padding: 20px 40px;
    border-radius: 15px;
    border: 3px solid #4ecca3;
    font-size: 1.5em;
    font-weight: bold;
    text-align: center;
    z-index: 1000;
    box-shadow: 0 0 30px rgba(78, 204, 163, 0.8);
    animation: pausePulse 2s infinite;
}

@keyframes pausePulse {
    0%, 100% { 
        box-shadow: 0 0 30px rgba(78, 204, 163, 0.8);
        transform: translate(-50%, -50%) scale(1);
    }
    50% { 
        box-shadow: 0 0 40px rgba(78, 204, 163, 1);
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* High Score Styles */
.highscore-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.difficulty-filter {
    padding: 8px 16px;
    border: 2px solid #666;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty-filter:hover {
    border-color: #4ecca3;
    background: rgba(78, 204, 163, 0.2);
}

.difficulty-filter.active {
    border-color: #4ecca3;
    background: rgba(78, 204, 163, 0.3);
    color: #4ecca3;
}

.highscore-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding-right: 10px;
}

.highscore-entry {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #666;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.highscore-entry:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #4ecca3;
}

.highscore-entry.top-three {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
}

.highscore-entry.top-three:first-child {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.2);
}

.rank {
    font-size: 24px;
    font-weight: bold;
    color: #4ecca3;
    margin-right: 15px;
    min-width: 40px;
}

.top-three .rank {
    color: #ffd700;
}

.score-details {
    flex: 1;
}

.player-name {
    font-size: 18px;
    font-weight: bold;
    color: white;
    margin-bottom: 5px;
}

.score-info {
    display: flex;
    gap: 15px;
    margin-bottom: 5px;
}

.score {
    font-size: 16px;
    font-weight: bold;
    color: #4ecca3;
}

.difficulty, .level {
    font-size: 14px;
    color: #ccc;
}

.molecules-formed {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 3px;
}

.date {
    font-size: 10px;
    color: #888;
}

.no-scores {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px;
}

.highscore-stats {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #666;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.highscore-stats h3 {
    margin: 0 0 15px 0;
    color: #4ecca3;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.stat-item {
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    padding: 10px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #4ecca3;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #ccc;
    text-transform: uppercase;
}

.highscore-notification {
    background: rgba(78, 204, 163, 0.2);
    border: 2px solid #4ecca3;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
    animation: highScoreGlow 1s ease-in-out infinite alternate;
}

.highscore-notification h3 {
    margin: 0 0 10px 0;
    color: #4ecca3;
}

@keyframes highScoreGlow {
    from {
        box-shadow: 0 0 20px rgba(78, 204, 163, 0.5);
    }
    to {
        box-shadow: 0 0 30px rgba(78, 204, 163, 0.8);
    }
}

.menu-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* Scrollbar styling for high score list */
.highscore-list::-webkit-scrollbar {
    width: 8px;
}

.highscore-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.highscore-list::-webkit-scrollbar-thumb {
    background: #4ecca3;
    border-radius: 4px;
}

.highscore-list::-webkit-scrollbar-thumb:hover {
    background: #45b393;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    #game-canvas {
        max-width: 95vw;
        max-height: 60vh;
    }
    
    h1 {
        font-size: 2em;
    }
    
    #hud {
        font-size: 14px;
        padding: 10px;
    }

    .highscore-filters {
        flex-wrap: wrap;
        gap: 5px;
    }

    .difficulty-filter {
        padding: 6px 12px;
        font-size: 14px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .highscore-entry {
        padding: 10px;
    }

    .rank {
        font-size: 20px;
        margin-right: 10px;
        min-width: 35px;
    }

    .player-name {
        font-size: 16px;
    }

    .score-info {
        flex-direction: column;
        gap: 5px;
    }
}