/**
 * jigsaw.css - Jigsaw Puzzle game styles
 */

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px;
    overflow-x: hidden;
}

.header {
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

h1 {
    font-size: 1.6rem;
}

.back-btn {
    padding: 8px 16px;
    border-radius: 20px;
}

.back-btn:hover, .back-btn:active {
    color: #764ba2;
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.info-box {
    background: rgba(255,255,255,0.2);
    padding: 8px 20px;
    border-radius: 12px;
    color: white;
    font-weight: bold;
    text-align: center;
}

.info-box span {
    display: block;
    font-size: 1.3rem;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.control-btn {
    background: linear-gradient(45deg, #ff6b6b, #feca57);
    border: none;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: bold;
    color: white;
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.control-btn:hover, .control-btn:active {
    transform: scale(1.05);
}

.control-btn.new-game {
    background: linear-gradient(45deg, #a8e6cf, #88d8b0);
}

.difficulty-select {
    padding: 10px 15px;
    font-size: 0.9rem;
    border-radius: 20px;
    border: none;
    background: white;
    color: #764ba2;
    font-weight: bold;
    cursor: pointer;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.board-section {
    text-align: center;
}

.section-label {
    color: white;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.puzzle-board {
    display: grid;
    gap: 2px;
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.board-slot {
    background: rgba(0,0,0,0.2);
    border: 2px dashed rgba(255,255,255,0.4);
    border-radius: 3px;
    position: relative;
}

.board-slot.has-piece {
    border-color: transparent;
}

.board-slot.highlight {
    border-color: #feca57;
    background: rgba(254, 202, 87, 0.3);
}

.piece-tray {
    background: rgba(0,0,0,0.3);
    border-radius: 15px;
    padding: 15px;
    min-height: 120px;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    gap: 8px;
}

.puzzle-piece {
    background-size: cover;
    background-position: center;
    cursor: grab;
    border-radius: 3px;
    touch-action: none;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    transition: transform 0.1s, box-shadow 0.1s;
    position: relative;
    z-index: 1;
}

.puzzle-piece:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

.puzzle-piece.dragging {
    cursor: grabbing;
    transform: scale(1.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 1000;
    position: fixed;
    pointer-events: none;
}

.puzzle-piece.placed {
    cursor: default;
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

.puzzle-piece.placed:hover {
    transform: none;
}

.preview-container {
    text-align: center;
}

.preview-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 10px;
    border: 3px solid white;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    display: none;
}

.win-overlay.show {
    display: flex;
}

.win-content {
    background: white;
    padding: 40px;
    border-radius: 25px;
    text-align: center;
    animation: bounceIn 0.5s;
    margin: 20px;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.win-content h2 {
    font-size: 2rem;
    color: #764ba2;
    margin-bottom: 10px;
}

.win-content p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 20px;
}

@media (max-width: 500px) {
    h1 { font-size: 1.3rem; }
    .info-box { padding: 6px 12px; }
    .info-box span { font-size: 1.1rem; }
    .preview-image { width: 70px; height: 70px; }
    .piece-tray { min-height: 100px; padding: 10px; }
}

/* Level Select Styles */
.jigsaw_level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
}

.jigsaw_level-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid white;
    border-radius: 15px;
    padding: 15px 10px;
    color: white;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
    font-family: inherit;
}

.jigsaw_level-btn:hover:not(.locked) {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.jigsaw_level-btn:active:not(.locked) {
    transform: scale(0.98);
}

.jigsaw_level-btn.locked {
    background: linear-gradient(135deg, #888 0%, #555 100%);
    cursor: not-allowed;
    opacity: 0.7;
}

.jigsaw_level-num {
    font-size: 2rem;
    font-weight: bold;
    line-height: 1;
}

.jigsaw_level-name {
    font-size: 0.95rem;
    margin: 5px 0;
    font-weight: bold;
}

.jigsaw_level-info {
    font-size: 0.8rem;
    opacity: 0.8;
}

.jigsaw_stars {
    font-size: 1.2rem;
    margin-top: 8px;
    letter-spacing: 2px;
}

.jigsaw_lock {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    opacity: 0.9;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.jigsaw_level-title {
    text-align: center;
    color: white;
    font-size: 1.3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.jigsaw_win-stars {
    font-size: 2.5rem;
    margin: 10px 0;
    letter-spacing: 5px;
}

.jigsaw_level-complete {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

/* Timer warning state */
.jigsaw_timer-warning {
    background: rgba(255, 100, 100, 0.4) !important;
    animation: jigsaw_timerPulse 0.5s ease-in-out infinite;
}

@keyframes jigsaw_timerPulse {
    0%, 100% { background: rgba(255, 100, 100, 0.4); }
    50% { background: rgba(255, 50, 50, 0.6); }
}

/* Game over overlay */
.jigsaw_gameOver-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.jigsaw_gameOver-overlay.show {
    display: flex;
}

.jigsaw_gameOver-content {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    padding: 40px;
    border-radius: 25px;
    text-align: center;
    animation: bounceIn 0.5s;
    margin: 20px;
    color: white;
}

.jigsaw_gameOver-content h2 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.jigsaw_gameOver-content p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    opacity: 0.9;
}

/* Wrong rotation glow */
.jigsaw_wrongRotation {
    box-shadow: 0 0 8px 3px rgba(255, 150, 0, 0.5) !important;
    animation: jigsaw_rotateHint 1.5s ease-in-out infinite;
}

@keyframes jigsaw_rotateHint {
    0%, 100% { box-shadow: 0 0 8px 3px rgba(255, 150, 0, 0.4); }
    50% { box-shadow: 0 0 12px 5px rgba(255, 150, 0, 0.7); }
}

/* Piece snap animation - bounce when correctly placed */
.jigsaw_piece-snap {
    animation: jigsaw_snapBounce 0.3s ease-out;
}

@keyframes jigsaw_snapBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Screen transitions */
#jigsaw_levelSelect, #jigsaw_gameplay {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#jigsaw_levelSelect.jigsaw_hidden,
#jigsaw_gameplay.jigsaw_hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

/* Progress indicator */
.jigsaw_progress-box {
    background: rgba(100, 200, 100, 0.3);
}

/* Animated stars display */
.jigsaw_stars-display {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.jigsaw_star {
    font-size: 2.5rem;
    opacity: 0;
    transform: scale(0);
    animation: jigsaw_starPop 0.4s ease-out forwards;
}

.jigsaw_star:nth-child(1) { animation-delay: 0.2s; }
.jigsaw_star:nth-child(2) { animation-delay: 0.5s; }
.jigsaw_star:nth-child(3) { animation-delay: 0.8s; }

@keyframes jigsaw_starPop {
    0% { opacity: 0; transform: scale(0) rotate(-30deg); }
    70% { transform: scale(1.3) rotate(10deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.jigsaw_star.empty {
    filter: grayscale(1) opacity(0.4);
}

/* Best moves display on level buttons */
.jigsaw_best-moves {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 5px;
}

/* Level Complete buttons */
.jigsaw_nextLevel-btn {
    background: linear-gradient(135deg, #FFD700, #FFA500) !important;
    color: #333 !important;
}

/* Result text styling */
.jigsaw_result {
    font-weight: bold;
    font-size: 1.1rem;
    margin-top: 5px;
}

.jigsaw_result.under-par { color: #4CAF50; }
.jigsaw_result.over-par { color: #ff6b6b; }

/* Speed Demon Easter Egg */
.jigsaw_speed-demon-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: jigsaw_fadeIn 0.3s ease;
}

.jigsaw_speed-demon-content {
    text-align: center;
}

.jigsaw_speed-demon-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: jigsaw_speedPulse 0.5s ease infinite;
}

.jigsaw_speed-demon-text {
    font-size: 3rem;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 0 0 20px #FFA500, 0 0 40px #FF6347;
    animation: jigsaw_speedFlash 0.2s ease infinite alternate;
}

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

@keyframes jigsaw_speedPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

@keyframes jigsaw_speedFlash {
    from { opacity: 0.8; }
    to { opacity: 1; }
}

/* Frustrated Easter Egg */
.jigsaw_frustrated-wobble {
    animation: jigsaw_wobble 0.5s ease !important;
}

@keyframes jigsaw_wobble {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.jigsaw_frustrated-message {
    position: fixed;
    background: linear-gradient(135deg, #333, #555);
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 1.1rem;
    z-index: 1500;
    animation: jigsaw_tooltipBounce 0.4s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

@keyframes jigsaw_tooltipBounce {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Mirror Mode Easter Egg */
.jigsaw_mirror-mode {
    transform: scaleX(-1);
}

.jigsaw_mirror-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    z-index: 100;
    animation: jigsaw_indicatorPulse 2s ease infinite;
}

@keyframes jigsaw_indicatorPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(155, 89, 182, 0.5); }
    50% { box-shadow: 0 0 15px rgba(155, 89, 182, 0.8); }
}

/* Straight Shooter egg */
.jigsaw_arrow-shower {
    position: fixed;
    top: -40px;
    font-size: 1.8rem;
    z-index: 1000;
    pointer-events: none;
    animation: jigsaw_arrowFall 2.5s ease-in forwards;
}
@keyframes jigsaw_arrowFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(360deg); opacity: 0; }
}
.jigsaw_float-text {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.6rem;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    z-index: 1001;
    pointer-events: none;
    animation: jigsaw_floatUp 2.5s ease-out forwards;
}
@keyframes jigsaw_floatUp {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.5); }
    20% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) translateY(-40px) scale(1); }
}

/* Zen egg */
.jigsaw_zen-overlay {
    position: fixed;
    inset: 0;
    background: rgba(100, 149, 237, 0.15);
    z-index: 500;
    pointer-events: none;
    animation: jigsaw_zenFadeIn 2s ease forwards;
}
@keyframes jigsaw_zenFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.jigsaw_zen-text {
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.4rem;
    color: #4a90d9;
    text-shadow: 0 1px 6px rgba(74, 144, 217, 0.4);
    z-index: 501;
    pointer-events: none;
    animation: jigsaw_zenTextFade 3s ease forwards;
}
@keyframes jigsaw_zenTextFade {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    30% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.jigsaw_zen-glow {
    box-shadow: 0 0 12px rgba(100, 149, 237, 0.6) !important;
    transition: box-shadow 1s ease;
}

/* Completionist egg */
.jigsaw_trophy-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    pointer-events: none;
    animation: jigsaw_trophyFadeIn 0.5s ease forwards;
}
@keyframes jigsaw_trophyFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.jigsaw_trophy-icon {
    font-size: 4rem;
    animation: jigsaw_trophySpin 1.5s ease;
}
@keyframes jigsaw_trophySpin {
    0% { transform: scale(0) rotate(-180deg); }
    60% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}
.jigsaw_trophy-text {
    font-size: 1.8rem;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 0 2px 8px rgba(255, 215, 0, 0.6);
    margin-top: 10px;
}
.jigsaw_trophy-sparkle {
    position: absolute;
    font-size: 1.2rem;
    pointer-events: none;
    animation: jigsaw_sparkle 1s ease forwards;
}
@keyframes jigsaw_sparkle {
    0% { opacity: 1; transform: scale(0); }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0; transform: scale(0.5) translateY(-20px); }
}

@media (prefers-reduced-motion: reduce) {
    .jigsaw_arrow-shower,
    .jigsaw_float-text,
    .jigsaw_zen-overlay,
    .jigsaw_zen-text,
    .jigsaw_trophy-icon,
    .jigsaw_trophy-sparkle {
        animation: none !important;
    }
    .jigsaw_arrow-shower { opacity: 0; }
    .jigsaw_float-text,
    .jigsaw_zen-text { opacity: 1; }
    .jigsaw_zen-overlay { opacity: 1; }
    .jigsaw_trophy-overlay { opacity: 1; }
    .jigsaw_trophy-icon { transform: scale(1); }
}
