* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background-color: #181818;
    color: #ffffff;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

#game-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 50px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

#canvas-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Reserve space for scaled canvas: 512px * 1.3 = 665.6px */
    width: 665.6px;
    height: 665.6px;
    flex-shrink: 0;
}

#game-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background-color: #212121;
    border: 2px solid #333;
    /* Scale canvas display size to 1.3x (internal resolution stays 512x512) */
    width: 665.6px !important;
    height: 665.6px !important;
}

#left-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 15px;
    width: 250px;
    flex-shrink: 0;
    padding-right: 20px;
}

#right-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
    width: 250px;
    flex-shrink: 0;
    padding-left: 20px;
    height: 665.6px; /* Match canvas height */
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#ui-overlay > * {
    pointer-events: auto;
}

#hud {
    background-color: rgba(33, 33, 33, 0.9);
    padding: 15px;
    border: 1px solid #555;
    border-radius: 4px;
    width: 100%;
    max-width: 230px;
}

#instructions {
    background-color: rgba(33, 33, 33, 0.9);
    padding: 15px;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 12px;
    width: 100%;
    max-width: 230px;
}

#leaderboard-panel {
    background-color: rgba(33, 33, 33, 0.9);
    padding: 15px;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 12px;
    width: 100%;
    max-width: 230px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#leaderboard-panel h3 {
    color: #4CAF50;
    margin-bottom: 10px;
    margin-top: 0;
    font-size: 14px;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

#leaderboard-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #555 #333;
}

#leaderboard-content::-webkit-scrollbar {
    width: 8px;
}

#leaderboard-content::-webkit-scrollbar-track {
    background: #333;
    border-radius: 4px;
}

#leaderboard-content::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

#leaderboard-content::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.leaderboard-entry-mini {
    padding: 6px 0;
    margin: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
    line-height: 1.4;
}

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

.leaderboard-entry-mini .rank {
    color: #4CAF50;
    font-weight: bold;
    display: inline-block;
    min-width: 25px;
}

.leaderboard-entry-mini .name {
    color: #fff;
    font-weight: bold;
}

.leaderboard-entry-mini .score {
    color: #aaa;
    font-size: 10px;
    display: block;
    margin-top: 2px;
}

#messages {
    background-color: rgba(33, 33, 33, 0.9);
    padding: 15px;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 12px;
    width: 100%;
    max-width: 230px;
    flex: 0 0 15%; /* 15% of right panel height (approximately 10-20% as requested) */
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#messages h3 {
    color: #4CAF50;
    margin-bottom: 10px;
    margin-top: 0;
    font-size: 14px;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

#messages-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #555 #333;
}

#messages-content::-webkit-scrollbar {
    width: 8px;
}

#messages-content::-webkit-scrollbar-track {
    background: #333;
    border-radius: 4px;
}

#messages-content::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

#messages-content::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.message-item {
    margin: 8px 0;
    padding: 5px 0;
    color: #fff;
    line-height: 1.4;
    font-size: 11px;
}

#instructions h3 {
    color: #4CAF50;
    margin-bottom: 10px;
    margin-top: 0;
    font-size: 14px;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

#instructions h3:not(:first-child) {
    margin-top: 15px;
}

#instructions p {
    margin: 8px 0;
    color: #aaa;
    line-height: 1.4;
}

.instruction-item {
    margin: 8px 0;
    padding: 5px 0;
    color: #fff;
}

.instruction-item strong {
    color: #4CAF50;
    display: inline-block;
    min-width: 80px;
}

#energy-bar-container {
    margin-bottom: 10px;
}

#energy-label {
    font-size: 12px;
    margin-bottom: 5px;
}

#energy-bar {
    width: 200px;
    height: 20px;
    background-color: #333;
    border: 1px solid #555;
    position: relative;
}

#energy-fill {
    height: 100%;
    background-color: #4CAF50;
    transition: width 0.1s linear;
    width: 100%;
}

#energy-value {
    font-size: 10px;
    margin-top: 3px;
    text-align: right;
}

#stats {
    font-size: 12px;
    line-height: 1.6;
}

#stats span {
    color: #4CAF50;
}

#game-over-screen,
#leaderboard-screen,
#pause-screen,
#start-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(33, 33, 33, 0.95);
    padding: 30px;
    border: 2px solid #555;
    text-align: center;
    min-width: 300px;
}

#game-stats {
    margin: 20px 0;
    text-align: left;
    display: inline-block;
    min-width: 250px;
}

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

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: #aaa;
    font-weight: normal;
}

.stat-value {
    color: #4CAF50;
    font-weight: bold;
}

#start-screen h1 {
    margin-bottom: 20px;
    color: #4CAF50;
}

#start-screen p {
    margin: 10px 0;
    color: #aaa;
}

#start-button,
#submit-score,
#skip-submit,
#play-again {
    padding: 12px 24px !important;
    background-color: #4CAF50;
    color: white !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 16px !important;
    font-family: 'Courier New', monospace !important;
    border-radius: 4px !important;
    transition: all 0.3s ease !important;
    font-weight: bold !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
}

#start-button,
#play-again {
    margin-top: 20px;
}

/* Game Over Buttons Styling - Updated v2 */
#skip-submit {
    background-color: #2196F3 !important;
    border: none !important;
    outline: none !important;
}

#start-button:hover,
#submit-score:hover,
#play-again:hover {
    background-color: #45a049 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.4);
}

#skip-submit:hover {
    background-color: #1976D2 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.4);
}

#start-button:active,
#submit-score:active,
#skip-submit:active,
#play-again:active {
    transform: translateY(0);
    box-shadow: none;
}

#game-over-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

#player-name {
    margin: 15px 0;
    padding: 8px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    background-color: #333;
    color: white;
    border: 1px solid #555;
    width: 100%;
}

#player-name:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#submit-score:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#submitting-message {
    margin-top: 10px;
    color: #4CAF50;
    font-size: 12px;
}

#play-again-container {
    margin-top: 20px;
}

#play-again-from-gameover {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-family: 'Courier New', monospace;
}

#play-again-from-gameover:hover {
    background-color: #45a049;
}

#leaderboard-list {
    max-height: 400px;
    overflow-y: auto;
    margin: 20px 0;
    text-align: left;
}

.leaderboard-entry {
    padding: 8px;
    margin: 5px 0;
    background-color: rgba(255, 255, 255, 0.05);
    border-left: 3px solid #4CAF50;
}

.leaderboard-entry:nth-child(1) {
    border-left-color: #FFD700;
}

.leaderboard-entry:nth-child(2) {
    border-left-color: #C0C0C0;
}

.leaderboard-entry:nth-child(3) {
    border-left-color: #CD7F32;
}

.hidden {
    display: none !important;
}

