* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #232F3E, #FF9900);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
}

/* 背景エフェクト用のスタイル */
#background-effect-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: -10;
    overflow: hidden;
}

#background-effect-container img {
    position: absolute;
    filter: grayscale(20%) brightness(0.8);
    will-change: transform, top;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    pointer-events: none;
}

.container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    text-align: center;
    position: relative;
    z-index: 10;
}

h1 {
    color: #232F3E;
    margin-bottom: 20px;
    font-size: 2em;
}

/* プレビューアイコンのスタイル */
.preview-icons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 20px 0 30px 0;
    height: 80px;
}

/* プレビューアイコンを非表示にするクラス */
.preview-icons.hidden {
    display: none;
}

.preview-icon {
    width: 64px;
    height: 64px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.preview-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.preview-icon img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    opacity: 0;
    transform: rotateY(0deg);
    transition: all 0.6s ease-in-out;
}

.preview-icon img.fade-in {
    opacity: 1;
}

.preview-icon img.rotate-out {
    opacity: 0;
    transform: rotateY(90deg);
}

.preview-icon img.rotate-in {
    opacity: 1;
    transform: rotateY(0deg);
}

h2 {
    color: #232F3E;
    margin-bottom: 15px;
}

.screen {
    display: block;
}

.screen.hidden {
    display: none;
}

.btn {
    background: #FF9900;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    margin: 10px;
    transition: background 0.3s;
}

.btn:hover {
    background: #e88a00;
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    background: #6c757d;
}

.btn-secondary:hover {
    background: #5a6268;
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

/* ゲーム情報 */
.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-weight: bold;
    color: #232F3E;
}

/* パズルグリッド */
#puzzle-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

#puzzle-grid {
    display: grid;
    grid-template-columns: repeat(3, 120px);
    grid-template-rows: repeat(3, 120px);
    gap: 2px;
    background: #ddd;
    padding: 10px;
    border-radius: 10px;
}

.puzzle-piece {
    background-size: 360px 360px;
    background-repeat: no-repeat;
    border: 2px solid #fff;
    border-radius: 5px;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #666;
    background-color: #f8f9fa;
    position: relative;
    z-index: 1;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overflow: hidden;
    will-change: border-color, transform;
    backface-visibility: hidden;
}

.puzzle-piece img {
    width: 360px;
    height: 360px;
    object-fit: contain;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    will-change: transform;
    backface-visibility: hidden;
}

.puzzle-piece:hover {
    border-color: #FF9900;
    transform: scale(1.05);
}

.puzzle-piece.empty {
    background: #f0f0f0;
    cursor: default;
}

.puzzle-piece.empty:hover {
    border-color: #fff;
    transform: none;
}

/* クイズ部分 */
#completed-image {
    width: 200px;
    height: 200px;
    margin: 20px auto;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 10px;
    border: 3px solid #ddd;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#completed-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 20px 0;
}

.quiz-option {
    background: #f8f9fa;
    border: 2px solid #ddd;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.quiz-option:hover {
    background: #e9ecef;
    border-color: #FF9900;
}

.quiz-option.correct {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.quiz-option.incorrect {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

#quiz-result {
    margin: 20px 0;
    font-size: 18px;
    font-weight: bold;
}

.quiz-result.correct {
    color: #28a745;
}

.quiz-result.incorrect {
    color: #dc3545;
}

/* 結果画面 */
#completed-service-info {
    margin: 20px 0;
    text-align: center;
}

#completed-service-icon {
    width: 150px;
    height: 150px;
    margin: 0 auto 15px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 15px;
    background-color: #f8f9fa;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#completed-service-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#completed-service-name {
    font-size: 20px;
    font-weight: bold;
    color: #232F3E;
    margin-bottom: 10px;
}

#final-time, #final-moves {
    font-size: 18px;
    margin: 10px 0;
    color: #232F3E;
}

/* モーダルダイアログ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px 20px 10px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    color: #232F3E;
    margin: 0;
    font-size: 1.3em;
}

.modal-body {
    padding: 20px;
    color: #666;
    line-height: 1.5;
}

.modal-body p {
    margin-bottom: 10px;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-footer {
    padding: 10px 20px 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-danger {
    background: #dc3545;
}

.btn-danger:hover {
    background: #c82333;
}

/* レスポンシブ対応 */
@media (max-width: 480px) {
    .container {
        padding: 20px;
    }
    
    .preview-icons {
        gap: 15px;
        margin: 15px 0 25px 0;
        height: 60px;
    }
    
    .preview-icon {
        width: 50px;
        height: 50px;
    }
    
    .preview-icon img {
        width: 36px;
        height: 36px;
        transform: rotateY(0deg);
        transition: all 0.6s ease-in-out;
    }
    
    #puzzle-grid {
        grid-template-columns: repeat(3, 80px);
        grid-template-rows: repeat(3, 80px);
    }
    
    .puzzle-piece img {
        width: 240px;
        height: 240px;
    }
    
    #completed-image {
        width: 150px;
        height: 150px;
    }
    
    #completed-service-icon {
        width: 120px;
        height: 120px;
    }
    
    #completed-service-name {
        font-size: 18px;
    }
    
    #quiz-options {
        grid-template-columns: 1fr;
    }
    
    .button-group {
        flex-direction: column;
        align-items: center;
    }
}
