/* ========================================
   SimplyMatch - Crystal Gems Edition
   Premium Match-3 Game Styles
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;900&display=swap');

:root {
    --bg-gradient-1: #0f0c29;
    --bg-gradient-2: #302b63;
    --bg-gradient-3: #24243e;
    --grid-bg: rgba(255, 255, 255, 0.06);
    --gap: 3px;
    --cell-size: 0px;
    --bounciness: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --glow-color: rgba(255, 255, 255, 0.3);
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
}

body {
    font-family: 'Outfit', sans-serif;
    color: white;
    background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 50%, var(--bg-gradient-3) 100%);
    position: relative;
}

/* Animated starfield background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.4), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.5), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255, 255, 255, 0.2), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(255, 255, 255, 0.4), transparent),
        radial-gradient(1px 1px at 200px 60px, rgba(255, 255, 255, 0.3), transparent);
    background-size: 250px 120px;
    animation: twinkle 8s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes twinkle {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* ==========================================
   MENU SCREEN
   ========================================== */
.menu-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.menu-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.4), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.5), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255, 255, 255, 0.2), transparent);
    background-size: 250px 120px;
    animation: twinkle 8s ease-in-out infinite alternate;
    pointer-events: none;
}

.menu-screen.hidden {
    display: none;
}

/* Language Selector */
.language-selector {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 6px;
}

.flag-icon {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.lang-btn.active {
    background: rgba(138, 43, 226, 0.5);
    border-color: rgba(186, 85, 255, 0.8);
    box-shadow: 0 0 20px rgba(138, 43, 226, 0.5);
}

/* Title */
.menu-title {
    font-size: 4rem;
    margin-bottom: 10px;
    font-weight: 900;
    letter-spacing: -2px;
    text-shadow: 0 4px 30px rgba(138, 43, 226, 0.8);
    animation: titleFloat 3s ease-in-out infinite;
    position: relative;
    z-index: 1;
}

@keyframes titleFloat {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-8px);
    }
}

.menu-title .highlight {
    background: linear-gradient(135deg, #ff00de, #00d4ff, #ff00de);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
    text-shadow: none;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.menu-subtitle {
    font-size: 1.1rem;
    margin-bottom: 20px;
    opacity: 0.8;
    text-align: center;
    max-width: 400px;
    position: relative;
    z-index: 1;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
    width: 100%;
    max-width: 380px;
    position: relative;
    z-index: 1;
}

.mode-btn {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.3), rgba(75, 0, 130, 0.3));
    border: 2px solid rgba(186, 85, 255, 0.4);
    color: white;
    padding: 18px 24px;
    border-radius: 16px;
    font-size: 1.1rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(138, 43, 226, 0.2);
    display: flex;
    align-items: center;
    gap: 18px;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.mode-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.mode-btn:hover::before {
    left: 100%;
}

.mode-btn:hover {
    transform: translateY(-3px);
    border-color: rgba(186, 85, 255, 0.8);
    box-shadow: 0 12px 40px rgba(138, 43, 226, 0.4);
}

.mode-btn:active {
    transform: translateY(-1px);
}

.mode-icon {
    font-size: 2.2rem;
    flex-shrink: 0;
}

.mode-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mode-text strong {
    font-size: 1.2rem;
}

.mode-text small {
    font-size: 0.85rem;
    opacity: 0.7;
    font-weight: normal;
}

.menu-footer {
    position: absolute;
    bottom: 20px;
    text-align: center;
    opacity: 0.5;
    font-size: 0.85rem;
}

/* ==========================================
   GAME CONTAINER
   ========================================== */
.app-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    box-sizing: border-box;
}

.app-container.hidden {
    display: none;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 10px;
    width: 100%;
}

header h1 {
    font-size: 1.8rem;
    margin: 0 0 8px 0;
    text-shadow: 0 4px 20px rgba(138, 43, 226, 0.6);
    font-weight: 900;
    letter-spacing: -1px;
}

.highlight {
    background: linear-gradient(135deg, #ff00de, #00d4ff, #ff00de);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
}

/* Info Bar */
.info-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.score-board,
.timer,
.level-display,
.moves-display {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    padding: 6px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.level-display {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.3), rgba(75, 0, 130, 0.3));
    border-color: rgba(186, 85, 255, 0.4);
}

.timer {
    background: rgba(255, 60, 60, 0.2);
    border-color: rgba(255, 100, 100, 0.4);
}

/* Level Progress Bar */
.level-progress-container {
    width: 100%;
    max-width: 400px;
    margin: 8px auto 4px;
    position: relative;
}

.level-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.level-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8a2be2, #ff00de, #00d4ff);
    background-size: 200% 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    animation: progressGlow 2s ease infinite;
    width: 0%;
}

@keyframes progressGlow {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

.level-progress-text {
    font-size: 0.7rem;
    opacity: 0.6;
    text-align: center;
    margin-top: 3px;
}

/* Game Board */
#game-board-container {
    width: 100%;
    display: flex;
    justify-content: center;
    position: relative;
    flex-grow: 0;
    align-items: center;
    margin: 8px auto;
}

.grid-board {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    position: relative;
    touch-action: none;
    border: 2px solid rgba(138, 43, 226, 0.3);
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.5),
        0 0 60px rgba(138, 43, 226, 0.15),
        0 20px 60px rgba(0, 0, 0, 0.4);
    overflow: visible;
    margin: 0 auto;
}

/* ==========================================
   CRYSTAL GEM STYLES
   ========================================== */
.gem {
    position: absolute;
    border-radius: 12%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 10;
    will-change: transform, top, left;
    transition: top 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
        left 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
        transform 0.2s ease;
}

.gem.dragging {
    transition: none;
    z-index: 1000;
}

.gem-content {
    width: 88%;
    height: 88%;
    border-radius: 22%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Crystal shine effect */
.gem-content::after {
    content: '';
    position: absolute;
    top: -30%;
    left: -30%;
    width: 60%;
    height: 60%;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 70%);
    filter: blur(2px);
    z-index: 2;
    pointer-events: none;
}

/* Inner crystal facet */
.gem-content::before {
    content: '';
    position: absolute;
    width: 50%;
    height: 50%;
    top: 15%;
    left: 15%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 60%);
    border-radius: 30%;
    z-index: 3;
    pointer-events: none;
}

/* Crystal symbol */
.gem-symbol {
    font-size: clamp(1rem, 4vw, 1.6rem);
    z-index: 4;
    filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.4));
    position: relative;
    line-height: 1;
}

/* Hover effect */
.gem:hover .gem-content {
    transform: scale(1.08);
    filter: brightness(1.15);
}

/* ==================== GEM TYPE STYLES ==================== */

/* Type 0 - Ruby (Red Crystal) */
.type-0 .gem-content {
    background: linear-gradient(135deg, #ff1744 0%, #d50000 50%, #b71c1c 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 3px 8px rgba(255, 255, 255, 0.4),
        inset 0 -3px 8px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(255, 23, 68, 0.5),
        2px 4px 8px rgba(0, 0, 0, 0.3);
}

/* Type 1 - Sapphire (Blue Crystal) */
.type-1 .gem-content {
    background: linear-gradient(135deg, #2979ff 0%, #1565c0 50%, #0d47a1 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 3px 8px rgba(255, 255, 255, 0.4),
        inset 0 -3px 8px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(41, 121, 255, 0.5),
        2px 4px 8px rgba(0, 0, 0, 0.3);
}

/* Type 2 - Emerald (Green Crystal) */
.type-2 .gem-content {
    background: linear-gradient(135deg, #00e676 0%, #00c853 50%, #1b5e20 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 3px 8px rgba(255, 255, 255, 0.4),
        inset 0 -3px 8px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(0, 230, 118, 0.5),
        2px 4px 8px rgba(0, 0, 0, 0.3);
}

/* Type 3 - Topaz (Yellow Crystal) */
.type-3 .gem-content {
    background: linear-gradient(135deg, #ffd600 0%, #ffab00 50%, #ff8f00 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 3px 8px rgba(255, 255, 255, 0.5),
        inset 0 -3px 8px rgba(0, 0, 0, 0.2),
        0 0 15px rgba(255, 214, 0, 0.5),
        2px 4px 8px rgba(0, 0, 0, 0.3);
}

/* Type 4 - Amethyst (Purple Crystal) */
.type-4 .gem-content {
    background: linear-gradient(135deg, #e040fb 0%, #aa00ff 50%, #6200ea 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 3px 8px rgba(255, 255, 255, 0.4),
        inset 0 -3px 8px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(170, 0, 255, 0.5),
        2px 4px 8px rgba(0, 0, 0, 0.3);
}

/* Type 5 - Citrine (Orange Crystal) */
.type-5 .gem-content {
    background: linear-gradient(135deg, #ff6d00 0%, #e65100 50%, #bf360c 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 3px 8px rgba(255, 255, 255, 0.4),
        inset 0 -3px 8px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(255, 109, 0, 0.5),
        2px 4px 8px rgba(0, 0, 0, 0.3);
}

/* Type 6 - Aquamarine (Cyan Crystal) */
.type-6 .gem-content {
    background: linear-gradient(135deg, #00e5ff 0%, #00b8d4 50%, #006064 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 3px 8px rgba(255, 255, 255, 0.4),
        inset 0 -3px 8px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(0, 229, 255, 0.5),
        2px 4px 8px rgba(0, 0, 0, 0.3);
}

/* Type 7 - Rose Quartz (Pink Crystal) */
.type-7 .gem-content {
    background: linear-gradient(135deg, #ff4081 0%, #f50057 50%, #c51162 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 3px 8px rgba(255, 255, 255, 0.4),
        inset 0 -3px 8px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(255, 64, 129, 0.5),
        2px 4px 8px rgba(0, 0, 0, 0.3);
}

/* Type 8 - Peridot (Lime Crystal) */
.type-8 .gem-content {
    background: linear-gradient(135deg, #c6ff00 0%, #aeea00 50%, #64dd17 100%);
    border-radius: 50%;
    box-shadow:
        inset 0 3px 8px rgba(255, 255, 255, 0.5),
        inset 0 -3px 8px rgba(0, 0, 0, 0.2),
        0 0 15px rgba(198, 255, 0, 0.4),
        2px 4px 8px rgba(0, 0, 0, 0.3);
}

/* Type 9 - Opal (White/Rainbow Crystal) */
.type-9 .gem-content {
    background: linear-gradient(135deg,
            #e8eaf6 0%, #b39ddb 25%, #80cbc4 50%, #f8bbd0 75%, #e8eaf6 100%);
    background-size: 200% 200%;
    animation: opalShimmer 4s ease infinite;
    border-radius: 50%;
    box-shadow:
        inset 0 3px 8px rgba(255, 255, 255, 0.6),
        inset 0 -3px 8px rgba(0, 0, 0, 0.15),
        0 0 15px rgba(179, 157, 219, 0.4),
        2px 4px 8px rgba(0, 0, 0, 0.3);
}

@keyframes opalShimmer {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* ==================== BLOCKER GEM ==================== */
.gem.blocker .gem-content {
    background: linear-gradient(135deg, #546e7a 0%, #37474f 50%, #263238 100%);
    border-radius: 15%;
    box-shadow:
        inset 0 3px 8px rgba(255, 255, 255, 0.15),
        inset 0 -3px 8px rgba(0, 0, 0, 0.5),
        0 0 10px rgba(84, 110, 122, 0.3),
        2px 4px 8px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(96, 125, 139, 0.5);
}

.gem.blocker .gem-content::after {
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
}

.gem.blocker .gem-content::before {
    display: none;
}

.gem.blocker .gem-symbol {
    opacity: 0.7;
}

.gem.blocker:hover .gem-content {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* Blocker crack animation when hit nearby */
.gem.blocker.cracking .gem-content {
    animation: blockerShake 0.3s ease;
}

@keyframes blockerShake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-2px) rotate(-1deg);
    }

    75% {
        transform: translateX(2px) rotate(1deg);
    }
}

/* ==================== SHINY GEM (4-match) ==================== */
.gem.shiny .gem-content {
    animation: shinyPulse 1.5s ease-in-out infinite;
}

.gem.shiny::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 14%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.6) 50%, transparent 70%);
    background-size: 200% 200%;
    animation: shinyShine 2s linear infinite;
    pointer-events: none;
    z-index: 5;
}

@keyframes shinyPulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: inherit;
        filter: brightness(1.1);
    }

    50% {
        transform: scale(1.08);
        filter: brightness(1.4);
    }
}

@keyframes shinyShine {
    0% {
        background-position: 200% 200%;
    }

    100% {
        background-position: -200% -200%;
    }
}

/* ==================== MAGIC GEM (5-match rainbow) ==================== */
.gem.magic .gem-content {
    background: linear-gradient(135deg, #ffd600, #ff6d00, #ff1744, #d500f9, #2979ff, #00e676, #ffd600);
    background-size: 400% 400%;
    animation: magicRainbow 2s ease-in-out infinite;
    border-radius: 50%;
    box-shadow:
        0 0 25px rgba(255, 214, 0, 0.9),
        0 0 50px rgba(213, 0, 249, 0.5),
        0 0 80px rgba(41, 121, 255, 0.3),
        inset 0 0 20px rgba(255, 255, 255, 0.6);
}

.gem.magic::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 3px solid transparent;
    background: linear-gradient(135deg, #ffd600, #ff1744, #d500f9, #2979ff, #ffd600) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: magicRotate 3s linear infinite;
    pointer-events: none;
    z-index: 5;
}

.gem.magic .gem-content::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.7) 0%, transparent 50%);
}

@keyframes magicRainbow {
    0% {
        background-position: 0% 50%;
        transform: scale(1);
    }

    25% {
        transform: scale(1.06);
    }

    50% {
        background-position: 100% 50%;
        transform: scale(1);
    }

    75% {
        transform: scale(1.06);
    }

    100% {
        background-position: 0% 50%;
        transform: scale(1);
    }
}

@keyframes magicRotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ==================== FLAME GEM (T/L-match) ==================== */
.gem.flame .gem-content {
    animation: flamePulse 0.8s ease-in-out infinite;
}

.gem.flame::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 14%;
    background: radial-gradient(circle, rgba(255, 100, 0, 0.6) 0%, rgba(255, 0, 0, 0.3) 50%, transparent 70%);
    animation: flameFlicker 0.5s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 5;
}

@keyframes flamePulse {

    0%,
    100% {
        transform: scale(1);
        filter: brightness(1.2);
    }

    50% {
        transform: scale(1.05);
        filter: brightness(1.5);
    }
}

@keyframes flameFlicker {
    0% {
        opacity: 0.7;
        transform: scale(1);
    }

    100% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* ==================== HINT GLOW ==================== */
.gem.hint-glow .gem-content {
    animation: hintPulse 0.8s ease-in-out infinite;
}

.gem.hint-glow::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 14%;
    border: 2px solid rgba(255, 255, 255, 0.7);
    animation: hintBorder 0.8s ease-in-out infinite;
    pointer-events: none;
    z-index: 6;
}

@keyframes hintPulse {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.4);
    }
}

@keyframes hintBorder {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* ==================== SELECTED STATE ==================== */
.gem.selected .gem-content {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 0 0 40px rgba(138, 43, 226, 0.6) !important;
    transform: scale(1.1);
}

.gem.selected::after {
    content: '';
    position: absolute;
    inset: -3px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 14%;
    animation: selectPulse 1s ease-in-out infinite;
    pointer-events: none;
}

@keyframes selectPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.05);
    }
}

/* Match Animation */
.gem.match-anim {
    animation: crystalShatter 0.4s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards;
}

@keyframes crystalShatter {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: brightness(1);
    }

    50% {
        transform: scale(1.3);
        opacity: 0.8;
        filter: brightness(2);
    }

    100% {
        transform: scale(0);
        opacity: 0;
        filter: brightness(3);
    }
}

/* ==================== PARTICLES ==================== */
.particle {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    animation: particleBurst 0.8s ease-out forwards;
    z-index: 20;
    box-shadow: 0 0 10px currentColor;
}

@keyframes particleBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* ==================== CONTROLS ==================== */
.controls {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 10px;
}

.glass-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
    font-weight: 600;
}

.glass-btn:hover {
    background: rgba(138, 43, 226, 0.3);
    border-color: rgba(186, 85, 255, 0.5);
    transform: scale(1.05);
}

.glass-btn:active {
    transform: scale(0.95);
}

/* ==================== GAME OVER ==================== */
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(15px);
}

.game-over.hidden {
    display: none;
}

.game-over h2 {
    font-size: 2.8rem;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #ff00de, #00d4ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleFloat 2s ease-in-out infinite;
    font-weight: 900;
}

.game-over .final-score {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.game-over .final-level {
    font-size: 1.2rem;
    margin-bottom: 25px;
    opacity: 0.7;
}

/* ==================== LEVEL UP OVERLAY ==================== */
.level-up-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(8px);
    animation: fadeInOverlay 0.3s ease;
}

@keyframes fadeInOverlay {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

.level-up-content {
    text-align: center;
    animation: levelUpBounce 0.6s var(--bounciness);
}

.level-up-content h2 {
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ffd600, #ff6d00, #ff1744);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.level-up-content .new-level {
    font-size: 5rem;
    font-weight: 900;
    text-shadow: 0 0 60px rgba(255, 214, 0, 0.8);
    margin-bottom: 15px;
}

.level-up-content .new-element-info {
    font-size: 1.2rem;
    opacity: 0.8;
    margin-bottom: 10px;
}

.level-up-content .new-gem-preview {
    font-size: 3rem;
    margin: 10px 0 20px;
}

@keyframes levelUpBounce {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==================== COMBO TEXT ==================== */
.combo-text {
    position: absolute;
    font-size: 1.5rem;
    font-weight: 900;
    color: #ffd600;
    text-shadow: 0 0 20px rgba(255, 214, 0, 0.8), 0 2px 10px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 100;
    animation: comboFloat 1s ease-out forwards;
}

@keyframes comboFloat {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translateY(-60px) scale(0.8);
        opacity: 0;
    }
}

/* ==================== RESPONSIVE DESIGN ==================== */

/* Large desktop */
@media (min-width: 601px) {
    .app-container {
        padding: 20px 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    #game-board-container {
        margin: 12px auto;
    }
}

/* Mobile */
@media (max-width: 600px) {
    .menu-title {
        font-size: 3rem;
        margin-bottom: 8px;
    }

    .menu-subtitle {
        font-size: 0.95rem;
        padding: 0 20px;
        margin-bottom: 20px;
    }

    .language-selector {
        top: 12px;
        right: 12px;
        gap: 6px;
    }

    .lang-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .flag-icon {
        width: 16px;
        height: 12px;
    }

    .mode-btn {
        padding: 14px 20px;
        font-size: 0.95rem;
        margin: 0 10px;
    }

    .mode-icon {
        font-size: 1.8rem;
    }

    .mode-text strong {
        font-size: 1rem;
    }

    .mode-text small {
        font-size: 0.75rem;
    }

    .app-container {
        padding: 10px 5px;
    }

    header {
        margin-bottom: 6px;
    }

    header h1 {
        font-size: 1.5rem;
        margin-bottom: 6px;
    }

    .info-bar {
        gap: 6px;
    }

    .score-board,
    .timer,
    .level-display,
    .moves-display {
        font-size: 0.8rem;
        padding: 4px 10px;
        border-radius: 8px;
    }

    .level-progress-container {
        margin: 5px auto 2px;
    }

    .level-progress-bar {
        height: 6px;
    }

    #game-board-container {
        margin: 6px auto;
    }

    .controls {
        gap: 8px;
        margin-top: 8px;
    }

    .glass-btn {
        padding: 6px 12px;
        font-size: 0.78rem;
    }

    .game-over h2 {
        font-size: 2.2rem;
    }

    .game-over .final-score {
        font-size: 1.4rem;
    }

    .level-up-content h2 {
        font-size: 2.2rem;
    }

    .level-up-content .new-level {
        font-size: 3.5rem;
    }
}

/* Very small */
@media (max-width: 380px) {
    .menu-title {
        font-size: 2.5rem;
    }

    .mode-btn {
        padding: 12px 14px;
        gap: 12px;
    }

    .mode-icon {
        font-size: 1.5rem;
    }

    .mode-text strong {
        font-size: 0.95rem;
    }

    header h1 {
        font-size: 1.3rem;
    }

    .glass-btn {
        padding: 5px 10px;
        font-size: 0.72rem;
    }
}

/* Landscape */
@media (max-height: 600px) and (orientation: landscape) {
    .menu-title {
        font-size: 2.5rem;
        margin-bottom: 5px;
    }

    .menu-subtitle {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }

    .mode-buttons {
        margin-top: 10px;
        gap: 8px;
    }

    .mode-btn {
        padding: 10px 18px;
    }

    .app-container {
        padding: 8px 5px;
    }

    header {
        margin-bottom: 5px;
    }

    .controls {
        margin-top: 5px;
    }
}

/* Shimmer animation for gems */
@keyframes gemShimmer {
    0% {
        background-position: -100% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.gem-content .shimmer-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: gemShimmer 3s ease-in-out infinite;
    border-radius: inherit;
    z-index: 5;
    pointer-events: none;
}

/* Score popup */
.score-popup {
    position: absolute;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    pointer-events: none;
    z-index: 100;
    animation: scorePopFloat 0.8s ease-out forwards;
}

@keyframes scorePopFloat {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }

    30% {
        transform: translateY(-15px) scale(1.1);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px) scale(0.7);
        opacity: 0;
    }
}