/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Utility: used throughout JS to show/hide modals and error messages */
.hidden {
    display: none !important;
}


html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0a1a;
    font-family: 'Outfit', sans-serif;
    touch-action: none;
}

/* ===== Layout: ads + game ===== */
body {
    display: flex;
    flex-direction: column;
}

/* ===== Ad Banners ===== */
.ad-banner {
    width: 100%;
    height: 50px;
    min-height: 50px;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    flex-shrink: 0;
}

.ad-placeholder {
    color: #444;
    font-size: 12px;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 2px;
}

/* Hide placeholder text when Capacitor AdMob renders real ads */
.ad-banner.ad-loaded .ad-placeholder {
    display: none;
}

/* ===== Game Container ===== */
#game-container {
    flex: 1;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ===== Settings UI ===== */
#settings-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    /* ... existing styles ... */
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#mute-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#mute-btn:active,
#settings-btn:active {
    transform: scale(0.9);
}

#settings-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
}

#settings-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.settings-content {
    background: #24243e;
    padding: 30px;
    border-radius: 20px;
    border: 2px solid #ff6b6b;
    box-shadow: 0 0 30px rgba(255, 107, 107, 0.3);
    text-align: center;
    width: 80%;
    max-width: 320px;
}

.settings-content h2 {
    color: white;
    font-size: 24px;
    margin-bottom: 25px;
    text-shadow: 0 0 10px #ff6b6b;
}

.setting-item {
    margin-bottom: 20px;
    text-align: left;
}

.setting-item label {
    display: block;
    color: #ffd32a;
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: bold;
}

.setting-item input[type="range"] {
    width: 100%;
}

.note {
    color: #888;
    font-size: 11px;
    margin-top: 10px;
    margin-bottom: 25px;
}

#close-settings {
    background: linear-gradient(to right, #e94560, #ff6b6b);
    border: none;
    color: white;
    padding: 10px 30px;
    border-radius: 30px;
    font-family: 'Outfit', sans-serif;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.4);
}

/* ===== Tutorial Overlay ===== */
#tutorial-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
}

#tutorial-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.tutorial-content {
    color: white;
    text-align: center;
    font-family: 'Outfit', sans-serif;
}

.hand-icon {
    font-size: 60px;
    margin-bottom: 20px;
    animation: bounce 1s infinite alternate;
}

.tutorial-content h3 {
    font-size: 24px;
    color: #ffd32a;
    margin-bottom: 15px;
}

.tutorial-content p {
    font-size: 18px;
    margin: 10px 0;
}

.tutorial-content strong {
    color: #ff6b6b;
}

#start-btn {
    margin-top: 30px;
    background: #ffd32a;
    color: #333;
    border: none;
    padding: 12px 40px;
    border-radius: 25px;
    font-size: 20px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 5px 0 #c9a620;
    transition: transform 0.1s, box-shadow 0.1s;
}

#start-btn:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 #c9a620;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-10px);
    }
}

/* ===== Flag Selection ===== */
.flag-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}



.flag-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

#title-flags {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 150;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    padding: 20px 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#title-flags.hidden {
    display: none;
    pointer-events: none;
}

#settings-flags {
    margin-top: 15px;
}

.flag-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 8px 12px;
    border-radius: 8px;
    text-transform: none;
    /* Keep capitalization as written */
    min-width: 80px;
}

.flag-btn:hover,
.flag-btn.active {
    background: white;
    color: #0a0a1a;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.3);
}

/* ===== Ranking UI ===== */
#ranking-btn {
    position: absolute;
    top: 20px;
    right: 80px;
    /* Left of settings btn */
    width: 44px;
    height: 44px;
    background: rgba(255, 215, 0, 0.2);
    /* Gold tint */
    border: 2px solid rgba(255, 215, 0, 0.5);
    border-radius: 50%;
    color: #ffd700;
    font-size: 24px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#ranking-btn:active {
    transform: scale(0.9);
}

#ranking-modal,
#name-input-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    /* Slightly darker */
    backdrop-filter: blur(8px);
    z-index: 350;
    /* Above settings */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
}

#ranking-modal.hidden,
#name-input-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.ranking-content,
.name-input-content {
    background: #1e1e2e;
    padding: 25px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 90%;
    max-width: 380px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.ranking-content h2,
.name-input-content h2 {
    color: #ffd700;
    font-size: 24px;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    letter-spacing: 1px;
}

/* Tabs */
.ranking-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
    background: transparent;
    border: none;
    color: #888;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s;
    position: relative;
}

.tab-btn.active {
    color: white;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -11px;
    /* Align with border-bottom */
    left: 0;
    width: 100%;
    height: 3px;
    background: #e94560;
    border-radius: 3px 3px 0 0;
}

.ranking-subtabs {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 15px;
}

.subtab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #aaa;
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 15px;
    transition: all 0.2s;
}

.subtab-btn.active {
    background: #e94560;
    color: white;
}

/* List */
#ranking-loading {
    color: #888;
    margin: 20px 0;
    font-style: italic;
}

#ranking-list {
    list-style: none;
    margin-bottom: 20px;
    overflow-y: auto;
    max-height: 300px;
    text-align: left;
    padding: 0 5px;
    /* Space for scrollbar */
}

#ranking-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 14px;
    color: #eee;
}

#ranking-list li:nth-child(1) {
    color: #ffd700;
    font-weight: bold;
    font-size: 16px;
}

/* Gold */
#ranking-list li:nth-child(2) {
    color: #c0c0c0;
    font-weight: bold;
}

/* Silver */
#ranking-list li:nth-child(3) {
    color: #cd7f32;
    font-weight: bold;
}

/* Bronze */

.rank-num {
    width: 25px;
    text-align: center;
    opacity: 0.7;
}

.rank-name {
    flex: 1;
    margin: 0 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-score {
    font-family: monospace;
    font-weight: bold;
}

.rank-country {
    font-size: 12px;
    margin-left: 5px;
    opacity: 0.8;
}

/* Name Input */
#name-input-desc {
    color: #ccc;
    font-size: 14px;
    margin-bottom: 20px;
}

#player-name-input {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: white;
    font-size: 18px;
    text-align: center;
    font-family: 'Outfit', sans-serif;
    margin-bottom: 10px;
    outline: none;
    transition: border-color 0.2s;
}

#player-name-input:focus {
    border-color: #e94560;
}

.error-msg {
    color: #ff6b6b;
    font-size: 12px;
    margin-bottom: 15px;
    min-height: 15px;
    /* Reserve space */
}

.name-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

#submit-score-btn,
#skip-score-btn,
#close-ranking {
    border: none;
    padding: 10px 25px;
    border-radius: 25px;
    font-family: 'Outfit', sans-serif;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.1s;
}

#submit-score-btn {
    background: #e94560;
    color: white;
    box-shadow: 0 4px 10px rgba(233, 69, 96, 0.3);
}

#skip-score-btn {
    background: transparent;
    border: 1px solid #666;
    color: #aaa;
}

#close-ranking {
    background: #333;
    color: white;
    margin-top: auto;
    width: 100%;
}

#submit-score-btn:active,
#close-ranking:active {
    transform: scale(0.95);
}