/* ========================================
   EMOJI MATCH - WOODY PUZZLE THEME
   Premium CodeCanyon Style
   ======================================== */

:root {
    /* Wooden Palette */
    --wood-dark: #8d5524;
    --wood-medium: #c68c53;
    --wood-light: #e0ac69;
    --paper-bg: #c19a6b;
    /* Dark Tan/Camel Wood tone */
    --gold: #ffcf40;
    --gold-shadow: #d4a31e;
    --text-brown: #5d4037;

    /* Accents */
    --accent-green: #8bc34a;
    --accent-red: #ff7043;

    /* Shadows */
    --shadow-depth: 0 10px 0 rgba(93, 64, 55, 0.4);
    --shadow-soft: 0 4px 12px rgba(93, 64, 55, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-drag: none;
}

html,
body {
    width: 100%;
    height: 100%;
    background: #2c1a0e;
    /* Dark fallback */
    overflow: hidden;
    color: var(--text-brown);
    font-family: 'Fredoka One', cursive;
}

button,
input,
textarea {
    font-family: inherit;
}

/* ========================================
   STRICT 1080x1920 CONTAINER
   ======================================== */
#gameWrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #2c1a0e;
    background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 20.5V18H0v-2h20v-2H0v-2h20v-2H0V8h20V6H0V4h20V2H0V0h20v30h20v-2H20v-2h20v-2H20v-2h20v-2H20v-2h20v-2H0z' fill='%233e2723' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
}

#gameContainer {
    width: 1080px;
    height: 1920px;
    position: relative;
    background: var(--paper-bg);
    overflow: hidden;
    transform-origin: center center;
    box-shadow: 0 0 100px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}

/* ========================================
   BACKGROUNDS & PATTERNS
   ======================================== */
.wood-pattern {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--wood-medium);
    background-image: linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 100px 100px;
    z-index: -1;
}

.wood-panel {
    background: var(--wood-light);
    border: 12px solid var(--wood-dark);
    box-shadow: inset 0 0 40px rgba(93, 64, 55, 0.4), var(--shadow-depth);
    border-radius: 40px;
}

/* ========================================
   SCREENS
   ======================================== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 1080px;
    height: 1920px;
    display: none;
    flex-direction: column;
    z-index: 10;
}

.screen.active {
    display: flex;
}

/* ========================================
   LOADING SCREEN
   ======================================== */
#loadingScreen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, var(--wood-light), var(--wood-dark));
    box-shadow: inset 0 0 200px rgba(0, 0, 0, 0.5);
}

.logo-container {
    text-align: center;
    margin-bottom: 200px;
}

.logo {
    font-size: 300px;
    animation: happy-dance 2s infinite ease-in-out;
    text-shadow: 0 30px 0 rgba(0, 0, 0, 0.2);
}

@keyframes happy-dance {

    0%,
    100% {
        transform: translateY(0) rotate(0deg) scale(1);
    }

    25% {
        transform: translateY(-50px) rotate(-10deg) scale(1.1);
    }

    50% {
        transform: translateY(0) rotate(0deg) scale(1);
    }

    75% {
        transform: translateY(-50px) rotate(10deg) scale(1.1);
    }
}

.game-title {
    font-family: 'Luckiest Guy';
    font-size: 160px;
    color: #fff;
    text-shadow: 5px 5px 0 var(--wood-dark), 0 10px 20px rgba(0, 0, 0, 0.4);
}

.loading-area {
    width: 800px;
}

.loading-bar-container {
    height: 80px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 40px;
    padding: 10px;
    box-shadow: inset 0 10px 20px rgba(0, 0, 0, 0.5);
    border: 4px solid rgba(255, 255, 255, 0.1);
}

.loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, #ffd700, #ffca28);
    border-radius: 30px;
    transition: width 0.1s;
    position: relative;
    box-shadow: 0 0 30px #ffd700;
}

.loading-footer {
    margin-top: 40px;
    font-family: 'Fredoka One';
    font-size: 40px;
    color: #fff;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
}

/* ========================================
   HOME SCREEN (Wooden Theme)
   ======================================== */
.home-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1;
    gap: 80px;
}

.settings-gear {
    position: absolute;
    top: 60px;
    left: 60px;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, var(--gold), var(--gold-shadow));
    border: 8px solid var(--wood-dark);
    border-radius: 50%;
    font-size: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 10px 0 rgba(0, 0, 0, 0.3);
    color: var(--text-brown);
}

.game-plate {
    background: var(--wood-dark);
    padding: 80px 120px;
    border-radius: 60px;
    border: 15px solid var(--wood-light);
    box-shadow: 0 30px 0 rgba(0, 0, 0, 0.2);
    transform: rotate(-3deg);
}

.game-plate span {
    font-family: 'Luckiest Guy';
    font-size: 120px;
    color: var(--paper-bg);
    letter-spacing: 5px;
    text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5);
}

.btn-play-wood {
    width: 600px;
    height: 220px;
    background: var(--wood-dark);
    border-radius: 110px;
    padding: 15px;
    border: none;
    box-shadow: 0 25px 0 rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: transform 0.1s;
}

.btn-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, var(--accent-green), #689f38);
    border-radius: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Luckiest Guy';
    font-size: 110px;
    color: #fff;
    border: 8px solid #aed581;
    text-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
}

.btn-play-wood:active {
    transform: translateY(10px);
    box-shadow: 0 15px 0 rgba(0, 0, 0, 0.4);
}

/* ========================================
   GAMEPLAY SCREEN (Paper & Wood)
   ======================================== */
.game-bg {
    background: var(--paper-bg);
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.hud {
    height: 300px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 60px 40px;
}

.hud-item {
    background: var(--wood-light);
    border: 8px solid var(--wood-dark);
    border-radius: 30px;
    width: 280px;
    height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 0 var(--wood-dark);
}

.hud-label {
    font-size: 30px;
    color: var(--text-brown);
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.hud-value {
    font-size: 70px;
    color: #fff;
    text-shadow: 3px 3px 0 var(--text-brown);
    font-family: 'Luckiest Guy';
}

.hud-center {
    font-family: 'Luckiest Guy';
    font-size: 140px;
    color: var(--wood-dark);
    text-shadow: 0 5px 0 rgba(0, 0, 0, 0.1);
    background: #fff;
    padding: 20px 60px;
    border-radius: 50px;
    border: 8px solid var(--wood-medium);
}

.goal-area {
    padding: 20px;
    display: flex;
    justify-content: center;
}

.target-card {
    background: var(--wood-dark);
    padding: 20px 80px;
    border-radius: 60px;
    font-size: 60px;
    color: var(--gold);
    font-family: 'Luckiest Guy';
    box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.5);
    border-bottom: 5px solid rgba(255, 255, 255, 0.1);
}

.grid-mask {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.game-grid {
    width: 1000px;
    height: 1000px;
    background: var(--wood-medium);
    border: 25px solid var(--wood-dark);
    border-radius: 60px;
    display: grid;
    gap: 20px;
    padding: 25px;
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.4), 0 30px 0 rgba(0, 0, 0, 0.2);
}

.tile {
    background: #fff;
    border-radius: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 12px 0 #d7ccc8;
    overflow: hidden;
    position: relative;
    border: 4px solid #efebe9;
}

.tile span {
    font-size: 120px;
    filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.1));
}

.game-footer {
    height: 300px;
    display: flex;
    justify-content: center;
    gap: 40px;
    align-items: center;
    padding-bottom: 60px;
}

.footer-btn {
    width: 250px;
    height: 120px;
    font-size: 40px;
    font-family: 'Luckiest Guy';
    color: #fff;
    border-radius: 40px;
    cursor: pointer;
    border: none;
    box-shadow: 0 10px 0 rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-restart {
    background: var(--accent-red);
    box-shadow: 0 10px 0 #bf360c;
}

.btn-hint {
    background: var(--gold);
    color: #3E2723;
    /* Dark brown for maximum contrast on yellow */
    box-shadow: 0 10px 0 #f57f17;
    font-weight: bold;
}


.btn-levels {
    background: var(--wood-dark);
    /* Original brown background */
    color: #FFFFFF;
    /* Pure white text */
    font-weight: bold;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.7);
    /* Very strong shadow */
    box-shadow: 0 10px 0 #3e2723;
    border: 3px solid rgba(255, 255, 255, 0.3);
    /* White border for definition */
}



/* ========================================
   MODALS (Wooden Signboards)
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-body {
    width: 900px;
    background: var(--wood-light);
    border-radius: 80px;
    padding: 100px 60px;
    text-align: center;
    border: 20px solid var(--wood-dark);
    box-shadow: 0 50px 0 rgba(0, 0, 0, 0.5);
    color: var(--text-brown);
    position: relative;
    z-index: 1;
}

.pop-title {
    font-size: 140px;
    color: var(--text-brown);
    text-shadow: 2px 2px 0 #fff;
    margin-bottom: 40px;
}

.pop-score {
    font-size: 80px;
    font-family: 'Fredoka One';
    margin-bottom: 40px;
    background: rgba(255, 255, 255, 0.4);
    padding: 20px;
    border-radius: 30px;
    display: inline-block;
}

.pop-stars {
    font-size: 100px;
    margin: 30px 0;
}

.pop-btn {
    width: 100%;
    height: 160px;
    margin-bottom: 30px;
    border-radius: 50px;
    border: none;
    font-family: 'Luckiest Guy';
    font-size: 70px;
    color: #3E2723;
    /* Dark brown instead of white */
    cursor: pointer;
    box-shadow: 0 15px 0 rgba(0, 0, 0, 0.3);
}

.p-next {
    background: var(--accent-green);
    box-shadow: 0 15px 0 #33691e;
}

.p-retry {
    background: var(--accent-red);
    box-shadow: 0 15px 0 #bf360c;
}

/* ========================================
   LEVEL SELECT & SETTINGS
   ======================================== */
.screen-header-wood {
    height: 300px;
    background: var(--wood-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--paper-bg);
    border-bottom: 10px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

.screen-header-wood h2 {
    font-family: 'Luckiest Guy';
    font-size: 100px;
}

.btn-back-wood {
    position: absolute;
    left: 60px;
    width: 120px;
    height: 120px;
    background: var(--wood-light);
    border: 6px solid #fff;
    border-radius: 30px;
    font-size: 60px;
    color: var(--text-brown);
    cursor: pointer;
    box-shadow: 0 10px 0 rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
}

.levels-container {
    background: var(--paper-bg);
    padding: 60px;
    flex: 1;
    overflow-y: auto;
    /* Enable scrolling for level buttons */
    overflow-x: hidden;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 40px;
    padding-bottom: 100px;
}

.level-btn {
    aspect-ratio: 1;
    background: linear-gradient(to bottom, #4CAF50, #45a049);
    /* Vibrant green */
    border: 8px solid #2E7D32;
    /* Dark green border */
    border-radius: 40px;
    font-family: 'Luckiest Guy';
    font-size: 80px;
    color: #FFFFFF;
    /* Pure white for maximum contrast */
    cursor: pointer;
    box-shadow: 0 15px 0 #1B5E20, 0 5px 20px rgba(0, 0, 0, 0.3);
    /* Green shadow + depth */
    display: flex;
    justify-content: center;
    align-items: center;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
    transition: transform 0.1s, box-shadow 0.1s;
    position: relative;
}

.level-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 0 #1B5E20, 0 10px 30px rgba(0, 0, 0, 0.4);
}

.level-btn.locked {
    background: linear-gradient(to bottom, #9E9E9E, #757575);
    /* Gray gradient */
    border-color: #616161;
    /* Dark gray border */
    color: #E0E0E0;
    /* Light gray text */
    box-shadow: 0 15px 0 #424242, 0 5px 20px rgba(0, 0, 0, 0.2);
    cursor: not-allowed;
    font-size: 60px;
    /* Smaller lock icon */
}


.settings-list {
    background: var(--paper-bg);
    padding: 80px;
    gap: 40px;
}

.setting-card {
    background: var(--wood-medium);
    padding: 50px 80px;
    border-radius: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    font-size: 60px;
    font-weight: bold;
    border-bottom: 10px solid var(--wood-dark);
}

.toggle-btn {
    width: 200px;
    height: 100px;
    background: var(--accent-green);
    border-radius: 50px;
    border: none;
    font-family: 'Luckiest Guy';
    font-size: 50px;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 10px 0 #33691e;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s;
}

.toggle-btn.off {
    background: var(--accent-red);
    box-shadow: 0 10px 0 #bf360c;
}

.toggle-btn:active {
    transform: translateY(5px);
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
}

/* ========================================
   ANIMATIONS
   ======================================== */
.tile.selected {
    transform: scale(1.1) !important;
    background: #fff8e1 !important;
    box-shadow: 0 0 0 10px var(--gold), 0 20px 0 #f57f17 !important;
    z-index: 100;
}

.tile.matched {
    animation: pop-wood-enhanced 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
}

/* Very subtle shake - no earthquake effect */
@keyframes shake-subtle {

    0%,
    100% {
        transform: translate3d(0, 0, 0);
    }

    25% {
        transform: translate3d(-2px, 0, 0);
    }

    75% {
        transform: translate3d(2px, 0, 0);
    }
}




/* Tile animation improvements */
.tile {
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.15s ease;
}

.tile:active {
    transform: scale(0.95);
}

/* Enhanced matched animation */
.tile.matched {
    animation: pop-wood-enhanced 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
}

@keyframes pop-wood-enhanced {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    40% {
        transform: scale(1.4) rotate(8deg);
        opacity: 0.9;
    }

    70% {
        transform: scale(1.2) rotate(-5deg);
        opacity: 0.5;
    }

    100% {
        transform: scale(0) rotate(20deg);
        opacity: 0;
    }
}

/* Score popup (floating +XX) */
.score-popup {
    animation: score-float 1.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes score-float {
    0% {
        transform: translate(-50%, 0) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -20px) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -100px) scale(1);
        opacity: 0;
    }
}

/* Particle styling */
.game-particle {
    user-select: none;
    -webkit-user-select: none;
}

/* Modal entrance animation */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: modal-fade-in 0.3s ease-out;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-body {
    position: relative;
    animation: modal-bounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-bounce {
    0% {
        transform: scale(0.3) translateY(-100px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Fixed Reset Button */
.btn-reset {
    width: 100%;
    height: 140px;
    background: var(--accent-red);
    border-radius: 40px;
    font-family: 'Luckiest Guy';
    font-size: 50px;
    color: #fff;
    border: none;
    box-shadow: 0 10px 0 #bf360c;
    cursor: pointer;
    margin-top: 40px;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-reset:active {
    transform: translateY(10px);
    box-shadow: 0 5px 0 #bf360c;
}

/* Button press animations for all buttons */
.footer-btn:active,
.pop-btn:active,
.btn-play-wood:active,
.level-btn:active {
    transform: translateY(8px) !important;
}

/* Winning stars animation */
.pop-stars {
    font-size: 100px;
    margin: 30px 0;
    animation: star-pulse 1s infinite alternate;
}

@keyframes star-pulse {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 10px gold);
    }

    100% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 30px gold);
    }
}