/* Afri Crush - African-Inspired Styling */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #E07C24;
    --primary-dark: #C56A1C;
    --secondary: #2D5016;
    --accent: #F4D03F;
    --dark: #1A1A2E;
    --darker: #0F0F1A;
    --light: #FFF8E7;
    --red: #C0392B;
    --gold: #FFD700;

    /* African earth tones */
    --earth-1: #8B4513;
    --earth-2: #D2691E;
    --earth-3: #CD853F;
    --earth-4: #DEB887;

    --cell-size: 60px;
    --gap: 4px;
}

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, var(--darker) 0%, var(--dark) 50%, #2D1B0E 100%);
    min-height: 100vh;
    color: var(--light);
    overflow-x: hidden;
}

/* African pattern background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(224, 124, 36, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(45, 80, 22, 0.1) 0%, transparent 50%),
        repeating-linear-gradient(45deg,
            transparent,
            transparent 20px,
            rgba(224, 124, 36, 0.03) 20px,
            rgba(224, 124, 36, 0.03) 40px);
    pointer-events: none;
    z-index: -1;
}

.game-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-title {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--gold) 0%, var(--primary) 50%, var(--earth-1) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 20px rgba(224, 124, 36, 0.3);
    margin-bottom: 5px;
}

.game-subtitle {
    font-size: 0.9rem;
    color: var(--earth-4);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Stats Panel */
.stats-panel {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.3), rgba(45, 80, 22, 0.2));
    border-radius: 16px;
    border: 1px solid rgba(224, 124, 36, 0.3);
    backdrop-filter: blur(10px);
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--earth-4);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
}

.stat-value.score-flash {
    animation: scoreFlash 0.3s ease;
}

@keyframes scoreFlash {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
        color: var(--accent);
    }
}

/* Progress Bar */
.progress-container {
    margin-bottom: 20px;
}

.progress-bar {
    height: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(224, 124, 36, 0.3);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--secondary), var(--primary), var(--gold));
    border-radius: 6px;
    transition: width 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 0 10px var(--primary);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-top: 5px;
    color: var(--earth-4);
}

/* Game Board */
.board-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(8, var(--cell-size));
    grid-template-rows: repeat(8, var(--cell-size));
    gap: var(--gap);
    padding: 15px;
    background: linear-gradient(145deg, rgba(139, 69, 19, 0.4), rgba(30, 30, 50, 0.8));
    border-radius: 20px;
    border: 3px solid var(--earth-1);
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 2px 10px rgba(255, 255, 255, 0.1),
        0 0 60px rgba(224, 124, 36, 0.2);
}

/* Helper Text */
.helper-text {
    text-align: center;
    width: 100%;
    font-size: 0.85rem;
    color: var(--earth-4);
    margin-top: 15px;
    opacity: 0.8;
    animation: subtlePulse 3s ease-in-out infinite;
}

@keyframes subtlePulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* Info Panel */
.info-panel {
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.4), rgba(45, 80, 22, 0.3));
    border: 1px solid rgba(224, 124, 36, 0.4);
    border-radius: 16px;
    padding: 12px 20px;
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    min-height: 70px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#info-emoji {
    font-size: 2.2rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.info-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#info-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 2px;
}

#info-country {
    font-size: 0.85rem;
    color: var(--earth-4);
    display: flex;
    align-items: center;
    gap: 5px;
}

#info-country::before {
    content: '📍';
    font-size: 0.8rem;
}

.info-panel.flash {
    animation: infoFlash 0.5s ease;
}

@keyframes infoFlash {

    0%,
    100% {
        transform: scale(1);
        border-color: rgba(224, 124, 36, 0.4);
        background: linear-gradient(135deg, rgba(139, 69, 19, 0.4), rgba(45, 80, 22, 0.3));
    }

    50% {
        transform: scale(1.02);
        border-color: var(--gold);
        background: linear-gradient(135deg, rgba(139, 69, 19, 0.6), rgba(45, 80, 22, 0.5));
    }
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: linear-gradient(145deg, rgba(255, 248, 231, 0.15), rgba(139, 69, 19, 0.2));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.2), transparent);
    border-radius: 10px;
    pointer-events: none;
}

.cell:hover {
    transform: scale(1.08);
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.cell.selected {
    border-color: var(--accent);
    box-shadow: 0 0 25px var(--accent);
    animation: selectedPulse 1s infinite;
}

@keyframes selectedPulse {

    0%,
    100% {
        box-shadow: 0 0 25px var(--accent);
    }

    50% {
        box-shadow: 0 0 40px var(--accent), 0 0 60px var(--primary);
    }
}

.cell.matched {
    animation: matchedAnim 0.4s ease forwards;
}

@keyframes matchedAnim {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3) rotate(10deg);
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.item-emoji {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s ease;
}

.cell:hover .item-emoji {
    transform: scale(1.1);
}

/* Shake animation for invalid moves */
.shake {
    animation: shake 0.3s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-8px);
    }

    75% {
        transform: translateX(8px);
    }
}

/* Pulse animation */
.pulse {
    animation: pulse 0.3s ease;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

/* Particles Container */
#particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.particle {
    position: absolute;
    pointer-events: none;
}

/* Combo Display */
#combo-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 3rem;
    font-weight: 800;
    color: var(--gold);
    text-shadow:
        0 0 20px var(--primary),
        0 0 40px var(--primary),
        2px 2px 0 var(--earth-1);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 100;
    pointer-events: none;
}

#combo-display.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    animation: comboAnim 1s ease forwards;
}

@keyframes comboAnim {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }

    20% {
        transform: translate(-50%, -50%) scale(1.2);
    }

    40% {
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Educational Popup */
#educational-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 2000;
}

#educational-popup.show {
    opacity: 1;
    visibility: visible;
}

.popup-content {
    background: linear-gradient(145deg, var(--dark), var(--darker));
    border: 3px solid var(--primary);
    border-radius: 24px;
    padding: 30px 40px;
    text-align: center;
    max-width: 380px;
    width: 90%;
    transform: scale(0.8) translateY(20px);
    transition: transform 0.3s ease;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(224, 124, 36, 0.3);
}

#educational-popup.show .popup-content {
    transform: scale(1) translateY(0);
}

#popup-emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 15px;
    animation: emojiFloat 2s ease-in-out infinite;
}

@keyframes emojiFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

#popup-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 8px;
}

#popup-country {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#popup-country::before {
    content: '📍';
}

#popup-description {
    font-size: 0.95rem;
    color: var(--earth-4);
    line-height: 1.5;
}

#popup-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: var(--light);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

#popup-close:hover {
    opacity: 1;
}

/* Don't show again checkbox */
.dont-show-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(224, 124, 36, 0.2);
    font-size: 0.85rem;
    color: var(--earth-4);
    cursor: pointer;
    user-select: none;
}

.dont-show-option input[type="checkbox"] {
    display: none;
}

.dont-show-option .checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: transparent;
}

.dont-show-option .checkmark::after {
    content: '✓';
    color: var(--gold);
    font-size: 14px;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s ease;
}

.dont-show-option input[type="checkbox"]:checked+.checkmark {
    background: var(--primary);
    border-color: var(--gold);
}

.dont-show-option input[type="checkbox"]:checked+.checkmark::after {
    opacity: 1;
    transform: scale(1);
}

.dont-show-option:hover .checkmark {
    border-color: var(--gold);
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    padding-bottom: 20px;
}

.btn {
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 20px rgba(224, 124, 36, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(224, 124, 36, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 550px) {
    :root {
        --cell-size: 42px;
        --gap: 3px;
    }

    .game-title {
        font-size: 2.2rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .item-emoji {
        font-size: 1.5rem;
    }

    #popup-emoji {
        font-size: 3rem;
    }

    #popup-name {
        font-size: 1.4rem;
    }
}

@media (max-width: 400px) {
    :root {
        --cell-size: 36px;
        --gap: 2px;
    }

    .game-container {
        padding: 10px;
    }

    #game-board {
        padding: 10px;
    }

    .stats-panel {
        padding: 10px;
    }
}