/**
 * 游戏页面通用样式
 */

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.game-title {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
}

.game-info {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.info-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--secondary-color);
}

.game-canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
}

.game-canvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 2px solid var(--secondary-color);
    background: #000;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.game-instructions {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.instructions-title {
    font-size: 1.125rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.instructions-list {
    list-style: none;
    padding: 0;
}

.instructions-list li {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

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

.instructions-list li::before {
    content: '▶';
    color: var(--primary-color);
    margin-right: 0.5rem;
}

/* 触摸控制按钮（移动端） */
.touch-controls {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 2rem;
}

.touch-controls.active {
    display: grid;
}

.touch-btn {
    padding: 1.5rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    transition: all 0.2s ease;
}

.touch-btn:active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(0.95);
}

.touch-btn.direction-up { grid-column: 2; }
.touch-btn.direction-left { grid-column: 1; grid-row: 2; }
.touch-btn.direction-down { grid-column: 2; grid-row: 2; }
.touch-btn.direction-right { grid-column: 3; grid-row: 2; }

/* 游戏状态提示 */
.game-status {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.game-status.success {
    background: rgba(80, 200, 120, 0.2);
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
}

.game-status.error {
    background: rgba(231, 76, 60, 0.2);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.game-status.info {
    background: rgba(74, 144, 226, 0.2);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

/* 响应式调整 */
@media (max-width: 767px) {
    .game-container {
        padding: 0.25rem;
    }
    
    .game-header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 0.5rem;
        gap: 0.25rem;
    }
    
    .game-title {
        font-size: 1.25rem;
    }
    
    .game-info {
        width: 100%;
        justify-content: space-around;
        gap: 0.5rem;
    }
    
    .info-item {
        gap: 0;
    }
    
    .info-label {
        font-size: 0.6rem;
    }
    
    .info-value {
        font-size: 1rem;
    }
    
    .game-canvas-container {
        padding: 4px;
        margin-bottom: 0.5rem;
        border-radius: 6px;
    }
    
    .game-instructions {
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .instructions-title {
        font-size: 0.85rem;
        margin-bottom: 0.35rem;
    }
    
    .instructions-list li {
        font-size: 0.7rem;
        padding: 0.2rem 0;
    }
    
    .footer {
        font-size: 0.65rem;
    }
    
    .footer p {
        margin: 0.1rem 0;
        line-height: 1.3;
    }
    
    .touch-controls {
        display: grid;
    }
}

/* 游戏特定样式 */
.score-display {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--secondary-color);
}

.high-score-display {
    font-size: 1rem;
    color: var(--text-secondary);
}

.level-display {
    font-size: 1.125rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* ===== 井字棋样式 ===== */
.tic-tac-toe-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    background: var(--border-color);
    padding: 4px;
    border-radius: 8px;
    width: min(300px, 100%);
    aspect-ratio: 1;
}

.cell {
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
    min-height: 60px;
    user-select: none;
}

.cell:hover:not(.disabled) {
    background: rgba(74, 144, 226, 0.25);
}

.cell.disabled {
    cursor: default;
}

.cell.x {
    color: #4a90e2;
}

.cell.o {
    color: #50c878;
}

/* ===== 2048 样式 ===== */
.game-2048-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.grid-2048 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: #bbada0;
    padding: 8px;
    border-radius: 8px;
    width: min(360px, 100%);
    aspect-ratio: 1;
    position: relative;
}

.tile {
    background: #cdc1b4;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #776e65;
    aspect-ratio: 1;
    transition: transform 0.15s;
}

.tile[data-value="2"]   { background: #eee4da; }
.tile[data-value="4"]   { background: #ede0c8; }
.tile[data-value="8"]   { background: #f2b179; color: #f9f6f2; }
.tile[data-value="16"]  { background: #f59563; color: #f9f6f2; }
.tile[data-value="32"]  { background: #f67c5f; color: #f9f6f2; }
.tile[data-value="64"]  { background: #f65e3b; color: #f9f6f2; }
.tile[data-value="128"] { background: #edcf72; color: #f9f6f2; font-size: 1.25rem; }
.tile[data-value="256"] { background: #edcc61; color: #f9f6f2; font-size: 1.25rem; }
.tile[data-value="512"] { background: #edc850; color: #f9f6f2; font-size: 1.25rem; }
.tile[data-value="1024"]{ background: #edc53f; color: #f9f6f2; font-size: 1rem; }
.tile[data-value="2048"]{ background: #edc22e; color: #f9f6f2; font-size: 1rem; }

/* ===== 记忆翻牌样式 ===== */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-width: 400px;
    margin: 0 auto;
}

.memory-card {
    aspect-ratio: 1;
    position: relative;
    cursor: pointer;
    perspective: 600px;
    min-height: 70px;
}

.memory-card .card-back,
.memory-card .card-front {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.5rem;
    backface-visibility: hidden;
    transition: transform 0.4s;
}

.memory-card .card-back {
    background: var(--primary-color);
    color: var(--text-primary);
    font-size: 2rem;
}

.memory-card .card-front {
    background: var(--card-bg);
    color: var(--text-primary);
    transform: rotateY(180deg);
    font-size: 2rem;
}

.memory-card.flipped .card-back {
    transform: rotateY(180deg);
}

.memory-card.flipped .card-front {
    transform: rotateY(0deg);
}

.memory-card.matched .card-front {
    background: rgba(80, 200, 120, 0.3);
    border: 2px solid var(--secondary-color);
}

@media (max-width: 480px) {
    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
    .memory-card .card-back,
    .memory-card .card-front {
        font-size: 1.25rem;
    }
    .minesweeper-grid {
        max-width: 340px;
        gap: 1px;
        padding: 3px;
    }
    .minesweeper-grid .cell {
        font-size: 0.7rem;
    }
}

/* ===== 扫雷样式 ===== */
.minesweeper-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 2px;
    max-width: 500px;
    margin: 0 auto;
    background: #2c2c2c;
    padding: 4px;
    border-radius: 8px;
}

.minesweeper-grid .cell {
    aspect-ratio: 1;
    background: #3a3a3a;
    border: 1px solid #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 3px;
    user-select: none;
    transition: background 0.15s;
    color: #fff;
    width: auto;
    height: auto;
}

.minesweeper-grid .cell:hover {
    background: #4a4a4a;
}

.minesweeper-grid .cell.revealed {
    background: #555;
    cursor: default;
}

.minesweeper-grid .cell.revealed:hover {
    background: #555;
}

.minesweeper-grid .cell.mine {
    background: #e74c3c;
}

.minesweeper-grid .cell.flagged {
    background: #2a2a4a;
}

.minesweeper-grid .cell[data-count="1"] { color: #3498db; }
.minesweeper-grid .cell[data-count="2"] { color: #2ecc71; }
.minesweeper-grid .cell[data-count="3"] { color: #e74c3c; }
.minesweeper-grid .cell[data-count="4"] { color: #9b59b6; }
.minesweeper-grid .cell[data-count="5"] { color: #e67e22; }
.minesweeper-grid .cell[data-count="6"] { color: #1abc9c; }
.minesweeper-grid .cell[data-count="7"] { color: #ecf0f1; }
.minesweeper-grid .cell[data-count="8"] { color: #95a5a6; }

/* ===== 打地鼠样式 ===== */
.mole-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 550px;
    margin: 0 auto;
}

.mole-hole {
    aspect-ratio: 1;
    background: #5D4037;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 4px solid #3E2723;
}

.mole {
    position: absolute;
    bottom: -100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 4.2rem;
    transition: bottom 0.15s ease;
    z-index: 1;
}

.mole.active {
    bottom: 8%;
}

.mole.hit {
    bottom: 8%;
    filter: brightness(0.4) sepia(1);
}

/* ===== 拼图样式 ===== */
.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    max-width: 360px;
    margin: 0 auto;
    aspect-ratio: 1;
    background: #333;
    padding: 4px;
    border-radius: 8px;
}

.puzzle-piece {
    background: #4a90e2;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 4px;
    width: 100%;
    aspect-ratio: 1;
    cursor: default;
    transition: transform 0.15s, background 0.15s;
}

.puzzle-piece:hover:not(.empty) {
    transform: scale(0.95);
    background: #5aa0f2;
}

.puzzle-piece.empty {
    background: transparent;
    cursor: default;
}

/* ===== 倒水谜题样式 ===== */
.tubes-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 0;
    min-height: 200px;
}

.tube {
    width: 48px;
    height: 160px;
    background: rgba(255,255,255,0.1);
    border: 2px solid #888;
    border-radius: 0 0 12px 12px;
    display: flex;
    flex-direction: column-reverse;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tube:hover {
    border-color: #ccc;
    box-shadow: 0 0 8px rgba(255,255,255,0.15);
}

.tube.selected {
    border-color: #f39c12;
    box-shadow: 0 0 16px rgba(243, 156, 18, 0.6);
}

.liquid-layer {
    width: 100%;
    height: 25%;
    min-height: 10px;
}

.liquid-layer:first-child {
    border-radius: 0 0 8px 8px;
}

/* ===== 节奏点击样式 ===== */
.rhythm-canvas {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 500px;
    margin: 0 auto;
    background: linear-gradient(180deg, #1a1a2e, #16213e);
    border-radius: 8px;
    overflow: hidden;
}

.hit-line {
    position: absolute;
    bottom: 60px;
    left: 0;
    right: 0;
    height: 3px;
    background: #f39c12;
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.6);
}

.hit-circle {
    position: absolute;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
    user-select: none;
    transition: transform 0.05s;
}

.hit-circle:active {
    transform: scale(1.3);
}

/* ===== 游戏结束弹窗样式 ===== */
.game-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.25s ease-out;
}

.game-modal {
    background: var(--card-bg, #0f3460);
    border-radius: 16px;
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    animation: modalScaleIn 0.3s ease-out;
    border: 2px solid var(--border-color);
}

.game-modal.success {
    background: linear-gradient(135deg, #1a3a2a, #0d2818);
    border-color: #2ecc71;
}

.game-modal.error {
    background: linear-gradient(135deg, #3a1a1a, #281010);
    border-color: #e74c3c;
}

.game-modal.info {
    background: linear-gradient(135deg, #1a2a3a, #0f3460);
    border-color: #4a90e2;
}

.game-modal-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.game-modal-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 0.75rem;
}

.game-modal-message {
    font-size: 1rem;
    color: #ccc;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.game-modal-message .highlight {
    color: var(--secondary-color, #50c878);
    font-weight: bold;
    font-size: 1.2rem;
}

.game-modal-error .highlight {
    color: #e74c3c;
}

.game-modal-btn {
    display: inline-block;
    padding: 0.75rem 2.5rem;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    background: var(--primary-color, #4a90e2);
}

.game-modal.success .game-modal-btn {
    background: #2ecc71;
}

.game-modal.error .game-modal-btn {
    background: #e74c3c;
}

.game-modal.info .game-modal-btn {
    background: #4a90e2;
}

.game-modal-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalScaleIn {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@media (max-width: 600px) {
    .game-modal {
        max-width: 90vw;
        padding: 1.5rem;
    }
    .game-modal-title {
        font-size: 1.25rem;
    }
    .game-modal-btn {
        padding: 0.65rem 2rem;
    }
}

