/* Global Styles */
body {
    font-family: 'Inter', sans-serif;
    touch-action: manipulation;
    background: #f3f4f6; /* bg-gray-100 */
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Prevent zoom on double tap */
    touch-action: manipulation;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior: contain;
}

/* Dark mode background */
@media (prefers-color-scheme: dark) {
    body {
        background: #111827; /* dark:bg-gray-900 */
    }
}

/* Game Container */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

/* Level Display - Top Left */
.level-display {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.1) 100%);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
}

.level-display:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* Moves Display - Top Right */
.moves-display {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.1) 100%);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
}

.moves-display:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* Reset Button - Below Level (Left Side) */
.reset-button-container {
    position: fixed;
    top: 7rem;
    left: 1.5rem;
    z-index: 1000;
    transition: all 0.3s ease;
}

.reset-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.1) 100%);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
}

.reset-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.2) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.reset-button:hover::before {
    transform: translateX(100%);
}

.reset-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

.reset-button:active {
    transform: translateY(-1px) scale(1.02);
    transition: transform 0.1s ease;
}

.reset-icon {
    font-size: 1.2rem;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.reset-button:hover .reset-icon {
    transform: rotate(180deg);
}

.reset-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}


.hud-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.hud-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hud-separator {
    font-size: 1.5rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}


/* Game Board */
.game-board {
    display: grid;
    gap: 3px;
    grid-template-columns: var(--grid-columns, repeat(5, 1fr));
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(209, 213, 219, 0.8) 0%, rgba(209, 213, 219, 0.6) 100%);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.game-board::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: shimmer 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Dark mode game board */
@media (prefers-color-scheme: dark) {
    .game-board {
        background: linear-gradient(135deg, rgba(55, 65, 81, 0.8) 0%, rgba(55, 65, 81, 0.6) 100%);
    }
}


/* Grid size classes for different levels */
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-8 { grid-template-columns: repeat(8, 1fr); }
.grid-11 { grid-template-columns: repeat(11, 1fr); }
.grid-14 { grid-template-columns: repeat(14, 1fr); }
.grid-17 { grid-template-columns: repeat(17, 1fr); }
.grid-20 { grid-template-columns: repeat(20, 1fr); }

/* Cell Styles */
.cell {
    border-radius: 12px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cell:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 
        inset 0 2px 8px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 8px 25px rgba(0, 0, 0, 0.2);
}

.cell:hover::before {
    opacity: 1;
}

.cell:active {
    transform: scale(1.02);
    transition: transform 0.1s ease;
}

/* Color Palette */
.color-palette {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.25rem;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.05) 100%);
    backdrop-filter: blur(20px);
    border-radius: 60px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 1;
    pointer-events: auto;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.color-palette::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: shimmer 4s ease-in-out infinite;
    pointer-events: none;
}

.color-palette.disabled {
    opacity: 0.3;
    pointer-events: none;
    transform: scale(0.9);
    filter: grayscale(0.5);
}

/* Color Button Styles */
.color-button {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.2),
        inset 0 2px 4px rgba(255, 255, 255, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.color-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4), transparent 60%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.color-button::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.color-button:hover {
    transform: scale(1.2) translateY(-4px);
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.3),
        inset 0 2px 6px rgba(255, 255, 255, 0.4),
        inset 0 -2px 6px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 1);
}

.color-button:hover::before,
.color-button:hover::after {
    opacity: 1;
}

.color-button:active,
.color-button.touch-active {
    transform: scale(1.1) translateY(-2px);
    transition: transform 0.1s ease;
    box-shadow: 
        0 12px 30px rgba(0, 0, 0, 0.3),
        inset 0 2px 6px rgba(255, 255, 255, 0.4),
        inset 0 -2px 6px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 1);
}

.color-button:focus {
    outline: none;
    box-shadow: 
        0 0 0 6px rgba(255, 255, 255, 0.3),
        0 8px 25px rgba(0, 0, 0, 0.2),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

/* Legacy responsive adjustments - now handled in comprehensive responsive section above */

/* Pop-up Overlay */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.6) 100%);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Pop-up Container */
.popup-container {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.1) 100%);
    backdrop-filter: blur(30px);
    border-radius: 32px;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 2.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Start Pop-up Specific */
.start-popup {
    text-align: center;
}

/* Game Over Pop-up Specific */
.game-over-popup {
    text-align: center;
}

/* Pop-up Header */
.popup-header {
    margin-bottom: 2rem;
}

.game-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1rem;
    position: relative;
}

.logo-text {
    font-size: 3rem;
    font-weight: 900;
    margin: 0;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.1rem;
}

.logo-letter {
    display: inline-block;
    position: relative;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    animation: letterFloat 3s ease-in-out infinite;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.logo-letter:hover {
    transform: translateY(-10px) scale(1.1);
    animation-play-state: paused;
}

/* Individual letter colors and animations */
.logo-c {
    background: linear-gradient(45deg, #ef4444, #f87171, #fca5a5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation-delay: 0s;
}

.logo-o {
    background: linear-gradient(45deg, #3b82f6, #60a5fa, #93c5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation-delay: 0.2s;
}

.logo-l {
    background: linear-gradient(45deg, #22c55e, #4ade80, #86efac);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation-delay: 0.4s;
}

.logo-o2 {
    background: linear-gradient(45deg, #FFFF00, #fde047, #fef08a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation-delay: 0.6s;
}

.logo-r {
    background: linear-gradient(45deg, #FFA500, #fb923c, #fdba74);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation-delay: 0.8s;
}

.logo-space {
    width: 0.5rem;
}

.logo-f {
    background: linear-gradient(45deg, #ec4899, #f472b6, #f9a8d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation-delay: 1s;
}

.logo-l2 {
    background: linear-gradient(45deg, #8b5cf6, #a78bfa, #c4b5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation-delay: 1.2s;
}

.logo-o3 {
    background: linear-gradient(45deg, #06b6d4, #22d3ee, #67e8f9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation-delay: 1.4s;
}

.logo-o4 {
    background: linear-gradient(45deg, #84cc16, #a3e635, #bef264);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation-delay: 1.6s;
}

.logo-d {
    background: linear-gradient(45deg, #f59e0b, #fbbf24, #fcd34d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation-delay: 1.8s;
}

/* Floating animation for letters */
@keyframes letterFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-5px) rotate(1deg); }
    50% { transform: translateY(-8px) rotate(0deg); }
    75% { transform: translateY(-3px) rotate(-1deg); }
}

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



.result-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: celebration 1s ease-in-out;
}

@keyframes celebration {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

.result-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 0.5rem 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.result-subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Pop-up Content */
.popup-content {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 1rem 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-text {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    margin: 0 0 2rem 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.goal-section, .how-to-play-section {
    margin-bottom: 2rem;
}

.instructions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.instruction-item:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 100%);
    transform: translateX(5px);
}

.instruction-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
    color: #1f2937;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.instruction-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Mobile-only instruction */
.mobile-only {
    display: none;
}

@media (max-width: 640px) {
    .mobile-only {
        display: flex;
    }
}

/* Stats Section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.stat-item:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 100%);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Pop-up Footer */
.popup-footer {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Pop-up Buttons */
.popup-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-width: 160px;
    justify-content: center;
}

.popup-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.2) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.popup-button:hover::before {
    transform: translateX(100%);
}

.popup-button.primary {
    background: linear-gradient(135deg, #ef4444 0%, #3b82f6 25%, #22c55e 50%, #FFFF00 75%, #ec4899 100%);
    color: #ffffff;
    box-shadow: 
        0 8px 25px rgba(239, 68, 68, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

.popup-button.primary:hover {
    transform: translateY(-3px) scale(1.05);
    background: linear-gradient(135deg, #f87171 0%, #60a5fa 25%, #4ade80 50%, #fde047 75%, #f472b6 100%);
    box-shadow: 
        0 15px 40px rgba(239, 68, 68, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.popup-button.secondary {
    background: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 25%, #84cc16 50%, #f59e0b 75%, #ec4899 100%);
    color: #ffffff;
    box-shadow: 
        0 8px 25px rgba(139, 92, 246, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite reverse;
}

.popup-button.secondary:hover {
    transform: translateY(-3px) scale(1.05);
    background: linear-gradient(135deg, #a78bfa 0%, #22d3ee 25%, #a3e635 50%, #fbbf24 75%, #f472b6 100%);
    box-shadow: 
        0 15px 40px rgba(139, 92, 246, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.popup-button:active,
.popup-button.touch-active {
    transform: translateY(-1px) scale(1.02);
    transition: transform 0.1s ease;
}

.button-text {
    position: relative;
    z-index: 1;
}

.button-icon {
    position: relative;
    z-index: 1;
    font-size: 1.2rem;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Mobile Touch Optimizations */
@media (max-width: 640px) {
    .game-container {
        padding: 1rem;
        min-height: 100vh;
        min-height: 100dvh; /* Dynamic viewport height for mobile */
    }

    .game-board {
        max-width: 280px;
        padding: 1rem;
        gap: 2px; /* Smaller gap for mobile */
    }

    .color-palette {
        gap: 1rem; /* Increased gap for better touch targets */
        padding: 1.5rem;
        border-radius: 40px; /* Slightly less rounded for mobile */
    }

    .color-button {
        width: 3.5rem; /* Larger touch target */
        height: 3.5rem;
        min-width: 44px; /* iOS minimum touch target */
        min-height: 44px;
        border-width: 3px; /* Thinner border for mobile */
    }

    .level-display,
    .moves-display {
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
        min-height: 44px; /* Ensure minimum touch target */
        display: flex;
        align-items: center;
    }

    .reset-button {
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
        min-height: 44px;
        min-width: 44px;
    }

    .popup-container {
        padding: 1.5rem;
        margin: 1rem;
        max-width: 90vw;
        max-height: 90vh;
        max-height: 90dvh; /* Dynamic viewport height */
    }
    
    .logo-text {
        font-size: 2rem;
    }
    
    .result-title {
        font-size: 2rem;
    }
    
    .popup-footer {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .popup-button {
        width: 100%;
        min-height: 48px; /* Larger touch target for buttons */
        padding: 1rem 1.5rem;
    }
    
    .stats-section {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .instruction-item {
        padding: 0.75rem;
        min-height: 44px;
    }

    /* Enhanced touch feedback for mobile */
    .color-button:active,
    .color-button.touch-active {
        transform: scale(1.15) translateY(-3px);
        transition: transform 0.15s ease;
    }

    /* Improve cell touch targets */
    .cell {
        min-height: 32px;
        min-width: 32px;
    }

    /* Better spacing for mobile HUD */
    .level-display {
        top: 1rem;
        left: 1rem;
    }

    .moves-display {
        top: 1rem;
        right: 1rem;
    }

    .reset-button-container {
        top: 6rem;
        left: 1rem;
    }
}

@media (max-width: 480px) {
    .game-board {
        max-width: 260px;
    }

    .color-button {
        width: 2.75rem;
        height: 2.75rem;
    }

    .popup-container {
        padding: 1.25rem;
        margin: 0.75rem;
    }

    .logo-text {
        font-size: 1.75rem;
    }

    .result-title {
        font-size: 1.75rem;
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    .game-board {
        max-width: 360px;
    }

    .color-button {
        width: 3.5rem;
        height: 3.5rem;
    }

    .popup-container {
        max-width: 85vw;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .game-board {
        max-width: 400px;
    }

    .color-button {
        width: 4rem;
        height: 4rem;
    }

    .popup-container {
        max-width: 80vw;
    }
}

@media (min-width: 1025px) {
    .game-board {
        max-width: 480px;
    }

    .color-button {
        width: 4.5rem;
        height: 4.5rem;
    }
}

/* Landscape orientation for mobile - Keep vertical layout */
@media (orientation: landscape) and (max-height: 600px) {
    .game-container {
        flex-direction: column; /* Keep vertical layout even in landscape */
        gap: 0.5rem;
        padding: 0.5rem;
        min-height: 100vh;
        min-height: 100dvh;
        justify-content: flex-start; /* Align to top in landscape */
    }

    .game-board {
        margin-top: 2rem;
        max-width: 70vh; /* Increased max-width for landscape */
        margin-bottom: 0.25rem; /* Reduced margin bottom */
        gap: 2px;
    }

    .color-palette {
        flex-direction: row; /* Keep horizontal palette */
        gap: 1rem; /* Increased gap in color palette */
        padding: 0.75rem;
        border-radius: 30px;
    }

    .color-button {
        width: 2.5rem; /* Smaller buttons in landscape */
        height: 2.5rem;
        min-width: 44px;
        min-height: 44px;
    }

    /* Adjust HUD for landscape */
    .level-display,
    .moves-display {
        top: 0.5rem;
        padding: 0.5rem 0.75rem;
        font-size: 0.7rem;
    }

    .reset-button-container {
        top: 4rem;
    }

    .reset-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.7rem;
    }
}

/* Color-specific classes for game cells and buttons */
.cell-red { background-color: #ef4444; }
.cell-blue { background-color: #3b82f6; }
.cell-green { background-color: #22c55e; }
.cell-yellow { background-color: #FFFF00; }
.cell-orange { background-color: #FFA500; }
.cell-pink { background-color: #ec4899; }

.button-red { 
    background-color: #ef4444; 
    border-color: #ef4444; 
}
.button-blue { 
    background-color: #3b82f6; 
    border-color: #3b82f6; 
}
.button-green { 
    background-color: #22c55e; 
    border-color: #22c55e; 
}
.button-yellow { 
    background-color: #FFFF00; 
    border-color: #FFFF00; 
}
.button-orange { 
    background-color: #FFA500; 
    border-color: #FFA500; 
}
.button-pink { 
    background-color: #ec4899; 
    border-color: #ec4899; 
}

