/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mobile-first brain training lobby */
body.training-home {
    background:
        radial-gradient(120% 80% at 10% -10%, #2c3d62 0%, transparent 46%),
        radial-gradient(90% 60% at 110% 8%, #1a4a4a 0%, transparent 42%),
        #12151c;
    color: #f4f1ea;
    padding: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.training-shell {
    width: min(100%, 430px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 22px 18px 48px;
}

.brand-panel {
    text-align: left;
    padding: 8px 4px 22px;
}

.brand-kicker {
    margin: 0 0 8px;
    color: #8fd3c8;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.brain-mark {
    position: relative;
    width: 94px;
    height: 94px;
    margin: 0 auto 16px;
    border: 3px solid #1680ce;
    border-radius: 50%;
    background: #fffdf8;
    overflow: hidden;
}

.brain-mark::after {
    content: '';
    position: absolute;
    top: 16px;
    bottom: 16px;
    left: 50%;
    width: 2px;
    background: #1680ce;
}

.brain-left,
.brain-right {
    position: absolute;
    top: 22px;
    width: 28px;
    height: 48px;
    border: 5px solid #1680ce;
    border-radius: 40% 55% 45% 55%;
}

.brain-left {
    left: 19px;
    border-right-width: 2px;
}

.brain-right {
    right: 17px;
    border-left-width: 2px;
    transform: scaleX(-1);
}

.brand-panel h1 {
    margin: 0;
    color: #fff;
    font-size: clamp(2rem, 8vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.08;
}

.brand-panel p:not(.brand-kicker) {
    margin: 10px 0 0;
    max-width: 28em;
    color: rgba(244, 241, 234, 0.72);
    font-size: 0.95rem;
    line-height: 1.55;
}

.score-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(244, 241, 234, 0.78);
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.score-badge strong {
    color: #8fd3c8;
    font-size: 1.12em;
}

.training-category {
    margin-bottom: 18px;
    padding: 16px 14px 18px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.training-category h2 {
    margin: 0 0 14px;
    color: #fff;
    font-size: 1.05rem;
    line-height: 1.2;
    font-weight: 700;
}

.training-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.training-card {
    min-width: 0;
    min-height: 88px;
    color: #f4f1ea;
    text-decoration: none;
    text-align: left;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 18px;
    background: rgba(18, 21, 28, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.training-card strong {
    display: block;
    margin-top: 0;
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.25;
}

.training-icon {
    position: relative;
    display: block;
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    aspect-ratio: 1;
    max-width: none;
    margin: 0;
    padding: 5px;
    border-radius: 16px;
    background: #2a2f3b;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.26),
        inset 0 0 0 1px rgba(255, 255, 255, 0.07),
        0 6px 14px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transition: transform 0.18s ease;
}

.training-card:active .training-icon {
    transform: scale(0.94);
}

.training-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.tile-schulte { background: linear-gradient(150deg, #7a6dff, #3c2fc9); }
.tile-track { background: linear-gradient(150deg, #ff7063, #cf2a1d); }
.tile-time { background: linear-gradient(150deg, #2fd6bb, #0d8a79); }
.tile-odd { background: linear-gradient(150deg, #ffc25c, #d8830a); }
.tile-stroop { background: linear-gradient(150deg, #b673ff, #6a26c7); }
.tile-whack { background: linear-gradient(150deg, #ff9a58, #dc5613); }
.tile-numseq { background: linear-gradient(150deg, #5cbcff, #1668cb); }
.tile-lights { background: linear-gradient(150deg, #ff74ad, #c21f68); }
.tile-palette { background: linear-gradient(150deg, #97dd58, #418f19); }
.tile-cards { background: linear-gradient(150deg, #6f8bff, #2941c0); }
.tile-sudoku { background: linear-gradient(150deg, #34cbe6, #0a7c96); }
.tile-nummatch { background: linear-gradient(150deg, #3ad597, #0f8256); }
.tile-24 { background: linear-gradient(150deg, #ebbd4b, #a1710b); }
.tile-pinyin { background: linear-gradient(150deg, #f8718a, #b52540); }
.tile-one-stroke { background: linear-gradient(150deg, #8f8de4, #4651ae); }
.one-stroke-icon-glyph {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 45%;
    height: 34%;
    border: 2px solid #fff;
    border-radius: 3px;
}
.one-stroke-icon-glyph::after {
    content: '';
    position: absolute;
    left: 50%;
    top: -50%;
    bottom: -50%;
    border-left: 3px solid #ffe0a6;
    border-radius: 2px;
    transform: translateX(-50%);
}
.tile-slide { background: linear-gradient(150deg, #8b9cb3, #45536a); }
.tile-2048 { background: linear-gradient(150deg, #c9bbae, #8c7a68); }
.tile-link { background: linear-gradient(150deg, #46aef0, #14669b); }
.tile-forest { background: linear-gradient(150deg, #43c67c, #0e7a3d); }
.tile-hanoi { background: linear-gradient(150deg, #8b6cff, #4b2ec9); }
.tile-gonogo { background: linear-gradient(150deg, #ff8a5c, #d8431d); }
/* v1.4 短视频风格 4 玩法图标（stroop 用独立 .tile-interfere，不复用老 .tile-stroop） */
.tile-spin { background: linear-gradient(150deg, #6ad2ff, #1668c8); }
.tile-dual { background: linear-gradient(150deg, #ff6fae, #c31a63); }
.tile-interfere { background: linear-gradient(150deg, #3ad6c0, #0f7a96); }
.tile-reverse { background: linear-gradient(150deg, #4be3c1, #0b7f9b); }
/* v1.5 短视频风格第二批 4 玩法图标（避开既有 tile 色相拥挤区，端点已做明度/饱和度偏移）*/
.tile-poem     { background: linear-gradient(150deg, #f0a94e, #c05e1f); }  /* 诗书：muted 铜橙，比 whack/gonogo 更金、更哑，规避纯橙红 */
.tile-nonogram { background: linear-gradient(150deg, #b39dff, #6d3fd6); }  /* 逻辑：lavender 紫，比 schulte/hanoi 更亮更偏品红 */
.tile-maze     { background: linear-gradient(150deg, #54c8a0, #147f5e); }  /* 路径：teal 绿，比 nummatch 更偏青、比 forest 更亮 */
.tile-mine     { background: linear-gradient(150deg, #ff6b6b, #c0392b); }  /* 危险：纯正亮红，与 track/gonogo 橙红、pinyin 粉红明显区分（风险最低，沿用 PRD） */
.tile-spatial  { background: linear-gradient(150deg, #42d392, #13795b); }
.tile-flash    { background: linear-gradient(150deg, #ffd166, #d5488b); }
.tile-switch   { background: linear-gradient(150deg, #66d9ff, #246bfe); }
.tile-matrix   { background: linear-gradient(150deg, #84cc16, #0f766e); }
.tile-logic-quest { background: linear-gradient(150deg, #f6c453, #3454d1); }

@media (max-width: 899px) {
    .training-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .training-shell {
        width: 100%;
        padding: 18px 14px 40px;
    }

    .training-card {
        min-height: 84px;
        padding: 10px;
    }

    .training-icon {
        width: 48px;
        height: 48px;
        flex-basis: 48px;
        border-radius: 14px;
    }

    .training-card strong {
        font-size: 0.92rem;
    }
}

@media (min-width: 560px) {
    .training-shell {
        width: min(100%, 560px);
    }
}

@media (min-width: 900px) {
    body.training-home {
        min-height: 100vh;
        background:
            radial-gradient(900px 520px at 0% 0%, rgba(54, 74, 116, 0.72), transparent 58%),
            radial-gradient(760px 460px at 100% 8%, rgba(25, 91, 84, 0.48), transparent 55%),
            linear-gradient(135deg, #10131a 0%, #171b24 48%, #10151c 100%);
    }

    .training-shell {
        width: min(100%, 1280px);
        min-height: 100vh;
        display: grid;
        grid-template-columns: 300px minmax(0, 1fr);
        gap: 36px;
        padding: 40px 32px 56px;
    }

    .brand-panel {
        position: sticky;
        top: 40px;
        align-self: start;
        min-height: calc(100vh - 96px);
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 0;
    }

    .brand-panel h1 {
        font-size: 3.7rem;
        letter-spacing: 0;
    }

    .brand-panel p:not(.brand-kicker) {
        max-width: 18em;
        font-size: 1.02rem;
    }

    .score-badge {
        width: fit-content;
        margin-top: 26px;
        padding: 10px 16px;
    }

    .training-list {
        align-self: center;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
    }

    .training-category {
        margin: 0;
        padding: 20px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.065);
        border-color: rgba(255, 255, 255, 0.08);
        box-shadow: 0 18px 42px rgba(0, 0, 0, 0.18);
    }

    .training-category h2 {
        margin-bottom: 16px;
        font-size: 1rem;
        letter-spacing: 0;
    }

    .training-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }

    .training-card {
        min-height: 128px;
        flex-direction: column;
        align-items: flex-start;
        justify-content: space-between;
        gap: 14px;
        padding: 16px;
        border-radius: 8px;
        background: rgba(18, 21, 28, 0.62);
        transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
    }

    .training-card:hover {
        transform: translateY(-3px);
        background: rgba(28, 33, 44, 0.86);
        border-color: rgba(255, 255, 255, 0.16);
    }

    .training-icon {
        width: 58px;
        height: 58px;
        flex-basis: 58px;
        border-radius: 8px;
    }

    .training-card strong {
        font-size: 1rem;
    }
}

@media (min-width: 1180px) {
    .training-shell {
        grid-template-columns: 340px minmax(0, 1fr);
        gap: 44px;
        padding-left: 44px;
        padding-right: 44px;
    }

    .training-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* 防止 iOS 横屏字体放大 */
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    padding: 20px;
    color: #333;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-x: none;
    overscroll-behavior-y: auto;
    /* 防止文字溢出导致横向滚动 */
    overflow-wrap: break-word;
    word-wrap: break-word;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* iOS 安全区域 */
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    min-width: 0;
}

/* 头部样式 */
.header {
    background: white;
    border-radius: 20px;
    padding: 20px 30px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.title {
    font-size: 2em;
    color: #667eea;
    font-weight: bold;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.score {
    font-size: 1.2em;
    color: #666;
}

.score strong {
    color: #ff6b6b;
    font-size: 1.3em;
}

/* 欢迎区域 */
.welcome-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.welcome-section h2 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.8em;
}

.welcome-section p {
    color: #666;
    font-size: 1.2em;
}

/* 游戏选择区域 */
.grade-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.grade-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
    min-width: 0;
}

.grade-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.grade-1-2:hover {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    color: white;
}

.grade-3-4:hover {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.grade-5-6:hover {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.grade-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.grade-card h3 {
    font-size: 1.8em;
    margin-bottom: 10px;
    color: #667eea;
}

.grade-card p {
    font-size: 1.2em;
    color: #999;
    margin-bottom: 15px;
}

.game-count {
    background: #667eea;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 15px;
    font-weight: bold;
}

.game-list {
    list-style: none;
    text-align: left;
    margin-top: 15px;
}

.game-list li {
    padding: 8px 0;
    font-size: 1.1em;
    color: #666;
    border-bottom: 1px dashed #eee;
}

.game-list li:last-child {
    border-bottom: none;
}

/* 提示区域 */
.tips-section {
    margin-bottom: 30px;
}

.tip-card {
    background: #fff3cd;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.tip-icon {
    font-size: 2em;
}

.tip-card p {
    color: #856404;
    font-size: 1.1em;
}

/* 底部 */
.footer {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    color: #666;
}

/* 脉冲动画 */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

  /* 响应式设计 - 平板及大手机 */
@media (max-width: 768px) {
    body {
        padding: 10px;
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }

    .header {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 15px;
        margin-bottom: 15px;
        border-radius: 14px;
        justify-content: center;
        position: sticky;
        top: max(8px, env(safe-area-inset-top));
        z-index: 10;
    }

    .title {
        font-size: 1.4em;
        line-height: 1.2;
    }

    .user-info {
        gap: 10px;
        width: 100%;
        justify-content: center;
    }

    .score {
        font-size: 1em;
    }

    /* 移动端双列卡片布局 */
    .grade-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 15px;
    }

    .grade-card {
        padding: 14px 10px;
        border-radius: 14px;
        box-shadow: 0 3px 12px rgba(33, 37, 41, 0.1);
    }

    .grade-icon {
        font-size: 2.5em;
        margin-bottom: 6px;
    }

    .grade-card h3 {
        font-size: 1.05em;
        margin-bottom: 4px;
        line-height: 1.3;
    }

    .grade-card p {
        font-size: 0.8em;
        margin-bottom: 6px;
        line-height: 1.3;
    }

    .game-count {
        padding: 3px 10px;
        font-size: 0.75em;
        border-radius: 12px;
        margin-bottom: 6px;
    }

    .game-list {
        display: none;
    }

    .welcome-section {
        padding: 15px;
        margin-bottom: 15px;
        border-radius: 14px;
    }

    .welcome-section h2 {
        font-size: 1.3em;
    }

    .welcome-section p {
        font-size: 0.95em;
    }

    .tip-card {
        padding: 12px;
        gap: 10px;
        border-radius: 12px;
    }

    .tip-icon {
        font-size: 1.5em;
    }

    .tip-card p {
        font-size: 0.95em;
        line-height: 1.4;
    }

    .footer {
        padding: 12px;
        font-size: 0.85em;
        border-radius: 12px;
    }
}

/* 小屏手机优化 */
@media (max-width: 480px) {
    body {
        padding: 8px;
        padding-top: max(8px, env(safe-area-inset-top));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }

    .header {
        padding: 10px 12px;
        margin-bottom: 10px;
        border-radius: 12px;
        box-shadow: 0 4px 18px rgba(33, 37, 41, 0.12);
    }

    .title {
        font-size: 1.2em;
    }

    .grade-section {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-bottom: 8px;
    }

    .grade-card {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) auto;
        align-items: center;
        column-gap: 10px;
        text-align: left;
        padding: 10px 12px;
        border-radius: 12px;
        /* 保证最小触摸高度 */
        min-height: 64px;
    }

    .grade-icon {
        font-size: 1.8em;
        margin-bottom: 0;
        grid-row: 1 / span 3;
        text-align: center;
    }

    .grade-card h3 {
        font-size: 1em;
        line-height: 1.2;
        margin-bottom: 2px;
    }

    .grade-card p {
        font-size: 0.78em;
        margin-bottom: 0;
    }

    .game-count {
        grid-column: 3;
        grid-row: 1 / span 2;
        align-self: center;
        padding: 3px 8px;
        font-size: 0.68em;
        margin: 0;
        white-space: nowrap;
    }

    .welcome-section {
        padding: 12px;
        margin-bottom: 10px;
        border-radius: 12px;
    }

    .welcome-section h2 {
        font-size: 1.15em;
    }

    .welcome-section p {
        font-size: 0.88em;
    }

    .tip-card {
        padding: 10px;
        gap: 8px;
    }

    .tip-icon {
        font-size: 1.3em;
    }

    .tip-card p {
        font-size: 0.88em;
    }

    .footer {
        padding: 10px;
        font-size: 0.8em;
    }
}

/* 超小屏手机优化 */
@media (max-width: 360px) {
    .grade-section {
        /* 超小屏单列保证可读性和触摸区域 */
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .grade-card {
        grid-template-columns: 38px minmax(0, 1fr);
        padding: 10px 12px;
        min-height: 60px;
    }

    .grade-icon {
        font-size: 1.8em;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .grade-card h3 {
        font-size: 0.95em;
        margin-bottom: 2px;
    }

    .grade-card p {
        font-size: 0.75em;
        margin-bottom: 0;
    }

    .game-count {
        display: none;
    }
}

/* 触摸设备优化 - 移除 hover 效果，使用 active 反馈 */
@media (hover: none) and (pointer: coarse) {
    .grade-card:hover {
        transform: none;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }

    .grade-card:active {
        transform: scale(0.96);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    .grade-1-2:active {
        background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
        color: white;
    }

    .grade-3-4:active {
        background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    }

    .grade-5-6:active {
        background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    }
}

/* 横屏手机优化 */
@media (max-width: 900px) and (orientation: landscape) {
    body {
        padding: 8px;
    }

    .header {
        padding: 8px 15px;
        margin-bottom: 10px;
    }

    .title {
        font-size: 1.3em;
    }

    .grade-section {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 10px;
    }

    .grade-card {
        padding: 10px 6px;
        border-radius: 10px;
    }

    .grade-icon {
        font-size: 1.8em;
        margin-bottom: 4px;
    }

    .grade-card h3 {
        font-size: 0.9em;
        margin-bottom: 2px;
    }

    .grade-card p {
        font-size: 0.7em;
        margin-bottom: 4px;
    }

    .game-count {
        display: none;
    }

    .game-list {
        display: none;
    }

    .welcome-section {
        padding: 10px;
        margin-bottom: 10px;
    }

    .welcome-section h2 {
        font-size: 1.1em;
        margin-bottom: 4px;
    }

    .welcome-section p {
        font-size: 0.85em;
    }

    .tip-card {
        padding: 8px 12px;
    }
}
