/* Enhanced Styling with Modern Design */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Animated background particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: float 20s infinite linear;
}

@keyframes float {
    0% { transform: translateY(100vh) translateX(0px); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-10vh) translateX(100px); opacity: 0; }
}

/* Welcome Screen */
.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: all 0.5s ease;
}

.hidden {
    display: none !important;
}

.slide-out {
    transform: translateX(-100vw);
    opacity: 0;
}

.slide-in {
    transform: translateX(0);
    opacity: 1;
}

h1 {
    font-size: clamp(2rem, 5vw, 4rem);
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 2px 2px 4px rgba(0,0,0,0.3), 0 0 10px rgba(255,255,255,0.2); }
    to { text-shadow: 2px 2px 4px rgba(0,0,0,0.3), 0 0 20px rgba(255,255,255,0.4); }
}

/* Enhanced Controls */
.controls {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 2rem;
    min-width: 300px;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

select, input[type="range"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 1rem;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-size: 1rem;
}

.difficulty-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 1rem 0;
}

.difficulty-btn {
    padding: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    background: transparent;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty-btn:hover, .difficulty-btn.active {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin: 0.5rem;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.btn:active {
    transform: translateY(1px);
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    flex-wrap: wrap;
    gap: 1rem;
}

.game-stats {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.stat {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 15px;
    font-weight: 600;
}

.game-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.icon-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Enhanced Puzzle Container */
#puzzle-container {
    display: grid;
    gap: 2px;
    margin: 2rem auto;
    width: min(90vw, 400px);
    height: min(90vw, 400px);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 10px;
}

.puzzle-piece {
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: grab;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    /* Default background and text color for number puzzles */
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

/* Updated CSS rule: Hide text content and ensure image visibility */
.puzzle-piece[style*="background-image"] {
    font-size: 0; /* Shrink text to zero to ensure it's not visible */
    color: transparent !important; /* Force transparency for text */
    /* Only ensure background-color is transparent, do not override background-image */
    background-color: transparent !important; 
}

.puzzle-piece:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 10;
}

.puzzle-piece:active {
    cursor: grabbing;
    transform: scale(1.02);
}

.puzzle-piece.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.puzzle-piece.drop-target {
    background: rgba(255, 255, 100, 0.3);
    border: 2px dashed #ffeb3b;
}

/* Upload area styling */
.upload-area {
    margin: 1rem 0;
}

.upload-label {
    display: inline-block;
    padding: 15px 30px;
    border: 2px dashed rgba(255, 255, 255, 0.5);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
}

.upload-label:hover {
    border-color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.2);
}

#upload-image {
    display: none;
}

/* Success Message */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-content {
    background: linear-gradient(135deg, #00c9ff, #92fe9d);
    padding: 3rem;
    border-radius: 25px;
    text-align: center;
    animation: celebration 1s ease-out;
    max-width: 90vw;
}

@keyframes celebration {
    0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
    50% { transform: scale(1.1) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.success-content h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.stats-summary {
    background: rgba(255, 255, 255, 0.2);
    padding: 1rem;
    border-radius: 15px;
    margin: 1rem 0;
}

/* Progress bar */
.progress-container {
    width: 100%;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin: 1rem 0;
    overflow: hidden;
}

.progress-bar {
    height: 8px;
    background: linear-gradient(90deg, #00c9ff, #92fe9d);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-header {
        flex-direction: column;
        padding: 1rem;
    }
    
    .game-stats, .game-controls {
        justify-content: center;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .controls {
        min-width: unset;
        width: 100%;
        max-width: 350px;
    }
}

/* Hint system */
.hint-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 235, 59, 0.3);
    border: 2px solid #ffeb3b;
    border-radius: 8px;
    pointer-events: none;
    animation: hint-pulse 1s ease-in-out 3;
}

@keyframes hint-pulse {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

/* Easter egg animation */
@keyframes rainbow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}
