/* リセットCSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    min-height: 95vh;
    margin-top: 2.5vh;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
    border-bottom: 3px solid #667eea;
}

header h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

header p {
    color: #666;
    font-size: 1.1em;
}

main {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    align-items: start;
}

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

#gameCanvas {
    border: 3px solid #333;
    border-radius: 10px;
    background: #f8f9fa;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.controls {
    display: flex;
    gap: 15px;
}

.controls button {
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    min-height: 48px;
    min-width: 100px;
    touch-action: manipulation;
}

#resetBtn {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
}

#resetBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

#helpBtn {
    background: linear-gradient(45deg, #4ecdc4, #45b7aa);
    color: white;
}

#helpBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(78, 205, 196, 0.4);
}

.info-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #e9ecef;
    text-align: center;
    min-width: 250px;
}

.move-counter {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.status {
    color: #666;
    font-style: italic;
}

.instructions {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    border: 2px solid #e9ecef;
}

.instructions h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 5px;
}

.instructions ul {
    margin-left: 20px;
    margin-bottom: 20px;
}

.instructions li {
    margin-bottom: 8px;
}

.piece-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.color-box {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid #333;
    flex-shrink: 0;
}

/* 駒の色定義 */
.daughter { background-color: rgb(255, 100, 100); }
.father { background-color: rgb(100, 50, 200); }
.mother { background-color: rgb(200, 50, 100); }
.head-clerk { background-color: rgb(50, 150, 200); }
.assistant { background-color: rgb(255, 150, 0); }
.maid { background-color: rgb(100, 200, 50); }
.clerk { background-color: rgb(200, 150, 50); }
.grandfather { background-color: rgb(150, 100, 50); }
.grandmother { background-color: rgb(200, 100, 200); }
.dog { background-color: rgb(100, 100, 100); }
.sister-in-law { background-color: rgb(150, 200, 150); }
.apprentice { background-color: rgb(200, 200, 100); }

footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px 0;
    border-top: 2px solid #e9ecef;
    color: #666;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 80%;
    max-width: 600px;
    position: relative;
    animation: modalFadeIn 0.3s ease;
}

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

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    top: 15px;
    cursor: pointer;
}

.close:hover {
    color: #333;
}

.modal-content h2 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.modal-content h3 {
    color: #667eea;
    margin: 20px 0 10px 0;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
        border-radius: 10px;
    }
    
    main {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    #gameCanvas {
        max-width: 100%;
        height: auto;
    }
    
    .instructions {
        order: -1;
    }
    
    .piece-legend {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .controls {
        flex-direction: column;
        width: 100%;
    }
    
    .controls button {
        width: 100%;
    }
    
    .info-panel {
        width: 100%;
    }
}