* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    color: #f8fafc;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.page {
    position: absolute; inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: env(safe-area-inset-top) 24px 24px 24px;
}
.page.active { display: flex; }

/* 登录 */
#login { justify-content: center; padding: max(24px, env(safe-area-inset-top)) 24px 24px 24px; }
.login-card {
    width: 100%; max-width: 340px;
    padding: 32px 28px;
    border-radius: 28px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    text-align: center;
    box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.login-title { font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.login-sub { font-size: 13px; color: #94a3b8; margin-bottom: 24px; }
.qr-box {
    width: 160px; height: 160px;
    margin: 0 auto 20px;
    border-radius: 16px;
    background: #fff;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.qr-placeholder { font-size: 48px; }
.qr-text { font-size: 12px; color: #64748b; font-weight: 600; }
.login-divider {
    display: flex; align-items: center;
    color: #64748b; font-size: 12px;
    margin: 16px 0;
}
.login-divider::before, .login-divider::after {
    content: ''; flex: 1; height: 1px;
    background: rgba(255,255,255,.12);
}
.login-divider span { padding: 0 12px; }
.login-input {
    width: 100%; height: 48px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.08);
    color: #f8fafc; font-size: 15px;
    outline: none;
}
.login-input::placeholder { color: #64748b; }
.login-tip {
    margin-top: 16px;
    font-size: 11px; color: #64748b; line-height: 1.5;
}
.login-actions { margin-top: 16px; }
.login-actions .btn-primary { width: 100%; }
.user-bar {
    position: absolute; top: 16px; right: 20px;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    border-radius: 20px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.1);
    font-size: 13px; font-weight: 600;
    z-index: 20;
}
.user-bar span { color: #60a5fa; }
.user-bar button {
    background: transparent; border: none;
    color: #94a3b8; font-size: 12px;
    cursor: pointer;
}

/* ==================== 封面 / 主页：三栏弹性布局 ==================== */

/* 封面页面容器：使用 min-height 而非固定高度，预留安全区 */
#cover {
    position: relative;
    min-height: 100vh;                       /* 基础兜底 */
    min-height: 100dvh;                      /* 动态视口，适配折叠屏开合、键盘弹出 */
    height: auto;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;  /* 顶部/底部安全区内边距 */
    overflow: hidden;
    box-sizing: border-box;
}

/* 整体布局容器：标题 + 主体 + 按钮 */
.cover-layout {
    width: 100%;
    max-width: 560px;                        /* 宽屏限制最大宽度，避免元素过度拉伸 */
    min-height: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0 24px;
    box-sizing: border-box;
}

/* 顶部标题区 */
.cover-header {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: max(12px, env(safe-area-inset-top));
    position: relative;
    z-index: 2;
}

/* 标题文字 */
.cover-title {
    text-align: center;
    animation: float 3s ease-in-out infinite;
}
.cover-title h1 {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #60a5fa, #c084fc, #f472b6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 10px 30px rgba(96,165,250,.3);
}
.cover-title p {
    margin-top: 12px;
    font-size: 16px;
    color: #94a3b8;
    letter-spacing: 4px;
}

/* 装饰气泡 */
.cover-bubbles {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.cover-bubbles .demo-bubble {
    position: absolute;
}
.demo-bubble {
    position: absolute;
    width: 50px; height: 50px;
    border-radius: 50%;
    background: rgba(96,165,250,.25);
    border: 1px solid rgba(147,197,253,.35);
    box-shadow: 0 4px 20px rgba(96,165,250,.2), inset 0 0 20px rgba(147,197,253,.1);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    color: rgba(255,255,255,.7);
    animation: bubbleFloat 2.5s ease-in-out infinite;
}
@keyframes bubbleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* 中间游戏主体区：flex:1 占满剩余空间，内容过多时可纵向滚动 */
.cover-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    position: relative;
    z-index: 1;
    min-height: 0;                           /* 关键：允许 flex 子项在主轴上收缩 */
}

/* 游戏内容包装 */
.cover-game-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    position: relative;
    z-index: 1;
}

/* 底部功能按钮区：margin-top:auto 固定在页面最底端 */
.cover-footer {
    flex-shrink: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: auto;                        /* 将按钮推到最底部 */
    padding-top: 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));  /* 底部安全区内边距，避开手势条 */
    position: relative;
    z-index: 2;
}

/* 按钮基础样式：最低 48px 触控高度 */
.btn-primary, .btn-secondary {
    width: 220px;
    min-height: 48px;
    height: auto;
    border: none; border-radius: 27px;
    font-size: 18px; font-weight: 700;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    display: flex; align-items: center; justify-content: center;
    padding: 10px 20px;
    box-sizing: border-box;
}
.btn-primary {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    color: #fff;
    box-shadow: 0 8px 24px rgba(59,130,246,.4);
}
.btn-secondary {
    background: rgba(255,255,255,.08);
    color: #e2e8f0;
    border: 1px solid rgba(255,255,255,.15);
}
.btn-primary:active, .btn-secondary:active { transform: scale(.96); }

/* 封面底部按钮：宽度铺满容器、触控更友好 */
.cover-footer .btn-primary,
.cover-footer .btn-secondary {
    width: 100%;
    max-width: 320px;
    min-height: 48px;
}

/* 用户栏：在封面顶部右侧，不脱离文档流 */
.cover-header .user-bar {
    position: relative;
    top: auto; right: auto;
    align-self: flex-end;
    margin-bottom: 8px;
}

/* 模式卡片 */
.mode-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, auto);
    gap: 12px;
    width: 100%;
    max-width: 360px;
    margin-bottom: 8px;
}
.mode-card {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px;
    padding: 14px 10px;
    border-radius: 18px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    cursor: pointer;
    text-align: center;
    transition: transform .15s, background .15s, border-color .15s;
}
.mode-card:active { transform: scale(.97); }
.mode-card.active {
    border-color: rgba(96,165,250,.7);
    background: rgba(96,165,250,.12);
}
.mode-card-icon {
    width: 56px; height: 56px;
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}
.mode-card.seq .mode-card-icon {
    background: linear-gradient(135deg, rgba(59,130,246,.3), rgba(139,92,246,.3));
    box-shadow: 0 4px 16px rgba(59,130,246,.25);
}
.mode-card.schultz .mode-card-icon {
    background: linear-gradient(135deg, rgba(16,185,129,.3), rgba(6,182,212,.3));
    box-shadow: 0 4px 16px rgba(16,185,129,.25);
}
.mode-card.mem .mode-card-icon {
    background: linear-gradient(135deg, rgba(245,158,11,.3), rgba(249,115,22,.3));
    box-shadow: 0 4px 16px rgba(245,158,11,.25);
}
.mode-card.circle .mode-card-icon {
    background: linear-gradient(135deg, rgba(236,72,153,.3), rgba(168,85,247,.3));
    box-shadow: 0 4px 16px rgba(236,72,153,.25);
}
.mode-card.compass .mode-card-icon {
    background: linear-gradient(135deg, rgba(45,212,191,.3), rgba(6,182,212,.3));
    box-shadow: 0 4px 16px rgba(45,212,191,.25);
}
.mode-card.voronoi .mode-card-icon {
    background: linear-gradient(135deg, rgba(139,92,246,.3), rgba(236,72,153,.3));
    box-shadow: 0 4px 16px rgba(139,92,246,.25);
}
.mode-card-title { font-size: 18px; font-weight: 800; }
.mode-card-desc { font-size: 12px; color: #94a3b8; margin-top: 4px; line-height: 1.4; }

/* 难度切换 */
.mode-switch {
    display: flex;
    width: 220px;
    min-height: 44px;
    height: auto;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 22px;
    overflow: hidden;
    margin-bottom: 8px;
}
.mode-btn {
    flex: 1;
    border: none; background: transparent;
    color: #94a3b8; font-size: 14px; font-weight: 700;
    cursor: pointer; transition: all .2s;
    min-height: 44px;
    padding: 8px;
}
.mode-btn.active {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    color: #fff;
}

/* 兜底缩放方案：JS 在内容溢出且滑动受限时添加 cover-scaled 类 */
#cover.cover-scaled .cover-layout {
    transform: scale(var(--cover-scale, 1));
    transform-origin: center top;
}

/* ==================== 屏幕适配：小屏 / 方形折叠外屏 / 大屏折叠内屏 / 横屏 ==================== */

/* 小屏手机 */
@media (max-width: 380px) {
    .cover-layout { padding: 0 16px; }
    .cover-title h1 { font-size: 34px; }
    .cover-title p { font-size: 14px; margin-top: 8px; }
    .mode-cards { gap: 8px; max-width: 300px; }
    .mode-card { padding: 10px 8px; gap: 6px; }
    .mode-card-icon { width: 44px; height: 44px; font-size: 22px; border-radius: 14px; }
    .mode-card-title { font-size: 14px; }
    .mode-card-desc { font-size: 10px; }
    .mode-switch { width: 200px; min-height: 40px; }
    .mode-btn { font-size: 13px; min-height: 40px; }
    .cover-footer { gap: 8px; padding-top: 12px; }
    .cover-footer .btn-primary,
    .cover-footer .btn-secondary { font-size: 16px; min-height: 44px; }
}

/* 方形折叠外屏：约 980×980，屏幕较大但高度有限 */
@media (min-width: 700px) and (max-width: 1100px) and (min-height: 700px) and (max-height: 1100px) {
    .cover-layout { max-width: 520px; }
    .cover-title h1 { font-size: 48px; }
    .cover-title p { font-size: 18px; }
    .mode-cards { max-width: 420px; gap: 16px; }
    .mode-card { padding: 18px 14px; }
    .mode-card-icon { width: 64px; height: 64px; font-size: 30px; }
    .mode-card-title { font-size: 20px; }
    .mode-card-desc { font-size: 13px; }
    .mode-switch { width: 260px; min-height: 48px; }
    .mode-btn { font-size: 15px; min-height: 48px; }
    .cover-footer .btn-primary,
    .cover-footer .btn-secondary { max-width: 360px; font-size: 19px; }
}

/* 大屏折叠内屏 / 平板：1320×2120 等 */
@media (min-width: 768px) {
    .cover-layout { max-width: 640px; }
    .cover-title h1 { font-size: 52px; }
    .mode-cards { max-width: 460px; gap: 16px; }
    .mode-card { padding: 18px 14px; }
    .mode-card-icon { width: 60px; height: 60px; font-size: 30px; }
    .cover-footer .btn-primary,
    .cover-footer .btn-secondary { max-width: 360px; }
}

/* 横屏或高度极小：优先保证按钮可见，内容可滚动 */
@media (max-height: 500px) and (orientation: landscape) {
    .cover-header { padding-top: 8px; }
    .cover-title h1 { font-size: 28px; }
    .cover-title p { font-size: 12px; margin-top: 4px; }
    .mode-cards { gap: 8px; max-width: 340px; }
    .mode-card { padding: 8px; gap: 4px; }
    .mode-card-icon { width: 40px; height: 40px; font-size: 20px; border-radius: 12px; }
    .mode-card-title { font-size: 13px; }
    .mode-card-desc { font-size: 9px; margin-top: 2px; }
    .mode-switch { width: 200px; min-height: 36px; }
    .mode-btn { font-size: 12px; min-height: 36px; }
    .cover-footer { gap: 6px; padding-top: 8px; }
    .cover-footer .btn-primary,
    .cover-footer .btn-secondary { min-height: 40px; padding: 6px 16px; font-size: 14px; }
}

/* 选关 */
#menu, #memory-menu, #circle-menu, #compass-menu, #voronoi-menu {
    justify-content: flex-start;
    padding-top: max(50px, env(safe-area-inset-top));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}
.menu-header {
    width: 100%; max-width: 420px;
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    justify-items: center;
    margin-bottom: 10px;
}
.menu-header h2 { grid-column: 2; font-size: 26px; text-align: center; }
.menu-title {
    text-align: center;
    margin: 10px 0;
    font-size: 26px;
    font-weight: 800;
}
.back-icon {
    grid-column: 1;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 20px;
}
.level-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%; max-width: 420px;
}
.level-card {
    aspect-ratio: 1;
    border-radius: 20px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 8px;
    position: relative;
    transition: transform .15s, background .15s;
}
.level-card.unlocked { cursor: pointer; }
.level-card.unlocked:active { transform: scale(.96); }
.level-card.locked { opacity: .55; }
.level-card.current { border-color: rgba(96,165,250,.6); background: rgba(96,165,250,.12); }
.level-num { font-size: 36px; font-weight: 800; }
.level-name { font-size: 14px; color: #94a3b8; }
.level-best { font-size: 12px; color: #60a5fa; margin-top: 2px; }
.level-stars { font-size: 14px; color: #fbbf24; letter-spacing: 1px; margin-top: 4px; }
.level-stars .gray-stars { color: rgba(255,255,255,.15); }
.lock-icon {
    position: absolute; top: 12px; right: 12px;
    font-size: 16px; color: #94a3b8;
}

/* 游戏 */
#game, #memory-game { padding: env(safe-area-inset-top) 0 0 0; justify-content: flex-start; }
.game-bar {
    width: 100%; height: 70px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    background: rgba(15,23,42,.7);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.game-info { display: flex; gap: 20px; }
.info-item { display: flex; flex-direction: column; align-items: flex-start; }
.info-label { font-size: 11px; color: #94a3b8; }
.info-value { font-size: 22px; font-weight: 800; color: #f8fafc; }
.timer.warning { color: #f87171; animation: pulse .5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.6} }
.pause-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    color: #fff; font-size: 18px; cursor: pointer;
}
.play-area {
    flex: 1; width: 100%;
    position: relative;
    overflow: hidden;
}
.bubble {
    position: absolute;
    border-radius: 50%;
    background: rgba(96,165,250,.22);
    border: 1px solid rgba(147,197,253,.32);
    box-shadow: 0 4px 20px rgba(96,165,250,.18), inset 0 0 24px rgba(147,197,253,.08);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    color: rgba(255,255,255,.88);
    cursor: pointer;
    transition: transform .12s, box-shadow .2s, border-color .2s;
    will-change: transform;
}
.bubble::after {
    content: '';
    position: absolute; inset: -2px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.04);
}
.bubble:active { transform: scale(.92); }
.grid-container {
    position: absolute;
    display: grid;
    gap: 10px;
    justify-content: center;
    align-content: center;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    transition: transform .3s ease;
}
.grid-cell {
    display: flex; align-items: center; justify-content: center;
    border-radius: 14px;
    background: rgba(96,165,250,.18);
    border: 1px solid rgba(147,197,253,.28);
    box-shadow: 0 4px 16px rgba(96,165,250,.12), inset 0 0 18px rgba(147,197,253,.06);
    font-weight: 800;
    color: rgba(255,255,255,.9);
    cursor: pointer;
    user-select: none;
    transition: transform .1s, background .2s, border-color .2s;
    will-change: transform, left, top;
}
.grid-cell:active { transform: scale(.94); }

.big-countdown {
    position: absolute; inset: 0;
    display: none; align-items: center; justify-content: center;
    z-index: 50;
    pointer-events: none;
}
.big-countdown.active { display: flex; }
.big-countdown span {
    font-size: 120px; font-weight: 900;
    color: #fff;
    text-shadow: 0 0 40px rgba(255,255,255,.4);
    animation: popIn .45s ease-out;
}
@keyframes popIn {
    0% { transform: scale(.2); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
.memory-result-modal {
    position: absolute; inset: 0;
    display: none; align-items: center; justify-content: center;
    background: rgba(15,23,42,.92);
    z-index: 100;
    padding: 24px;
}
.memory-result-modal.active { display: flex; }
.memory-result-card {
    width: 100%; max-width: 320px;
    padding: 36px 28px;
    border-radius: 28px;
    text-align: center;
    background: linear-gradient(160deg, rgba(30,41,59,.95), rgba(15,23,42,.95));
    border: 1px solid rgba(255,255,255,.12);
    box-shadow: 0 24px 60px rgba(0,0,0,.4);
    animation: cardPop .4s ease-out;
}
@keyframes cardPop {
    0% { transform: scale(.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.memory-result-icon { font-size: 64px; margin-bottom: 16px; }
.memory-result-title { font-size: 26px; font-weight: 800; margin-bottom: 10px; }
.memory-result-hint {
    display: none;
    font-size: 15px; font-weight: 700;
    color: #fbbf24;
    background: linear-gradient(135deg, rgba(245,158,11,.18), rgba(251,191,36,.10));
    border: 1px solid rgba(245,158,11,.4);
    border-radius: 16px;
    padding: 14px 18px;
    margin-bottom: 18px;
    line-height: 1.55;
    box-shadow: 0 0 24px rgba(245,158,11,.12), inset 0 0 16px rgba(251,191,36,.06);
    animation: hintPulse 2s ease-in-out infinite;
}
.memory-result-hint.active { display: block; }
@keyframes hintPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 24px rgba(245,158,11,.12); }
    50% { transform: scale(1.02); box-shadow: 0 0 32px rgba(245,158,11,.22); }
}
.memory-result-text { font-size: 15px; color: #94a3b8; line-height: 1.5; margin-bottom: 28px; }
.memory-result-actions { display: flex; gap: 12px; justify-content: center; }
.memory-result-actions .btn-primary, .memory-result-actions .btn-secondary { width: 130px; height: 48px; font-size: 15px; }

.progress-ring {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 8px; align-items: center;
    background: rgba(15,23,42,.7);
    padding: 10px 18px; border-radius: 24px;
    border: 1px solid rgba(255,255,255,.1);
}
.progress-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.2); }
.progress-dot.done { background: #60a5fa; box-shadow: 0 0 8px #60a5fa; }

/* 结算 */
#result { text-align: center; }
.result-icon { font-size: 64px; margin-bottom: 12px; }
.result-title { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.result-sub { font-size: 15px; color: #94a3b8; margin-bottom: 30px; }
#resultStars {
    font-size: 28px;
    color: #fbbf24;
    letter-spacing: 4px;
    margin-bottom: 20px;
}
.result-stats {
    display: flex; gap: 16px; margin-bottom: 36px;
}
.stat-card {
    flex: 1; min-width: 110px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 16px;
    padding: 18px 12px;
}
.stat-value { font-size: 26px; font-weight: 800; color: #60a5fa; }
.stat-label { font-size: 12px; color: #94a3b8; margin-top: 6px; }
.result-actions { display: flex; flex-direction: column; gap: 14px; align-items: center; }

/* 个人记录 */
#records { justify-content: flex-start; padding-top: max(50px, env(safe-area-inset-top)); }
.records-header {
    width: 100%; max-width: 420px;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px;
}
.records-header h2 { font-size: 26px; }
.record-list {
    width: 100%; max-width: 420px;
    display: flex; flex-direction: column; gap: 12px;
}
.record-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 18px;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
}
.record-left { display: flex; flex-direction: column; gap: 4px; }
.record-level { font-size: 16px; font-weight: 700; }
.record-count { font-size: 12px; color: #94a3b8; }
.record-time { font-size: 20px; font-weight: 800; color: #60a5fa; }
.record-empty { text-align: center; color: #64748b; padding: 40px 0; }
.record-section { font-size: 14px; color: #94a3b8; font-weight: 700; letter-spacing: 1px; margin-bottom: 8px; }
.record-stars { color: #fbbf24; font-size: 13px; letter-spacing: 1px; margin-left: 6px; }
.record-stars .gray-stars { color: rgba(255,255,255,.15); }

/* 弹窗 */
.modal {
    position: absolute; inset: 0;
    background: rgba(15,23,42,.92);
    display: none; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 100; padding: 24px; text-align: center;
}
.modal.active { display: flex; }
.modal h3 { font-size: 24px; margin-bottom: 12px; }
.modal p { color: #94a3b8; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 16px; }
.modal-actions .btn-primary, .modal-actions .btn-secondary { width: 130px; }

/* 挑战模式激励弹窗（儿童友好风格） */
#motivationModal.modal { background: rgba(15,23,42,.78); backdrop-filter: blur(4px); }
.moti-card {
    position: relative;
    width: 100%; max-width: 360px;
    background: linear-gradient(180deg, #fffbf2 0%, #fff5e6 100%);
    border-radius: 28px;
    padding: 48px 26px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25), 0 8px 24px rgba(245,158,11,.15), inset 0 0 0 4px rgba(255,255,255,.6);
    text-align: center;
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;
    animation: motiFloat .6s ease-out;
}
@keyframes motiFloat {
    0% { transform: translateY(20px) scale(.92); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}
.moti-hero {
    width: 120px; height: 120px;
    margin: 0 auto 10px;
}
.moti-hero svg { width: 100%; height: 100%; }
.moti-corner {
    position: absolute;
    width: 32px; height: 32px;
    font-size: 24px;
    line-height: 32px;
    text-align: center;
    pointer-events: none;
    opacity: .85;
}
.moti-tl { top: 14px; left: 14px; transform: rotate(-12deg); }
.moti-tr { top: 14px; right: 14px; transform: rotate(12deg); }
.moti-bl { bottom: 14px; left: 14px; transform: rotate(8deg); }
.moti-br { bottom: 14px; right: 14px; transform: rotate(-8deg); }
.moti-title {
    font-size: 28px; font-weight: 900;
    color: #78350f;
    margin: 0 0 12px;
    letter-spacing: 1px;
    text-shadow: 0 2px 0 rgba(255,255,255,.8);
}
.moti-text {
    font-size: 16px; line-height: 1.6;
    color: #92400e;
    margin: 0 0 28px;
    font-weight: 600;
}
.moti-actions { display: flex; justify-content: center; }
.moti-btn {
    width: 200px; height: 54px;
    border: none; border-radius: 27px;
    font-size: 19px; font-weight: 900;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(90deg, #f59e0b, #f97316);
    box-shadow: 0 8px 24px rgba(245,158,11,.45);
    animation: motiBreath 1.6s ease-in-out infinite;
    transition: transform .15s;
}
.moti-btn:active { transform: scale(.95); }
@keyframes motiBreath {
    0%, 100% { box-shadow: 0 8px 24px rgba(245,158,11,.45); transform: scale(1); }
    50% { box-shadow: 0 10px 32px rgba(249,115,22,.6); transform: scale(1.03); }
}

/* 我的档案 */
#profile { justify-content: flex-start; padding-top: max(50px, env(safe-area-inset-top)); overflow-y: auto; }
.profile-header {
    width: 100%; max-width: 420px;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px;
}
.profile-header h2 { font-size: 26px; }
.profile-card {
    width: 100%; max-width: 420px;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 16px;
}
.profile-section-title {
    font-size: 16px; font-weight: 800;
    margin-bottom: 14px;
    color: #e2e8f0;
}
.profile-field {
    display: flex; flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.profile-field label {
    font-size: 12px; color: #94a3b8;
}
.profile-field input {
    width: 100%; height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.08);
    color: #f8fafc; font-size: 15px;
    outline: none;
}
.profile-field input::placeholder { color: #64748b; }
.profile-field .profile-value {
    font-size: 15px; color: #f8fafc;
    padding: 10px 0;
}
.profile-stats {
    width: 100%; max-width: 420px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.profile-stat {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 16px;
    padding: 16px 12px;
    text-align: center;
}
.profile-stat-value {
    font-size: 22px; font-weight: 800; color: #60a5fa;
}
.profile-stat-label {
    font-size: 11px; color: #94a3b8; margin-top: 6px;
}
.profile-games {
    width: 100%; max-width: 420px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.profile-game-card {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 16px;
    padding: 14px;
    text-align: center;
}
.profile-game-name {
    font-size: 13px; font-weight: 700; color: #e2e8f0;
    margin-bottom: 8px;
}
.profile-game-stat {
    font-size: 12px; color: #94a3b8;
    margin-top: 4px;
}
.profile-save {
    width: 100%; max-width: 420px;
    margin-bottom: 24px;
}

/* 游戏历史记录面板 */
#history { justify-content: flex-start; padding-top: max(50px, env(safe-area-inset-top)); overflow-y: auto; }
.history-header {
    width: 100%; max-width: 420px;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px;
}
.history-header h2 { font-size: 26px; }
.history-tabs {
    width: 100%; max-width: 420px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 12px;
}
.history-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 20px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    color: #94a3b8;
    font-size: 13px; font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.history-tab.active {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    color: #fff;
    border-color: transparent;
}
.history-actions {
    width: 100%; max-width: 420px;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}
.history-actions button {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid rgba(248,113,113,.4);
    background: rgba(239,68,68,.1);
    color: #f87171;
    font-size: 12px; font-weight: 700;
    cursor: pointer;
}
.history-list {
    width: 100%; max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}
.history-item {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 14px 16px;
}
.history-item-top {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
}
.history-item-level {
    font-size: 16px; font-weight: 700;
}
.history-item-stars { color: #fbbf24; font-size: 13px; letter-spacing: 1px; }
.history-item-stars .gray-stars { color: rgba(255,255,255,.15); }
.history-item-detail {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    font-size: 12px; color: #94a3b8;
    margin-bottom: 10px;
}
.history-item-detail span { color: #f8fafc; }
.history-item-actions {
    display: flex; justify-content: flex-end;
}
.history-item-actions button {
    padding: 6px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.08);
    color: #e2e8f0;
    font-size: 12px; font-weight: 600;
    cursor: pointer;
}
.history-empty { text-align: center; color: #64748b; padding: 40px 0; }
.history-mode-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.history-mode-title {
    font-size: 14px;
    font-weight: 800;
    color: #e2e8f0;
    padding: 6px 4px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

/* 响应式适配 */
@media (max-width: 380px) {
    .cover-title h1 { font-size: 34px; }
    .cover-title p { font-size: 14px; }
    .cover-bubbles { width: 220px; height: 220px; }
    .demo-bubble { width: 42px; height: 42px; font-size: 14px; }
    .btn-primary, .btn-secondary { width: 200px; height: 50px; font-size: 16px; }
    .mode-cards { max-width: 300px; gap: 10px; }
    .mode-card { padding: 12px 8px; gap: 6px; }
    .mode-card-icon { width: 44px; height: 44px; font-size: 22px; border-radius: 14px; }
    .mode-card-title { font-size: 14px; }
    .mode-card-desc { font-size: 10px; }
    .mode-switch { width: 200px; height: 40px; }
    .mode-btn { font-size: 13px; }
    .menu-header h2 { font-size: 22px; }
    .menu-title { font-size: 22px; }
    .level-num { font-size: 28px; }
    .level-name { font-size: 12px; }
    .level-best { font-size: 11px; }
    .game-bar { height: 60px; padding: 0 16px; }
    .stage-badge { top: 110px; font-size: 12px; padding: 6px 14px; }
    .info-value { font-size: 18px; }
    .info-label { font-size: 10px; }
    .pause-btn { width: 36px; height: 36px; font-size: 18px; }
    .bubble { font-size: 18px !important; }
    .big-countdown span { font-size: 90px; }
    .memory-result-card { padding: 28px 22px; }
    .memory-result-icon { font-size: 52px; }
    .memory-result-title { font-size: 22px; }
    .profile-stats { grid-template-columns: repeat(2, 1fr); }
    .profile-games { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
    .cover-title h1 { font-size: 52px; }
    .cover-bubbles { width: 320px; height: 320px; }
    .demo-bubble { width: 58px; height: 58px; font-size: 18px; }
    .btn-primary, .btn-secondary { width: 260px; height: 60px; font-size: 20px; }
    .mode-cards { max-width: 460px; gap: 16px; }
    .mode-card { padding: 18px 14px; gap: 10px; }
    .mode-card-icon { width: 60px; height: 60px; font-size: 30px; }
    .mode-card-title { font-size: 18px; }
    .mode-card-desc { font-size: 12px; }
    .mode-switch { width: 260px; height: 48px; }
    .mode-btn { font-size: 15px; }
    .menu-header h2 { font-size: 30px; }
    .menu-title { font-size: 30px; }
    .level-grid { grid-template-columns: repeat(3, 1fr); max-width: 560px; }
    .level-num { font-size: 42px; }
    .level-name { font-size: 15px; }
    .game-bar { height: 80px; }
    .stage-badge { top: 130px; font-size: 15px; }
    .info-value { font-size: 24px; }
    .pause-btn { width: 44px; height: 44px; font-size: 22px; }
    .bubble { font-size: 26px !important; }
    .big-countdown span { font-size: 150px; }
    .memory-result-card { max-width: 380px; padding: 44px 36px; }
    .memory-result-icon { font-size: 72px; }
    .memory-result-title { font-size: 30px; }
    .profile-games { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
    .level-grid { grid-template-columns: repeat(4, 1fr); max-width: 720px; }
    .memory-result-card { max-width: 420px; }
}
@media (max-height: 500px) and (orientation: landscape) {
    #cover { padding: max(30px, env(safe-area-inset-top)) 24px 24px 24px; }
    .cover-bubbles { width: 160px; height: 160px; }
    .cover-title h1 { font-size: 28px; }
    .cover-title p { font-size: 13px; }
    .mode-cards { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, auto); max-width: 560px; }
    .mode-card { padding: 10px 8px; }
    .mode-card-icon { width: 40px; height: 40px; font-size: 20px; }
    .mode-card-title { font-size: 13px; }
    .mode-card-desc { display: none; }
    .game-bar { height: 52px; }
    .stage-badge { top: 100px; }
    .bubble { font-size: 16px !important; }
}
