@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #202123;
    font-family: 'Press Start 2P', monospace;
}

.game-container {
    width: 680px;
    height: 388px;
    position: relative;
    background-color: #202123;
    border: 2px solid #40414f;
    border-radius: 10px;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #e5e5e5;
}

.hidden {
    display: none;
}

h1, h2 {
    color: #ffffff;
    margin-bottom: 20px;
}

button {
    padding: 12px 24px;
    font-size: 1.0em;
    background-color: #3a4a7c;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-family: 'Press Start 2P', monospace;
}

button:hover {
    background-color: #4a5a8c;
}

/* Main Game Buttons */
.main-buttons {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.game-button {
    background-color: #555555;
    color: #ffffff;
    border: 2px solid #777777;
    border-radius: 0px;
    padding: 10px 18px;
    font-size: 10px;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 112px;
    text-align: center;
}

.game-button:hover {
    background-color: #666666;
    border-color: #999999;
    transform: translateY(-2px);
}

.game-button:active {
    transform: translateY(0px);
}

.game-button.disabled {
    background-color: #333333;
    color: #666666;
    border-color: #444444;
    cursor: not-allowed;
    transform: none;
}

.game-button.disabled:hover {
    background-color: #333333;
    border-color: #444444;
    transform: none;
}

/* Training Menu Styles */
.training-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(32, 33, 35, 0.95);
    border: 2px solid #40414f;
    border-radius: 10px;
    padding: 30px;
    z-index: 1000;
    min-width: 400px;
    backdrop-filter: blur(10px);
}

.game-container.training-menu-open #startScreen {
    filter: blur(5px);
    transition: filter 0.3s ease;
}

.training-menu h3 {
    color: #ffffff;
    margin-bottom: 25px;
    text-align: center;
    font-size: 1.2em;
}

.training-zones {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 15px;
}

.training-zone-button {
    background-color: #444444;
    color: #ffffff;
    border: 2px solid #666666;
    border-radius: 0px;
    padding: 8px 12px;
    font-size: 9px;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
}

.training-zone-button:hover {
    background-color: #555555;
    border-color: #888888;
    transform: translateY(-1px);
}

/* Multiplayer Lobby Styles */
.multiplayer-lobby {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(32, 33, 35, 0.95);
    border: 2px solid #40414f;
    border-radius: 9px;
    padding: 27px;
    z-index: 1000;
    min-width: 360px;
    backdrop-filter: blur(10px);
}

.game-container.multiplayer-lobby-open #startScreen {
    filter: blur(5px);
    transition: filter 0.3s ease;
}

.multiplayer-lobby h3 {
    color: #ffffff;
    margin-bottom: 25px;
    text-align: center;
    font-size: 1.2em;
}

.lobby-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.lobby-option-button {
    background-color: #3a4a7c;
    color: #ffffff;
    border: 2px solid #4a5a8c;
    border-radius: 7px;
    padding: 13px 22px;
    font-size: 13px;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.lobby-option-button:hover {
    background-color: #4a5a8c;
    border-color: #5a6a9c;
    transform: translateY(-1px);
}

.lobby-option-button:active {
    transform: translateY(0px);
}

/* Active Lobby Styles */
.active-lobby {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(32, 33, 35, 0.95);
    border: 2px solid #40414f;
    border-radius: 9px;
    padding: 20px;
    z-index: 1000;
    min-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    backdrop-filter: blur(10px);
}
.game-container.active-lobby-open #startScreen {
    filter: blur(5px);
    transition: filter 0.3s ease;
}
.lobby-code-section {
    margin-bottom: 12px;
}
.lobby-code-section h4 {
    color: #ffffff;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    margin-bottom: 6px;
}
.lobby-code {
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    background-color: #3a4a7c;
    padding: 6px 12px;
    border-radius: 4px;
    margin: 6px 0;
    font-family: 'Press Start 2P', monospace;
    letter-spacing: 1px;
}
.copy-code-button {
    background-color: #28a745;
    color: #ffffff;
    border: 1px solid #2fb344;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 8px;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
}
.copy-code-button:hover {
    background-color: #2fb344;
    transform: translateY(-1px);
}
.player-list-section {
    margin-bottom: 12px;
}
.player-list-section h4 {
    color: #ffffff;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    margin-bottom: 6px;
}
.player-list {
    max-height: 80px;
    overflow-y: auto;
    border: 1px solid #4a5a8c;
    border-radius: 4px;
    padding: 6px;
    background-color: rgba(32, 33, 35, 0.5);
}
.player-item {
    display: flex;
    align-items: center;
    padding: 3px 6px;
    background-color: rgba(58, 74, 124, 0.5);
    border-radius: 3px;
    border: 1px solid #4a5a8c;
    margin-bottom: 2px;
    font-size: 8px;
}
.player-item.host {
    background-color: rgba(255, 215, 0, 0.2);
    border-color: #ffd700;
}
.player-name {
    flex: 1;
    color: #ffffff;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
}
.player-role {
    color: #cccccc;
    font-family: 'Press Start 2P', monospace;
    font-size: 6px;
    margin-left: 4px;
}
.lobby-actions {
    margin-top: 10px;
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}
.start-game-button, .leave-lobby-button, .test-webrtc-button {
    background-color: #3a4a7c;
    color: #ffffff;
    border: 1px solid #4a5a8c;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 8px;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}
.start-game-button:hover, .leave-lobby-button:hover, .test-webrtc-button:hover {
    background-color: #4a5a8c;
    border-color: #5a6a9c;
}
.start-game-button:disabled {
    background-color: #2a3a6c;
    border-color: #3a4a7c;
    color: #888888;
    cursor: not-allowed;
}
.test-webrtc-button {
    background-color: #7c3a4a;
    border-color: #8c4a5a;
}
.test-webrtc-button:hover {
    background-color: #8c4a5a;
    border-color: #9c5a6a;
}

.leave-lobby-button:hover {
    background-color: #e04455;
    transform: translateY(-2px);
}

.close-menu-button {
    background-color: #dc3545;
    color: #ffffff;
    border: 2px solid #e04455;
    border-radius: 7px;
    padding: 8px 16px;
    font-size: 12px;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 15px;
}

.close-menu-button:hover {
    background-color: #e04455;
    transform: translateY(-1px);
}

/* Leaderboard */
.leaderboard {
    margin-top: 15px;
    width: 100%;
    max-width: 300px;
}

.leaderboard h3 {
    color: #ffffff;
    text-align: center;
    margin-bottom: 8px;
    font-size: 10px;
}

.leaderboard-list {
    background-color: #2a2a2a;
    border: 2px solid #555555;
    border-radius: 0px;
    padding: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #444444;
    font-size: 9px;
    min-height: 16px;
}

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

.player-name {
    color: #cccccc;
    font-family: 'Press Start 2P', monospace;
    flex: 1;
    margin-right: 10px;
    word-break: break-word;
    line-height: 1.2;
}

.player-score {
    color: #ffffff;
    font-family: 'Press Start 2P', monospace;
    font-weight: bold;
    white-space: nowrap;
    text-align: right;
}

#gameArea {
    position: relative;
    width: 100%;
    height: 100%;
}

#gameArea.blurred {
    filter: blur(4px) grayscale(0.7);
    transition: filter 0.3s;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    /* Remove blur from canvas itself */
    filter: none !important;
}

#score {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #ffffff;
    font-size: 1.0em;
    z-index: 10;
    text-align: right;
    line-height: 1.4; /* Ensure score is visible with proper line height */
}

#score.training-mode {
}

#score.new-record {
    animation: newRecordColors 1s infinite;
}

@keyframes newRecordColors {
    0% { color: #ffff44; }
    25% { color: #ff8844; }
    50% { color: #ff4444; }
    75% { color: #ff8844; }
    100% { color: #ffff44; }
}





.debug-mode-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #ffffff;
    font-size: 0.6em;
    z-index: 15;
    background: rgba(0, 0, 0, 0.8);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #ffffff;
    opacity: 0.9;
}

.bonus-indicator {
    position: absolute;
    top: 50px;
    right: 20px;
    color: #ffff00;
    font-size: 0.8em;
    z-index: 10;
    animation: pulse 1s infinite;
}

/* Game Over Screen Styles */
.game-over-title {
    font-size: 2.5em !important; /* 2.5x larger */
    color: #ffffff; /* Back to white */
    margin-bottom: 5px; /* Back to normal spacing */
    margin-top: -60px; /* Move higher to create space */
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    line-height: 1.1; /* Normal line spacing */
    letter-spacing: -2px; /* Tighter letter spacing between "Game" and "Over" */
}

.final-score {
    font-size: 1.62em; /* 10% smaller: 1.8 * 0.9 = 1.62 */
    color: #ffffff;
    margin: 3px 0; /* Back to normal margins */
    font-weight: bold;
    line-height: 1.2; /* Normal line spacing */
    letter-spacing: -1px; /* Tighter letter spacing in "Score: 21" */
}

.game-over-high-score {
    font-size: 1.26em; /* 10% smaller: 1.4 * 0.9 = 1.26 */
    color: #cccccc;
    margin-bottom: 15px; /* Keep bottom spacing for buttons */
    margin-top: 0px; /* No top margin */
    line-height: 1.2; /* Normal line spacing */
    letter-spacing: -1px; /* Tighter letter spacing in "High Score: 32" */
}

.game-over-buttons {
    display: flex;
    gap: 20px; /* Spacing between buttons */
    margin-left: -30px; /* Shift buttons slightly to the left */
    margin-top: -10px; /* Slight lift but not too much */
}

.game-over-btn {
    padding: 9.6px 16px; /* 20% smaller: 12px * 0.8 = 9.6px, 20px * 0.8 = 16px */
    font-size: 0.72em; /* 20% smaller: 0.9em * 0.8 = 0.72em */
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Press Start 2P', monospace;
    min-width: 96px; /* 20% smaller: 120px * 0.8 = 96px */
}

.game-over-btn.primary {
    background-color: #4a6fa5;
    color: white;
    border: 2px solid #5a7fb5;
}

.game-over-btn.primary:hover {
    background-color: #5a7fb5;
    transform: translateY(-2px);
}

.game-over-btn.secondary {
    background-color: #777777;
    color: white;
    border: 2px solid #888888;
}

.game-over-btn.secondary:hover {
    background-color: #888888;
    transform: translateY(-2px);
}

/* Fade out animation for in-game score */
#score.fade-out {
    animation: fadeOut 2s ease-out forwards;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.reviving-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 1.2em;
    z-index: 15;
    animation: pulse 1s infinite;
}

.restarting-notification {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 1.2em;
    z-index: 15;
    animation: fastPulse 1s infinite;
}

@keyframes fastPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1.0; }
}

.debug-info {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #a0a0a0;
    font-size: 0.7em;
    z-index: 10;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 8px;
}

.debug-info div {
    margin: 5px 0;
}

.debug-section {
    margin-top: 30px;
    text-align: center;
}

.debug-section h3 {
    color: #a0a0a0;
    font-size: 1em;
    margin-bottom: 15px;
}

.debug-section button {
    margin: 5px;
    padding: 8px 15px;
    font-size: 0.7em;
    background-color: #2a3a5c;
    border-radius: 6px;
}

.debug-section button:hover {
    background-color: #3a4a7c;
}

.debug-section select {
    margin: 5px;
    padding: 8px 15px;
    font-size: 0.7em;
    background-color: #2a3a5c;
    color: white;
    border: 1px solid #40414f;
    border-radius: 6px;
    cursor: pointer;
}

.debug-section select:hover {
    background-color: #3a4a7c;
}

.debug-controls {
    margin: 10px 0;
    color: #90a0b0;
    font-size: 0.7em;
}

#debugOutput {
    margin-top: 15px;
    color: #90a0b0;
    font-size: 0.7em;
    max-height: 100px;
    overflow-y: auto;
    text-align: left;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    animation: modalFadeIn 0.3s ease-out forwards;
}

.modal-content {
    background: #1a1a2e;
    border: 2px solid #888888;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    color: white;
    transform: scale(0.7) translateY(-50px);
    opacity: 0;
    animation: modalSlideIn 0.4s ease-out 0.1s forwards;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(2px);
    }
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.7) translateY(-50px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal.closing {
    animation: modalFadeOut 0.3s ease-in forwards;
}

.modal.closing .modal-content {
    animation: modalSlideOut 0.3s ease-in forwards;
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        backdrop-filter: blur(2px);
    }
    to {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
}

@keyframes modalSlideOut {
    from {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
    to {
        transform: scale(0.8) translateY(30px);
        opacity: 0;
    }
}

.modal-content h3 {
    margin-top: 0;
    color: #4CAF50;
    font-size: 1.5em;
}

.modal-content p {
    margin: 15px 0;
    font-size: 1.1em;
}

#playerNameInput {
    width: 100%;
    padding: 12px;
    border: 2px solid #888888;
    border-radius: 0px;
    background: #0f0f23;
    color: white;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    text-align: center;
    margin: 15px 0;
    box-sizing: border-box;
    letter-spacing: 1px;
}

#playerNameInput:focus {
    outline: none;
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.modal-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-btn.primary {
    background: #cccccc;
    color: black;
    border: 2px solid #888888;
}

.modal-btn.primary:hover {
    background: #bbbbbb;
}

.modal-btn:not(.primary) {
    background: transparent;
    color: white;
    border: 2px solid #888888;
}

.modal-btn:not(.primary):hover {
    background: rgba(136, 136, 136, 0.1);
}

/* Enhanced leaderboard styles */
.leaderboard-entry.user-score {
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid #4CAF50;
    border-radius: 3px;
    margin-top: 5px;
}

.leaderboard-entry.loading {
    opacity: 0.6;
    font-style: italic;
}

.player-rank {
    font-weight: bold;
    margin-right: -2px; /* Negative margin to pull medal closer to name */
    font-size: 18.9px; /* 10% smaller: 21px * 0.9 = 18.9px */
    vertical-align: baseline; /* Better alignment with text baseline */
    display: inline-block; /* Better control over positioning */
    line-height: 1; /* Match text line height */
}

.player-rank.gold { color: #ffd700; }
.player-rank.silver { color: #c0c0c0; }
.player-rank.bronze { color: #cd7f32; }







@keyframes detailedFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(3px);
    }
}

@keyframes detailedSlideIn {
    from {
        transform: scale(0.8) translateY(-50px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}



/* Mobile Not Supported Message */
.orientation-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f0f23;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
    box-sizing: border-box;
    text-align: center;
}

.orientation-message h2 {
    color: #ffffff;
    margin-bottom: 20px;
    font-size: 16px;
    line-height: 1.5;
}

.orientation-message p {
    color: #cccccc;
    margin-bottom: 30px;
    font-size: 10px;
    line-height: 1.4;
    max-width: 350px;
}

.rotate-icon {
    font-size: 48px;
    margin: 20px 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* Mobile Device Detection - Show Desktop-Only Message */
/* Only trigger when clearly VERTICAL (height > width) AND very small width */
@media screen and (max-width: 500px) and (orientation: portrait) {
    .orientation-message {
        display: flex !important;
    }
    
    .game-container {
        display: none !important;
    }
}

#gameOverScreen {
    z-index: 30;
    /* Ensure overlay is not blurred */
    filter: none !important;
}

#score {
    /* Remove fade-out on game over, always visible */
    opacity: 1 !important;
    transition: opacity 0.3s;
    z-index: 10;
}

#score.fade-out {
    /* Disable fade-out animation */
    animation: none !important;
    opacity: 1 !important;
}

 