body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    font-family: sans-serif;
    background-color: #f8f9fa;
}

.main-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    padding: 20px;
    box-sizing: border-box;
}

.game-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 500px;
}

.highscores-section {
    width: 300px;
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
}

.highscores-section h2 {
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
    color: #2c3e50;
    font-size: 1.5em;
}

#highscoresList {
    max-height: 400px;
    overflow-y: auto;
}

.highscore-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid #3498db;
}

.highscore-item:nth-child(1) { border-left-color: #f1c40f; }
.highscore-item:nth-child(2) { border-left-color: #95a5a6; }
.highscore-item:nth-child(3) { border-left-color: #cd7f32; }

.highscore-rank {
    font-weight: bold;
    color: #7f8c8d;
    min-width: 25px;
}

.highscore-name {
    flex: 1;
    margin: 0 10px;
    font-weight: 500;
    color: #2c3e50;
}

.highscore-score {
    font-weight: bold;
    color: #e74c3c;
}

.loading {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
}

#nameInputSection {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

#playerName {
    padding: 8px 12px;
    border: 2px solid #bdc3c7;
    border-radius: 5px;
    font-size: 1em;
    width: 200px;
    text-align: center;
}

#playerName:focus {
    outline: none;
    border-color: #3498db;
}

#submitScore {
    padding: 8px 16px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
}

#submitScore:hover {
    background-color: #c0392b;
}

#submitScore:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

/* Responsive design */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        gap: 20px;
        padding: 10px;
        margin: 0 10px;
        max-width: calc(100vw - 20px);
        box-sizing: border-box;
    }
    
    .game-section {
        width: 100%;
        max-width: none;
    }
    
    .highscores-section {
        width: 100%;
        max-width: none;
        margin: 0;
        box-sizing: border-box;
    }
    
    .highscore-item {
        min-width: 0;
    }
    
    .highscore-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }
}

/* Additional responsive breakpoint for very small screens */
@media (max-width: 480px) {
    .main-container {
        padding: 5px;
        margin: 0 5px;
        max-width: calc(100vw - 10px);
    }
    
    .highscores-section {
        padding: 15px;
    }
    
    .highscore-item {
        padding: 8px;
        font-size: 0.9em;
    }
    
    .highscores-section h2 {
        font-size: 1.3em;
    }
}

h1 {
    margin-top: 10px;
    margin-bottom: 15px;
}

canvas {
    border: 1px solid black;
    background-color: #fff;
    display: block;
    max-width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
}

#gameContainer {
    position: relative;
    margin-top: 10px;
    width: 95%;
    max-width: 400px;
}

#gameInfo {
    margin-bottom: 10px;
    font-size: 1.2em;
    width: calc(100% - 2px);
    height: calc(100% - 2px);
    top: 1px;
    left: 1px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#gameOver {
    position: absolute;
    top: 1px;
    left: 1px;
    width: calc(100% - 2px);
    height: calc(100% - 2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    color: #e74c3c;
    font-weight: bold;
    text-align: center;
    background-color: rgba(236, 240, 241, 0.85);
    box-sizing: border-box;
}

#gameOver h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #c0392b;
}

#gameOver p {
    font-size: 0.8em;
    color: #34495e;
    margin-bottom: 20px;
}

#restartButton {
    padding: 12px 25px;
    font-size: 0.8em;
    cursor: pointer;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.2s ease;
}

#restartButton:hover {
    background-color: #2980b9;
}

#instructions {
    margin-top: 20px;
    font-size: 0.9em;
    text-align: center;
}

#instructions p {
    margin: 5px 0;
}

/* Style for Start Game Screen (similar to Game Over) */
#startGameScreen {
    position: absolute;
    top: 1px;
    left: 1px;
    width: calc(100% - 2px);
    height: calc(100% - 2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    color: #34495e;
    font-weight: bold;
    text-align: center;
    background-color: rgba(236, 240, 241, 0.9);
    box-sizing: border-box;
}

#startGameScreen h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
}

#startGameScreen p {
    font-size: 0.8em;
    color: #34495e;
    margin-bottom: 20px;
}

#startButton {
    padding: 12px 25px;
    font-size: 0.8em;
    cursor: pointer;
    background-color: #2ecc71;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.2s ease;
}

#startButton:hover {
    background-color: #27ae60;
}

.score-container {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    padding: 0 10px;
    box-sizing: border-box;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

#difficultySelector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    width: 100%;
    max-width: 400px;
    padding: 0 10px;
    box-sizing: border-box;
}
