/* 达芬奇密码 - 样式文件 */

/* ==================== 基础样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #00d4aa;
    --primary-dark: #00a880;
    --secondary: #ff6b6b;
    --bg-dark: #0f0f23;
    --bg-card: #1a1a2e;
    --bg-card-active: #252542;
    --text-primary: #ffffff;
    --text-secondary: #8b8b9e;
    --black-card: #1a1a1a;
    --white-card: #f5f5f5;
    --success: #00d4aa;
    --error: #ff6b6b;
    --gold: #ffd700;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', -apple-system, sans-serif;
    background: var(--bg-dark);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ==================== 布局 ==================== */
.game-layout {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
}

.game-container {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* 规则侧边栏 */
.rules-sidebar {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(255, 215, 0, 0.2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.rules-sidebar h3 {
    color: var(--gold);
    font-size: 1.15rem;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

.rules-list {
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
}

.rules-list li {
    margin-bottom: 10px;
}

.rules-list li b {
    color: var(--text-primary);
}

.rules-list li em {
    color: var(--secondary);
    font-style: normal;
    font-weight: 500;
}

.rules-tips {
    margin-top: 18px;
    padding: 14px;
    background: rgba(0, 212, 170, 0.06);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.rules-tips b {
    color: var(--primary);
    display: block;
    margin-bottom: 6px;
}

.rules-tips ul {
    padding-left: 18px;
    margin: 0;
}

.rules-tips li {
    margin-bottom: 4px;
}

/* 操作日志 */
.game-log {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 40vh;
    overflow-y: auto;
    font-size: 0.85rem;
}

.game-log li {
    padding: 8px 10px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: var(--text-secondary);
    line-height: 1.5;
    word-break: break-word;
}

.game-log li:first-child {
    border-left-color: var(--primary);
    background: rgba(0, 212, 170, 0.08);
    color: var(--text-primary);
}

.game-log li b {
    color: var(--text-primary);
    font-weight: 600;
}

.game-log .log-empty {
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

/* 日志里的迷你卡牌 */
.card-mini {
    display: inline-block;
    min-width: 22px;
    padding: 1px 6px;
    margin: 0 2px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    line-height: 1.3;
    vertical-align: middle;
}

.card-mini.black {
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #444;
}

.card-mini.white {
    background: #f5f5f5;
    color: #1a1a1a;
    border: 1px solid #ccc;
}

/* 窄屏：侧边栏移到内容上方折叠 */
@media (max-width: 900px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
    .rules-sidebar {
        position: static;
        max-height: none;
        order: 2; /* 放在游戏区域下方 */
    }
}

header {
    text-align: center;
    padding: 20px 0;
    position: relative;
}

header h1 {
    font-size: 2.8rem;
    background: linear-gradient(135deg, var(--gold), #ffaa00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 20px rgba(255, 215, 0, 0.3);
    margin-bottom: 10px;
    letter-spacing: 4px;
}

/* 游戏规则 */
.rules-section {
    text-align: center;
    margin-bottom: 20px;
}

.rules-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 16px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
}

.rules-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
}

.rules-content {
    text-align: left;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.rules-content h4 {
    color: var(--gold);
    margin-bottom: 10px;
}

.rules-content ul, .rules-content ol {
    color: var(--text-secondary);
    padding-left: 20px;
}

.rules-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.status-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    font-size: 1rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.mode-badge, .room-badge {
    padding: 2px 10px;
    background: rgba(255, 215, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--gold);
    margin-left: 8px;
}

.room-badge { background: rgba(0, 212, 170, 0.15); border-color: rgba(0,212,170,0.4); color: var(--primary); }

.me-tag {
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: normal;
}

/* 对手暗牌：只显示颜色的牌背 */
.card.hidden-num.black {
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    color: transparent;
    border: 2px solid #444;
}
.card.hidden-num.white {
    background: linear-gradient(145deg, #ffffff, #e0e0e0);
    color: transparent;
    border: 2px solid #ccc;
}
.card.hidden-num::after {
    content: '?';
    color: rgba(128, 128, 128, 0.6);
    font-size: 1.2rem;
    font-weight: bold;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==================== 玩家区域 ==================== */
.players-area {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
}

.player-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.player-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.player-card.active {
    border-color: var(--primary);
    background: var(--bg-card-active);
    box-shadow: 0 0 30px rgba(0, 212, 170, 0.15);
}

.player-card.active::before {
    opacity: 1;
}

.player-card.eliminated {
    opacity: 0.5;
    border-color: var(--secondary);
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.player-card h3 {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.player-card.active h3 {
    color: var(--primary);
}

.card-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 12px;
}

.eliminated-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    font-size: 2rem;
    color: var(--secondary);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 4px;
    opacity: 0.8;
    text-shadow: 0 2px 10px rgba(255, 107, 107, 0.5);
}

/* ==================== 卡牌 ==================== */
.card-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 60px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.card {
    width: 48px;
    height: 64px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    position: relative;
}

.card.black {
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
    color: #fff;
    border: 2px solid #444;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}

.card.white {
    background: linear-gradient(145deg, #ffffff, #e0e0e0);
    color: #1a1a1a;
    border: 2px solid #ccc;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2), inset 0 -1px 0 rgba(0,0,0,0.1);
}

/* 自己看到的牌 - 加个边框标识 */
.card.own {
    border-width: 3px;
    border-color: var(--gold);
}

.card.hidden {
    background: repeating-linear-gradient(
        45deg,
        #2a2a3a,
        #2a2a3a 5px,
        #1a1a2a 5px,
        #1a1a2a 10px
    );
    color: transparent;
    border: 2px solid #444;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.card.target {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    transform: scale(1.1);
}

/* 卡牌背面（抽牌展示） */
.card-back {
    width: 80px;
    height: 110px;
    background: repeating-linear-gradient(
        45deg,
        #2a2a3a,
        #2a2a3a 8px,
        #1a1a2a 8px,
        #1a1a2a 16px
    );
    border-radius: 10px;
    border: 3px solid #444;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: #555;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* ==================== 控制面板 ==================== */
.control-panel {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.panel-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.step-num {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    color: #000;
}

.section-header h3 {
    font-size: 1.3rem;
    color: var(--text-primary);
}

/* 抽牌区域 */
.draw-section {
    text-align: center;
    padding: 20px;
}

.card-display {
    margin: 20px 0;
    min-height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.draw-section .hint {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

/* 选择器 */
.select-group {
    margin-bottom: 20px;
}

.select-group label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.player-chips, .card-index-chips, .number-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
}

.chip.selected {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary);
    color: #000;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 212, 170, 0.4);
}

.chip.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.chip-number {
    min-width: 44px;
    text-align: center;
}

/* 按钮 */
.action-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 25px;
}

.btn {
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #000;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 212, 170, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-reset {
    background: rgba(255, 107, 107, 0.2);
    color: var(--secondary);
    border: 1px solid var(--secondary);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-large {
    padding: 18px 36px;
    font-size: 1.1rem;
}

/* 结果区域 */
.result-section {
    text-align: center;
    padding: 20px;
}

.result-display {
    margin: 20px 0;
    min-height: 100px;
}

.result-correct, .result-wrong {
    padding: 30px;
    border-radius: 16px;
    animation: bounceIn 0.4s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.result-correct {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.2), rgba(0, 168, 128, 0.1));
    border: 2px solid var(--success);
}

.result-wrong {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(255, 107, 107, 0.1));
    border: 2px solid var(--error);
}

.result-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

.result-correct p, .result-wrong p {
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.result-correct p { color: var(--success); }
.result-wrong p { color: var(--error); }

.result-correct .detail, .result-wrong .detail {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: normal;
}

/* ==================== 牌堆信息 ==================== */
.deck-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.deck-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

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

.deck-info strong {
    color: var(--text-primary);
    font-size: 1.1rem;
}

/* ==================== 弹窗 ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal {
    background: linear-gradient(145deg, var(--bg-card), #12122a);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 2px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease;
}

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

.modal-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.modal h2 {
    font-size: 2rem;
    color: var(--gold);
    margin-bottom: 15px;
}

.modal p {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 25px;
}

.final-cards {
    margin: 20px 0;
    text-align: left;
}

.final-player {
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.final-player span {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ==================== 工具类 ==================== */
.hidden {
    display: none !important;
}

/* ==================== 响应式 ==================== */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.8rem;
        letter-spacing: 2px;
    }

    .players-area {
        grid-template-columns: 1fr;
    }

    .card {
        width: 40px;
        height: 54px;
        font-size: 1rem;
    }

    .card-row {
        gap: 6px;
    }

    .card-back {
        width: 60px;
        height: 84px;
        font-size: 1.8rem;
    }

    .chip {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    .deck-bar {
        flex-wrap: wrap;
        gap: 15px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
}