/* ============================================================
   common.css - 尤里卡数学实验室 公共样式
   包含：顶部导航栏、页脚、右侧滑菜单、星空背景、返回按钮、
        页面标题组件、圆角方框卡片、移动端适配、自定义分享菜单
   ============================================================ */

:root {
    --font-sans: 'DengXian', 'Microsoft YaHei', 'PingFang SC', sans-serif;
    --color-blue: #2e86c1;
    --bg-page: #f2f5f9;
    --white: #ffffff;
    --text-main: #0f172a;
    --text-sub: #475569;
    --text-muted: #94a3b8;
    --gray-border: #d5dbe3;
    --btn-blue: #66a9d9;

    /* ★ 统一顶栏 / 侧滑菜单玻璃背景 */
    --top-bar-bg: rgba(45, 127, 193, 0.55);
    --top-bar-blur: 12px;

    /* 卡片变量 */
    --card-size: 250px;
    --card-radius: 20px;
    --card-bg: rgba(255, 255, 255, 0.1);
    --card-bg-hover: rgba(255, 255, 255, 0.2);
    --card-border: rgba(255, 255, 255, 0.3);
    --card-border-hover: #facc15;
    --card-glow: 0 0 20px rgba(250, 204, 21, 0.6);
    --card-text: #ffffff;
    --card-icon-size: 50px;
    --card-icon-container: 70px;
    --card-icon-margin: 15px;
    --card-font-size: 18px;
    --card-gap: 30px;
    --card-grid-max-width: 900px;
    --mobile-hint-side-gap: 10px;
    --gold-highlight: #FFCE25;
}

/* ========== 圆标样式（公用卡片类） ========== */
.home-option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 240px;
    height: 240px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #f1f5f9;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s, background 0.3s;
}

.home-option-btn:hover,
.home-option-btn:active {
    border-color: #facc15;
    box-shadow: 0 0 20px rgba(250, 204, 21, 0.8);
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.15);
}

/* ========== 顶部导航栏 ========== */
.eureka-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 72px;
    padding: 8px 28px;
    background: transparent !important;
    border-bottom: none !important;
    box-shadow: none !important;
    position: sticky;
    top: 0;
    z-index: 100;
    box-sizing: border-box;
    flex-shrink: 0;
}
.eureka-top-bar .header-left {
    display: flex;
    align-items: center;
}
.eureka-top-bar .header-logo {
    display: flex;
    align-items: center;
    cursor: pointer;
    text-decoration: none;
    gap: 5px;
}

.eureka-top-bar .logo_triangle {
    height: 43.2px;
    width: auto;
    display: block;
    mix-blend-mode: multiply;
}

.eureka-top-bar .logo_eureka-text {
    display: flex;
    align-items: baseline;
    gap: 0;
    font-size: 22px;
    line-height: 1;
    color: #ffffff;
    white-space: nowrap;
}

.eureka-top-bar .logo_eureka-text .logo-sigma {
    font-family: 'Kozuka Mincho Pr6N H', 'Kozuka Mincho Pro', 'Yu Mincho', serif;
    font-weight: 500;
}

.eureka-top-bar .logo_eureka-text .logo-ureka {
    font-family: 'BankGothic Md BT', 'BankGothic', 'Arial Narrow', sans-serif;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.eureka-top-bar .header-logo:hover .logo_triangle,
.eureka-top-bar .header-logo:hover .logo_eureka-text {
    opacity: 0.85;
}

.eureka-top-bar .nav-center {
    display: flex;
    align-items: center;
    gap: 27px;
    flex: 1 1 auto;
    justify-content: center;
    align-self: flex-end;
    padding-bottom: 8px;
}

/* 导航栏文字：默认白色，当前页 #FFCE25 高亮 */
.eureka-top-bar .nav-center a {
    text-decoration: none;
    color: #ffffff;
    font-size: 16px;
    font-family: 'DengXian', 'Microsoft YaHei', 'PingFang SC', sans-serif;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1;
    padding: 6px 12px;
    border-radius: 20px;
    transition: color 0.2s, background 0.2s;
}

.eureka-top-bar .nav-center a:hover,
.eureka-top-bar .nav-center a.nav-dimmed:hover {
    background: rgba(200, 200, 200, 0.3);
    color: #ffffff;
    text-shadow: none;
    opacity: 1;
    transform: none;
}

.eureka-top-bar .nav-center a.active,
.eureka-top-bar .nav-center a.nav-current,
.eureka-top-bar .nav-center a.nav-active {
    color: var(--gold-highlight) !important;
    font-weight: 700 !important;
    text-shadow: none !important;
    background: transparent;
}

.eureka-top-bar .nav-center a.active:hover,
.eureka-top-bar .nav-center a.nav-current:hover,
.eureka-top-bar .nav-center a.nav-active:hover {
    color: var(--gold-highlight) !important;
    background: rgba(200, 200, 200, 0.3);
}

.eureka-top-bar .header-right {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}
.eureka-top-bar .search-box-top {
    display: flex;
    align-items: center;
    gap: 8px;
}
.eureka-top-bar .search-input-top {
    width: 0;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 15px;
    font-family: 'KaiTi', '楷体', STKaiti, serif;
    font-size: 0.95rem;
    background: transparent;
    color: #ffffff;
    outline: none;
    line-height: 34px;
    transition: width 0.3s ease, padding 0.3s ease, border-color 0.3s ease, background 0.3s ease, opacity 0.3s, color 0.3s;
    box-sizing: border-box;
    opacity: 0;
}
.eureka-top-bar .search-input-top.expanded {
    width: 180px;
    padding: 0 12px;
    border-color: rgba(255, 255, 255, 0.6);
    background: #ffffff;
    color: #0f172a;
    opacity: 1;
}
.eureka-top-bar .search-input-top:focus {
    border-color: #ffffff;
    color: #0f172a;
}
.eureka-top-bar .search-icon-top {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    color: #ffffff;
    box-sizing: border-box;
    transition: color 0.2s, opacity 0.2s;
}
.eureka-top-bar .search-icon-top svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
}
.eureka-top-bar .search-icon-top.active {
    color: #ffffff;
    opacity: 0.8;
}

.eureka-top-bar .share-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #ffffff;
    transition: opacity 0.2s;
}
.eureka-top-bar .share-icon:hover {
    opacity: 0.8;
}
.eureka-top-bar .share-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.eureka-top-bar .contact-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #ffffff;
    transition: opacity 0.2s, color 0.2s;
    text-decoration: none;
}
.eureka-top-bar .contact-icon:hover {
    color: #facc15;
}
.eureka-top-bar .contact-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.eureka-top-bar .menu-toggle {
    width: 40px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #ffffff;
    transition: opacity 0.2s;
}
.eureka-top-bar .menu-toggle:hover {
    opacity: 0.8;
}
.eureka-top-bar .menu-toggle svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
}

.eureka-top-bar .profile-icon-only {
    width: 40px;
    height: 40px;
    border-radius: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s, opacity 0.2s;
    color: #ffffff;
    text-decoration: none;
}
.eureka-top-bar .profile-icon-only:focus,
.eureka-top-bar .profile-icon-only:active {
    background: transparent;
    color: #ffffff;
    opacity: 0.8;
    outline: none;
}
.eureka-top-bar .profile-icon-only svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

/* ========== 底部 Footer ========== */
.eureka-brand-footer {
    width: 100%;
    padding: 10px 0 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    z-index: 1;
    background: transparent;
}
.footer-eureka-img {
    height: 20px;
    width: auto;
    display: block;
}
.footer-icp {
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
}

/* ========== 公共返回键组件 ========== */
.back-btn-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #475569;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.25s, color 0.25s, border-color 0.25s;
    text-decoration: none;
    flex-shrink: 0;
    opacity: 0.7;
}
.back-btn-inner:hover {
    background: #e2e8f0;
    color: #334155;
    border-color: #cbd5e1;
    opacity: 1;
}
.back-btn-inner:active {
    background: var(--color-blue, #2e86c1);
    color: #ffffff;
}
.back-btn-inner svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
    display: block;
}

/* ========== 带返回键的标题栏 ========== */
.page-title-row {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 30px auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    z-index: 10;
}
.page-title-row .page-title {
    margin: 0;
    color: #ffffff;
    font-size: 1.6rem;
    letter-spacing: 0.02em;
    text-align: center;
    flex: 1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.page-title-row .back-btn-inner {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
}

/* ========== 页面标题组件 ========== */
.page-header {
    text-align: center;
    margin: 30px auto 20px;
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 1000px;
    box-sizing: border-box;
    z-index: 10;
}
.page-header .page-title {
    font-size: 2rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.04em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    margin: 0;
    line-height: 1.2;
}
.page-header .page-subtitle {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.72);
    letter-spacing: 0.05em;
    margin: 10px 0 0 0;
    line-height: 1.4;
}

/* ========== 通用圆角方框卡片 ========== */
.panel-card {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 1.2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    backdrop-filter: blur(4px);
}
.panel-card.size-200 { max-width: 200px; }
.panel-card.size-300 { max-width: 300px; }
.panel-card.size-400 { max-width: 400px; }
.panel-card.size-500 { max-width: 500px; }
.panel-card.size-600 { max-width: 600px; }
.panel-card.size-700 { max-width: 700px; }
.panel-card.size-800 { max-width: 800px; }
.panel-card.size-900 { max-width: 900px; }
.panel-card.size-1000 { max-width: 1000px; }

/* ========== 右侧滑菜单及遮罩层 ========== */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.menu-overlay.open {
    display: block;
    opacity: 1;
}

.side-menu {
    position: fixed;
    top: 0;
    right: -200px;
    width: 200px;
    height: 100%;
    background: #195889;
    color: #ffffff;
    z-index: 1000;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.25);
    transition: right 0.3s ease;
    padding: 20px 20px 30px;
    box-sizing: border-box;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.side-menu.open {
    right: 0;
}

.side-menu .menu-close {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}
.side-menu .menu-close button {
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #ffffff;
    padding: 0;
    line-height: 1;
}

.side-menu ul.main-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

.side-menu ul.bottom-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.side-menu ul li a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px 10px;
    border-radius: 12px;
    text-decoration: none;
    color: #ffffff;
    transition: background 0.2s, color 0.2s, text-shadow 0.2s, transform 0.15s;
    line-height: 1.3;
    gap: 18px;
    background: transparent;
}

.side-menu ul.main-menu li a .menu-zh {
    font-size: 1.1rem;
}

.side-menu ul li a .menu-en {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #ffffff;
}

.side-menu ul li a .menu-zh {
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
}

.side-menu ul li a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    text-shadow: 0 0 10px rgba(250, 204, 21, 0.6);
    transform: translateX(2px);
}

.side-menu ul li a.active {
    background: transparent;
    color: var(--gold-highlight);
    text-shadow: none;
}
.side-menu ul li a.active .menu-en,
.side-menu ul li a.active .menu-zh {
    color: var(--gold-highlight);
}

.side-menu ul.bottom-menu li a .menu-en {
    display: none;
}

.side-menu .menu-separator-item {
    list-style: none;
    padding: 0;
    margin: 6px 0;
}
.side-menu .menu-separator {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.6);
    margin: 0 15px;
}

/* ========== 自定义分享菜单 ========== */
.custom-share-menu {
    position: fixed;
    z-index: 9999;
    background: #1e293b;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    padding: 8px;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: shareMenuFadeIn 0.2s ease;
    transform-origin: top center;
}
@keyframes shareMenuFadeIn {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.custom-share-menu .share-menu-title {
    font-size: 0.75rem;
    color: #94a3b8;
    padding: 6px 12px;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.custom-share-menu .share-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: #f1f5f9;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.2s;
    text-align: left;
    font-family: var(--font-sans, 'DengXian', 'Microsoft YaHei', sans-serif);
}
.custom-share-menu .share-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}
.custom-share-menu .share-menu-item span:first-child {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

/* ========== 星空背景 ========== */
.night-sky-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    display: block;
}
.night-sky-glow {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 50% 40%, rgba(90, 170, 255, 0.28) 0%, rgba(30, 70, 160, 0.12) 45%, transparent 75%);
    animation: nightSkyGlow 8s ease-in-out infinite alternate;
    z-index: 0;
    pointer-events: none;
}

@keyframes nightSkyGlow {
    0% { opacity: 0.3; }
    100% { opacity: 0.85; }
}
body.night-sky-active {
    background: linear-gradient(165deg, #16356b 0%, #0c1d44 30%, #05102b 65%, #01040f 100%);
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
}

/* ========== 公共圆角方框卡片组件 ========== */
.card-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--card-gap);
    max-width: var(--card-grid-max-width);
    margin: 0 auto;
}

.math-card {
    flex-shrink: 0;
    width: var(--card-size);
    height: var(--card-size);
    border-radius: var(--card-radius);
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s, background 0.3s, border-color 0.3s;
    cursor: pointer;
    border: 1px solid var(--card-border);
    color: var(--card-text);
    text-decoration: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.math-card:hover {
    transform: translateY(-5px);
    background: var(--card-bg-hover);
    border-color: var(--card-border-hover);
    box-shadow: var(--card-glow);
}

.math-card .card-icon {
    width: var(--card-icon-container);
    height: var(--card-icon-container);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--card-icon-margin);
}

.math-card .card-icon svg {
    width: var(--card-icon-size);
    height: var(--card-icon-size);
    stroke: currentColor;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.math-card .card-label,
.math-card .card-name {
    font-size: var(--card-font-size);
    font-weight: 700;
    color: var(--card-text);
}

/* ========== 移动端适配 ========== */
@media (max-width: 768px) {
    .eureka-top-bar {
        height: 60px;
        padding: 4px 12px;
    }
    .eureka-top-bar .logo_triangle {
        height: 38.88px;
    }
    .eureka-top-bar .logo_eureka-text {
        display: none;
    }
    .eureka-top-bar .nav-center {
        display: none;
    }
    .eureka-top-bar .search-input-top.expanded {
        width: 140px;
    }
    .eureka-top-bar .search-icon-top {
        width: 41px;
        height: 41px;
        background: transparent;
    }
    .eureka-top-bar .search-icon-top svg {
        width: 22px;
        height: 22px;
    }
    .eureka-top-bar .profile-icon-only {
        display: none;
    }
    .eureka-top-bar .contact-icon {
        display: none;
    }
    .eureka-top-bar .header-right {
        gap: 2px;
    }
    .eureka-top-bar .menu-toggle {
        display: flex;
        width: 48px;
        height: 48px;
    }
    .eureka-top-bar .menu-toggle svg {
        width: 26px;
        height: 26px;
    }

    .side-menu {
        width: 220px;
        right: -220px;
    }
    .side-menu ul li a {
        padding: 10px 8px;
    }

    .page-header {
        margin: 15px auto 15px;
        height: 80px;
    }
    .page-header .page-title {
        font-size: 1.6rem;
    }
    .page-header .page-subtitle {
        font-size: 0.9rem;
        margin-top: 8px;
    }

    .page-title-row {
        margin-top: 10px;
    }
    .page-title-row .page-title {
        font-size: 1.3rem;
    }

    .custom-share-menu {
        min-width: 200px;
    }
}

@media (max-width: 480px) {
    .back-btn-inner {
        width: 30px;
        height: 30px;
    }
    .back-btn-inner svg {
        width: 14px;
        height: 14px;
    }
    .side-menu {
        width: 160px;
        right: -160px;
    }
    .custom-share-menu {
        min-width: 160px;
        font-size: 0.9rem;
    }
}

/* 确保公共组件容器在 flex 父容器中始终拉伸填满宽度 */
#global-header {
    align-self: stretch;
    flex-shrink: 0;
    width: 100%;
}
#global-footer {
    align-self: stretch;
    margin-top: auto;
    flex-shrink: 0;
    width: 100%;
    background: transparent;
}

/* ============================================================
   隐藏导航栏搜索图标（时间轴页面自带标题栏搜索）
   ============================================================ */
.eureka-top-bar .search-box-top {
    display: none !important;
}

/* ============================================================
   探索页：手机端一行三个卡片
   ============================================================ */
@media (max-width: 768px) {
    .group-cards {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    .math-card {
        width: 100% !important;
        aspect-ratio: 1 / 1;
        border-radius: 16px;
        padding: 6px;
        box-sizing: border-box;
    }

    .math-card .card-icon {
        transform: none !important;
    }
    .math-card .card-icon svg {
        width: 48px;
        height: 48px;
    }
    .math-card .card-name {
        font-size: 13px;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ============================================================
   页面标题统一为白色
   ============================================================ */
.page-header .page-title,
.page-title-row .page-title,
.title-cn,
h1.page-title,
h2.page-title {
    color: #ffffff !important;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35) !important;
}

/* ============================================================
   ★★★ 手机端统一覆盖块（追加在文件末尾）
   ------------------------------------------------------------
   作用：无论页面顶栏内部结构如何（.mobile-top-bar-back /
        .mobile-top-bar-center / .mobile-top-bar-title /
        .mobile-title-selectors / .mobile-top-search /
        .mobile-menu-slot），统一压成探索页/游戏页观感：
        - 顶栏：sticky 50px + 半透明蓝 + 毛玻璃
        - 左侧返回/logo 靠左
        - 中间标题绝对居中
        - 搜索、菜单按顺序贴右
        - 侧滑菜单与顶栏同色

   注意：各页 HTML 自带的"手机端顶栏 CSS"必须删除，
        否则内联样式会覆盖这里。
   ============================================================ */
@media (max-width: 768px) {

    /* ---------- ⓿ 隐藏所有旧顶栏容器 ---------- */
    #global-header,
    body.has-mobile-topbar #global-header {
        display: none !important;
        height: 0 !important;
        min-height: 0 !important;
        max-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        border: 0 !important;
    }
    .eureka-top-bar { display: none !important; }
    #handwrittenHeaderBar { display: none !important; }

    /* ---------- ① 顶栏容器 ---------- */
    body .mobile-top-bar {
        position: sticky !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        min-height: 50px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        padding: 0 8px !important;
        box-sizing: border-box !important;
        background: var(--top-bar-bg, rgba(45,127,193,0.55)) !important;
        -webkit-backdrop-filter: blur(var(--top-bar-blur, 12px)) !important;
        backdrop-filter: blur(var(--top-bar-blur, 12px)) !important;
        box-shadow: 0 1px 6px rgba(0,0,0,0.18) !important;
        border: none !important;
        z-index: 999 !important;
        overflow: visible !important;
    }

    /* ---------- ② 左侧：返回 / logo ---------- */
    body .mobile-top-bar > .mobile-top-bar-back,
    body .mobile-top-bar > .mtb-left,
    body .mobile-top-bar > a[aria-label*="返回"] {
        position: static !important;
        order: 1 !important;
        flex-shrink: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 34px !important;
        height: 34px !important;
        padding: 0 !important;
        margin: 0 4px 0 0 !important;
        border-radius: 50% !important;
        background: transparent !important;
        border: none !important;
        color: #fff !important;
        text-decoration: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    body .mobile-top-bar > .mobile-top-bar-back svg,
    body .mobile-top-bar > .mtb-left svg {
        width: 22px !important;
        height: 22px !important;
        fill: none !important;
        stroke: currentColor !important;
        stroke-width: 2.2 !important;
        stroke-linecap: round !important;
        stroke-linejoin: round !important;
        display: block !important;
    }
    body .mobile-top-bar > .mtb-logo { width: auto !important; padding: 0 4px !important; }
    body .mobile-top-bar > .mtb-logo .mtb-logo-img { height: 32px !important; width: auto !important; display: block !important; }

    /* ---------- ③ 中间：标题（绝对居中） ---------- */
    body .mobile-top-bar > .mobile-top-bar-center,
    body .mobile-top-bar > .mobile-top-bar-title,
    body .mobile-top-bar > .mobile-title-selectors,
    body .mobile-top-bar > .mtb-title {
        position: absolute !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        max-width: calc(100% - 150px) !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        font-size: 1.05rem !important;
        font-weight: 800 !important;
        letter-spacing: 0.04em !important;
        color: #fff !important;
        white-space: nowrap !important;
        overflow: visible !important;
        z-index: 2 !important;
        pointer-events: none !important;
        text-shadow: 0 1px 3px rgba(0,0,0,0.35) !important;
    }
    body .mobile-top-bar > .mobile-top-bar-center > *,
    body .mobile-top-bar > .mobile-title-selectors > *,
    body .mobile-top-bar > .mobile-top-bar-title .mobile-menu-slot,
    body .mobile-top-bar > .mtb-title > * {
        pointer-events: auto !important;
    }
    body .mobile-top-bar > .mobile-top-bar-center *,
    body .mobile-top-bar > .mobile-top-bar-title *,
    body .mobile-top-bar > .mobile-title-selectors *,
    body .mobile-top-bar > .mtb-title * {
        color: #fff !important;
        fill: #fff !important;
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        font-size: inherit !important;
        font-weight: inherit !important;
    }
    body .mobile-top-bar > .mobile-top-bar-center .divider,
    body .mobile-top-bar > .mobile-title-selectors .divider {
        color: rgba(255,255,255,0.4) !important;
        font-weight: 400 !important;
        margin: 0 2px !important;
    }

    /* ---------- ④ 右侧：搜索 ---------- */
    body .mobile-top-bar > .mobile-top-search,
    body .mobile-top-bar > .mtb-search {
        position: static !important;
        order: 2 !important;
        margin-left: auto !important;
        margin-right: 0 !important;
        flex-shrink: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 34px !important;
        height: 34px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        background: transparent !important;
        border: none !important;
        color: #fff !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    body .mobile-top-bar > .mobile-top-search svg,
    body .mobile-top-bar > .mtb-search svg {
        width: 22px !important;
        height: 22px !important;
        fill: none !important;
        stroke: currentColor !important;
        stroke-width: 2 !important;
        display: block !important;
    }

    /* ---------- ⑤ 右侧：菜单 ---------- */
    body .mobile-top-bar > .mobile-menu-slot,
    body .mobile-top-bar > .mtb-menu {
        position: static !important;
        order: 3 !important;
        flex-shrink: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 34px !important;
        height: 34px !important;
        padding: 0 !important;
        margin: 0 0 0 4px !important;
        border-radius: 50% !important;
        background: transparent !important;
        border: none !important;
        color: #fff !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    body .mobile-top-bar > .mobile-menu-slot svg,
    body .mobile-top-bar > .mtb-menu svg {
        width: 22px !important;
        height: 22px !important;
        fill: none !important;
        stroke: currentColor !important;
        stroke-width: 2 !important;
        display: block !important;
    }
    body .mobile-top-bar > .mobile-menu-slot img {
        width: 18px !important;
        height: 18px !important;
        filter: brightness(0) invert(1);
    }

    /* ---------- ⑥ 搜索输入框展开态 ---------- */
    body .mobile-top-bar > .mobile-top-search-inline {
        display: none !important;
    }
    body .mobile-top-bar.searching > .mobile-top-search-inline {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100% !important;
        height: 100% !important;
        padding: 0 6px !important;
        order: 4 !important;
        flex: 1 1 auto !important;
        box-sizing: border-box !important;
    }
    body .mobile-top-bar.searching > .mobile-top-bar-back,
    body .mobile-top-bar.searching > .mobile-top-bar-center,
    body .mobile-top-bar.searching > .mobile-top-bar-title,
    body .mobile-top-bar.searching > .mobile-title-selectors,
    body .mobile-top-bar.searching > .mtb-title,
    body .mobile-top-bar.searching > .mobile-top-search,
    body .mobile-top-bar.searching > .mtb-search,
    body .mobile-top-bar.searching > .mobile-menu-slot,
    body .mobile-top-bar.searching > .mtb-menu {
        display: none !important;
    }
    body .mobile-top-search-inline input {
        flex: 1;
        min-width: 0;
        background: #fff;
        border: 1px solid rgba(255,255,255,0.6);
        border-radius: 16px;
        padding: 6px 14px;
        font-size: 14px;
        color: #1a2a4a;
        outline: none;
        height: 32px;
        box-sizing: border-box;
    }
    body .mobile-top-search-inline .search-confirm-btn {
        height: 32px;
        padding: 6px 14px;
        border-radius: 16px;
        background: #2b7fdb;
        color: #fff;
        border: none;
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
        flex-shrink: 0;
    }
    body .mobile-top-search-inline .search-clear-btn {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: rgba(255,255,255,0.55);
        border: none;
        color: #333;
        font-size: 18px;
        font-weight: 700;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    /* ---------- ⑦ 主题切换按钮（挑战页专属） ---------- */
    body .mobile-top-bar > .theme-toggle-btn {
        position: static !important;
        order: 2.5 !important;
        margin-left: auto !important;
        margin-right: 0 !important;
        flex-shrink: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 34px !important;
        height: 34px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        background: transparent !important;
        border: none !important;
        color: #fff !important;
        cursor: pointer !important;
    }
    body .mobile-top-bar > .theme-toggle-btn svg {
        width: 22px !important;
        height: 22px !important;
        display: block !important;
    }
    body .mobile-top-bar > .theme-toggle-btn ~ .mobile-top-search,
    body .mobile-top-bar > .theme-toggle-btn ~ .mtb-search {
        margin-left: 0 !important;
    }

    /* ---------- ⑧ 侧滑菜单：与顶栏同色同透明度 ---------- */
    .side-menu {
        background: var(--top-bar-bg, rgba(45,127,193,0.55)) !important;
        -webkit-backdrop-filter: blur(var(--top-bar-blur, 12px)) !important;
        backdrop-filter: blur(var(--top-bar-blur, 12px)) !important;
        color: #ffffff !important;
    }

    /* ---------- ⑨ 遮罩不透明度降低 ---------- */
    .menu-overlay {
        background: rgba(0, 0, 0, 0.32) !important;
    }

    /* ---------- ⑩ Alice 层级 ---------- */
    .alice-component,
    .alice-wrapper,
    .alice-container,
    [class*="alice-root"],
    [class*="alice"][class*="wrap"] {
        z-index: 100 !important;
    }
    body.side-menu-open .alice-component {
        position: fixed !important;
        top: auto !important;
        left: auto !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 1002 !important;
    }
    body.side-menu-open .alice-wrapper,
    body.side-menu-open .alice-container {
        position: fixed !important;
        top: auto !important;
        left: auto !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 220px !important;
        max-width: 220px !important;
        z-index: 1002 !important;
        margin: 0 !important;
        padding: 0 0 12px !important;
        box-sizing: border-box !important;
        transition: transform 0.3s ease, opacity 0.3s ease !important;
    }
}

@media (max-width: 480px) {
    .eureka-top-bar { display: none !important; }
    #handwrittenHeaderBar { display: none !important; }
}

/* ============================================================
   ★★★ 游戏页通用顶栏（.mtb-main 结构）统一块
   ------------------------------------------------------------
   GameCommon.buildMobileTopBar() 生成的顶栏结构为：
       .mobile-top-bar > .mtb-main > [back, title, menu-slot]
   上方"手机端统一覆盖块"里的规则用的是 `body .mobile-top-bar > xxx`
   直接子选择器，匹配不到 .mtb-main 内部的元素。
   本块专治这种结构，让所有使用 buildMobileTopBar 的游戏页
   （四子棋、五子棋、找质数……）共享一致外观。

   ★ 本块必须放在"手机端统一覆盖块"之后，
     并使用 :has() 提升特异性，才能覆盖上面的 row + sticky 规则。
   ============================================================ */
@media (max-width: 768px) {

    /* ⓵ 容器：识别 .mtb-main 结构，切回 column + relative */
    body .mobile-top-bar:has(> .mtb-main) {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        min-height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 0 !important;
        gap: 0 !important;
        background: var(--top-bar-bg, rgba(255,255,255,0.06)) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        backdrop-filter: blur(10px) !important;
        box-shadow: none !important;
        border: none !important;
        z-index: 100 !important;
        overflow: visible !important;
    }

    /* ⓶ 主行 */
    body .mobile-top-bar > .mtb-main {
        position: relative;
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 8px 12px;
        width: 100%;
        box-sizing: border-box;
    }
    body .mobile-top-bar > .mtb-main > .mobile-top-bar-back {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        border-radius: 50%;
        color: #fff;
        text-decoration: none;
        z-index: 2;
    }
    body .mobile-top-bar > .mtb-main > .mobile-top-bar-back svg {
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2.5;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
    body .mobile-top-bar > .mtb-main > .mobile-top-bar-title {
        flex: 1 1 auto;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        margin: 0;
        padding: 0;
        font-size: 1.05rem;
        font-weight: 800;
        line-height: 1.2;
        letter-spacing: 0.04em;
        color: #ffffff;
        white-space: nowrap;
    }
    body .mobile-top-bar > .mtb-main > .mobile-top-bar-title .title-text {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    body .mobile-top-bar > .mtb-main > .mobile-top-bar-title .mtb-title-sep {
        color: rgba(255,255,255,0.35);
        font-weight: 400;
        font-size: 0.95rem;
        line-height: 1;
    }
    body .mobile-top-bar > .mtb-main > .mobile-top-bar-title .mtb-level-toggle {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        padding: 2px 4px;
        border-radius: 6px;
        background: transparent;
        border: none;
        color: #cbd5e1;
        font-family: inherit;
        font-size: 0.82rem;
        font-weight: 700;
        letter-spacing: 0.02em;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.2s;
        flex-shrink: 0;
    }
    body .mobile-top-bar > .mtb-main > .mobile-top-bar-title .mtb-level-toggle:active {
        color: #facc15;
    }
    body .mobile-top-bar > .mtb-main > .mobile-top-bar-title .mtb-level-toggle .level-arrow {
        width: 10px;
        height: 10px;
        fill: currentColor;
        transition: transform 0.25s;
        margin-left: 1px;
    }
    body .mobile-top-bar > .mtb-main > .mobile-top-bar-title .mtb-level-toggle.expanded .level-arrow {
        transform: rotate(180deg);
    }
    body .mobile-top-bar > .mtb-main > .mobile-menu-slot {
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        padding: 0;
        margin: 0;
        background: transparent;
        border: none;
        color: #ffffff;
        cursor: pointer;
        border-radius: 50%;
        -webkit-tap-highlight-color: transparent;
    }
    body .mobile-top-bar > .mtb-main > .mobile-menu-slot svg {
        width: 22px;
        height: 22px;
        display: block;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    /* ⓷ 关卡抽屉 */
    body .mobile-top-bar > .mtb-level-drawer {
        width: 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s cubic-bezier(0.2,0.9,0.3,1), opacity 0.2s;
        opacity: 0;
        background: rgba(30, 45, 80, 0.7);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        border-top: 1px solid rgba(255,255,255,0.08);
    }
    body .mobile-top-bar > .mtb-level-drawer.open {
        max-height: 130px;
        opacity: 1;
    }
    body .mobile-top-bar > .mtb-level-drawer-inner {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
        padding: 12px;
        box-sizing: border-box;
    }
    body .mobile-top-bar > .mtb-level-drawer .level-tile {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 2px;
        border-radius: 10px;
        background: rgba(255,255,255,0.06);
        border: 1px solid rgba(255,255,255,0.1);
        cursor: pointer;
        transition: all 0.2s;
        min-width: 0;
        -webkit-tap-highlight-color: transparent;
    }
    body .mobile-top-bar > .mtb-level-drawer .level-tile:active:not(.locked) {
        transform: scale(0.95);
        background: rgba(255,255,255,0.14);
    }
    body .mobile-top-bar > .mtb-level-drawer .level-tile .tile-num {
        font-size: 0.9rem;
        font-weight: 800;
        line-height: 1.1;
        color: #94a3b8;
    }
    body .mobile-top-bar > .mtb-level-drawer .level-tile .tile-name {
        font-size: 0.55rem;
        margin-top: 2px;
        color: #64748b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    body .mobile-top-bar > .mtb-level-drawer .level-tile.completed .tile-num { color: #ffffff; }
    body .mobile-top-bar > .mtb-level-drawer .level-tile.completed .tile-name { color: #cbd5e1; }
    body .mobile-top-bar > .mtb-level-drawer .level-tile.current {
        background: rgba(250,204,21,0.15);
        border-color: rgba(250,204,21,0.55);
        box-shadow: 0 0 8px rgba(250,204,21,0.3);
    }
    body .mobile-top-bar > .mtb-level-drawer .level-tile.current .tile-num {
        color: #facc15;
        text-shadow: 0 0 8px rgba(250,204,21,0.5);
    }
    body .mobile-top-bar > .mtb-level-drawer .level-tile.current .tile-name {
        color: #facc15;
        opacity: 0.9;
    }
    body .mobile-top-bar > .mtb-level-drawer .level-tile.unlocked .tile-num { color: #94a3b8; }
    body .mobile-top-bar > .mtb-level-drawer .level-tile.locked {
        opacity: 0.45;
        cursor: not-allowed;
    }
    body .mobile-top-bar > .mtb-level-drawer .level-tile.locked .tile-num { color: #475569; }
}