@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap');

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    overflow: hidden;
    color: #2d3748;
    transition: background 0.5s ease;
}

/* Dark Mode Body Gradient */
body.dark-mode {
    background: linear-gradient(-45deg, #1a202c, #2d3748, #2c5282, #1a365d);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 100vh;
    max-height: 850px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: rgba(255, 255, 255, 0.95);
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode .game-container {
    background-color: rgba(23, 25, 35, 0.95);
    color: #f7fafc;
}

@media (min-width: 500px) {
    .game-container {
        height: 90vh;
        border-radius: 1.5rem;
    }
}

canvas {
    display: block;
    background-color: transparent;
    flex-grow: 1;
    cursor: pointer;
}

.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

.ui-controls {
    display: flex;
    gap: 0.5rem;
    pointer-events: auto;
}

/* UI Buttons & Text */
.icon-btn {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #4a5568;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(4px);
}

.icon-btn:hover {
    color: #2d3748;
    transform: scale(1.1);
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.dark-mode .icon-btn {
    background: rgba(45, 55, 72, 0.8);
    color: #e2e8f0;
}

body.dark-mode .icon-btn:hover {
    background: rgba(74, 85, 104, 0.9);
    color: white;
}

.ui-badge {
    background: rgba(255, 255, 255, 0.8);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 800;
    font-size: 1rem;
    color: #4a5568;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(4px);
    transition: background 0.3s ease, color 0.3s ease;
}

body.dark-mode .ui-badge {
    background: rgba(45, 55, 72, 0.8);
    color: #e2e8f0;
}

#score-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 6rem;
    font-weight: 900;
    color: rgba(203, 213, 224, 0.3);
    pointer-events: none;
    user-select: none;
    z-index: 0;
    transition: color 0.3s ease;
}

body.dark-mode #score-display {
    color: rgba(255, 255, 255, 0.05);
}

#lives-container {
    display: flex;
    gap: 0.5rem;
}

.heart {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.heart.removed {
    opacity: 0;
    transform: scale(0);
}

/* Modern Glassmorphism Modal */
.modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    transition: opacity 0.3s ease;
}

.modal-content {
    background: rgba(255, 255, 255, 0.85);
    padding: 2.5rem;
    border-radius: 2rem;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.5);
    max-width: 90%;
    width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: background 0.3s ease, border-color 0.3s ease;
}

body.dark-mode .modal-content {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes modalPop {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-content h2 {
    font-size: 2.5rem;
    font-weight: 900;
    background: -webkit-linear-gradient(45deg, #3182ce, #2b6cb0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -0.05em;
}

body.dark-mode .modal-content h2 {
    background: -webkit-linear-gradient(45deg, #63b3ed, #4299e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-content p {
    color: #718096;
    margin-bottom: 2rem;
    font-size: 1.05rem;
    line-height: 1.6;
}

body.dark-mode .modal-content p {
    color: #cbd5e0;
}

/* Styled Buttons */
.btn {
    display: inline-block;
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0.75rem;
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
    box-shadow: 0 10px 15px -3px rgba(66, 153, 225, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 20px -3px rgba(66, 153, 225, 0.5);
    background: linear-gradient(135deg, #63b3ed 0%, #4299e1 100%);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Pro Button Specifics */
.btn-pro {
    background: linear-gradient(135deg, #d69e2e 0%, #b7791f 100%);
    color: white;
    box-shadow: 0 10px 15px -3px rgba(214, 158, 46, 0.4);
}

.btn-pro:hover {
    background: linear-gradient(135deg, #ecc94b 0%, #d69e2e 100%);
    box-shadow: 0 14px 20px -3px rgba(214, 158, 46, 0.5);
}

.btn-pro:disabled {
    background: #cbd5e0;
    /* Gray */
    background-image: none;
    color: #718096;
    box-shadow: none;
}

.btn-secondary {
    background: white;
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background-color: #f7fafc;
    border-color: #cbd5e0;
    transform: translateY(-2px);
}

body.dark-mode .btn-secondary {
    background: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
}

body.dark-mode .btn-secondary:hover {
    background: #4a5568;
    border-color: #718096;
}

/* Text Utils for Dark Mode */
body.dark-mode .text-gray-400 {
    color: #a0aec0;
}

body.dark-mode .text-gray-500 {
    color: #cbd5e0;
}

body.dark-mode .text-gray-800 {
    color: #f7fafc;
}

body.dark-mode .text-blue-800 {
    color: #63b3ed;
}

body.dark-mode .bg-blue-50 {
    background-color: rgba(49, 130, 206, 0.2);
}

.hidden {
    display: none !important;
}

/* Flag Grid Styling */
.flag-grid-container {
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
    /* Prevent shadow cut-off */
}

.flag-btn {
    border: 2px solid transparent;
    border-radius: 0.75rem;
    padding: 0.5rem;
    transition: all 0.2s;
    background: #f7fafc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.dark-mode .flag-btn {
    background: #2d3748;
    border-color: #4a5568;
}

.flag-btn:hover {
    background: #edf2f7;
    transform: scale(1.05);
}

body.dark-mode .flag-btn:hover {
    background: #4a5568;
}

.flag-btn.selected {
    border-color: #3182ce;
    background: #ebf8ff;
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.3);
}

body.dark-mode .flag-btn.selected {
    background: rgba(49, 130, 206, 0.2);
    border-color: #63b3ed;
}

.flag-img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Language List Styling */
.lang-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}

.lang-btn {
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

body.dark-mode .lang-btn {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

.lang-btn:hover {
    background: #ebf8ff;
    border-color: #3182ce;
}

body.dark-mode .lang-btn:hover {
    background: #4a5568;
    border-color: #63b3ed;
}

.lang-btn.active {
    background: #3182ce;
    color: white;
    border-color: #3182ce;
}

/* Scrollbar for grid */
.flag-grid-container::-webkit-scrollbar,
.lang-grid::-webkit-scrollbar {
    width: 8px;
}

.flag-grid-container::-webkit-scrollbar-track,
.lang-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.flag-grid-container::-webkit-scrollbar-thumb,
.lang-grid::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

/* Flash Effect */
#flash-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    z-index: 50;
    transition: opacity 0.1s ease-out;
}

#flash-overlay.hit {
    background-color: rgba(72, 187, 120, 0.4);
    opacity: 1;
}

#flash-overlay.miss {
    background-color: rgba(245, 101, 101, 0.4);
    opacity: 1;
}

#flash-overlay.life-gain {
    background-color: rgba(250, 204, 21, 0.5);
    /* Gold flash */
    opacity: 1;
}

/* Floating Text Animation */
.floating-text {
    position: absolute;
    color: #F6E05E;
    /* Gold Default */
    font-weight: 900;
    font-size: 2rem;
    pointer-events: none;
    animation: floatUp 0.8s ease-out forwards;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 60;
    white-space: nowrap;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.2);
    }
}

/* Leaderboard Styles */
.tab-container {
    display: flex;
    background: #e2e8f0;
    padding: 0.25rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
}

body.dark-mode .tab-container {
    background: #2d3748;
}

.tab-btn {
    flex: 1;
    padding: 0.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    color: #718096;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

body.dark-mode .tab-btn {
    color: #a0aec0;
}

.tab-btn.active {
    background: white;
    color: #2b6cb0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

body.dark-mode .tab-btn.active {
    background: #4a5568;
    color: white;
}

.leaderboard-list {
    max-height: 250px;
    overflow-y: auto;
    text-align: left;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid #edf2f7;
}

body.dark-mode .leaderboard-item {
    background: #2d3748;
    border-color: #4a5568;
}

.leaderboard-item.self {
    background: #ebf8ff;
    border-color: #4299e1;
}

body.dark-mode .leaderboard-item.self {
    background: #2c5282;
    border-color: #63b3ed;
}

.rank {
    font-weight: 800;
    width: 30px;
    color: #a0aec0;
}

.rank-1 {
    color: #d69e2e;
}

.rank-2 {
    color: #718096;
}

.rank-3 {
    color: #b794f4;
}

.player-info {
    flex-grow: 1;
    padding-left: 0.5rem;
}

.player-name {
    font-weight: 700;
    color: #2d3748;
    font-size: 0.95rem;
}

body.dark-mode .player-name {
    color: #f7fafc;
}

.player-location {
    font-size: 0.75rem;
    color: #a0aec0;
}

.player-score {
    font-weight: 900;
    color: #3182ce;
}

body.dark-mode .player-score {
    color: #63b3ed;
}

/* Language Modal specific */
#start-modal .modal-content {
    position: relative;
}

.lang-btn-trigger {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #edf2f7;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

body.dark-mode .lang-btn-trigger {
    background: #2d3748;
    color: white;
}

.lang-btn-trigger:hover {
    transform: scale(1.1);
    background: #e2e8f0;
}

/* Timer */
#timer-display {
    display: none;
    font-size: 1.25rem;
    font-weight: 800;
    color: #d69e2e;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body.dark-mode #timer-display {
    background: rgba(45, 55, 72, 0.9);
}