/* リセットとベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ヘッダー */
header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    color: #4a5568;
}

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

/* 画面切り替え */
.screen {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.screen.hidden {
    display: none;
}

/* ゲーム設定画面 */
.setup-container {
    max-width: 600px;
    margin: 0 auto;
}

.setup-container h2 {
    text-align: center;
    color: #4a5568;
    margin-bottom: 30px;
    font-size: 2em;
}

.setup-section {
    margin-bottom: 25px;
}

.setup-section label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.setup-section select,
.setup-section input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.setup-section select:focus,
.setup-section input:focus {
    outline: none;
    border-color: #667eea;
}

.player-name-input {
    margin-bottom: 15px;
}

.player-name-input label {
    font-size: 1em;
    font-weight: 500;
}

/* ボタン */
.button-group {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-secondary {
    background: #edf2f7;
    color: #4a5568;
    border: 2px solid #cbd5e0;
}

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

.btn-back {
    background: #fed7d7;
    color: #c53030;
    border: 2px solid #fc8181;
}

.btn-back:hover {
    background: #feb2b2;
    transform: translateY(-2px);
}

/* ゲーム画面 */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
}

.current-turn {
    font-size: 1.3em;
    font-weight: 600;
    color: #667eea;
}

.current-turn #current-player {
    color: #4a5568;
}

.moves-count {
    font-size: 1.1em;
    color: #718096;
}

/* カードグリッド */
.card-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.card {
    aspect-ratio: 2/3;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.card:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.card.flipped {
    transform: rotateY(180deg);
}

.card.matched {
    cursor: default;
}

.card-face,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 2em;
}

.card-face {
    background: white;
    border: 3px solid #e2e8f0;
    transform: rotateY(180deg);
}

.card-face img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.card-face .card-number {
    font-size: 3em;
    font-weight: bold;
    color: #667eea;
}

/* スコアボード */
.scoreboard {
    background: rgba(72, 187, 120, 0.1);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.scoreboard h3 {
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 1.5em;
}

#score-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.score-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.score-item.active {
    border: 3px solid #667eea;
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.player-name {
    font-weight: 600;
    color: #4a5568;
}

.player-score {
    font-size: 1.3em;
    font-weight: bold;
    color: #48bb78;
}

/* 結果画面 */
.result-container {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.result-container h2 {
    font-size: 2.5em;
    color: #4a5568;
    margin-bottom: 30px;
}

.winner-announcement {
    font-size: 1.5em;
    color: #667eea;
    font-weight: 600;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
}

.final-scores {
    margin-bottom: 30px;
}

.final-score-item {
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    background: white;
    margin-bottom: 10px;
    border-radius: 8px;
    font-size: 1.2em;
}

.final-score-item.winner {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

/* レスポンシブデザイン */
@media (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

    .card-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }

    .game-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    #score-list {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .screen {
        padding: 20px;
    }

    .card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .card-back {
        font-size: 1.5em;
    }

    .card-face .card-number {
        font-size: 2em;
    }
}

/* アニメーション */
@keyframes matchSuccess {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.card.match-animation {
    animation: matchSuccess 0.5s ease;
}
