/* ============================================
   STAGE 3: PUZZLE GAME STYLES
   ============================================ */

/* Puzzle Stage Container */
#puzzle-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0a0a12 100%);
    overflow: hidden;
}

/* ============ INTRO SCREEN ============ */
.puzzle-intro {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    z-index: 20;
}

.puzzle-intro.show {
    opacity: 1;
}

.puzzle-intro p {
    font-size: 1.4rem;
    color: #e9d5ff;
    margin: 0.8rem 0;
    text-shadow: 0 0 20px rgba(192, 132, 252, 0.5);
    opacity: 0;
    transform: translateY(20px);
}

.puzzle-intro.show p {
    animation: fadeInUp 0.8s ease forwards;
}

.puzzle-intro.show p:nth-child(1) { animation-delay: 0.3s; }
.puzzle-intro.show p:nth-child(2) { animation-delay: 1.2s; }
.puzzle-intro.show p:nth-child(3) { animation-delay: 2.1s; }

.puzzle-instruction {
    font-size: 1.1rem !important;
    color: #f472b6 !important;
    margin-top: 1.5rem !important;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============ PUZZLE CONTAINER ============ */
.puzzle-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s ease, transform 0.6s ease;
    pointer-events: none;
}

.puzzle-container.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

/* ============ PUZZLE GRID ============ */
.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(4, 80px);
    grid-template-rows: repeat(4, 80px);
    gap: 4px;
    padding: 8px;
    background: linear-gradient(145deg, #2a2a4e, #1a1a2e);
    border-radius: 12px;
    box-shadow:
        0 0 30px rgba(192, 132, 252, 0.3),
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 0 20px rgba(244, 114, 182, 0.1);
}

/* ============ PUZZLE TILES ============ */
.puzzle-tile {
    width: 80px;
    height: 80px;
    background-image: url('../images/couple-photo.jpg');
    background-size: 320px 320px;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.4),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.puzzle-tile:hover {
    transform: scale(1.05);
    box-shadow:
        0 4px 15px rgba(244, 114, 182, 0.4),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.puzzle-tile:active {
    transform: scale(0.98);
}

.puzzle-tile.sliding {
    transition: all 0.15s ease;
    z-index: 10;
}

.puzzle-tile.empty {
    background: transparent;
    cursor: default;
    box-shadow: none;
    pointer-events: none;
}

.puzzle-tile.empty:hover {
    transform: none;
}

/* Tile correct position indicator (subtle) */
.puzzle-tile.correct {
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.4),
        inset 0 0 0 2px rgba(74, 222, 128, 0.4);
}

/* Revealed missing piece animation */
.puzzle-tile.revealed {
    animation: revealPiece 0.6s ease forwards;
    box-shadow:
        0 0 20px rgba(244, 114, 182, 0.6),
        0 0 40px rgba(192, 132, 252, 0.4),
        inset 0 0 0 2px rgba(255, 255, 255, 0.3);
}

@keyframes revealPiece {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* ============ PUZZLE CONTROLS ============ */
.puzzle-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.puzzle-moves {
    font-size: 1rem;
    color: #c4b5fd;
    text-shadow: 0 0 10px rgba(192, 132, 252, 0.3);
}

#move-count {
    font-weight: 600;
    color: #f472b6;
}

/* ============ HINT BUTTON ============ */
.hint-btn {
    padding: 0.5rem 1rem;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #e9d5ff;
    background: linear-gradient(145deg, #3a3a5e, #2a2a4e);
    border: 1px solid rgba(192, 132, 252, 0.3);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.hint-btn:hover {
    background: linear-gradient(145deg, #4a4a6e, #3a3a5e);
    border-color: rgba(244, 114, 182, 0.5);
    box-shadow: 0 4px 15px rgba(244, 114, 182, 0.3);
    transform: translateY(-2px);
}

.hint-btn:active {
    transform: translateY(0);
}

/* ============ HELP BUTTON ============ */
.help-btn {
    padding: 0.5rem 1rem;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fce7f3;
    background: linear-gradient(145deg, #ec4899, #db2777);
    border: 1px solid rgba(244, 114, 182, 0.5);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(236, 72, 153, 0.4);
}

.help-btn:hover {
    background: linear-gradient(145deg, #f472b6, #ec4899);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(244, 114, 182, 0.5);
}

.help-btn:active {
    transform: translateY(0);
}

/* ============ HELP MESSAGE OVERLAY ============ */
.help-message-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 18, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 60;
}

.help-message-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.help-message-bubble {
    max-width: 320px;
    padding: 1.5rem 2rem;
    background: linear-gradient(145deg, #3a3a5e, #2a2a4e);
    border: 2px solid rgba(244, 114, 182, 0.4);
    border-radius: 20px;
    font-size: 1.2rem;
    color: #fce7f3;
    text-align: center;
    line-height: 1.6;
    box-shadow:
        0 0 40px rgba(244, 114, 182, 0.3),
        0 10px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s ease;
}

.help-message-overlay.show .help-message-bubble {
    transform: scale(1);
    opacity: 1;
}

.help-message-bubble .michalis-name {
    display: block;
    font-size: 0.85rem;
    color: #a78bfa;
    margin-bottom: 0.8rem;
    opacity: 0.8;
}

.help-message-bubble .help-emoji {
    display: block;
    font-size: 2.5rem;
    margin-top: 1rem;
}

/* ============ ZERO PUZZLE MESSAGE ============ */
.zero-puzzle-message {
    font-size: 1.3rem;
    color: #f472b6;
    text-align: center;
    text-shadow: 0 0 20px rgba(244, 114, 182, 0.5);
    animation: pulseText 1.5s ease-in-out infinite;
}

@keyframes pulseText {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

/* ============ HINT OVERLAY ============ */
.hint-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 18, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 50;
}

.hint-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.hint-overlay img {
    width: 280px;
    height: 280px;
    border-radius: 12px;
    box-shadow:
        0 0 40px rgba(244, 114, 182, 0.4),
        0 10px 40px rgba(0, 0, 0, 0.5);
    animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% {
        box-shadow:
            0 0 40px rgba(244, 114, 182, 0.4),
            0 10px 40px rgba(0, 0, 0, 0.5);
    }
    50% {
        box-shadow:
            0 0 60px rgba(244, 114, 182, 0.6),
            0 10px 40px rgba(0, 0, 0, 0.5);
    }
}

.hint-overlay p {
    font-size: 1rem;
    color: #c4b5fd;
    text-shadow: 0 0 10px rgba(192, 132, 252, 0.3);
}

/* ============ HINT TEXT ============ */
.puzzle-hint {
    font-size: 0.9rem;
    color: #a78bfa;
    opacity: 0.7;
    margin-top: 0.5rem;
}

/* ============ COMPLETION OVERLAY ============ */
.puzzle-complete {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(244, 114, 182, 0.2) 0%, rgba(26, 26, 46, 0.95) 70%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease;
    z-index: 30;
}

.puzzle-complete.show {
    opacity: 1;
}

.puzzle-complete-photo {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow:
        0 0 40px rgba(244, 114, 182, 0.5),
        0 0 80px rgba(192, 132, 252, 0.3);
    animation: photoReveal 1s ease forwards;
    opacity: 0;
    transform: scale(0.5);
}

.puzzle-complete-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes photoReveal {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.puzzle-complete-text {
    font-size: 1.6rem;
    color: #fce7f3;
    text-align: center;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 30px rgba(244, 114, 182, 0.6);
    opacity: 0;
    animation: fadeInUp 0.8s ease 0.5s forwards;
}

.puzzle-complete-sub {
    font-size: 1.2rem;
    color: #f472b6;
    text-shadow: 0 0 20px rgba(244, 114, 182, 0.4);
    opacity: 0;
    animation: fadeInUp 0.8s ease 1s forwards;
}

/* ============ SPARKLE EFFECTS ============ */
.puzzle-sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, #fff 0%, #f472b6 50%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: sparkle 1s ease forwards;
}

@keyframes sparkle {
    0% {
        opacity: 1;
        transform: scale(0) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.5) rotate(180deg);
    }
    100% {
        opacity: 0;
        transform: scale(0) rotate(360deg);
    }
}

/* ============ RESPONSIVE DESIGN ============ */
@media (max-width: 400px) {
    .puzzle-grid {
        grid-template-columns: repeat(4, 70px);
        grid-template-rows: repeat(4, 70px);
        gap: 3px;
        padding: 6px;
    }

    .puzzle-tile {
        width: 70px;
        height: 70px;
        background-size: 280px 280px;
    }

    .puzzle-intro p {
        font-size: 1.2rem;
    }

    .puzzle-complete-text {
        font-size: 1.3rem;
    }
}

@media (max-width: 340px) {
    .puzzle-grid {
        grid-template-columns: repeat(4, 60px);
        grid-template-rows: repeat(4, 60px);
    }

    .puzzle-tile {
        width: 60px;
        height: 60px;
        background-size: 240px 240px;
    }
}
