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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    overflow: hidden;
}

.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hidden {
    display: none !important;
}

/* Home Screen */
#home-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.flag-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    padding: 20px;
    opacity: 0.3;
    z-index: 0;
}

.flag-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.7) 0%, rgba(22, 33, 62, 0.7) 100%);
    z-index: 1;
}

.home-content {
    position: relative;
    z-index: 10;
    text-align: center;
}

.title {
    font-size: 4rem;
    color: #fff;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    margin-bottom: 40px;
    animation: pulse 2s infinite;
}

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

.play-button {
    font-size: 2rem;
    padding: 20px 80px;
    background: linear-gradient(145deg, #2ecc71, #27ae60);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(46, 204, 113, 0.4);
    transition: all 0.3s ease;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.play-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(46, 204, 113, 0.5);
}

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

/* Home Name Entry */
.name-entry {
    margin-bottom: 20px;
}

.home-name-input {
    padding: 15px 25px;
    font-size: 1.3rem;
    border: none;
    border-radius: 30px;
    width: 280px;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
}

.home-name-input:focus {
    outline: 3px solid #2ecc71;
}

.home-name-input::placeholder {
    color: #999;
}

/* Home Leaderboard */
.home-leaderboard {
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 25px;
    border-radius: 20px;
    min-width: 300px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.home-leaderboard h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.home-leaderboard-entries {
    color: #333;
}

.home-leaderboard-entry {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #f5f5f5;
    border-radius: 10px;
}

.home-leaderboard-entry:last-child {
    margin-bottom: 0;
}

.home-leaderboard-entry .rank {
    width: 30px;
    text-align: left;
}

.home-leaderboard-entry .name {
    flex: 1;
    text-align: left;
    font-weight: 500;
}

.home-leaderboard-entry .score {
    width: 60px;
    text-align: right;
    color: #27ae60;
    font-weight: bold;
}

.no-scores-home {
    color: #999;
    font-style: italic;
    padding: 10px 0;
}

.score-saved-msg {
    color: #2ecc71;
    font-size: 1.2rem;
    margin-bottom: 20px;
}

/* Game Screen */
#game-screen {
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    flex-direction: column;
    padding: 20px;
}

.game-header {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 800px;
    display: flex;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.stats {
    display: flex;
    gap: 15px;
    color: #333;
    font-size: 1.2rem;
    font-weight: 500;
}

.lives, .score, .round {
    background: #f0f0f0;
    padding: 8px 15px;
    border-radius: 20px;
}

.timer {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #333;
    font-size: 1.5rem;
    font-weight: bold;
}

.timer-bar {
    width: 150px;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #e74c3c, #f39c12, #2ecc71);
    border-radius: 10px;
    transition: width 0.1s linear;
}

.question {
    position: relative;
    z-index: 10;
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.question h2 {
    font-size: 1.5rem;
    font-weight: normal;
    margin-bottom: 10px;
    opacity: 0.9;
}

.country-name {
    font-size: 2.5rem;
    color: #f1c40f;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.flags-container {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    max-width: 600px;
    width: 100%;
}

.flag-option {
    aspect-ratio: 3/2;
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    border: 4px solid transparent;
}

@media (hover: hover) {
    .flag-option:hover {
        transform: scale(1.05);
        border-color: #f1c40f;
    }
}

.flag-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flag-option.correct {
    border: 6px solid #2ecc71;
    box-shadow: 0 0 20px #2ecc71, 0 0 40px rgba(46, 204, 113, 0.5);
    animation: correctPulse 0.8s ease infinite;
    transform: scale(1.05);
}

.flag-option.wrong {
    border-color: #e74c3c;
    animation: shake 0.5s ease;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Shop Screen */
#shop-screen {
    background: linear-gradient(135deg, #8e44ad 0%, #9b59b6 100%);
}

.shop-content {
    text-align: center;
    color: white;
    max-width: 500px;
    width: 90%;
}

.shop-title {
    font-size: 3rem;
    margin-bottom: 10px;
}

.shop-score {
    font-size: 1.5rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

.shop-items {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.shop-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    padding: 20px;
    border-radius: 15px;
    gap: 15px;
}

.item-icon {
    font-size: 2.5rem;
}

.item-info {
    text-align: left;
    flex: 1;
}

.item-info h3 {
    font-size: 1.3rem;
    margin-bottom: 5px;
}

.item-info p {
    opacity: 0.8;
}

.buy-btn {
    padding: 12px 25px;
    background: #2ecc71;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.buy-btn:hover {
    background: #27ae60;
    transform: scale(1.05);
}

.buy-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
}

.continue-button {
    padding: 15px 40px;
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.continue-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.4);
}

/* Game Over Screen */
#gameover-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.gameover-content {
    text-align: center;
    color: white;
}

.gameover-title {
    font-size: 4rem;
    margin-bottom: 20px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
}

.final-score {
    font-size: 2rem;
    margin-bottom: 10px;
}

.final-round {
    font-size: 1.5rem;
    margin-bottom: 20px;
    opacity: 0.9;
}

.name-input-section {
    margin-bottom: 20px;
}

.name-input-section p {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.player-name-input {
    padding: 12px 20px;
    font-size: 1.2rem;
    border: none;
    border-radius: 25px;
    width: 250px;
    text-align: center;
    margin-bottom: 15px;
}

.player-name-input:focus {
    outline: 3px solid #f1c40f;
}

.submit-button {
    padding: 12px 30px;
    background: linear-gradient(145deg, #f1c40f, #f39c12);
    color: #333;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(241, 196, 15, 0.4);
}

.score-submitted p {
    font-size: 1.2rem;
    color: #f1c40f;
    margin-bottom: 20px;
}

.gameover-leaderboard {
    margin: 20px 0;
}

.gameover-leaderboard h3 {
    color: white;
    margin-bottom: 10px;
}

.gameover-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Leaderboard Button */
.leaderboard-button {
    font-size: 1.2rem;
    padding: 15px 40px;
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
    transition: all 0.3s ease;
    font-weight: bold;
    margin-top: 20px;
}

.leaderboard-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.5);
}

/* Leaderboard Screen */
#leaderboard-screen {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

.leaderboard-content {
    text-align: center;
    color: white;
    max-width: 600px;
    width: 90%;
}

.leaderboard-title {
    font-size: 3rem;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

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

.leaderboard-header {
    display: grid;
    grid-template-columns: 50px 1fr 80px 80px;
    padding: 15px 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    font-weight: bold;
    font-size: 1.1rem;
    color: #f1c40f;
}

.leaderboard-entries {
    max-height: 400px;
    overflow-y: auto;
}

.leaderboard-entry {
    display: grid;
    grid-template-columns: 50px 1fr 80px 80px;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.3s ease;
}

.leaderboard-entry:hover {
    background: rgba(255, 255, 255, 0.1);
}

.leaderboard-entry.gold {
    background: rgba(255, 215, 0, 0.2);
}

.leaderboard-entry.silver {
    background: rgba(192, 192, 192, 0.2);
}

.leaderboard-entry.bronze {
    background: rgba(205, 127, 50, 0.2);
}

.rank-col {
    font-weight: bold;
}

.name-col {
    text-align: left;
    padding-left: 10px;
}

.score-col, .round-col {
    text-align: center;
}

.no-scores {
    padding: 30px;
    opacity: 0.7;
    font-style: italic;
}

.back-button {
    padding: 15px 40px;
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Result Popup */
.result-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 30px 60px;
    border-radius: 20px;
    z-index: 100;
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    0% { transform: translate(-50%, -50%) scale(0); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

.result-content {
    display: flex;
    align-items: center;
    gap: 15px;
    color: white;
    font-size: 1.5rem;
}

#result-icon {
    font-size: 2.5rem;
}

/* Background flags */
.bg-flag {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

/* Responsive */
@media (max-width: 600px) {
    .title {
        font-size: 2.5rem;
    }

    .play-button {
        font-size: 1.5rem;
        padding: 15px 50px;
    }

    .stats {
        flex-wrap: wrap;
        justify-content: center;
        font-size: 1rem;
    }

    .lives, .score, .round {
        padding: 8px 15px;
    }

    .game-header {
        flex-direction: column;
        gap: 15px;
    }

    .country-name {
        font-size: 1.8rem;
    }

    .flags-container {
        gap: 15px;
    }

    .shop-title {
        font-size: 2rem;
    }

    .gameover-title {
        font-size: 2.5rem;
    }
}
