/* Base Style */
body {
    margin: 0;
    background-image: url('/static/images/ali-ac-milaan.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    font-family: 'Poppins', sans-serif;
    color: #ff0023;
    text-align: center;
    padding-top: 80px; /* Accommodate fixed header */
}

/* Prevent scrolling on snake page */
body.no-scroll {
    overflow: hidden;
    height: 100vh;
}

/* Header Styles */
.top-header {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: #00ff05;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
}

.branding {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-size: 2.5em;
}

.top-header h1 {
    font-size: 1.2em;
    font-weight: 600;
    margin: 0;
}

.top-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 20px;
}

.top-nav a {
    text-decoration: none;
    color: #2e8b57;
    font-weight: 600;
    padding: 10px 0;
    display: inline-block;
    border-bottom: 2px solid transparent;
    transition: border-color 0.3s;
}

.top-nav a:hover,
.top-nav a.active {
    border-bottom: 2px solid #2e8b57;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.intro-section {
    margin-top: 40px;
}

.intro-section h2 {
    color: #2e8b57;
    margin-bottom: 20px;
}

.intro-section p {
    font-size: 1em;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
    color: #555;
}

.main-footer {
    background: #ffffff;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    position: fixed;
    bottom: 0;
    width: 100%;
    font-size: 0.9em;
    color: #888;
}

.cta-button {
    display: inline-block;
    padding: 12px 24px;
    background-color: #ffe900;
    color: #000000;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 600;
    transition: background-color 0.3s;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-family: 'Poppins', sans-serif;
}

.cta-button:hover {
    background-color: #87741f;
}

.cta-button.secondary {
    background-color: #e0e0e0;
    color: #333;
}

.cta-button.secondary:hover {
    background-color: #c0c0c0;
}

.snake-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: calc(100vh - 80px);
    overflow: hidden;
    padding: 20px;
    box-sizing: border-box;
}

.snake-main h2 {
    color: #0065fa;
    margin: 0 0 10px 0;
    font-size: 1.5em;
}

.scoreboard {
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #002eff;
}

#gameCanvas {
    border: 2px solid #214231;
    background-color: #5fff00;
    margin: 10px 0;
    max-width: 90vw;
    max-height: 50vh;
}

.game-over {
    font-size: 1.5em;
    color: #721c24;
    margin-top: 20px;
}

.hidden {
    display: none !important;
}

.mobile-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    z-index: 100;
}

.mobile-controls .arrow-button {
    background: rgba(46, 139, 87, 0.9);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
}

.mobile-controls .arrow-button:active {
    background: rgba(36, 109, 69, 0.9);
    transform: scale(0.95);
}

.mobile-controls .middle-row {
    display: flex;
    gap: 15px;
}

/* Hide mobile controls on larger screens */
@media (min-width: 600px) {
    #mobileControls {
        display: none;
    }
}

/* Game Mode Selection */
.mode-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.mode-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.mode-group label {
    font-weight: 600;
    color: #2e8b57;
    font-size: 1.1em;
}

.mode-buttons {
    display: flex;
    gap: 10px;
}

.mode-button {
    padding: 10px 20px;
    background-color: #f0f0f0;
    color: #333;
    border: 2px solid #2e8b57;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Poppins', sans-serif;
    font-size: 1em;
}

.mode-button:hover {
    background-color: #e0e0e0;
}

.mode-button.active {
    background-color: #2e8b57;
    color: white;
}

.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Game Over Modal */
.game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    color: #721c24;
    font-size: 2em;
    margin: 0 0 20px 0;
}

.final-score-text {
    font-size: 1.5em;
    margin: 20px 0;
    color: #333;
}

.name-entry {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.name-entry label {
    font-weight: 600;
    color: #2e8b57;
}

.name-entry input {
    padding: 10px;
    font-size: 1em;
    border: 2px solid #2e8b57;
    border-radius: 5px;
    font-family: 'Poppins', sans-serif;
}

.name-entry button {
    margin-top: 10px;
}

/* Leaderboards Page */
.leaderboards-main {
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.leaderboards-main h2 {
    color: #0065fa;
    text-align: center;
    font-size: 2.5em;
    margin-bottom: 40px;
}

.leaderboard-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.leaderboard-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.leaderboard-card h3 {
    color: #2e8b57;
    text-align: center;
    margin: 0 0 20px 0;
    font-size: 1.3em;
    border-bottom: 2px solid #2e8b57;
    padding-bottom: 10px;
}

.score-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.score-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin: 5px 0;
    background: #f9f9f9;
    border-radius: 5px;
    transition: background 0.2s;
}

.score-entry:hover {
    background: #f0f0f0;
}

.score-entry.top-three {
    background: #fff9e6;
    font-weight: 600;
}

.score-entry .rank {
    min-width: 30px;
    font-size: 1.2em;
}

.score-entry .name {
    flex: 1;
    margin: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-entry .score {
    font-weight: 600;
    color: #2e8b57;
}

.loading, .error, .empty {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.error {
    color: #721c24;
}

/* Show mobile controls on smaller screens */
@media (max-width: 599px) {
    #mobileControls {
        display: flex;
    }
    
    .snake-main h2 {
        font-size: 1.2em;
    }
    
    .scoreboard {
        font-size: 1em;
    }
    
    #gameCanvas {
        max-width: 85vw;
        max-height: 40vh;
    }
    
    .mobile-controls .arrow-button {
        width: 60px;
        height: 60px;
        font-size: 1.5em;
    }
    
    .leaderboard-container {
        grid-template-columns: 1fr;
    }
    
    .mode-selection {
        padding: 10px;
    }
}
