/* ==================== 全局样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 复古游戏配色 */
    --primary-color: #FF6B6B;
    --secondary-color: #4ECDC4;
    --accent-color: #FFE66D;
    --dark-bg: #1A1A2E;
    --light-bg: #16213E;
    --text-light: #EAEAEA;
    --text-dark: #0F3460;
    
    /* 动画参数 */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

body {
    font-family: 'Press Start 2P', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--light-bg) 100%);
    color: var(--text-light);
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.hidden {
    display: none !important;
}

.page {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.5s ease;
    overflow: hidden;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== 加载屏幕 ==================== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: slideUp 0.5s ease 2s forwards;
}

@keyframes slideUp {
    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

.loading-content {
    text-align: center;
}

.loading-logo {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 30px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.loading-bar {
    width: 300px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin: 20px auto;
    border: 2px solid var(--secondary-color);
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--secondary-color);
}

.loading-text {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 10px;
}

/* ==================== 首页样式 ==================== */
.home-container {
    text-align: center;
    max-width: 800px;
    width: 100%;
    transform-origin: center center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.main-title {
    font-size: 72px;
    margin-bottom: 20px;
    line-height: 1.2;
    text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.3);
}

.title-mm {
    color: var(--primary-color);
    animation: bounceIn 1s ease;
}

.title-64 {
    color: var(--secondary-color);
    animation: bounceIn 1s ease 0.2s backwards;
}

@keyframes bounceIn {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.subtitle {
    font-size: 14px;
    color: var(--accent-color);
    margin-bottom: 40px;
    letter-spacing: 2px;
}

.grid-showcase {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-width: 400px;
    margin: 0 auto 40px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 2px solid var(--secondary-color);
}

.showcase-cell {
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--light-bg), var(--dark-bg));
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--transition-fast);
    cursor: pointer;
    animation: floatIn 0.5s ease backwards;
}

.showcase-cell:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 0 15px var(--secondary-color);
}

@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.home-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.btn {
    padding: 15px 30px;
    font-size: 12px;
    font-family: 'Press Start 2P', sans-serif;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #ff5252;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #3dbdb3;
}

.btn-hint {
    background: var(--accent-color);
    color: var(--text-dark);
}

.btn-hint:hover {
    background: #ffd93d;
}

.btn-icon {
    font-size: 16px;
}

.home-footer {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 20px;
}

.beian-link {
    color: inherit;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.beian-link:hover {
    color: var(--accent-color);
}

/* ==================== 规则页面 ==================== */
.rules-container {
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    background: rgba(255, 255, 255, 0.05);
    padding: 40px;
    border-radius: 20px;
    border: 2px solid var(--secondary-color);
    overflow-y: auto;
    transform-origin: center center;
}

.page-title {
    font-size: 32px;
    text-align: center;
    margin-bottom: 40px;
    color: var(--accent-color);
}

.rules-content {
    margin-bottom: 30px;
}

/* 规则容器滚动条样式 */
.rules-container::-webkit-scrollbar {
    width: 8px;
}

.rules-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.rules-container::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

.rules-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.rule-item {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    animation: slideInLeft 0.5s ease backwards;
}

.rule-item:nth-child(1) { animation-delay: 0.1s; }
.rule-item:nth-child(2) { animation-delay: 0.2s; }
.rule-item:nth-child(3) { animation-delay: 0.3s; }
.rule-item:nth-child(4) { animation-delay: 0.4s; }

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.rule-number {
    font-size: 24px;
    color: var(--primary-color);
    min-width: 50px;
}

.rule-text h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--secondary-color);
}

.rule-text p {
    font-size: 10px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
}

/* ==================== 游戏页面 ==================== */
.game-container {
    max-width: 500px;
    width: 100%;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transform-origin: center center;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 10px;
    border: 2px solid var(--secondary-color);
}

.score-panel {
    display: flex;
    gap: 30px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 8px;
    color: rgba(255, 255, 255, 0.6);
}

.stat-value {
    font-size: 16px;
    color: var(--accent-color);
}

.btn-icon-only {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon-only:hover {
    background: #ff5252;
    transform: rotate(90deg);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 2px solid var(--secondary-color);
}

.game-cell {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #2C3E50, #34495E);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    user-select: none;
}

.game-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.game-cell.selected {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent-color);
    animation: selectedPulse 0.5s ease infinite;
}

@keyframes selectedPulse {
    0%, 100% { box-shadow: 0 0 20px var(--accent-color); }
    50% { box-shadow: 0 0 30px var(--accent-color); }
}

.game-cell.matched {
    animation: matchAnimation 0.5s ease forwards;
}

@keyframes matchAnimation {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3) rotate(180deg);
        opacity: 0.5;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.game-footer {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* ==================== 弹窗样式 ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: linear-gradient(135deg, var(--dark-bg), var(--light-bg));
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 3px solid var(--secondary-color);
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.victory-icon,
.gameover-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.victory-title,
.gameover-title {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--accent-color);
}

.victory-score,
.gameover-score {
    font-size: 16px;
    margin-bottom: 20px;
    color: var(--text-light);
}

.victory-stars {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    font-size: 32px;
}

.star {
    animation: starPop 0.5s ease backwards;
}

.star:nth-child(1) { animation-delay: 0.1s; }
.star:nth-child(2) { animation-delay: 0.2s; }
.star:nth-child(3) { animation-delay: 0.3s; }

@keyframes starPop {
    from {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.gameover-message {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
}

/* ==================== 粒子效果 ==================== */
#particlesContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: particleFloat 1s ease-out forwards;
}

@keyframes particleFloat {
    to {
        transform: translateY(-100px) scale(0);
        opacity: 0;
    }
}

/* ==================== 64暴击特效 ==================== */
.blast-effect {
    animation: blastFlash 0.5s ease;
}

@keyframes blastFlash {
    0%, 100% { background: linear-gradient(135deg, var(--dark-bg) 0%, var(--light-bg) 100%); }
    25%, 75% { background: linear-gradient(135deg, var(--accent-color) 0%, var(--primary-color) 100%); }
    50% { background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%); }
}

/* ==================== 响应式设计 ==================== */
/* ==================== 响应式设计 ==================== */

/* 排行榜样式 */
.leaderboard {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid var(--secondary-color);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 100;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
}

.leaderboard.collapsed .leaderboard-content {
    display: none;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid rgba(78, 205, 196, 0.3);
}

.leaderboard-title {
    font-size: 14px;
    color: var(--accent-color);
    margin: 0;
}

.leaderboard-toggle {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 20px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    transition: all var(--transition-fast);
}

.leaderboard-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.leaderboard-content {
    padding: 10px;
    max-height: 500px;
    overflow-y: auto;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rank-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all var(--transition-fast);
    animation: slideInRight 0.3s ease backwards;
}

.rank-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-5px);
}

.rank-item:nth-child(1) { animation-delay: 0.05s; }
.rank-item:nth-child(2) { animation-delay: 0.1s; }
.rank-item:nth-child(3) { animation-delay: 0.15s; }
.rank-item:nth-child(4) { animation-delay: 0.2s; }
.rank-item:nth-child(5) { animation-delay: 0.25s; }
.rank-item:nth-child(6) { animation-delay: 0.3s; }
.rank-item:nth-child(7) { animation-delay: 0.35s; }
.rank-item:nth-child(8) { animation-delay: 0.4s; }
.rank-item:nth-child(9) { animation-delay: 0.45s; }
.rank-item:nth-child(10) { animation-delay: 0.5s; }

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.rank-number {
    font-size: 16px;
    font-weight: bold;
    min-width: 30px;
    text-align: center;
}

.rank-item:nth-child(1) .rank-number {
    color: #FFD700;
    text-shadow: 0 0 10px #FFD700;
}

.rank-item:nth-child(2) .rank-number {
    color: #C0C0C0;
    text-shadow: 0 0 10px #C0C0C0;
}

.rank-item:nth-child(3) .rank-number {
    color: #CD7F32;
    text-shadow: 0 0 10px #CD7F32;
}

.rank-info {
    flex: 1;
    overflow: hidden;
}

.rank-nickname {
    font-size: 11px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.rank-score {
    font-size: 10px;
    color: var(--secondary-color);
}

.rank-time {
    font-size: 8px;
    color: rgba(255, 255, 255, 0.5);
}

.loading-ranks {
    text-align: center;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    padding: 20px;
}

/* 排行榜滚动条 */
.leaderboard-content::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.leaderboard-content::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 3px;
}

.leaderboard-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* 昵称输入样式 */
.nickname-input-group {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    align-items: center;
}

.nickname-input {
    flex: 1;
    padding: 12px 15px;
    font-size: 12px;
    font-family: 'Press Start 2P', sans-serif;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    color: var(--text-light);
    outline: none;
    transition: all var(--transition-fast);
}

.nickname-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(255, 230, 109, 0.3);
}

.nickname-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.btn-submit {
    padding: 12px 20px;
    font-size: 10px;
}

.submit-message {
    font-size: 10px;
    min-height: 20px;
    margin-bottom: 10px;
    transition: all var(--transition-fast);
}

.submit-message.success {
    color: var(--secondary-color);
    animation: fadeIn 0.3s ease;
}

.submit-message.error {
    color: var(--primary-color);
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* 移动端排行榜样式 */
@media (max-width: 768px) {
    .leaderboard {
        right: auto;
        left: 50%;
        top: auto;
        bottom: 0;
        transform: translateX(-50%);
        width: 100%;
        max-width: 100%;
        border-radius: 15px 15px 0 0;
        max-height: 40vh;
    }
    
    .leaderboard.collapsed {
        max-height: 60px;
    }
    
    .leaderboard-content {
        max-height: calc(40vh - 60px);
    }
    
    .leaderboard-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        gap: 10px;
        padding: 5px;
    }
    
    .rank-item {
        min-width: 200px;
        flex-shrink: 0;
    }
    
    .leaderboard-list::-webkit-scrollbar {
        height: 6px;
    }
    
    .leaderboard-list::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
        border-radius: 3px;
    }
    
    .leaderboard-list::-webkit-scrollbar-thumb {
        background: var(--secondary-color);
        border-radius: 3px;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .home-container {
        transform: scale(0.85);
    }
    
    .rules-container {
        transform: scale(0.85);
        max-height: 85vh;
    }
    
    .game-container {
        transform: scale(0.85);
    }
    
    .main-title {
        font-size: 48px;
    }
    
    .subtitle {
        font-size: 10px;
    }
    
    .grid-showcase {
        max-width: 300px;
        gap: 3px;
    }
    
    .showcase-cell {
        font-size: 12px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 10px;
    }
    
    .game-board {
        gap: 3px;
        padding: 8px;
    }
    
    .game-cell {
        font-size: 16px;
    }
    
    .page-title {
        font-size: 24px;
    }
    
    .rule-text h3 {
        font-size: 12px;
    }
    
    .rule-text p {
        font-size: 8px;
    }
}

@media (max-width: 480px) {
    .nickname-input {
        font-size: 10px;
        padding: 10px 12px;
    }
    
    .btn-submit {
        padding: 10px 15px;
        font-size: 9px;
    }
    
    .home-footer {
        font-size: 8px;
    }
    
    .home-container {
        transform: scale(0.7);
    }
    
    .rules-container {
        transform: scale(0.7);
        max-height: 80vh;
    }
    
    .game-container {
        transform: scale(0.7);
    }
    
    .main-title {
        font-size: 36px;
    }
    
    .grid-showcase {
        max-width: 250px;
    }
    
    .home-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 250px;
        justify-content: center;
    }
    
    .score-panel {
        gap: 15px;
    }
    
    .stat-value {
        font-size: 14px;
    }
}
