body {
    margin: 0;
    min-height: 100vh;
    background: #f0f2f5;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 2rem;
    padding: 20px;
    box-sizing: border-box;
}

#game-container {
    position: relative;
    width: 900px;
    height: 700px;
    background: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    justify-self: center;
    align-self: center;
}

.screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #333;
    background: rgba(255, 255, 255, 0.95);
    padding: 2.5rem;
    border-radius: 20px;
    width: 80%;
    z-index: 10;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.hidden {
    display: none !important;
}

#game-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    position: relative;
}

button {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    background: #4CAF50;
    border: none;
    color: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 20;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

button:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

#pause-button {
    position: absolute;
    top: -50px;
    right: 0;
    padding: 0.5rem 1.5rem;
    font-size: 1rem;
    background: #6c757d;
}

#pause-button:hover {
    background: #5a6268;
}

canvas {
    border: none;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: block;
}

h1 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

h2 {
    color: #2c3e50;
    font-size: 1.8rem;
    font-weight: 600;
}

p {
    margin-bottom: 2rem;
    font-size: 1.1rem;
    line-height: 1.6;
    color: #666;
}

#game-over-message {
    color: #e74c3c;
    font-weight: bold;
    margin: 1rem 0;
    font-size: 1.2rem;
}

#scoreboard {
    position: relative;
    background-color: rgba(0, 0, 0, 0.9);
    padding: 25px;
    border-radius: 15px;
    color: white;
    width: 350px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    font-family: 'Segoe UI', Arial, sans-serif;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    align-self: start;
}

#scoreboard h2 {
    text-align: center;
    margin: 0 0 20px 0;
    color: #fff;
    font-size: 1.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#scores-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Table header */
.scores-header {
    display: grid;
    grid-template-columns: 0.5fr 2fr 0.8fr 1fr;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 10px;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.score-entry {
    display: grid;
    grid-template-columns: 0.5fr 2fr 0.8fr 1fr;
    align-items: center;
    padding: 12px 15px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.score-entry:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
    border-color: rgba(255, 255, 255, 0.2);
}

.score-entry .rank {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
}

.score-entry .player-name {
    font-weight: 500;
    font-size: 1.1em;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 10px;
}

.score-entry .level {
    font-size: 0.9em;
    color: #8be9fd;
    background-color: rgba(139, 233, 253, 0.1);
    padding: 4px 8px;
    border-radius: 12px;
    text-align: center;
    width: fit-content;
}

.score-entry .score {
    font-weight: bold;
    font-size: 1.1em;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    text-align: right;
}

/* Top 3 styling */
.score-entry:nth-child(2) {
    background-color: rgba(255, 215, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.score-entry:nth-child(2) .rank {
    color: #ffd700;
}

.score-entry:nth-child(3) {
    background-color: rgba(192, 192, 192, 0.15);
    border: 1px solid rgba(192, 192, 192, 0.3);
}

.score-entry:nth-child(3) .rank {
    color: #c0c0c0;
}

.score-entry:nth-child(4) {
    background-color: rgba(205, 127, 50, 0.15);
    border: 1px solid rgba(205, 127, 50, 0.3);
}

.score-entry:nth-child(4) .rank {
    color: #cd7f32;
}

/* Custom scrollbar */
#scoreboard::-webkit-scrollbar {
    width: 6px;
}

#scoreboard::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

#scoreboard::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

#scoreboard::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

#player-name {
    padding: 0.8rem;
    font-size: 1.1rem;
    border: 2px solid #4CAF50;
    border-radius: 10px;
    width: 200px;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
}

#player-name:focus {
    border-color: #45a049;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.4);
}

.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    min-width: 300px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.popup-content h2 {
    color: #333;
    font-size: 1.2rem;
    margin-bottom: 15px;
    font-weight: normal;
}

.popup-content p {
    color: #000;
    margin-bottom: 20px;
}

.popup-button {
    background: #008CBA;
    color: white;
    padding: 8px 30px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

.popup-button:hover {
    background: #007399;
}

.level-up-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #4CAF50;
    font-size: 48px;
    font-weight: bold;
    padding: 20px 40px;
    border-radius: 15px;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
    animation: levelUp 2s ease-out forwards;
    z-index: 100;
    border: 2px solid #4CAF50;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.3);
}

@keyframes levelUp {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    40% {
        transform: translate(-50%, -50%) scale(1);
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5);
    }
}

@keyframes particle {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

.particle {
    position: absolute;
    pointer-events: none;
    animation: particle 1s ease-out forwards;
}