/* 晋剧消消乐独立页面样式 */

/* CSS变量定义 */
:root {
    --primary-color: #8B0000;
    --secondary-color: #DAA520;
    --text-color: #5A3E36;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --border-color: #e9ecef;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
    --nav-height: 60px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "华文楷体", "KaiTi", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #F4F1DE 0%, #E7D7C1 100%);
    color: var(--text-color);
    margin: 0;
    padding: 60px 0 80px 0;
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== 顶部导航栏 ===== */
.top-nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    background: linear-gradient(135deg, var(--primary-color) 0%, #A52A2A 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.top-nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    max-width: 100%;
}

.back-button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    width: 40px;
    height: 40px;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.back-button i {
    font-size: 1rem;
}

.nav-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

.nav-title i {
    font-size: 1.3rem;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}


/* ===== 游戏主容器 ===== */
.game-main-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 80px 15px 90px 15px; /* 顶部留出导航栏空间，底部保留导航栏空间 */
    min-height: calc(100vh - 140px);
}


/* ===== 游戏时长选择器 ===== */
.time-selector {
    margin: 20px 0;
    text-align: center;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.time-selector label {
    font-size: 1.1rem;
    color: var(--text-dark);
    margin-right: 15px;
    font-weight: 500;
}

.time-select {
    padding: 10px 20px;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    background: white;
    color: var(--text-dark);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    min-width: 200px;
}

.time-select:hover {
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(232, 199, 195, 0.3);
}

.time-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(232, 199, 195, 0.2);
}

.time-select option {
    padding: 8px;
    background: white;
    color: var(--text-dark);
}

/* ===== 游戏统计信息 ===== */
.game-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 25px 0;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stat-item i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--text-dark);
}

.stat-unit {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ===== 开始挑战按钮 ===== */
.start-game-container {
    margin: 30px 0;
    text-align: center;
}

.start-game-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, #A52A2A 100%);
    color: white;
    border: none;
    padding: 18px 40px;
    border-radius: 15px;
    font-size: 1.3rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(165, 42, 42, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: "华文楷体", "KaiTi", "Microsoft YaHei", sans-serif;
    position: relative;
    overflow: hidden;
}

.start-game-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.start-game-btn:hover::before {
    left: 100%;
}

.start-game-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(165, 42, 42, 0.4);
    background: linear-gradient(135deg, var(--accent-color) 0%, #8B0000 100%);
}

.start-game-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(165, 42, 42, 0.3);
}

.start-game-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.start-game-btn i {
    font-size: 1.2rem;
}

/* 切换图集按钮样式（与开始按钮视觉一致） */
.toggle-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, #A52A2A 100%);
    color: white;
    border: none;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.toggle-btn.active {
    box-shadow: 0 6px 20px rgba(165, 42, 42, 0.3);
    transform: translateY(-2px);
    background: linear-gradient(135deg, var(--accent-color) 0%, #8B0000 100%);
}

.toggle-btn:hover {
    transform: translateY(-2px);
}

/* ===== 游戏网格 ===== */
.game-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

.grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    background: var(--card-bg);
    padding: 15px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    max-width: 450px; /* 增加最大宽度 */
    width: 100%;
    min-height: 400px; /* 增加最小高度 */
}

.cell {
    aspect-ratio: 1;
    background: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem; /* 增加字体大小 */
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 2px solid transparent;
    min-height: 45px; /* 增加最小高度 */
    position: relative;
    overflow: hidden;
}

/* 确保格子内图片完整可见（不裁切），并填充格子 */
.cell img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 显示完整图片，不裁切 */
    display: block;
}

.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.cell:hover::before {
    transform: translateX(100%);
}

.cell:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.cell.selected {
    border-color: var(--accent-color);
    background: rgba(232, 199, 195, 0.2);
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(232, 199, 195, 0.3);
}

.cell.matched {
    animation: matchAnimation 0.6s ease-out;
    background: rgba(165, 201, 183, 0.3);
}

@keyframes matchAnimation {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ===== 游戏结束提示 ===== */
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.game-over.show {
    display: flex;
    animation: fadeIn 0.5s ease-in;
}

.game-over-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 300px;
    width: 90%;
}

.game-over-content i {
    font-size: 3rem;
    color: #FFD700;
    margin-bottom: 20px;
}

.game-over-content h2 {
    font-size: 1.8rem;
    color: var(--text-dark);
    margin-bottom: 15px;
    font-family: "华文楷体", "KaiTi", "Microsoft YaHei", sans-serif;
}

.final-score {
    font-size: 1.2rem;
    color: var(--text-light);
    margin-bottom: 25px;
}

.final-score span {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.4rem;
}

.restart-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, #A52A2A 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: "华文楷体", "KaiTi", "Microsoft YaHei", sans-serif;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(165, 42, 42, 0.3);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}


/* ===== 底部导航栏 ===== */
.nav-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.8rem 0;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    border-top: 2px solid var(--secondary-color);
}

.nav-item {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
    border-radius: 25px;
    transition: var(--transition);
    background: var(--primary-color);
    border: 2px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    overflow: hidden;
    flex: 1;
    justify-content: center;
    min-height: 44px;
}

.nav-item i {
    font-size: 1.1rem;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.nav-item.active {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* 移动端触摸时的:active伪类样式 */
.nav-item:active {
    background: var(--primary-color);
    color: white;
    border-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* 确保只有当前页面的导航项保持高亮状态 */
.nav-item:not(.active) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: none;
    box-shadow: none;
}

.nav-item:not(.active):hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.nav-item:hover i {
    color: var(--secondary-color);
    transform: scale(1.1);
}

/* 游戏导航按钮样式 - 与其他导航项保持一致 */
/* 使用默认 .nav-item 样式，无需额外规则 */

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .game-main-container {
        padding: 70px 10px 90px 10px; /* 顶部留出导航栏空间，底部保留导航栏空间 */
    }
    
    
    .time-selector {
        padding: 15px;
        margin: 15px 0;
    }
    
    .time-selector label {
        font-size: 1.1rem;
        margin-right: 10px;
    }
    
    .time-select {
        padding: 8px 15px;
        font-size: 1rem;
        min-width: 150px;
    }
    
    .game-stats {
        gap: 30px;
        margin: 20px 0;
        padding: 15px;
    }
    
    .stat-item i {
        font-size: 1.4rem;
    }
    
    .stat-value {
        font-size: 1.6rem;
    }
    
    .stat-unit {
        font-size: 0.9rem;
        color: var(--text-light);
    }
    
    .start-game-btn {
        padding: 15px 30px;
        font-size: 1.3rem;
    }
    
    .grid {
        gap: 4px;
        padding: 15px;
        max-width: 450px; /* 增大移动端最大宽度 */
        min-height: 400px; /* 增大移动端最小高度 */
    }
    
    .cell {
        font-size: 2.2rem; /* 增大移动端字体大小 */
        border-radius: 10px;
        min-height: 55px; /* 增大移动端最小高度 */
    }
    
}

@media (max-width: 480px) {
    .nav-item {
        padding: 0.6rem 0;
        border-radius: 15px;
        font-size: 0.8rem;
        margin: 0;
        flex: 1 1 auto;
        justify-content: center;
    }
    
    .nav-item span {
        display: none;
    }
    
    .nav-item i {
        font-size: 1.3rem;
    }
    
    .game-main-container {
        padding: 60px 8px 90px 8px; /* 顶部留出导航栏空间，底部保留导航栏空间 */
    }
    
    
    .time-selector {
        padding: 12px;
        margin: 12px 0;
    }
    
    .time-selector label {
        font-size: 1rem;
        margin-right: 8px;
    }
    
    .time-select {
        padding: 6px 12px;
        font-size: 0.9rem;
        min-width: 120px;
    }
    
    .game-stats {
        gap: 20px;
        margin: 15px 0;
        padding: 12px;
    }
    
    .stat-item i {
        font-size: 1.3rem;
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    .stat-unit {
        font-size: 0.8rem;
        color: var(--text-light);
    }
    
    .start-game-btn {
        padding: 12px 25px;
        font-size: 1.2rem;
    }
    
    .grid {
        gap: 4px;
        padding: 12px;
        max-width: 400px; /* 增大小屏幕最大宽度 */
        min-height: 360px; /* 增大小屏幕最小高度 */
    }
    
    .cell {
        font-size: 1.8rem; /* 增大小屏幕字体大小 */
        border-radius: 8px;
        min-height: 45px; /* 增大小屏幕最小高度 */
    }
    
}

/* 触摸优化 */
@media (max-width: 768px) {
    .nav-item {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
        margin: 0;
        flex: 1 1 auto;
        justify-content: center;
        border-radius: 20px;
    }
    
    .nav-item span {
        display: none;
    }
    
    .nav-item i {
        font-size: 1.2rem;
    }
    
    .cell {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    .cell:active {
        transform: scale(0.95);
    }
    
    .nav-item {
        -webkit-tap-highlight-color: transparent;
    }
}

/* ===== 深色模式样式 ===== */
body.dark-theme {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #e0e0e0;
}

body.dark-theme .game-container {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

body.dark-theme .game-header {
    background: rgba(45, 45, 45, 0.9);
    border: 1px solid #404040;
}

body.dark-theme .game-title {
    color: #e0e0e0;
}

body.dark-theme .game-subtitle {
    color: #b0b0b0;
}

body.dark-theme .game-controls {
    background: rgba(45, 45, 45, 0.9);
    border: 1px solid #404040;
}

body.dark-theme .time-selector {
    background: #2d2d2d;
    border: 1px solid #404040;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

body.dark-theme .time-selector label {
    color: #e0e0e0;
}

body.dark-theme .time-select {
    background: #1a1a1a;
    border: 1px solid #404040;
    color: #e0e0e0;
}

body.dark-theme .game-stats {
    background: #2d2d2d;
    border: 1px solid #404040;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

body.dark-theme .stat-item {
    background: #2d2d2d;
    border: 1px solid #404040;
}

body.dark-theme .stat-item i {
    color: #DAA520;
}

body.dark-theme .stat-value {
    color: #e0e0e0;
}

body.dark-theme .stat-unit {
    color: #b0b0b0;
}

body.dark-theme .start-game-btn {
    background: linear-gradient(135deg, #8B0000, #A52A2A);
    color: #fff;
    border: 1px solid #DAA520;
}

body.dark-theme .start-game-btn:hover {
    background: linear-gradient(135deg, #A52A2A, #8B0000);
    box-shadow: 0 4px 12px rgba(139, 0, 0, 0.4);
}

body.dark-theme .grid {
    background: #2d2d2d;
    border: 1px solid #404040;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

body.dark-theme .cell {
    background: #2d2d2d;
    border: 1px solid #404040;
    color: #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-theme .cell:hover {
    background: rgba(139, 0, 0, 0.2);
    border-color: #DAA520;
}

body.dark-theme .cell.selected {
    background: linear-gradient(135deg, #8B0000, #A52A2A);
    border-color: #DAA520;
    color: #fff;
}

body.dark-theme .cell.matched {
    background: linear-gradient(135deg, #DAA520, #FFD700);
    color: #1a1a1a;
}

body.dark-theme .nav-menu {
    background: rgba(45, 45, 45, 0.95);
    border-top-color: #DAA520;
}

body.dark-theme .nav-item {
    background: linear-gradient(135deg, #8B0000, #A52A2A);
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.4);
}

body.dark-theme .nav-item.active {
    background: linear-gradient(135deg, #DAA520, #FFD700);
    color: #1a1a1a;
    box-shadow: 0 4px 12px rgba(218, 165, 32, 0.4);
}

body.dark-theme .nav-item:hover {
    box-shadow: 0 4px 12px rgba(139, 0, 0, 0.5);
}

/* 深色模式主题切换按钮 */
body.dark-theme .theme-toggle-btn {
    background: linear-gradient(135deg, #DAA520, #FFD700) !important;
    color: #1a1a1a !important;
    box-shadow: 0 4px 12px rgba(218, 165, 32, 0.4) !important;
}

/* ===== 主题切换动画 ===== */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

.game-container,
.game-header,
.game-controls,
.time-selector,
.game-stats,
.stat-item,
.start-game-btn,
.grid,
.cell,
.nav-menu,
.nav-item {
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}