/* ── 全局电路板背景 Canvas ── */
#bgCanvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    display: block;
}

/* ═══════════════════════════════════════════════════════
   INTRO 入场动画（仅桌面端，直接操作真实元素）
   ═══════════════════════════════════════════════════════ */
#intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
    pointer-events: all;
    visibility: visible;
    transition: opacity 0.8s ease;
}
#intro-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* 真实 logo：从中心缩放弹入 */
.logo-img {
    transition: filter 0.8s ease;
}
.logo-img.intro-zoom {
    animation: logoIntroZoom 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.logo-img.zoom-done {
    animation: none;
    transform: scale(1);
    opacity: 1;
    filter: drop-shadow(0 0 5px rgba(216,30,68,0.3));
}
.logo-img.glow-in {
    filter: drop-shadow(0 0 8px rgba(216,30,68,0.8)) drop-shadow(0 0 20px rgba(216,30,68,0.4));
}

/* SVG 描边文字：JS 动态创建，放入 h1 内部，共用原点 */
.server-title h1 {
    position: relative;
    transition: text-shadow 0.8s ease;
}
.server-title h1.intro-stroke {
    color: transparent;
    text-shadow: none;
}
.server-title h1.intro-stroke .stroke-svg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.server-title h1.intro-stroke .stroke-svg .stroke-path {
    stroke: var(--gold, #D4AF37);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Sections 分段弹入 */
.main-content .section {
    opacity: 0;
    transform: translateY(30px);
}
.main-content .section.reveal {
    animation: uiReveal 0.5s ease forwards;
}

/* 侧边栏分段弹入 */
.sidebar .sidebar-btn {
    opacity: 0;
    transform: translateX(20px);
}
.sidebar .sidebar-btn.reveal {
    animation: uiReveal 0.4s ease forwards;
}

@keyframes logoIntroZoom {
    0%   { transform: scale(2.5); opacity: 0; filter: drop-shadow(0 0 30px rgba(216,30,68,1)); }
    40%  { opacity: 1; }
    100% { transform: scale(1); opacity: 1; filter: drop-shadow(0 0 5px rgba(216,30,68,0.3)); }
}
@keyframes uiReveal {
    to { opacity: 1; transform: translateY(0) translateX(0); }
}

/* 手机端跳过 */
@media (max-width: 768px) {
    #intro-overlay { display: none !important; }
    .main-content .section,
    .sidebar .sidebar-btn { opacity: 1; transform: none; }
    .back-btn { display: none; }
}
body {
    overflow-x: hidden;
}

/* ── 单页 Section 显示/隐藏 (仅新增) ── */
.content-section { display: none; }
.content-section.active { display: block; flex: 1; position: relative; z-index: 1; }
#section-main.active { display: flex; }

/* ── 防止CSS未加载完成时的闪烁 ── */
body.loading { visibility: hidden; }
body.loaded { visibility: visible; }

:root {
    --red: #D81E44;
    --dark-red: #A51834;
    --black: #121212;
    --dark-gray: #1E1E1E;
    --gold: #D4AF37;
    --light-gold: #F0E68C;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
}
html {
    scroll-behavior: smooth;
}
body {
    background: linear-gradient(rgba(18,18,18,0.9), rgba(18,18,18,0.9)),
                linear-gradient(135deg, #1a1a1a 0%, #000 100%);
    color: #fff;
    display: flex;
    min-height: 100vh;
}
.main-content {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: calc(100% - 180px);
    margin-right: 30px;
    position: relative;
}
.main-content::after {
    content: '';
    position: absolute;
    right: -30px;
    top: 10%;
    bottom: 10%;
    width: 2px;
    background: var(--red);
}
.logo-container {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
}
.logo-img {
    width: 100px;
    height: 100px;
    border-radius: 20px;
    object-fit: cover;
    filter: drop-shadow(0 0 5px var(--red));
}
.server-title h1 {
    font-size: 2.5rem;
    color: var(--light-gold);
    text-shadow: 0 0 5px var(--light-gold), 0 0 15px var(--gold), 0 0 30px rgba(212,175,55,0.6);
}
.server-title p {
    font-size: 1.2rem;
    color: #ccc;
    margin-top: 5px;
}
.section {
    background: rgba(30, 30, 30, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid rgba(216, 30, 68, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.section h2 {
    color: var(--gold);
    margin-bottom: 15px;
    font-size: 1.5rem;
    border-bottom: 2px solid var(--red);
    padding-bottom: 10px;
}
.section p, .section a {
    font-size: 1.1rem;
    line-height: 1.6;
}
.section a {
    color: var(--light-gold);
    text-decoration: none;
}
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.action-btn {
    display: inline-block;
    background: linear-gradient(135deg, var(--red), var(--dark-red));
    color: var(--light-gold) !important;
    text-decoration: none;
    padding: 12px 25px;
    border-radius: 15px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.action-btn:visited {
    color: var(--light-gold) !important;
}
.action-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(216, 30, 68, 0.7);
    color: var(--light-gold) !important;
}
.action-btn:active {
    transform: scale(0.95);
}
.sidebar {
    width: 180px;
    background: linear-gradient(180deg, var(--dark-gray), var(--black));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-left: 1px solid rgba(216, 30, 68, 0.3);
    position: fixed;
    top: 50%;
    transform: translateX(0) translateY(-50%);
    right: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}
.sidebar.hidden {
    transform: translateX(100%) translateY(-50%);
}
/* 右侧悬浮触发区 */
.sidebar-trigger {
    position: fixed;
    right: 0;
    top: 0;
    width: 12px;
    height: 100vh;
    z-index: 99;
    display: none;
}
.sidebar-btn {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--dark-gray), var(--black));
    border: 2px solid var(--red);
    border-radius: 20px;
    margin: 15px 0;
    color: var(--gold);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}
.sb-break { display: inline; }
.sidebar-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(216, 30, 68, 0.5);
}
.sidebar-btn:active {
    transform: scale(0.95);
}

/* 手机端优化：底部悬浮横排按钮 */
@media (max-width: 768px) {
    /* 关闭背景特效层（省电 + 流畅） */
    #bgCanvas {
        display: none !important;
    }
    /* 关闭毛玻璃效果（GPU 开销大） */
    .section {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(30, 30, 30, 0.85);
    }
    /* 全局关掉过渡动画 */
    * {
        transition: none !important;
        animation: none !important;
    }
    body {
        flex-direction: column;
        padding-bottom: 120px;
    }
    .main-content {
        max-width: 100%;
        padding: 20px;
        margin-right: 0;
    }
    .main-content::after {
        display: none;
    }
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        border-left: none;
        border-top: 1px solid rgba(216, 30, 68, 0.3);
        background: linear-gradient(180deg, var(--dark-gray), var(--black));
        z-index: 999;
        padding: 10px 0;
        transform: none;
        top: auto;
    }
    .sidebar-btn {
        width: 80px;
        height: 80px;
        margin: 0 5px;
        font-size: 0.9rem;
        flex-direction: column;
        line-height: 1.3;
    }
    .sb-break { display: block; }
    .logo-container {
        flex-direction: column;
        text-align: center;
    }
    .server-title h1 {
        font-size: 2rem;
    }
    .section h2 {
        font-size: 1.3rem;
    }
    /* 移动端侧边栏始终可见 */
    .sidebar.hidden { transform: none; }
    .sidebar-trigger { display: none !important; }
}

/* ── 公告列表 ── */
.announcement-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.announcement-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    background: rgba(40, 40, 40, 0.9);
    border: 1px solid rgba(216, 30, 68, 0.15);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.92rem;
    line-height: 1.5;
    color: #ccc;
    transition: border-color 0.2s;
}
.announcement-item:hover {
    border-color: rgba(216, 30, 68, 0.2);
}
.announcement-item:nth-child(n+4) {
    display: none;
}
.ann-date {
    color: #888;
    font-size: 0.8rem;
    font-family: Consolas, 'Courier New', monospace;
    white-space: nowrap;
    min-width: 42px;
}
.ann-badge {
    background: var(--red);
    color: #fff;
    font-size: 0.72rem;
    padding: 1px 7px;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
}
.announcement-toggle {
    color: var(--light-gold);
    cursor: pointer;
    margin-top: 4px;
    display: inline-block;
    font-size: 0.9rem;
}
.announcement-toggle:hover {
    color: #fff;
}
.announcement-close {
    color: #888;
    cursor: pointer;
    text-align: right;
    margin-top: 4px;
    display: none;
    font-size: 0.9rem;
}
.announcement-close:hover {
    color: #fff;
}

/* ── 下载与卡包 ── */
.download-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.download-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(30, 30, 30, 0.7);
    border: 1px solid rgba(216, 30, 68, 0.25);
    border-radius: 14px;
    padding: 18px 14px;
    text-decoration: none;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.download-card:hover {
    transform: translateY(-3px);
    border-color: var(--red);
    box-shadow: 0 6px 20px rgba(216, 30, 68, 0.25);
}
.download-icon {
    font-size: 2rem;
}
.download-title {
    color: #eee;
    font-size: 1.05rem;
    font-weight: 600;
}
.download-hint {
    color: #777;
    font-size: 0.8rem;
}
.download-install {
    background: rgba(212, 175, 55, 0.06);
    border: 1px solid rgba(212, 175, 55, 0.15);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.95rem;
    line-height: 1.8;
    color: #bbb;
}
.download-install code {
    background: #2a2a2a;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--light-gold);
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .download-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .download-card {
        padding: 12px 8px;
    }
    .download-icon {
        font-size: 1.5rem;
    }
    .download-title {
        font-size: 0.85rem;
    }
    .download-hint {
        font-size: 0.7rem;
    }
    .download-install {
        font-size: 0.82rem;
    }
}

/* ── 服务器介绍 ── */
.server-desc {
    font-size: 1.15rem;
    line-height: 1.8;
    margin-bottom: 15px;
    color: #ddd;
}
.server-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.feature-item {
    background: rgba(216, 30, 68, 0.1);
    border: 1px solid rgba(216, 30, 68, 0.2);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 1rem;
    color: #ccc;
}
.server-address {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1a1a1a;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 1.2rem;
    flex-wrap: wrap;
}
.addr-label {
    color: #888;
    font-size: 0.85rem;
    margin-right: 4px;
}
.server-address code {
    color: var(--light-gold);
    font-family: Consolas, 'Courier New', monospace;
    font-size: 1.2rem;
    background: #111;
    padding: 4px 10px;
    border-radius: 5px;
}
.addr-sep {
    color: #555;
    font-weight: bold;
}

@media (max-width: 768px) {
    .server-features {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    .feature-item {
        font-size: 0.85rem;
        padding: 8px 10px;
    }
    .server-address {
        font-size: 1rem;
        padding: 10px 14px;
    }
    .server-address code {
        font-size: 1rem;
    }
}

/* ── 玩法规则 Tab 切换 ── */
.rules-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.rules-tab {
    flex: 1;
    min-width: 120px;
    padding: 10px 14px;
    background: #222;
    border: 1px solid #333;
    border-radius: 10px;
    color: #aaa;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.rules-tab.active {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
    font-weight: 600;
}
.rules-tab:hover:not(.active) {
    border-color: #555;
    color: #fff;
}
.rules-panel {
    display: none;
}
.rules-panel.active {
    display: block;
}
.rules-panel p {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 8px;
}
.rules-panel p:last-child {
    margin-bottom: 0;
}
.code-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
}
.code-table td {
    padding: 6px 10px;
    font-size: 0.95rem;
    border-bottom: 1px solid #2a2a2a;
}
.code-table td:first-child {
    white-space: nowrap;
    width: 140px;
}
.code-table code {
    background: #2a2a2a;
    padding: 2px 7px;
    border-radius: 4px;
    color: var(--light-gold);
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.9rem;
}
.code-table .param {
    color: #888;
    font-style: italic;
}
.section .code-table td p {
    margin: 0;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .rules-tab {
        font-size: 0.82rem;
        padding: 8px 10px;
    }
    .code-table td:first-child {
        width: auto;
    }
}

/* ── 统一返回按钮动画：从小到大 + 白光闪现 ── */
@keyframes backBtnAppear {
    0%   { transform: scale(0); filter: brightness(3); opacity: 0; }
    60%  { transform: scale(1.15); filter: brightness(1.5); opacity: 1; }
    100% { transform: scale(1); filter: brightness(1); opacity: 1; }
}
.back-btn.animate-in {
    animation: backBtnAppear 0.5s ease-out both;
}

/* ── 卡图悬停 tooltip（禁限分值 / 玩家排名共用）── */
.card-tooltip {
    position: fixed;
    z-index: 99999;
    max-width: 280px;
    padding: 10px 12px;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid var(--red, #D81E44);
    border-radius: 6px;
    color: #ddd;
    font-size: 0.78rem;
    line-height: 1.5;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.7);
}

.tooltip-name {
    color: var(--gold, #D4AF37);
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.tooltip-type {
    color: #aaa;
    font-size: 0.7rem;
}

.tooltip-raceattr {
    color: #999;
    font-size: 0.7rem;
}

.tooltip-atkdef {
    color: #ccc;
    font-size: 0.75rem;
    font-weight: 600;
}

.tooltip-desc {
    color: #bbb;
    font-size: 0.72rem;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.1);
    white-space: pre-wrap;
}

/* ═══════════════════════════════════════════════════════
   GLOBAL LOGIN — 全局登录框（右下角固定）
   ═══════════════════════════════════════════════════════ */
.global-login {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 180px;
    z-index: 500;
    display: block;
}
.gl-login-trigger {
    width: 100%;
    background: var(--dark-gray, #1E1E1E);
    color: var(--light-gold, #F0E68C);
    border: 2px solid var(--red, #D81E44);
    border-radius: 0;
    padding: 8px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    letter-spacing: 1px;
    opacity: 0;
    transform: translateX(20px);
}
.gl-login-trigger.reveal {
    animation: uiReveal 0.4s ease forwards;
}
.gl-login-trigger:hover {
    background: rgba(216, 30, 68, 0.15);
    color: #fff;
}

.gl-loggedin {
    display: flex;
    align-items: center;
    gap: 8px;
}
.gl-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(216, 30, 68, 0.3);
    border-radius: 8px;
    transition: background 0.2s;
    flex: 1;
}
.gl-profile:hover {
    background: rgba(255, 255, 255, 0.05);
}
.gl-avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid rgba(216, 30, 68, 0.3);
    object-fit: cover;
}
.gl-name {
    color: #F0E68C;
    font-size: 0.85rem;
    font-weight: 600;
}

/* 登录弹窗 */
.gl-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
}
.gl-modal-overlay.active {
    display: flex;
}
.gl-modal {
    background: #1a1a1a;
    border: 1px solid rgba(216, 30, 68, 0.3);
    border-radius: 12px;
    width: min(360px, 92vw);
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    animation: glModalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes glModalIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.gl-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.gl-modal-title {
    color: #F0E68C;
    font-size: 1rem;
    font-weight: 700;
}
.gl-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.gl-modal-close:hover {
    color: #fff;
}
.gl-modal-body {
    padding: 18px;
}
.gl-input {
    width: 100%;
    box-sizing: border-box;
    background: #0d0d0d;
    border: 1px solid #333;
    color: #ddd;
    padding: 8px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
    margin-bottom: 10px;
    outline: none;
    transition: border-color 0.2s;
}
.gl-input:focus {
    border-color: rgba(216, 30, 68, 0.6);
}
.gl-btn {
    width: 100%;
    background: rgba(216, 30, 68, 0.8);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.gl-btn:hover {
    background: rgba(216, 30, 68, 1);
}
.gl-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.gl-error {
    color: #ff6b6b;
    font-size: 0.72rem;
    text-align: center;
    margin-top: 8px;
}
.gl-hint {
    color: #555;
    font-size: 0.65rem;
    text-align: center;
    margin-top: 10px;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .global-login {
        bottom: 90px;
        right: 8px;
        display: none; /* 默认隐藏，仅在论坛页面显示 */
    }
    .gl-login-trigger {
        padding: 6px 16px;
        font-size: 0.75rem;
    }
    .gl-avatar {
        width: 26px;
        height: 26px;
    }
    .gl-name {
        font-size: 0.78rem;
    }
}
