/* ===========================================
   スライドパズル - Slide Puzzle (イラスト版)
   =========================================== */
/* Mobile Responsive Fixes */
@media (max-width: 480px) {
    .game-header {
        padding: 60px 10px 10px;
    }
    .level-badge {
        font-size: 0.9rem;
        padding: 5px 10px;
    }
    .home-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        top: 10px;
        left: 10px;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Zen Maru Gothic', sans-serif;
    touch-action: none;
    user-select: none;
}

body {
    background: linear-gradient(180deg, #E8F5E9 0%, #C8E6C9 50%, #A5D6A7 100%);
}

.home-btn {
    position: fixed;
    top: 12px;
    left: 12px;
    width: 48px;
    height: 48px;
    background: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    border: 3px solid #66BB6A;
}

#game-container {
    max-width: 500px;
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header */
.game-header {
    padding: 55px 15px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-badge {
    background: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 3px 0 #BDBDBD;
}

.moves-display {
    background: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-weight: bold;
    box-shadow: 0 3px 0 #BDBDBD;
}

#moves-count {
    font-size: 1.3rem;
    color: #4CAF50;
}

/* Screens */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.screen.hidden {
    display: none;
}

/* Select Screen */
#select-screen h2,
#difficulty-screen h2 {
    font-size: 1.3rem;
    color: #2E7D32;
    margin-bottom: 20px;
}

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 300px;
}

.puzzle-option {
    background: white;
    border: 4px solid #A5D6A7;
    border-radius: 20px;
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.puzzle-option:active {
    transform: scale(0.95);
    border-color: #4CAF50;
}

.puzzle-icon {
    font-size: 2.5rem;
}

.puzzle-name {
    font-size: 0.85rem;
    font-weight: bold;
    color: #333;
}

/* Difficulty Screen */
.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 280px;
}

.difficulty-btn {
    background: white;
    border: 4px solid #A5D6A7;
    border-radius: 20px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.difficulty-btn:active {
    transform: scale(0.97);
    border-color: #4CAF50;
}

.diff-icon {
    font-size: 1.5rem;
}

.diff-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

.diff-desc {
    font-size: 0.85rem;
    color: #666;
}

/* Game Screen */
#game-screen {
    justify-content: flex-start;
    padding-top: 15px;
}

.puzzle-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.puzzle-board {
    display: grid;
    grid-template-columns: repeat(3, 85px);
    grid-template-rows: repeat(3, 85px);
    gap: 6px;
    background: #37474F;
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

@media (max-width: 380px) {
    .puzzle-board {
        transform: scale(0.85);
    }
}

.puzzle-tile {
    width: 85px;
    height: 85px;
    background: linear-gradient(135deg, #4CAF50 0%, #43A047 100%);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.8rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 5px 0 #2E7D32;
}

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

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

.puzzle-tile.correct {
    background: linear-gradient(135deg, #81C784 0%, #66BB6A 100%);
}

.puzzle-tile.moving {
    animation: tileMove 0.15s ease-out;
}

@keyframes tileMove {
    0% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Goal Area */
.goal-area {
    background: white;
    border-radius: 15px;
    padding: 12px 20px;
    margin: 15px 0;
    text-align: center;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
}

.goal-label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #666;
    margin-bottom: 8px;
}

.goal-grid {
    display: grid;
    grid-template-columns: repeat(3, 28px);
    gap: 4px;
    justify-content: center;
}

.goal-grid span {
    width: 28px;
    height: 28px;
    background: #E8F5E9;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

.shuffle-button {
    padding: 15px 40px;
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 5px 0 #E65100;
}

.shuffle-button:active {
    transform: translateY(5px);
    box-shadow: none;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.overlay.hidden {
    display: none;
}

.complete-modal {
    background: white;
    border-radius: 30px;
    padding: 25px;
    text-align: center;
    animation: modalPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 320px;
    width: 90%;
}

@keyframes modalPop {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

.clear-banner {
    width: 160px;
    margin-bottom: 10px;
}

.complete-modal h2 {
    font-size: 1.5rem;
    color: #4CAF50;
    margin-bottom: 15px;
}

.clear-stats {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 20px;
}

#final-moves {
    font-size: 2rem;
    font-weight: bold;
    color: #FF9800;
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #4CAF50 0%, #43A047 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 0 #2E7D32;
}

.btn-secondary {
    background: #EEEEEE;
    color: #333;
    border: none;
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
}

.btn-primary:active,
.btn-secondary:active {
    transform: translateY(4px);
    box-shadow: none;
}