/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --player-color: #3b82f6;
    --computer-color: #ef4444;
    --draw-color: #f59e0b;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --card-bg: rgba(255, 255, 255, 0.08);
    --card-border: rgba(255, 255, 255, 0.15);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ========== 头部 ========== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

/* 品牌区：图标 + 品牌名 + 副标题 */
.brand-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon-header {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.1;
}

.brand-name {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fbbf24, #f59e0b, #f97316);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    letter-spacing: 2px;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary, #94a3b8);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 1.2rem;
    line-height: 1;
}

.btn-icon.muted {
    opacity: 0.55;
}

/* ========== 按钮 ========== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--card-bg);
}

/* ========== 分数面板 ========== */
.score-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.score-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    transition: transform 0.2s ease;
}

.score-card:hover {
    transform: translateY(-2px);
}

.score-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
}

.score-unit {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.score-player .score-value { color: var(--player-color); }
.score-draw .score-value { color: var(--draw-color); }
.score-computer .score-value { color: var(--computer-color); }

/* ========== 结果显示 ========== */
.result-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 32px 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.choice-display {
    display: flex;
    align-items: center;
    gap: 32px;
}

.choice-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.choice-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.choice-icon {
    font-size: 4rem;
    line-height: 1;
    transition: transform 0.3s ease;
}

.choice-icon.animate-shake {
    animation: shake 0.4s ease;
}

.choice-icon.animate-bounce {
    animation: bounce 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.vs {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-secondary);
    padding: 8px 16px;
    border: 2px dashed var(--card-border);
    border-radius: 12px;
}

.result-text {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    min-height: 2em;
    transition: color 0.3s ease;
}

.result-text.win { color: var(--success); }
.result-text.lose { color: var(--danger); }
.result-text.draw { color: var(--draw-color); }

/* ========== 选择按钮 ========== */
.choices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.choice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 16px;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.25s ease;
    min-height: 100px;
}

.choice-btn:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
}

.choice-btn:active {
    transform: translateY(0) scale(0.96);
}

.choice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.choice-emoji {
    font-size: 2.5rem;
    line-height: 1;
}

.choice-name {
    font-size: 0.95rem;
    font-weight: 600;
}

/* ========== 历史记录 ========== */
.history-section {
    padding: 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.history-section h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 3px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    font-size: 0.9rem;
}

.history-item .round-num {
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 40px;
}

.history-item .round-detail {
    flex: 1;
    display: flex;
    justify-content: center;
    gap: 12px;
}

.history-item .round-time {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.history-item .result-badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
}

.result-badge.win { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.result-badge.lose { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.result-badge.draw { background: rgba(245, 158, 11, 0.2); color: var(--draw-color); }

.empty-hint {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px;
    font-size: 0.9rem;
}

/* ========== 规则弹窗 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, #1e293b, #334155);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 32px;
    max-width: 480px;
    width: 100%;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 1.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.rules-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.rules-list li {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    font-size: 1rem;
}

.rules-note {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

/* ============================================
   新增样式：资料条 / 登录注册 / 排行榜 / 里程碑 / 升段
   ============================================ */

/* 顶部资料条 */
.profile-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: var(--card-bg, rgba(255,255,255,0.06));
    border-radius: 12px;
    font-size: 0.95rem;
}
.profile-nick { font-weight: 700; }
.profile-coins { color: #ffd86b; }
.profile-rank { color: #ffdfba; }
.profile-streak { color: #ff7e5f; }
.profile-maxstreak { color: #ffd700; }

/* 登录注册浮层 */
.auth-content { max-width: 360px; text-align: left; }
.auth-content h2 {
    text-align: center;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fbbf24, #f59e0b, #f97316);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 2px;
}
.brand-icon-sm {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tab {
    flex: 1; padding: 8px; border: 1px solid var(--border, rgba(255,255,255,0.1));
    background: transparent; color: var(--text-secondary, #aaa); border-radius: 8px;
    cursor: pointer; font-size: 0.95rem;
}
.auth-tab.active { background: var(--accent, #6366f1); color: #fff; border-color: transparent; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--text-secondary, #aaa); }
.auth-form input {
    width: 100%; box-sizing: border-box;
    padding: 8px 10px; border: 1px solid var(--border, rgba(255,255,255,0.15));
    background: rgba(255,255,255,0.05); color: var(--text, #fff); border-radius: 8px; font-size: 1rem;
}
.auth-form input:focus { outline: none; border-color: var(--accent, #6366f1); }
.auth-error { color: #ff6b6b; font-size: 0.85rem; min-height: 1em; }

/* 排行榜浮层 */
.leaderboard-content { max-width: 600px; max-height: 80vh; overflow-y: auto; }
.lb-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.lb-row {
    display: flex; gap: 10px; align-items: center; padding: 8px 12px;
    background: rgba(255,255,255,0.04); border-radius: 8px; font-size: 0.95rem;
}
.lb-row.self { background: rgba(99,102,241,0.18); border: 1px solid rgba(99,102,241,0.5); }
.lb-rank { min-width: 40px; font-weight: 700; color: #ffd86b; }
.lb-nick { flex: 1; }
.lb-coins { color: #ffd86b; }
.lb-ranktag { color: #ffdfba; }
.lb-streak { color: #ff7e5f; font-size: 0.85rem; }
.lb-sep { text-align: center; color: var(--text-secondary, #888); margin: 8px 0; }

/* 升段弹窗 */
.rank-up-content { max-width: 320px; text-align: center; }
.rank-up-icon { font-size: 4rem; margin: 16px 0; }
.rank-up-name { font-size: 1.6rem; font-weight: 700; margin-bottom: 20px; }

/* 里程碑庆祝遮罩 */
.milestone-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85);
    z-index: 1000; align-items: center; justify-content: center;
}
.milestone-overlay.active { display: flex; }
.milestone-card {
    max-width: 420px; padding: 28px 32px; background: var(--card-bg, #1f2937);
    border-radius: 16px; text-align: center; box-shadow: 0 0 40px rgba(255,200,80,0.4);
    animation: milestone-pop 0.4s ease;
}
@keyframes milestone-pop {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.milestone-text { font-size: 1.2rem; font-weight: 700; margin-bottom: 16px; }
.milestone-clip { color: var(--text-secondary, #aaa); margin-bottom: 16px; font-size: 0.95rem; }
.milestone-skip { margin-top: 8px; }

/* 金币获得提示 */
.coin-gain {
    text-align: center; margin-top: 8px; min-height: 1.2em; font-weight: 700; font-size: 1.05rem;
}
.coin-gain.positive { color: #ffd86b; }
.coin-gain.neutral { color: var(--text-secondary, #888); }

/* 响应式：小屏资料条紧凑 */
@media (max-width: 600px) {
    .profile-bar { gap: 10px; font-size: 0.85rem; padding: 8px 10px; }
}

/* ========== 响应式设计 ========== */
@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    .app-header {
        padding: 14px 16px;
    }

    .brand-name {
        font-size: 1.2rem;
    }

    .brand-subtitle {
        font-size: 0.7rem;
    }

    .score-panel {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .score-card {
        padding: 16px 8px;
    }

    .score-value {
        font-size: 2rem;
    }

    .choice-display {
        gap: 20px;
    }

    .choice-icon {
        font-size: 3rem;
    }

    .choices {
        gap: 10px;
    }

    .choice-btn {
        padding: 18px 8px;
        min-height: 80px;
    }

    .choice-emoji {
        font-size: 2rem;
    }

    .choice-name {
        font-size: 0.85rem;
    }

    .result-text {
        font-size: 1.05rem;
    }

    .modal-content {
        padding: 24px 20px;
    }
}

@media (max-width: 380px) {
    .choice-display {
        gap: 12px;
    }

    .vs {
        font-size: 1.1rem;
        padding: 4px 10px;
    }

    .choice-icon {
        font-size: 2.5rem;
    }
}

/* ========== 对战历史行（当天） ========== */
.history-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    font-size: 0.9rem;
}
.history-row .history-time {
    color: var(--text-secondary, #aaa);
    font-size: 0.78rem;
    min-width: 70px;
}
.history-row .history-choices {
    flex: 1;
    font-size: 1.15rem;
    letter-spacing: 2px;
}
.history-row .history-result {
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 6px;
    min-width: 36px;
    text-align: center;
    font-size: 0.85rem;
}
.history-row.win  .history-result { background: rgba(16, 185, 129, 0.2); color: var(--success, #10b981); }
.history-row.lose .history-result { background: rgba(239, 68, 68, 0.2);  color: var(--danger, #ef4444); }
.history-row.draw .history-result { background: rgba(245, 158, 11, 0.2); color: var(--draw-color, #f59e0b); }
.history-row .history-coins {
    min-width: 80px;
    text-align: right;
    font-weight: 600;
    font-size: 0.85rem;
}
.history-row .history-coins.positive { color: var(--success, #10b981); }
.history-row .history-coins.negative { color: var(--danger, #ef4444); }
.history-row .history-coins.neutral  { color: var(--text-secondary, #aaa); }

/* ========== 页脚（备案信息） ========== */
.footer {
    margin-top: 30px;
    padding: 24px 16px;
    text-align: center;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid var(--card-border, rgba(255, 255, 255, 0.08));
    font-size: 0.8rem;
    color: var(--text-secondary, #aaa);
}
.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.footer-content > span,
.footer-content > a {
    display: block;
}
.footer-content a {
    color: var(--text-secondary, #aaa);
    text-decoration: none;
    transition: color 0.2s;
}
.footer-content a:hover {
    color: var(--text, #fff);
}
.beian-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.beian-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}