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

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%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

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

.container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
}

/* 首页样式 */
.title {
    font-size: 2.5rem;
    color: #fff;
    text-align: center;
    margin-bottom: 30px;
    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);
    }
}

.intro-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: scaleIn 0.5s ease-out;
    position: relative;
}

.help-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #667eea;
    background: #fff;
    color: #667eea;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.help-btn:hover {
    background: #667eea;
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.help-btn:active {
    transform: scale(0.95);
}

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

.intro-card {
    margin-bottom: 20px;
}

.intro-card h2 {
    font-size: 1.3rem;
    color: #667eea;
    margin-bottom: 10px;
}

.intro-card p {
    font-size: 1rem;
    color: #666;
    line-height: 1.6;
}

.difficulty-selector {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 2px solid #eee;
}

.difficulty-selector h3 {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 15px;
    text-align: center;
}

.difficulty-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 15px;
}

/* 难度按钮样式使用主styles.css中的统一样式，这里只保留必要的覆盖 */
/* 如果需要自定义，请确保遵循主样式的层级结构 */

.difficulty-info {
    background: #f5f5f5;
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
    text-align: center;
}

.difficulty-info p {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.6;
}

.rule-info {
    margin-top: 25px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    color: #fff;
    font-size: 1rem;
    line-height: 1.8;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.rule-info strong {
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 按钮样式已移至主styles.css */

/* 倒计时样式已移至主styles.css */

/* 训练页 */
#game-screen.screen {
    display: none;
}

#game-screen.screen.active {
    display: flex;
    flex-direction: column;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    justify-content: flex-start;
}

/* 游戏页面侧边栏布局 */
.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;
}

.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;
    }
}

@media (max-width: 768px) {
    .game-sidebar {
        margin: 15px auto 0;
    }
    
    .game-wrapper {
        align-items: center; /* 确保移动端居中 */
    }
    
    .game-main {
        width: 100%;
        align-items: center; /* 确保移动端居中 */
    }
    
    .game-header {
        margin-left: auto;
        margin-right: auto;
    }
}

.game-header {
    width: 100%;
    max-width: 500px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.timer-container {
    text-align: center;
    flex: 1;
    min-width: 120px;
}

.timer-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.timer {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    animation: timerPulse 1s ease-in-out infinite;
}

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

.progress-container {
    text-align: center;
    flex: 1;
    min-width: 150px;
}

.progress-text {
    font-size: 1rem;
    color: #333;
    margin-bottom: 5px;
    font-weight: 600;
}

.item-timer-container {
    text-align: center;
    padding: 12px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
    border-radius: 10px;
    margin-top: 10px;
    border: 2px solid #ffc107;
}

.item-timer-label {
    font-size: 0.85rem;
    color: #856404;
    margin-bottom: 5px;
    font-weight: 600;
}

.item-timer {
    font-size: 2rem;
    font-weight: bold;
    color: #856404;
    font-variant-numeric: tabular-nums;
}

.item-timer.warning {
    color: #ff6b6b;
    animation: timerWarning 0.5s ease-in-out infinite;
}

@keyframes timerWarning {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.item-timer.danger {
    color: #f44336;
    animation: timerDanger 0.3s ease-in-out infinite;
}

@keyframes timerDanger {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0px;
    width: 100%;
    max-width: 500px;
}

.item-display {
    width: 100%;
    margin-bottom: 30px;
}

.item-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: itemAppear 0.5s ease-out;
}

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

.item-image {
    font-size: 6rem;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

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

.item-name {
    font-size: 1.5rem;
    color: #333;
    font-weight: 600;
    margin-bottom: 10px;
}

.item-info {
    font-size: 1rem;
    color: #666;
    margin-top: 10px;
}

.category-buttons-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0px;
    width: 100%;
    max-width: 500px;
}

.category-buttons {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 15px;
}

.category-btn {
    padding: 20px;
    border: 3px solid #667eea;
    background: rgba(255, 255, 255, 0.95);
    color: #667eea;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.category-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.4s, height 0.4s;
    z-index: 0;
}

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

.category-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.category-btn:active {
    transform: translateY(-1px);
}

.category-btn span {
    position: relative;
    z-index: 1;
}

.category-icon {
    font-size: 2rem;
    position: relative;
    z-index: 1;
}

.category-label {
    position: relative;
    z-index: 1;
}

.category-btn.correct {
    background: #4caf50;
    border-color: #4caf50;
    color: #fff;
    animation: correctPulse 0.5s ease-out;
}

.category-btn.error {
    background: #f44336;
    border-color: #f44336;
    color: #fff;
    animation: errorShake 0.5s ease-out;
}

.category-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: #fff;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

@keyframes correctPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes errorShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

/* 多维度分类按钮组 */
.dimension-group {
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dimension-label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
    text-align: center;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.multi-dimension-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.feedback-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    pointer-events: none;
}

.feedback-icon {
    font-size: 5rem;
    animation: feedbackPop 0.6s ease-out;
}

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

/* 结果页 */
.result-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: scaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.result-title {
    font-size: 2rem;
    color: #667eea;
    text-align: center;
    margin-bottom: 30px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(245, 245, 245, 0.9) 100%);
    border-radius: 18px;
    padding: 25px 20px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 2px solid rgba(102, 126, 234, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.stat-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.3);
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 详情页 */
.detail-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: scaleIn 0.5s ease-out;
}

.detail-title {
    font-size: 1.8rem;
    color: #667eea;
    text-align: center;
    margin-bottom: 30px;
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.detail-card {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.detail-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

.detail-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: #667eea;
}

.detail-actions {
    display: flex;
    flex-direction: column;
}

/* 帮助模态框 */
.help-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-in-out;
}

.help-modal.active {
    display: flex;
}

.help-modal-content {
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    margin: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: scaleIn 0.3s ease-out;
}

.help-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.help-modal-header h2 {
    font-size: 1.5rem;
    color: #667eea;
}

.close-help-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #f5f5f5;
    color: #666;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-help-btn:hover {
    background: #667eea;
    color: #fff;
    transform: rotate(90deg);
}

.help-modal-body h3 {
    font-size: 1.2rem;
    color: #333;
    margin: 20px 0 10px 0;
}

.help-modal-body p {
    font-size: 1rem;
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
}

.help-modal-body ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.help-modal-body li {
    font-size: 1rem;
    color: #666;
    line-height: 1.8;
    margin-bottom: 8px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }
    
    .difficulty-options {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .category-buttons {
        grid-template-columns: repeat(1, 1fr);
    }
    
    .result-stats,
    .detail-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .item-image {
        font-size: 5rem;
    }
    
    .item-name {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.8rem;
    }
    
    .category-buttons {
        grid-template-columns: 1fr;
    }
    
    .multi-dimension-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .result-stats,
    .detail-stats {
        grid-template-columns: 1fr;
    }
    
    .item-image {
        font-size: 4rem;
    }
    
    .item-name {
        font-size: 1.2rem;
    }
}
