/* 色当てゲーム専用スタイル */

.game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: rgb(248, 248, 248);
    border: 2px solid #DDCDBF;
}

.game-phase {
    display: none;
    text-align: center;
    padding: 30px;
    min-height: 200px; /* 最小高さを設定 */
}

.game-phase.active {
    display: block !important; /* !important を追加して強制表示 */
}

.phase-title {
    margin-bottom: 30px;
}

.phase-title h3 {
    font-size: 2rem;
    color: #333;
    margin-bottom: 10px;
}

.question-counter {
    font-size: 1.2rem;
    color: #666;
    font-weight: bold;
}

/* 記憶フェーズ */
.color-display-container {
    margin: 40px 0;
    text-align: center;
}

.target-color {
    width: 300px;
    height: 300px;
    display: block;
    margin: 0 auto;
}

/* 選択フェーズ */
.color-picker-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    margin: 40px 0;
}

.color-picker {
    width: 200px;
    height: 200px;
    border: 2px solid #DDCDBF;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.color-picker:hover {
    transform: scale(1.1);
}

.selected-color-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.color-preview {
    width: 100px;
    height: 100px;
    border: 2px solid #DDCDBF;
}

.selected-color-preview p {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
}

/* 結果フェーズ */
.result-content {
    margin: 30px 0;
}

.color-comparison {
    margin-bottom: 30px;
}

.color-pair {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 20px 0;
}

.color-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}


    .color-display {
        width: 120px;
        height: 120px;
        border: 2px solid #DDCDBF;
    }
    
    .color-pair .color-display {
        width: 100px;
        height: 100px;
    }
    
    .rgb-display {
        min-width: 100px;
        font-size: 0.8rem;
    }

.color-box p {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
    margin: 0;
}

.rgb-display {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
    font-family: 'Courier New', monospace;
    background: rgb(248, 248, 248);
    padding: 5px 8px;
    border: 1px solid #DDCDBF;
    white-space: nowrap;
    width: 180px;
    text-align: center;
}

.score-calculation {
    margin-top: 20px;
    text-align: center;
}

.distance-info {
    background: rgba(221, 205, 191, 0.1);
    padding: 15px;
    border: 1px solid #DDCDBF;
    border-left: 4px solid rgb(113, 175, 182);
}

.distance-info h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1.1rem;
}

.distance-info p {
    margin: 5px 0;
    font-size: 0.95rem;
    color: #555;
}


/* 最終結果フェーズ */
#final-result-phase {
    display: none;
    text-align: center;
    padding: 10px;
    min-height: auto;
}

#final-result-phase.active {
    display: block !important;
}

.final-result-content {
    margin: 10px 0;
}

/* 名前入力セクション */
.name-input-section {
    background: #fff;
    padding: 8px;
    border-radius: 8px;
    margin-top: 8px;
}

.name-input-section h5 {
    font-size: 1rem;
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

.score-save-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 300px;
}

.input-group label {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    font-size: 1.1rem;
    border: 2px solid #DDCDBF;
    text-align: center;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: rgb(113, 175, 182);
    box-shadow: 0 0 0 3px rgba(113, 175, 182, 0.1);
}

.save-result {
    margin-top: 15px;
    padding: 10px;
    text-align: center;
    font-weight: bold;
    min-height: 0;
}

.save-result:empty {
    display: none;
}

.save-result.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.save-result.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ランキング表示フェーズ */
.ranking-content {
    margin: 30px 0;
}

.ranking-stats {
    background: #fff;
    padding: 20px;
    border: 2px solid #DDCDBF;
    margin-bottom: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.stat-item {
    text-align: center;
    padding: 15px;
    background: rgba(221, 205, 191, 0.1);
    border: 1px solid #DDCDBF;
    border-left: 4px solid rgb(113, 175, 182);
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
}

.ranking-list {
    background: #fff;
    border: 2px solid #DDCDBF;
    overflow: hidden;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.ranking-item:hover {
    background: rgba(221, 205, 191, 0.1);
}

.ranking-item:last-child {
    border-bottom: none;
}

.rank-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: rgb(113, 175, 182);
    min-width: 50px;
    text-align: center;
}

.rank-medal {
    font-size: 1.8rem;
    margin-right: 10px;
}

.rank-medal.gold { color: #ffd700; }
.rank-medal.silver { color: #c0c0c0; }
.rank-medal.bronze { color: #cd7f32; }

.player-info {
    flex: 1;
    margin-left: 15px;
}

.player-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.player-date {
    font-size: 0.9rem;
    color: #666;
}

.score-info {
    text-align: right;
}

.total-score {
    font-size: 1.4rem;
    font-weight: bold;
    color: rgb(113, 175, 182);
    margin-bottom: 5px;
}

.question-scores {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
}

.question-score {
    font-size: 0.8rem;
    color: #666;
    background: rgba(221, 205, 191, 0.1);
    padding: 2px 6px;
    border: 1px solid #DDCDBF;
}

.loading-indicator {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading-indicator p {
    font-size: 1.1rem;
}

.final-score {
    text-align: center;
    margin-bottom: 15px;
    padding: 10px;
    background: rgb(184, 217, 224);
    border-radius: 8px;
    color: #333;
}

.final-score-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-bottom: 5px;
}

.final-score-label {
    font-size: 1.2rem;
    font-weight: bold;
}

.final-score-value {
    font-size: 2.5rem;
    font-weight: bold;
}

.score-grade {
    font-size: 1rem;
    font-weight: bold;
}

.score-breakdown {
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.score-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.score-item {
    background: #f8f9fa;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #333;
    border: 1px solid #e9ecef;
}

/* ボタンスタイル */
.game-controls {
    margin-top: 15px;
    text-align: center;
}

.game-btn {
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: bold;
    border: 2px solid #DDCDBF;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    margin: 0 5px;
}

.game-btn.primary {
    background: rgb(113, 175, 182);
    color: white;
}

.game-btn.primary:hover {
    background: rgb(95, 155, 162);
    transform: translateY(-2px);
}

.game-btn.secondary {
    background: #95a5a6;
    color: white;
}

.game-btn.secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .game-container {
        margin: 10px;
        padding: 15px;
    }
    
    .target-color {
        width: 250px;
        height: 250px;
    }
    
    .color-picker {
        width: 150px;
        height: 150px;
    }
    
    .color-pair {
        flex-direction: row;
        gap: 15px;
        justify-content: center;
    }
    
    .final-score-value {
        font-size: 3rem;
    }
    
    .game-btn {
        padding: 12px 24px;
        font-size: 1.1rem;
        margin: 5px;
    }
}

@media (max-width: 480px) {
    .target-color {
        width: 200px;
        height: 200px;
    }
    
    .color-picker {
        width: 120px;
        height: 120px;
    }
    
    .color-pair .color-display {
        width: 80px;
        height: 80px;
    }
    
    .rgb-display {
        width: 140px;
        font-size: 0.75rem;
    }
    
    .final-score-value {
        font-size: 2.5rem;
    }
    
    .phase-title h3 {
        font-size: 1.3rem;
    }
    
    .name-input-section {
        padding: 15px;
    }
    
    .input-group input {
        font-size: 1rem;
        padding: 10px 12px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ranking-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .rank-number {
        font-size: 1.2rem;
        min-width: auto;
    }
    
    .player-info {
        margin-left: 0;
    }
    
    .score-info {
        text-align: left;
        width: 100%;
    }
    
    .question-scores {
        justify-content: flex-start;
    }
}
