* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Logo样式 */
.logo {
    display: inline-block;
    width: 60px;
    height: 60px;
    margin-bottom: 20px;
    animation: logoFloat 3s ease-in-out infinite;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.1);
}

.logo img,
.logo svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.logo-link {
    display: inline-block;
    text-decoration: none;
    color: inherit;
}

/* 子页面logo样式 */
.page-logo {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    z-index: 100;
    transition: transform 0.3s ease;
}

.page-logo:hover {
    transform: scale(1.1);
}

.page-logo img,
.page-logo svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

@media (max-width: 768px) {
    .logo {
        width: 50px;
        height: 50px;
        margin-bottom: 15px;
    }
    
    .page-logo {
        width: 40px;
        height: 40px;
        top: 15px;
        left: 15px;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.home-container {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.5s ease-in-out;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.home-content {
    width: 100%;
    max-width: 600px;
    text-align: center;
}

.home-title {
    font-size: 3rem;
    color: #fff;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.6s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.home-subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 50px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.6s ease-out 0.2s both;
}

.training-modes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-top: 30px; /* 减少顶部间距，因为上方有广告 */
}

.mode-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px 30px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    animation: scaleIn 0.5s ease-out;
    animation-fill-mode: both;
}

.mode-card:nth-child(1) {
    animation-delay: 0.3s;
}

.mode-card:nth-child(2) {
    animation-delay: 0.4s;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.mode-card::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    z-index: 0;
    opacity: 0.1;
}

.mode-card:hover:not(.disabled)::before {
    width: 300px;
    height: 300px;
}

.mode-card:hover:not(.disabled) {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.mode-card:active:not(.disabled) {
    transform: translateY(-4px);
}

.mode-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
}

.mode-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
    animation: float 3s ease-in-out infinite;
}

.mode-card:nth-child(2) .mode-icon {
    animation-delay: 0.5s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.mode-title {
    font-size: 1.8rem;
    color: #667eea;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
    font-weight: 600;
}

.mode-description {
    font-size: 1rem;
    color: #666;
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

.coming-soon {
    display: inline-block;
    margin-top: 15px;
    padding: 6px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    position: relative;
    z-index: 1;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* PC端显示两侧广告 */
@media (min-width: 1025px) {
    .adsense-home-left,
    .adsense-home-right {
        display: flex !important;
    }
    
    .adsense-home-bottom {
        display: none !important; /* PC端隐藏底部广告 */
    }
    
    .home-container {
        align-items: flex-start;
    }
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .home-container {
        flex-direction: column;
        align-items: center;
    }
    
    .adsense-home-left,
    .adsense-home-right {
        display: none !important; /* 移动端隐藏两侧广告 */
    }
    
    .adsense-home-bottom {
        display: flex !important; /* 移动端显示底部广告 */
    }
}

@media (max-width: 768px) {
    .home-title {
        font-size: 2.5rem;
    }
    
    .home-subtitle {
        font-size: 1rem;
        margin-bottom: 30px; /* 减少底部间距，因为下方有广告 */
    }
    
    .training-modes {
        grid-template-columns: 1fr;
        gap: 20px;
        margin-top: 25px;
    }
    
    .mode-card {
        padding: 30px 25px;
    }
    
    .mode-icon {
        font-size: 3.5rem;
    }
    
    .mode-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .home-title {
        font-size: 2rem;
    }
    
    .home-subtitle {
        font-size: 0.9rem;
    }
    
    .mode-card {
        padding: 25px 20px;
    }
    
    .mode-icon {
        font-size: 3rem;
    }
    
    .mode-title {
        font-size: 1.3rem;
    }
}

/* 页脚链接样式 */
.footer-links {
    margin-top: 30px;
    padding-top: 20px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.footer-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.footer-link:hover {
    color: #fff;
    text-decoration: underline;
}

.footer-separator {
    color: rgba(255, 255, 255, 0.5);
    margin: 0 10px;
}

@media (max-width: 768px) {
    .footer-links {
        margin-top: 25px;
        padding-top: 15px;
    }
    
    .footer-link {
        font-size: 0.85rem;
    }
}

/* ============================================
   Google AdSense 样式
   ============================================ */

/* AdSense 容器基础样式 */
.adsense-container {
    margin: 20px auto;
    text-align: center;
    min-height: 90px; /* 为广告预留空间，避免布局跳动 */
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 10px;
    position: relative;
    z-index: 1; /* 确保广告在内容之上，但在覆盖层之下 */
    overflow: hidden;
}

/* 首页顶部广告位 */
.adsense-home-top {
    margin-top: 20px;
    margin-bottom: 25px;
    max-width: 728px;
    width: 100%;
}

/* 首页底部广告位（仅移动端显示） */
.adsense-home-bottom {
    margin-top: 35px;
    margin-bottom: 15px;
    max-width: 728px;
    width: 100%;
}

/* 首页左侧广告位（仅PC端显示） */
.adsense-home-left {
    width: 160px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    margin: 0;
    min-height: 600px;
    display: none; /* 默认隐藏，PC端显示 */
}

/* 首页右侧广告位（仅PC端显示） */
.adsense-home-right {
    width: 160px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    margin: 0;
    min-height: 600px;
    display: none; /* 默认隐藏，PC端显示 */
}

/* 结果页广告位 */
.adsense-result {
    margin: 25px auto;
    max-width: 728px;
    width: 100%;
}

/* 详情页底部广告位 */
.adsense-page-bottom {
    margin: 25px auto 15px;
    max-width: 728px;
    width: 100%;
}

/* 侧边栏广告位 */
.adsense-sidebar {
    width: 100%;
    max-width: 300px;
    margin: 0;
    min-height: 250px; /* 为侧边栏广告预留空间 */
}

/* 游戏页面侧边栏布局 */
.game-wrapper {
    display: flex;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    gap: 20px;
    align-items: flex-start;
}

.game-main {
    flex: 1;
    min-width: 0; /* 防止 flex 子元素溢出 */
}

.game-sidebar {
    width: 300px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    z-index: 5; /* 确保侧边栏在游戏内容之上，但在反馈覆盖层之下 */
    max-height: calc(100vh - 40px); /* 限制侧边栏最大高度，避免超出视口 */
    overflow-y: auto; /* 如果内容过多，允许滚动 */
}

/* 响应式设计：移动端隐藏侧边栏广告 */
@media (max-width: 1024px) {
    .game-wrapper {
        flex-direction: column;
        align-items: center; /* 居中对齐 */
    }
    
    .game-main {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center; /* 居中对齐 */
    }
    
    .game-sidebar {
        width: 100%;
        max-width: 728px;
        position: static;
        margin: 20px auto 0;
        order: -1; /* 在移动端将广告移到顶部 */
    }
    
    .adsense-sidebar {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .adsense-container {
        min-height: 50px;
        margin: 15px auto;
        padding: 8px;
    }
    
    .adsense-home-top {
        margin-top: 15px;
        margin-bottom: 20px;
    }
    
    .adsense-home-bottom {
        margin-top: 25px;
        margin-bottom: 10px;
    }
    
    .adsense-result {
        margin: 20px auto;
    }
    
    .adsense-page-bottom {
        margin: 20px auto 10px;
    }
    
    .adsense-sidebar {
        min-height: 100px; /* 移动端侧边栏广告最小高度 */
        max-width: 100%;
    }
    
    .game-sidebar {
        margin: 15px auto 0;
        max-height: none; /* 移动端取消最大高度限制 */
    }
    
    .game-wrapper {
        align-items: center; /* 确保移动端居中 */
    }
    
    .game-main {
        width: 100%;
        align-items: center; /* 确保移动端居中 */
    }
}

/* 确保广告不会影响页面布局 */
.adsbygoogle {
    display: block !important;
    margin: 0 auto;
    max-width: 100%;
    overflow: hidden;
}

/* 广告加载时的占位样式 */
.adsense-container:empty::before {
    content: '';
    display: block;
    width: 100%;
    height: 90px;
    opacity: 0;
}

@media (max-width: 768px) {
    .adsense-container:empty::before {
        height: 50px;
    }
}

/* 确保广告不会遮挡重要元素 */
.adsense-container {
    pointer-events: auto; /* 允许点击广告 */
}

/* 确保结果页和详情页的按钮区域不被遮挡 */
.result-actions,
.detail-actions {
    position: relative;
    z-index: 10; /* 确保按钮在广告之上 */
    margin-top: 20px;
}

/* 确保游戏内容区域不被侧边栏遮挡 */
.game-main {
    position: relative;
    z-index: 1; /* 确保游戏内容在侧边栏下方（视觉上） */
}

/* 确保反馈覆盖层始终在最上层 */
.feedback-overlay {
    z-index: 1000 !important; /* 确保反馈覆盖层在广告之上 */
}

/* ============================================
   统一的训练模块样式
   ============================================ */

/* 统一的难度按钮样式 */
.difficulty-btn {
    padding: 15px 20px;
    border: 2px solid #667eea;
    border-radius: 12px;
    background: #fff;
    color: #667eea;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    isolation: isolate; /* 创建新的层叠上下文，确保文字在伪元素之上 */
}

.difficulty-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: #667eea;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    z-index: -1; /* 负值确保在按钮内容（包括文字）下方 */
    pointer-events: none; /* 防止伪元素拦截点击事件 */
}

.difficulty-btn:hover::before,
.difficulty-btn.active::before {
    width: 300px;
    height: 300px;
}

.difficulty-btn:hover,
.difficulty-btn.active {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    position: relative; /* 确保文字在伪元素之上 */
    z-index: 1; /* 确保文字层级高于伪元素 */
}

/* 统一的主按钮样式 */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #fff;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: #fff;
    transform: translateY(-2px);
}

/* 统一的倒计时样式 */
.countdown-container {
    text-align: center;
}

.countdown-number {
    font-size: 8rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
    animation: countdownPulse 1s ease-in-out infinite;
    margin-bottom: 30px;
}

@keyframes countdownPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

.countdown-hint {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
}

.countdown-example {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    margin-top: 10px;
}

/* 响应式：倒计时 */
@media (max-width: 768px) {
    .countdown-number {
        font-size: 6rem;
    }
    
    .countdown-hint {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .countdown-number {
        font-size: 5rem;
    }
    
    .countdown-hint {
        font-size: 1rem;
    }
    
    .countdown-example {
        font-size: 0.9rem;
    }
}
