/* games.css — 娱乐模块：游戏列表 + 四个小游戏（贪吃蛇 / 2048 / 俄罗斯方块 / 合成大西瓜）的样式
   约定：这些页面不加载首页壁纸层，用自带浅色底；如果该模块上传了封面，
   则由 js/page-bg.js 叠一层虚化封面当背景（见 css/pages.css 的 .page-bg）。
   模块页（fun / poem / culture / links）的统一底色写在 css/pages.css 里。 */

/* ===== 游戏页整体 ===== */
body[data-page="game"] {
    background: linear-gradient(135deg, #eef2fb 0%, #dfe7f7 55%, #ece6f8 100%);
    padding: 24px 20px 32px;
}

.game-shell {
    width: min(620px, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 22px 22px 20px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-lg);
    color: var(--ink);
}
.game-head { text-align: center; }
.game-title { font-size: 26px; letter-spacing: 2px; }
.game-sub { margin-top: 6px; font-size: 13px; color: var(--muted); }

.game-hud {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    font-size: 14px;
    color: var(--ink-soft);
}
.hud-item b { font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }
.hud-actions { margin-left: auto; display: flex; gap: 8px; }
.hud-actions button { padding: 6px 14px; font-size: 13px; }

/* 贪吃蛇的模式切换：经典 / 障碍物 / 双人 */
.mode-row {
    width: 100%;
    display: flex;
    gap: 6px;
    padding: 4px;
    border-radius: 60px;
    background: rgba(26, 26, 46, 0.06);
}
.mode-btn {
    flex: 1;
    padding: 7px 10px;
    border: none;
    border-radius: 60px;
    background: transparent;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.mode-btn.is-active { background: var(--ink); color: #fff; }

/* 棋盘容器：相对定位，覆盖层绝对叠在上面 */
.game-board {
    position: relative;
    border-radius: var(--radius-md);
    background: rgba(26, 26, 46, 0.06);
    border: 1px solid rgba(26, 26, 46, 0.08);
    outline: none;
}
.game-board:focus-visible { box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.45); }

.game-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    text-align: center;
    padding: 16px;
}
.overlay-title { font-size: 18px; font-weight: 700; color: var(--ink); }
.overlay-sub { font-size: 13px; color: var(--ink-soft); }

/* ===== 俄罗斯方块 ===== */
.tetris-stage {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
}
.tetris-board { touch-action: none; cursor: pointer; }
#tetris-canvas { display: block; border-radius: var(--radius-md); }
.tetris-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px;
    border-radius: var(--radius-md);
    background: rgba(26, 26, 46, 0.06);
}
.tetris-next-label { font-size: 12px; color: var(--muted); }
#tetris-next { display: block; }

/* 俄罗斯方块的按钮排：4 个小键 + 1 个宽的硬降键
   注意：这里必须写成 .dpad.dpad-tetris（两个类）—— 基础 .dpad 的 3 列模板写在文件后面，
   同优先级下后者会覆盖前者，曾经因此让第 4 个键掉进隐式列、四个键大小不一。 */
.dpad.dpad-tetris {
    grid-template-columns: repeat(4, minmax(52px, 62px));
    grid-template-rows: repeat(2, 50px);
    justify-content: center;
}
.dpad.dpad-tetris button[data-act="left"] { grid-column: 1; grid-row: 1; }
.dpad.dpad-tetris button[data-act="rotate"] { grid-column: 2; grid-row: 1; }
.dpad.dpad-tetris button[data-act="right"] { grid-column: 3; grid-row: 1; }
.dpad.dpad-tetris button[data-act="down"] { grid-column: 4; grid-row: 1; }
.dpad.dpad-tetris .dpad-wide {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 15px;
}

/* ===== 合成大西瓜 ===== */
.sk-wrap {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
}
.sk-board {
    padding: 0;
    overflow: hidden;
    line-height: 0;
    touch-action: none;
    background: rgba(26, 26, 46, 0.08);
}
#suika-canvas { display: block; }
.sk-next-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
#sk-next {
    display: block;
    border-radius: 50%;
    background: rgba(26, 26, 46, 0.06);
}
.sk-tips {
    margin: 0;
    font-size: 12px;
    line-height: 1.7;
    color: var(--muted);
    text-align: center;
}

/* ===== 贪吃蛇 ===== */
#snake-canvas { display: block; border-radius: var(--radius-md); touch-action: none; }

/* 手机方向键：3 列网格，上键居中 */
.dpad {
    display: grid;
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(2, 52px);
    gap: 8px;
    justify-content: center;
}
.dpad button {
    min-width: 0;
    height: 100%;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.85);
    color: var(--ink);
    font-family: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-md);
}
.dpad button[data-act] { font-size: 19px; }
.dpad button[data-act="drop"] { font-size: 15px; }
.dpad button:active { background: var(--ink); color: #fff; }
.dpad button[data-dir="up"] { grid-column: 2; grid-row: 1; }
.dpad button[data-dir="left"] { grid-column: 1; grid-row: 2; }
.dpad button[data-dir="down"] { grid-column: 2; grid-row: 2; }
.dpad button[data-dir="right"] { grid-column: 3; grid-row: 2; }

/* ===== 2048 ===== */
.g2048-board {
    width: min(92vw, 58vh, 460px);
    aspect-ratio: 1;
    padding: 8px;
    touch-action: none;
    user-select: none;
}
.g2048-cells,
.g2048-tiles { position: absolute; inset: 8px; }
.g2048-cells {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}
.g2048-cell { padding: 5px; box-sizing: border-box; }
.g2048-cell > span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    background: rgba(26, 26, 46, 0.08);
}
.g2048-tiles { pointer-events: none; }
.g2048-tile {
    position: absolute;
    left: 0;
    top: 0;
    width: 25%;
    height: 25%;
    padding: 5px;
    box-sizing: border-box;
    transition: none;
}
.g2048-tile.is-animated { transition: transform 110ms ease; }
.g2048-face {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    font-weight: 800;
    font-size: clamp(20px, 5.4vmin, 38px);
    font-variant-numeric: tabular-nums;
    background: #eceff4;
    color: #5b6b8c;
}
.g2048-tile.is-new .g2048-face { animation: tilePop 140ms ease; }
.g2048-tile.is-merged .g2048-face { animation: tileBump 160ms ease; }
@keyframes tilePop { from { transform: scale(0.4); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }
@keyframes tileBump { 0% { transform: scale(1); } 50% { transform: scale(1.16); } 100% { transform: scale(1); } }

/* 数字越大字号越小，四位数才放得下 */
.g2048-tile.v128 .g2048-face,
.g2048-tile.v256 .g2048-face,
.g2048-tile.v512 .g2048-face { font-size: clamp(17px, 4.4vmin, 30px); }
.g2048-tile.v1024 .g2048-face,
.g2048-tile.v2048 .g2048-face,
.g2048-tile.v-super .g2048-face { font-size: clamp(14px, 3.6vmin, 25px); }

.g2048-tile.v2 .g2048-face { background: #eceff4; color: #5b6b8c; }
.g2048-tile.v4 .g2048-face { background: #dfe6f2; color: #4a5a78; }
.g2048-tile.v8 .g2048-face { background: #9fc0ff; color: #1f3a63; }
.g2048-tile.v16 .g2048-face { background: #5b8def; color: #fff; }
.g2048-tile.v32 .g2048-face { background: #4a7ae0; color: #fff; }
.g2048-tile.v64 .g2048-face { background: #3b63c4; color: #fff; }
.g2048-tile.v128 .g2048-face { background: #22c55e; color: #fff; }
.g2048-tile.v256 .g2048-face { background: #16a34a; color: #fff; }
.g2048-tile.v512 .g2048-face { background: #f59e0b; color: #fff; }
.g2048-tile.v1024 .g2048-face { background: #ef4444; color: #fff; }
.g2048-tile.v2048 .g2048-face { background: #a855f7; color: #fff; }
.g2048-tile.v-super .g2048-face { background: #1a1a2e; color: #fff; }

/* ===== 娱乐列表页 ===== */
.games-intro { color: var(--ink-soft); font-size: 14px; line-height: 1.8; text-align: center; }
.games-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
.game-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 0 14px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.66);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.game-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.game-card-cover {
    height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 3px;
    color: #fff;
}
.game-card[data-game="snake"] .game-card-cover { background: linear-gradient(135deg, #22c55e, #0f766e); }
.game-card[data-game="2048"] .game-card-cover { background: linear-gradient(135deg, #5b8def, #a855f7); }
.game-card[data-game="tetris"] .game-card-cover { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.game-card[data-game="suika"] .game-card-cover { background: linear-gradient(135deg, #2f9e44, #e5484d); }
.game-card-body { padding: 0 14px; display: flex; flex-direction: column; gap: 6px; }
.game-card-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.game-card-desc { font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
.game-card-play { align-self: flex-start; margin-top: 2px; font-size: 13px; color: var(--accent); font-weight: 700; }

/* ===== 手机 ===== */
@media (max-width: 520px) {
    body[data-page="game"] { padding: 16px 12px 24px; }
    .game-shell { padding: 16px 14px; gap: 12px; }
    .game-title { font-size: 22px; }
    .dpad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 48px); }
    .back-btn { left: 12px; padding: 8px 12px; font-size: 12px; }
}
