/* マインスイーパー - スタイルシート */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #fff;
    user-select: none;
}

/* 共通 */
.hidden {
    display: none !important;
}

/* ゲームコンテナ */
.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ヘッダー */
.game-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 100;
}

.game-header h1 {
    font-size: 1.8rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ホームリンク */
.home-link {
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.home-link:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ボタン */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #545b62 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

.btn-gold {
    background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
    color: #333;
    font-weight: 600;
}

.btn-gold:hover {
    background: linear-gradient(135deg, #ffed4e 0%, #ffb700 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
}

.btn-gold:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-large {
    padding: 15px 40px;
    font-size: 1.1rem;
}

/* モード選択ドロップダウン */
.mode-dropdown {
    position: relative;
    display: inline-block;
}

.mode-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 220px;
    background: rgba(30, 30, 50, 0.98);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    margin-top: 8px;
    padding: 8px 0;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-dropdown-content.show {
    display: block;
}

.dropdown-section {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dropdown-section:last-child {
    border-bottom: none;
}

.dropdown-title {
    padding: 8px 16px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: #fff;
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-item.active {
    background: rgba(74, 144, 217, 0.3);
    color: #4a90d9;
}

/* ゲーム情報パネル */
.game-info-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.info-label {
    font-size: 0.85rem;
    opacity: 0.8;
}

.info-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffd700;
}

.timer-display .info-value {
    font-family: 'Courier New', monospace;
    min-width: 80px;
    text-align: center;
}

/* ゲームステータス */
.game-status {
    text-align: center;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: bold;
}

.game-status.hidden {
    display: none;
}

.game-status.win {
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.3) 0%, rgba(30, 126, 52, 0.3) 100%);
    color: #7dff7d;
}

.game-status.lose {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.3) 0%, rgba(200, 35, 51, 0.3) 100%);
    color: #ff7d7d;
}

/* オンライン対戦情報 */
.online-info {
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    margin-bottom: 15px;
    backdrop-filter: blur(10px);
}

.online-info.hidden {
    display: none;
}

.online-players {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
}

.online-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    min-width: 150px;
}

.online-player.self {
    border: 2px solid #4a90d9;
}

.online-player.opponent {
    border: 2px solid #ff6b6b;
}

.online-player .player-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.online-player .player-time {
    font-family: 'Courier New', monospace;
    font-size: 1.3rem;
    color: #ffd700;
}

.online-player .player-status {
    font-size: 0.85rem;
    opacity: 0.8;
}

.online-player .player-status.finished {
    color: #7dff7d;
}

.online-player .player-status.failed {
    color: #ff7d7d;
}

.vs-label {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffd700;
}

/* ボードラッパー */
.board-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10px 0;
    overflow: auto;
}

/* ゲームボード */
.board {
    display: grid;
    gap: 1px;
    background: #666;
    border: 3px solid #999;
    border-radius: 5px;
    padding: 2px;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

/* セル */
.cell {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.1s ease;
    border: 2px solid;
    border-color: #fff #999 #999 #fff;
    background: linear-gradient(145deg, #c0c0c0 0%, #a0a0a0 100%);
}

.cell:hover:not(.revealed):not(.flagged) {
    background: linear-gradient(145deg, #d0d0d0 0%, #b0b0b0 100%);
}

.cell.revealed {
    border-color: #888;
    background: #bdbdbd;
    cursor: default;
}

.cell.flagged {
    background: linear-gradient(145deg, #c0c0c0 0%, #a0a0a0 100%);
}

.cell.mine {
    background: #ff4444;
}

.cell.mine-clicked {
    background: #ff0000;
}

.cell.wrong-flag {
    background: #ffaaaa;
}

/* 数字の色 */
.cell.num-1 { color: #0000ff; }
.cell.num-2 { color: #008000; }
.cell.num-3 { color: #ff0000; }
.cell.num-4 { color: #000080; }
.cell.num-5 { color: #800000; }
.cell.num-6 { color: #008080; }
.cell.num-7 { color: #000000; }
.cell.num-8 { color: #808080; }

/* 操作説明 */
.controls-help {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 15px;
    font-size: 0.85rem;
    opacity: 0.7;
    flex-wrap: wrap;
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(145deg, #2a2a4a 0%, #1a1a2e 100%);
    padding: 40px 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modal-appear 0.3s ease;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
    flex-wrap: wrap;
}

/* モード選択 */
.mode-options {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.mode-section {
    text-align: left;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.mode-section h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    opacity: 0.8;
    text-align: center;
}

.difficulty-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 25px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #ffd700;
    transform: translateY(-5px);
}

.mode-icon {
    font-size: 2rem;
}

.mode-name {
    font-size: 1.1rem;
    font-weight: bold;
}

.mode-desc {
    font-size: 0.8rem;
    opacity: 0.7;
}

.online-description {
    margin-bottom: 15px;
    line-height: 1.6;
    opacity: 0.8;
    text-align: center;
}

/* オンラインロビー */
.online-screen {
    text-align: center;
}

.online-screen.hidden {
    display: none;
}

.name-input-section {
    margin: 20px 0;
}

.name-input-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.name-input-section input {
    width: 100%;
    max-width: 300px;
    padding: 12px 15px;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    text-align: center;
}

.name-input-section input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.name-input-section input:focus {
    outline: none;
    border-color: #4a90d9;
    box-shadow: 0 0 10px rgba(74, 144, 217, 0.3);
}

/* マッチングアニメーション */
.matching-animation {
    padding: 30px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.matching-animation p {
    margin: 15px 0;
}

.waiting-info {
    font-size: 0.9rem;
    opacity: 0.7;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 結果モーダル */
.result-content {
    min-width: 350px;
    text-align: center;
    max-width: 600px;
}

#result-modal .modal {
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(2px);
}

#result-title {
    font-size: 2.5rem;
    margin-bottom: 20px;
    animation: slideDown 0.5s ease;
}

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

#result-title.win {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

#result-title.lose {
    color: #ff6b6b;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.result-details {
    margin: 20px 0;
    font-size: 1.2rem;
    animation: fadeIn 0.6s ease 0.2s both;
}

.result-stats {
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    border-left: 4px solid #ff6b6b;
    animation: fadeIn 0.6s ease 0.3s both;
}

#result-stat-message {
    font-size: 1.1rem;
    color: #ffffff;
    margin: 0;
}

.result-board-toggle {
    margin: 20px 0;
    text-align: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 盤面非表示時のスタイル */
.board-wrapper.result-hidden {
    display: none;
}

.online-info.result-hidden {
    display: none;
}

/* ランキングモーダル */
.ranking-content {
    min-width: 400px;
}

.ranking-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.ranking-tab {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ranking-tab:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ranking-tab.active {
    background: rgba(255, 215, 0, 0.2);
    border-color: #ffd700;
}

.ranking-list {
    max-height: 400px;
    overflow-y: auto;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
}

.ranking-item.top-3 {
    background: rgba(255, 215, 0, 0.1);
}

.rank-number {
    font-size: 1.2rem;
    font-weight: bold;
    min-width: 40px;
}

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

.rank-name {
    flex: 1;
    text-align: left;
    margin-left: 10px;
}

.rank-time {
    font-family: 'Courier New', monospace;
    color: #ffd700;
}

.loading {
    padding: 40px;
    opacity: 0.7;
}

.no-data {
    padding: 40px;
    opacity: 0.5;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .game-header {
        flex-direction: column;
        text-align: center;
        padding: 12px;
    }
    
    .game-header h1 {
        font-size: 1.5rem;
    }
    
    .game-info-panel {
        gap: 15px;
        padding: 12px;
    }
    
    .info-value {
        font-size: 1.2rem;
    }
    
    .cell {
        width: 25px;
        height: 25px;
        font-size: 0.85rem;
    }
    
    .btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
    
    .modal-content {
        padding: 25px 20px;
    }
    
    .mode-btn {
        min-width: 100px;
        padding: 15px 15px;
    }
    
    .controls-help {
        flex-direction: column;
        align-items: center;
        gap: 5px;
    }
    
    .online-players {
        flex-direction: column;
        gap: 15px;
    }
    
    .vs-label {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .cell {
        width: 22px;
        height: 22px;
        font-size: 0.75rem;
    }
    
    .difficulty-options {
        flex-direction: column;
        align-items: center;
    }
    
    .mode-btn {
        width: 100%;
        max-width: 200px;
    }
}
