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

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

/* Loading animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

body {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    font-family: 'Press Start 2P', monospace;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100vw;
    height: 100vh;
    touch-action: manipulation;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#joystick-zone {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 150px;
    height: 150px;
    z-index: 1000;
}

.game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    color: #fff;
    z-index: 200;
    display: none; /* Initially hidden */
}

.logo-background {
    position: absolute;
    bottom: 5%;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 201;
    opacity: 0.2;
    pointer-events: none;
}

.background-logo {
    width: 70%;
    max-width: 600px;
    height: auto;
    opacity: 0.8;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.5));
}

.game-over-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 202;
    width: 90%;
    max-width: 550px;
    background: rgba(0,0,0,0.8);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    border: 3px solid white;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-over h2 {
    font-size: 24px;
    margin-bottom: 15px;
    color: #ff5a5f;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.leaderboard-section {
    margin-top: 20px;
    margin-bottom: 20px;
    width: 100%;
}

.leaderboard-section h3 {
    font-size: 14px;
    margin-bottom: 15px;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.mini-leaderboard {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.mini-leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    color: white;
    font-size: 9px;
}

.mini-leaderboard-entry.gold {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 165, 0, 0.3));
}

.mini-leaderboard-entry.silver {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.3), rgba(128, 128, 128, 0.3));
}

.mini-leaderboard-entry.bronze {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.3), rgba(139, 69, 19, 0.3));
}

.mini-leaderboard-entry .rank {
    font-weight: bold;
    min-width: 25px;
}

.mini-leaderboard-entry .player-name {
    flex: 1;
    text-align: left;
    margin: 0 8px;
}

.mini-leaderboard-entry .score-value {
    font-weight: bold;
}

.message-logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.connect-message {
    font-size: 12px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    margin-bottom: 5px;
}

.logo-container {
    background-color: rgba(255,255,255,0.95);
    padding: 15px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.tfss-logo {
    width: 180px;
    height: auto;
    max-height: 100px;
    object-fit: contain;
}

.start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    z-index: 300;
}

.title-container {
    background: rgba(0, 0, 0, 0.7);
    padding: 40px;
    border-radius: 20px;
    border: 3px solid #fff;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90%;
}

.title {
    font-size: 28px;
    margin-bottom: 15px;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    color: #fff;
    font-weight: bold;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 14px;
    margin-bottom: 25px;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    font-weight: normal;
}

.controls {
    margin-top: 15px;
    font-size: 8px;
    opacity: 0.8;
}

.start-btn {
    margin-top: 20px;
    padding: 15px 30px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.start-btn:hover {
    background: #45a049;
    transform: scale(1.05);
}

/* Style for the jump button */
#jumpButton {
    position: fixed;
    bottom: 60px;
    right: 40px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
    font-size: 14px;
    border: none;
    opacity: 0.8;
    user-select: none;
    background-color: #ff5a5f; /* Changed to a bright red color for better visibility */
    color: white;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

#jumpButton:active {
    background-color: #e04045; /* Darker shade when pressed */
    transform: scale(0.95);
}

/* Leaderboard Styles */
.leaderboard-btn {
    margin-top: 10px;
    padding: 12px 25px;
    background: #4ecdc4;
    color: white;
    border: none;
    border-radius: 5px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.leaderboard-btn:hover {
    background: #3db5ac;
    transform: scale(1.05);
}

.leaderboard-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    z-index: 400;
    display: flex;
    justify-content: center;
    align-items: center;
}

.leaderboard-container {
    background: rgba(0, 0, 0, 0.9);
    padding: 30px;
    border-radius: 20px;
    border: 3px solid #ffd700;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
}

.leaderboard-container h2 {
    color: #ffd700;
    margin-bottom: 20px;
    font-size: 20px;
}

.leaderboard-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 8px 16px;
    background: #333;
    color: #888;
    border: 2px solid #333;
    border-radius: 5px;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: #ffd700;
    color: #000;
    border-color: #ffd700;
}

.leaderboard-list {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    color: white;
    font-size: 10px;
}

.leaderboard-entry.gold {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
}

.leaderboard-entry.silver {
    background: linear-gradient(135deg, #C0C0C0, #808080);
    color: #000;
}

.leaderboard-entry.bronze {
    background: linear-gradient(135deg, #CD7F32, #8B4513);
    color: #fff;
}

.rank {
    font-weight: bold;
    margin-right: 10px;
    min-width: 30px;
}

.player-name {
    flex: 1;
    text-align: left;
    margin: 0 10px;
}

.score-value {
    font-weight: bold;
}

.back-btn {
    padding: 12px 25px;
    background: #666;
    color: white;
    border: none;
    border-radius: 5px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.back-btn:hover {
    background: #555;
    transform: scale(1.05);
}

/* Score Submission Styles */
.score-submission {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#playerNameInput {
    padding: 10px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #ffd700;
    border-radius: 5px;
    width: 80%;
    max-width: 300px;
    text-align: center;
}

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

.submit-btn {
    padding: 10px 20px;
    background: #4ecdc4;
    color: white;
    border: none;
    border-radius: 5px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.submit-btn:hover {
    background: #3db5ac;
    transform: scale(1.05);
}

.submit-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: scale(1);
}

.submission-message {
    font-size: 10px;
    margin-top: 10px;
    padding: 8px;
    border-radius: 5px;
    display: none;
}

.submission-message.success {
    background: rgba(76, 175, 80, 0.3);
    color: #4CAF50;
    display: block;
}

.submission-message.error {
    background: rgba(244, 67, 54, 0.3);
    color: #f44336;
    display: block;
}

.loading {
    color: #ffd700;
    font-size: 12px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Hide controls when start screen is visible */
.start-screen ~ #joystick-zone,
.start-screen ~ #jump-button {
    display: none !important;
}

/* Media query for smaller screens */
@media (max-width: 600px) {
    .qr-code {
        width: 180px;
        height: 180px;
    }

    .background-logo {
        width: 90%;
    }

    .leaderboard-container {
        width: 95%;
        padding: 20px;
    }

    .leaderboard-entry {
        font-size: 8px;
    }
}
