body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Arial', sans-serif;
}

#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#score, #length {
    position: absolute;
    top: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 10px;
    border-radius: 5px;
    font-size: 18px;
    z-index: 10;
}

#score {
    left: 20px;
}

#length {
    right: 20px;
}

#collectibles {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 10px;
    border-radius: 5px;
    z-index: 10;
    max-width: 350px;
}

#collectibles h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
    text-align: center;
}

.collectible {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 5px 8px;
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.1);
}

.collectible:last-child {
    margin-bottom: 0;
}

.collectible-coin {
    background-color: rgba(255, 204, 51, 0.2);
}

.collectible-bubble {
    background-color: rgba(136, 204, 255, 0.2);
}

.collectible-crystal {
    background-color: rgba(68, 170, 255, 0.2);
}

.collectible-cloud {
    background-color: rgba(255, 255, 255, 0.2);
}

.collectible-star {
    background-color: rgba(255, 255, 0, 0.2);
}

.collectible .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-right: 8px;
}

.collectible .icon svg {
    width: 24px;
    height: 24px;
}

.collectible .type {
    text-transform: capitalize;
    font-weight: bold;
    min-width: 60px;
}

.collectible .count {
    margin: 0 10px;
    min-width: 30px;
}

.collectible .value {
    color: #aaffaa;
    margin: 0 8px;
    min-width: 40px;
}

.collectible .total {
    margin-left: auto;
    font-weight: bold;
}

.total-score {
    margin-top: 12px;
    padding: 8px 10px;
    background-color: rgba(76, 175, 80, 0.3);
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

#instructions, #game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    z-index: 20;
    max-width: 80%;
    max-height: 80%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}

/* Display instructions vertically */
#instructions p {
    display: block;
    margin: 8px 0;
    text-align: left;
    padding-left: 20px;
    position: relative;
}

#instructions p:before {
    content: '•';
    position: absolute;
    left: 5px;
    color: #4CAF50;
}

.player-input {
    margin: 15px 0;
    width: 100%;
    text-align: center;
}

#player-name {
    padding: 12px 15px;
    border-radius: 5px;
    border: 2px solid #4CAF50;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 16px;
    width: 80%;
    max-width: 300px;
    transition: all 0.3s ease;
    text-align: center;
}

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

#player-name::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

button {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: #45a049;
}

#instructions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    max-width: 90%;
    width: 500px;
    margin: 0 auto;
    z-index: 100;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    max-width: 90%;
    width: 500px;
    margin: 0 auto;
    z-index: 100;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

@media (max-width: 768px) {
    body, html {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        touch-action: manipulation; /* Prevent browser handling of gestures */
    }
    
    #game-container {
        position: fixed;
    }
    
    #instructions, #game-over {
        width: 90%;
        padding: 15px;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    #instructions h2, #game-over h2 {
        font-size: 1.5rem;
        margin-top: 0;
    }
    
    #instructions p, #game-over p {
        font-size: 0.9rem;
        margin: 8px 0;
    }
    
    .player-input, #game-over button {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: 10px;
    }
    
    .player-input input {
        width: 90%;
        margin-bottom: 10px;
        padding: 8px;
        font-size: 16px; /* Prevent auto-zoom on focus on mobile */
    }
    
    .player-input button, #restart-button {
        width: 90%;
        padding: 10px;
        font-size: 16px;
    }
}

#game-stats-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px;
    border-radius: 10px;
    z-index: 100;
    width: 300px;
    max-width: 90%;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: none; /* Initially hidden, will be shown during gameplay */
    transition: all 0.3s ease;
}

#game-stats-panel.collapsed {
    width: auto;
    min-width: 150px;
    cursor: pointer;
}

#game-stats-panel.collapsed:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.expand-toggle {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.expand-toggle svg {
    transition: transform 0.3s ease;
    opacity: 0.7;
}

#game-stats-panel:hover .expand-toggle svg {
    opacity: 1;
}

.my-rank {
    display: inline-block;
    background-color: rgba(255, 215, 0, 0.3);
    color: #ffd700;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 12px;
    margin: 0 5px;
    font-size: 12px;
}

.my-score {
    margin-left: 5px;
    font-weight: bold;
    color: #8aff8a;
}

.stats-section {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.stats-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.section-title {
    font-size: 16px;
    font-weight: bold;
    margin: 0 0 10px 0;
    text-align: center;
    color: #4CAF50;
}

/* Players online section */
.players-online {
    text-align: center;
    font-size: 14px;
    padding: 5px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    margin-bottom: 10px;
}

.players-online.many-players {
    background-color: rgba(50, 150, 50, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { background-color: rgba(50, 150, 50, 0.4); }
    50% { background-color: rgba(70, 200, 70, 0.5); }
    100% { background-color: rgba(50, 150, 50, 0.4); }
}

/* Leaderboard section */
.leaderboard-entries {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 5px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.leaderboard-entries::-webkit-scrollbar {
    width: 4px;
}

.leaderboard-entries::-webkit-scrollbar-track {
    background: transparent;
}

.leaderboard-entries::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 3px 8px;
    margin-bottom: 2px;
    border-radius: 4px;
    font-size: 13px;
}

.leaderboard-entry.me {
    background: rgba(255, 215, 0, 0.3);
    font-weight: bold;
}

.no-players {
    text-align: center;
    padding: 5px 0;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
    font-size: 13px;
}

/* Collectibles section */
.collectible {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    padding: 3px 6px;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    font-size: 12px;
}

.collectible:last-child {
    margin-bottom: 0;
}

.collectible-coin {
    background-color: rgba(255, 204, 51, 0.2);
}

.collectible-bubble {
    background-color: rgba(136, 204, 255, 0.2);
}

.collectible-crystal {
    background-color: rgba(68, 170, 255, 0.2);
}

.collectible-cloud {
    background-color: rgba(255, 255, 255, 0.2);
}

.collectible-star {
    background-color: rgba(255, 255, 0, 0.2);
}

.collectible .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 8px;
}

.collectible .icon svg {
    width: 18px;
    height: 18px;
}

.collectible .type {
    text-transform: capitalize;
    font-weight: bold;
    min-width: 50px;
}

.collectible .count {
    margin: 0 8px;
    min-width: 20px;
}

.collectible .value {
    color: #aaffaa;
    margin: 0 6px;
    min-width: 20px;
}

.collectible .total {
    margin-left: auto;
    font-weight: bold;
}

.total-score {
    margin-top: 8px;
    padding: 5px 8px;
    background-color: rgba(76, 175, 80, 0.3);
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    #game-stats-panel {
        top: 10px;
        right: 10px;
        padding: 10px;
        width: 250px;
    }
    
    #game-stats-panel.collapsed {
        width: auto;
        min-width: 120px;
        max-width: 60%;
        padding: 8px 10px;
    }
    
    .my-rank {
        padding: 1px 6px;
        font-size: 10px;
        margin: 0 3px;
    }
    
    .my-score {
        display: block;
        margin: 5px 0 0 0;
        font-size: 11px;
    }
    
    .section-title {
        font-size: 14px;
        margin-bottom: 5px;
    }
    
    .players-online {
        font-size: 12px;
        padding: 3px;
    }
    
    .leaderboard-entries {
        max-height: 120px;
    }
    
    .leaderboard-entry {
        padding: 2px 5px;
        font-size: 11px;
    }
    
    .collectible {
        padding: 2px 4px;
        font-size: 10px;
    }
    
    .collectible .icon {
        width: 20px;
        height: 20px;
    }
    
    .collectible .icon svg {
        width: 16px;
        height: 16px;
    }
    
    .total-score {
        font-size: 12px;
        padding: 4px 6px;
    }
}

/* Kill feed styles */
.kill-message {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    margin-bottom: 5px;
    border-radius: 4px;
    transition: opacity 0.5s;
    animation: fadeIn 0.3s, fadeOut 0.5s 4.5s forwards;
}

.kill-message.red {
    background: rgba(200, 0, 0, 0.8);
}

.kill-message.green {
    background: rgba(0, 150, 0, 0.8);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
