/* ===== Sliding Puzzle Game Styles ===== */

/* ===== Game Board Layout ===== */
#game-board {
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

#game-board.active {
    display: flex;
}

/* ===== Game Container ===== */
.game-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    gap: 30px;
    min-height: 0;
    overflow: hidden;
}

/* ===== Reference Panel ===== */
.reference-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 200px;
}

.reference-panel.hidden {
    display: none;
}

.reference-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
    color: #666;
}

.toggle-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    background: #6B8BA8;
    transform: scale(1.1);
}

.reference-image {
    width: 200px;
    height: 200px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border: 3px solid #E0E0E0;
}

/* ===== Puzzle Container ===== */
.puzzle-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.puzzle-grid {
    display: grid;
    gap: 0;
    border: 4px solid #333;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    background: #F5F5F5;
}

.puzzle-grid.size-3 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 360px;
    height: 360px;
}

.puzzle-grid.size-4 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    width: 400px;
    height: 400px;
}

.puzzle-grid.size-5 {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    width: 400px;
    height: 400px;
}

/* ===== Puzzle Tile Styles ===== */
.puzzle-tile {
    background: white;
    border: 2px solid #DDD;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background-size: cover;
    background-position: center;
}

.puzzle-grid.size-3 .puzzle-tile {
    width: 120px;
    height: 120px;
}

.puzzle-grid.size-4 .puzzle-tile {
    width: 100px;
    height: 100px;
}

.puzzle-grid.size-5 .puzzle-tile {
    width: 80px;
    height: 80px;
}

.puzzle-tile.empty {
    background: #F5F5F5;
    cursor: default;
    border-color: #E0E0E0;
}

.puzzle-tile.moveable {
    cursor: pointer;
}

.puzzle-tile.moveable:hover {
    border-color: var(--secondary-color);
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(122, 156, 184, 0.4);
    z-index: 10;
}

.puzzle-tile.sliding {
    transition: transform 0.3s ease-in-out;
}

.puzzle-tile.hint-highlight {
    animation: hint-pulse 1s ease-in-out 3;
    border-color: #FFD700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

@keyframes hint-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.9);
    }
}

.puzzle-tile.invalid-click {
    animation: invalid-shake 0.3s ease-in-out;
}

@keyframes invalid-shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

/* ===== Tile Number Overlay (Optional) ===== */
.puzzle-tile .tile-number {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    display: none;
}

.show-numbers .puzzle-tile .tile-number {
    display: block;
}

/* ===== Victory Animation ===== */
.puzzle-grid.solved {
    animation: victory-glow 1s ease-in-out;
    border-color: #4CAF50;
}

@keyframes victory-glow {
    0%, 100% {
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 8px 40px rgba(76, 175, 80, 0.6);
        transform: scale(1.02);
    }
}

/* ===== Action Panel ===== */
.action-panel {
    background: white;
    padding: 20px;
    display: flex;
    gap: 15px;
    justify-content: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.action-btn {
    padding: 15px 40px;
    border: none;
    border-radius: 12px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    min-width: 180px;
}

.action-btn.primary {
    background: linear-gradient(135deg, #4CAF50 0%, #45A049 100%);
    color: white;
}

.action-btn.primary:hover {
    background: linear-gradient(135deg, #5CBF60 0%, #55B059 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.action-btn.secondary {
    background: linear-gradient(135deg, #7A9CB8 0%, #6B8BA8 100%);
    color: white;
}

.action-btn.secondary:hover {
    background: linear-gradient(135deg, #8AACC8 0%, #7B9BB8 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.action-btn:disabled {
    background: linear-gradient(135deg, #9E9E9E 0%, #757575 100%);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ===== Responsive Styles ===== */

/* Tablet */
@media (max-width: 1024px) {
    .game-container {
        flex-direction: column;
        gap: 20px;
    }

    .reference-panel {
        max-width: 180px;
    }

    .reference-image {
        width: 180px;
        height: 180px;
    }

    .puzzle-grid.size-3 {
        width: 330px;
        height: 330px;
    }

    .puzzle-grid.size-3 .puzzle-tile {
        width: 110px;
        height: 110px;
    }

    .puzzle-grid.size-4 {
        width: 360px;
        height: 360px;
    }

    .puzzle-grid.size-4 .puzzle-tile {
        width: 90px;
        height: 90px;
    }

    .puzzle-grid.size-5 {
        width: 360px;
        height: 360px;
    }

    .puzzle-grid.size-5 .puzzle-tile {
        width: 72px;
        height: 72px;
    }

    .action-btn {
        padding: 12px 30px;
        font-size: 18px;
        min-width: 150px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .game-container {
        padding: 15px 10px;
    }

    .reference-panel {
        max-width: 150px;
    }

    .reference-image {
        width: 150px;
        height: 150px;
    }

    .puzzle-grid.size-3 {
        width: 300px;
        height: 300px;
    }

    .puzzle-grid.size-3 .puzzle-tile {
        width: 100px;
        height: 100px;
    }

    .puzzle-grid.size-4 {
        width: 320px;
        height: 320px;
    }

    .puzzle-grid.size-4 .puzzle-tile {
        width: 80px;
        height: 80px;
    }

    .puzzle-grid.size-5 {
        width: 320px;
        height: 320px;
    }

    .puzzle-grid.size-5 .puzzle-tile {
        width: 64px;
        height: 64px;
    }

    .action-panel {
        padding: 15px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .action-btn {
        padding: 12px 25px;
        font-size: 16px;
        min-width: 120px;
        flex: 1;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .game-container {
        padding: 10px;
        flex-direction: column;
    }

    .reference-panel {
        display: none;
    }

    .puzzle-grid.size-3 {
        width: 270px;
        height: 270px;
    }

    .puzzle-grid.size-3 .puzzle-tile {
        width: 90px;
        height: 90px;
    }

    .puzzle-grid.size-4 {
        width: 280px;
        height: 280px;
    }

    .puzzle-grid.size-4 .puzzle-tile {
        width: 70px;
        height: 70px;
    }

    .puzzle-grid.size-5 {
        width: 280px;
        height: 280px;
    }

    .puzzle-grid.size-5 .puzzle-tile {
        width: 56px;
        height: 56px;
    }

    .action-panel {
        flex-direction: column;
    }

    .action-btn {
        width: 100%;
        min-width: 100%;
    }
}
