/* 基本スタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a5f3f;
    color: #fff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: auto;
}

#game-container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
    position: relative;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 40px);
}

/* 設定画面 */
#setup-screen {
    background-color: rgba(45, 125, 95, 0.9);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

#setup-screen h1 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.setup-options {
    background-color: rgba(255,255,255,0.1);
    padding: 2rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.option-group {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.option-group label {
    font-size: 1.1rem;
    min-width: 150px;
    font-weight: bold;
}

.option-group select {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border-radius: 5px;
    border: none;
    background-color: #fff;
    color: #333;
    cursor: pointer;
}

/* ゲームモードボタン */
.game-modes {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-button {
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: #339af0;
    color: #fff;
    transition: all 0.3s;
    font-weight: bold;
}

.mode-button:hover {
    background-color: #228be6;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.mode-button.selected {
    background-color: #ff6b6b;
}

/* ボタン */
.btn-primary {
    padding: 0.8rem 2rem;
    font-size: 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: #ff6b6b;
    color: #fff;
    transition: all 0.3s;
    margin-top: 1rem;
    font-weight: bold;
}

.btn-primary:hover {
    background-color: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.btn-info {
    padding: 0.6rem 1.5rem;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: #4dabf7;
    color: #fff;
    transition: all 0.3s;
    margin-bottom: 1.5rem;
    font-weight: bold;
}

.btn-info:hover {
    background-color: #339af0;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* 遊び方モーダル */
.how-to-play-content {
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    padding: 2.5rem;
}

.close-modal {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 2rem;
    cursor: pointer;
    color: #fff;
    transition: all 0.3s;
}

.close-modal:hover {
    color: #ff6b6b;
    transform: scale(1.1);
}

.rules-section {
    background-color: rgba(255,255,255,0.05);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.rules-section h3 {
    color: #ffd43b;
    margin-bottom: 0.8rem;
    font-size: 1.2rem;
}

.rules-section p {
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.rules-section ul {
    margin-left: 1.5rem;
}

.rules-section li {
    line-height: 1.8;
    margin-bottom: 0.5rem;
}

.rules-section li strong {
    color: #69db7c;
}

.close-modal-btn {
    margin-top: 1.5rem;
    width: 100%;
}

/* ゲーム画面 */
#game-screen {
    width: 100%;
    display: none;
}

/* スコアボード */
.scoreboard {
    background-color: rgba(0,0,0,0.3);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    text-align: center;
}

.scoreboard h3 {
    margin-bottom: 0.5rem;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.score-item {
    background-color: rgba(255,255,255,0.1);
    padding: 0.5rem;
    border-radius: 5px;
}

/* ゲームレイアウト */
.game-layout {
    display: grid;
    grid-template-areas:
        "top top top"
        "left board right"
        "bottom bottom bottom";
    grid-template-columns: auto 1fr auto;
    gap: 20px;
    align-items: center;
    justify-items: center;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

/* プレーヤーエリア */
.player-area {
    background-color: rgba(0,0,0,0.3);
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
    transition: all 0.3s;
}

.player-area.top { grid-area: top; }
.player-area.left { grid-area: left; }
.player-area.right { grid-area: right; }
.player-area.bottom { 
    grid-area: bottom;
    width: 100%;
    max-width: 600px;
}

.player-info {
    margin-bottom: 0.5rem;
}

.player-name {
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
}

.card-count {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    margin-bottom: 0.3rem;
}

.card-icon {
    font-size: 1.2rem;
}

/* パスボタンコンテナ */
.pass-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.pass-label {
    font-size: 0.9rem;
    font-weight: bold;
    color: #4dabf7;
}

/* パスボタン */
.pass-buttons {
    display: flex;
    gap: 0.3rem;
    justify-content: center;
}

.pass-button {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 2px solid #fff;
    background-color: #4dabf7;
    cursor: pointer;
    transition: all 0.3s;
}

.pass-button:hover:not(.used) {
    transform: scale(1.1);
}

.pass-button.used {
    background-color: #495057;
    cursor: not-allowed;
    opacity: 0.5;
}

.player-status {
    margin-top: 0.3rem;
    font-size: 0.9rem;
    min-height: 1.2rem;
    font-weight: bold;
}

/* ボード */
.board-container {
    grid-area: board;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.board {
    background-color: rgba(0,0,0,0.3);
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    display: inline-block;
}

.suit-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.8rem;
}

.suit-row:last-child {
    margin-bottom: 0;
}

.card-slots {
    display: flex;
    gap: 0.15rem;
    justify-content: center;
}

/* カード */
.card {
    width: 40px;
    height: 55px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid #000;
    position: relative;
    flex-shrink: 0;
}

.card.blue {
    background-color: #339af0;
    color: #fff;
}

.card.green {
    background-color: #51cf66;
    color: #fff;
}

.card.yellow {
    background-color: #ffd43b;
    color: #000;
}

.card.red {
    background-color: #ff6b6b;
    color: #fff;
}

.card.placeholder {
    background-color: rgba(255,255,255,0.1);
    border: 2px dashed rgba(255,255,255,0.3);
    color: transparent;
}

.card.playable {
    box-shadow: 0 0 15px rgba(255,255,255,1), 0 0 25px rgba(255,212,59,1);
    animation: pulse 1s infinite;
    border-color: #ffd43b;
    border-width: 3px;
    transform: scale(1.1);
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1.1);
        box-shadow: 0 0 15px rgba(255,255,255,1), 0 0 25px rgba(255,212,59,1);
    }
    50% { 
        transform: scale(1.15);
        box-shadow: 0 0 25px rgba(255,255,255,1), 0 0 35px rgba(255,212,59,1);
    }
}

/* 手札 */
.hand-container {
    width: 100%;
    margin-top: 0.5rem;
}

.hand {
    display: flex;
    gap: 0.2rem;
    padding: 0.8rem;
    background-color: rgba(0,0,0,0.3);
    border-radius: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.hand .card {
    flex-shrink: 0;
}

.hand .card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 現在のプレーヤー表示 */
.current-player {
    animation: glow 1s infinite alternate;
    border: 3px solid #ffd43b;
    background-color: rgba(255, 212, 59, 0.3);
    box-shadow: 0 0 20px rgba(255, 212, 59, 0.8);
}

@keyframes glow {
    0% { box-shadow: 0 0 10px rgba(255,255,255,0.5), 0 0 25px rgba(255, 212, 59, 0.8); }
    100% { box-shadow: 0 0 25px rgba(255,255,255,0.9), 0 0 45px rgba(255, 212, 59, 1); }
}

/* カード表示エリア */
.card-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    pointer-events: none;
}

.display-card {
    width: 80px;
    height: 110px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 2rem;
    border: 3px solid #000;
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
    animation: cardShow 0.8s ease-out;
}

.display-card.blue { background-color: #339af0; color: #fff; }
.display-card.green { background-color: #51cf66; color: #fff; }
.display-card.yellow { background-color: #ffd43b; color: #000; }
.display-card.red { background-color: #ff6b6b; color: #fff; }
.display-card.pass { background-color: #868e96; color: #fff; }
.display-card.finish { background-color: #ffd43b; color: #000; }

@keyframes cardShow {
    0% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
}

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

.modal-content {
    background-color: #2d7d5f;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    min-width: 350px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

#final-results {
    margin-bottom: 1.5rem;
    text-align: left;
    background-color: rgba(0,0,0,0.2);
    padding: 1rem;
    border-radius: 10px;
}

.result-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    border-radius: 5px;
    background-color: rgba(255,255,255,0.05);
}

.result-item.rank-1 {
    color: #ffd43b;
    font-weight: bold;
    background-color: rgba(255, 212, 59, 0.2);
}

.result-item.rank-2 {
    color: #c0c0c0;
    background-color: rgba(192, 192, 192, 0.2);
}

.result-item.rank-3 {
    color: #cd7f32;
    background-color: rgba(205, 127, 50, 0.2);
}

.result-item.eliminated {
    color: #ff6b6b;
    background-color: rgba(255, 107, 107, 0.2);
}

/* レスポンシブ対応 */
@media screen and (max-width: 768px) {
    .game-layout {
        grid-template-areas:
            "top"
            "board"
            "left"
            "right"
            "bottom";
        grid-template-columns: 1fr;
    }

    .card {
        width: 30px;
        height: 42px;
        font-size: 0.8rem;
    }

    .board {
        padding: 1rem;
    }

    .player-area {
        width: 100%;
        max-width: 400px;
    }
    
    .how-to-play-content {
        padding: 1.5rem;
    }
    
    .rules-section {
        padding: 0.8rem 1rem;
    }
}