/* ============================================================
   设置菜单 / 模态框 / 战绩看板 样式
   调色板:
     - 主色 (深蓝): #1e3f6f (深) / #2b5797 (亮)
     - 胜 (jade): #2e8b6f
     - 平 (amber): #d4a04c
     - 负 (terracotta): #c2583f
   字体: Segoe UI 主体，Georgia 数字标题（古典棋类气质）
   ============================================================ */

/* ---------- 右上角设置入口 ---------- */
.topbar {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

.greeting {
    font-size: 0.9rem;
    color: #2c3e50;
    background: rgba(255, 255, 255, 0.85);
    padding: 6px 14px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.greeting strong {
    color: #1e3f6f;
    margin-left: 2px;
}

.settings-trigger {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, #2b5797, #1e3f6f);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(30, 63, 111, 0.35);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-trigger:hover {
    transform: rotate(45deg);
    box-shadow: 0 6px 18px rgba(30, 63, 111, 0.45);
}

.settings-trigger:focus {
    outline: none;
    box-shadow: 0 4px 12px rgba(30, 63, 111, 0.35), 0 0 0 3px rgba(43, 87, 151, 0.3);
}

/* ---------- 下拉菜单 ---------- */
.settings-menu {
    position: absolute;
    top: 56px;
    right: 0;
    min-width: 200px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    padding: 6px 0;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.settings-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.settings-menu .menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 0.95rem;
    color: #2c3e50;
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: background 0.12s ease;
    font-family: inherit;
}

.settings-menu .menu-item:hover {
    background: #f4f7fb;
}

.settings-menu .menu-item .icon {
    width: 22px;
    text-align: center;
    font-size: 1rem;
}

.settings-menu .divider {
    height: 1px;
    background: #eef0f4;
    margin: 4px 0;
}

.settings-menu .menu-item.danger {
    color: #c2583f;
}

.settings-menu .menu-item.danger:hover {
    background: #fdf2ee;
}

/* ---------- 模态框（修改昵称 / 修改密码） ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-backdrop.open {
    display: flex;
    animation: fadeIn 0.18s ease;
}

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

.modal {
    background: white;
    border-radius: 16px;
    padding: 28px 28px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
    animation: rise 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes rise {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h2 {
    margin: 0 0 18px;
    font-size: 1.15rem;
    color: #1e3f6f;
    font-weight: 700;
}

.modal .form-group { margin-bottom: 14px; }

.modal .form-group label {
    display: block;
    margin-bottom: 6px;
    color: #555;
    font-size: 0.85rem;
}

.modal .form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e6e9ef;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s ease;
}

.modal .form-group input:focus {
    outline: none;
    border-color: #2b5797;
}

.modal .hint {
    display: block;
    margin-top: 4px;
    font-size: 0.78rem;
    color: #999;
    min-height: 1em;
}

.modal .hint.error { color: #c2583f; }
.modal .hint.success { color: #2e8b6f; }

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.modal-actions .btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.12s ease, background 0.12s ease;
}

.modal-actions .btn-primary {
    background: linear-gradient(145deg, #2b5797, #1e3f6f);
    color: white;
}

.modal-actions .btn-primary:hover { transform: translateY(-1px); }
.modal-actions .btn-primary:disabled { background: #aab2c0; cursor: not-allowed; transform: none; }

.modal-actions .btn-ghost {
    background: #f0f2f5;
    color: #555;
}

.modal-actions .btn-ghost:hover { background: #e3e7ec; }

/* ---------- 战绩看板 ---------- */
.stats-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 30px 20px 60px;
}

.stats-shell {
    max-width: 640px;
    margin: 0 auto;
}

.stats-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.stats-topbar h1 {
    margin: 0;
    font-size: 1.5rem;
    color: #2c3e50;
}

.stats-card {
    background: white;
    border-radius: 18px;
    padding: 28px 24px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 18px;
}

/* 英雄指标：胜率环 */
.hero-card {
    text-align: center;
    padding: 36px 24px 32px;
    background: radial-gradient(circle at 50% 0%, #ffffff 0%, #f5f8fc 100%);
}

.hero-label {
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-bottom: 18px;
    font-weight: 600;
}

.ring {
    --pct: 0;
    --color: #2b5797;
    width: 220px;
    height: 220px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background:
        conic-gradient(var(--color) calc(var(--pct) * 1%), #e8ecf3 0);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: --pct 0.8s ease;
}

.ring::before {
    content: '';
    position: absolute;
    inset: 14px;
    border-radius: 50%;
    background: white;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.06);
}

.ring-value {
    position: relative;
    z-index: 1;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 4rem;
    font-weight: 700;
    color: #1e3f6f;
    line-height: 1;
    letter-spacing: -1px;
}

.ring-value .pct {
    font-size: 1.4rem;
    color: #7f8c8d;
    font-weight: 400;
    margin-left: 2px;
    font-family: 'Segoe UI', sans-serif;
}

.hero-caption {
    font-size: 0.95rem;
    color: #555;
    margin-top: 6px;
}

.hero-caption strong { color: #1e3f6f; }

/* 三个数字条 */
.score-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    margin-top: 24px;
}

.score-cell {
    text-align: center;
    padding: 14px 8px;
    border-radius: 12px;
    background: #f5f7fa;
}

.score-cell .num {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: #1e3f6f;
}

.score-cell .lbl {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-cell.win .num { color: #2e8b6f; }
.score-cell.draw .num { color: #d4a04c; }
.score-cell.loss .num { color: #c2583f; }

/* 分段条（总场次构成） */
.breakdown-card h2 {
    font-size: 1rem;
    color: #2c3e50;
    margin: 0 0 16px;
    font-weight: 600;
}

.breakdown-bar {
    display: flex;
    height: 14px;
    border-radius: 7px;
    overflow: hidden;
    background: #eef1f5;
}

.breakdown-bar .seg {
    transition: flex 0.6s ease;
}

.breakdown-bar .seg-win { background: #2e8b6f; }
.breakdown-bar .seg-draw { background: #d4a04c; }
.breakdown-bar .seg-loss { background: #c2583f; }

.breakdown-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 14px;
    font-size: 0.85rem;
    color: #555;
}

.breakdown-legend .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.breakdown-legend .dot-win { background: #2e8b6f; }
.breakdown-legend .dot-draw { background: #d4a04c; }
.breakdown-legend .dot-loss { background: #c2583f; }

.breakdown-legend strong { color: #1e3f6f; margin-left: 2px; }

.empty-stats {
    text-align: center;
    padding: 40px 20px;
    color: #7f8c8d;
}

.empty-stats .glyph {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.back-link {
    display: inline-block;
    margin-top: 8px;
    color: #2b5797;
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover { text-decoration: underline; }

/* ---------- 响应式 ---------- */
@media (max-width: 480px) {
    .topbar { top: 10px; right: 10px; gap: 8px; }
    .greeting { display: none; }
    .ring { width: 180px; height: 180px; }
    .ring-value { font-size: 3rem; }
    .score-cell .num { font-size: 1.3rem; }
}