/* ============================================================
   2048（数字合并益智小游戏）
   私有样式表 —— 与 common.css 配套
   ============================================================ */

/* ================= 设置区（沿用站内 .form-group/.form-control） ================= */
.btn-row {
    display: flex;
    gap: 10px;
}

.btn-row .btn {
    flex: 1;
}

.score-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.score-item {
    background: #f9fafb;
    border: 1px solid #eef0f4;
    border-radius: 8px;
    text-align: center;
    padding: 12px 6px;
}

.score-item b {
    display: block;
    font-size: 24px;
    color: #4338ca;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.score-item span {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-top: 3px;
}

.score-item.special b {
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ================= 棋盘舞台区 ================= */
.stage-box {
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 18px;
    background: #fbfcfe;
}

.board-stage {
    padding: 14px;
    position: relative;
}

.stage-hint {
    font-size: 13px;
    color: #6b7280;
    text-align: center;
    line-height: 1.7;
    padding: 0 10px;
}

.win-badge {
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 20px;
    padding: 6px 16px;
    box-shadow: 0 6px 14px -8px rgba(245, 158, 11, 0.6);
}

/* ================= 4×4 固定棋盘 ================= */
.board-wrap {
    position: relative;
    width: max-content;
    margin: 0 auto;
    touch-action: none;
}

.board {
    display: grid;
    grid-template-columns: repeat(var(--n), 70px);
    grid-template-rows: repeat(var(--n), 70px);
    gap: 10px;
    padding: 10px;
    background: #eef0f4;
    border: 1px solid #e3e6ec;
    border-radius: 12px;
}

.cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: inset 0 0 0 0.5px rgba(148, 163, 184, 0.35);
    user-select: none;
}

.tile {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    animation: pop 0.16s ease;
}

/* ================= 各数值级配色（卡片白底 → 层级色 → 2048 特亮金） ================= */
.tile-v2    { background: #eef2ff; color: #4338ca; }
.tile-v4    { background: #e0e7ff; color: #4338ca; }
.tile-v8    { background: #c7d2fe; color: #312e81; }
.tile-v16   { background: #a5b4fc; color: #1e1b4b; }
.tile-v32   { background: linear-gradient(135deg, #6366f1, #4f46e5); color: #fff; }
.tile-v64   { background: linear-gradient(135deg, #4f46e5, #4338ca); color: #fff; }
.tile-v128  { background: linear-gradient(135deg, #4338ca, #5b21b6); color: #fff; }
.tile-v256  { background: linear-gradient(135deg, #5b21b6, #7c3aed); color: #fff; }
.tile-v512  { background: linear-gradient(135deg, #7c3aed, #a855f7); color: #fff; }
.tile-v1024 { background: linear-gradient(135deg, #d97706, #f59e0b); color: #fff; }
.tile-v2048 {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: #fff;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.4), 0 10px 24px -10px rgba(245, 158, 11, 0.9);
    animation: winPop 0.5s ease;
}
.tile-v4096 { background: linear-gradient(135deg, #dc2626, #b91c1c); color: #fff; }
.tile-v8192 { background: linear-gradient(135deg, #0f172a, #334155); color: #fff; }

.tile.big {
    font-size: 24px;
}

.tile.xl {
    font-size: 19px;
}

/* ================= 结束 / 通关遮罩 ================= */
.board-overlay {
    position: absolute;
    inset: 0;
    background: rgba(249, 250, 251, 0.92);
    border-radius: 12px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 5;
    text-align: center;
    padding: 20px;
}

.ov-txt {
    font-size: 17px;
    font-weight: 700;
    color: #374151;
    line-height: 1.8;
    white-space: pre-line;
}

/* ================= 合并规则提示 ================= */
.rule-note {
    font-size: 12.5px;
    line-height: 1.8;
    color: #6b7280;
    background: #f9fafb;
    border: 1px dashed #e5e7eb;
    border-radius: 8px;
    padding: 8px 12px;
}

/* ================= 统计区 ================= */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 9px;
}

.stat {
    background: #f9fafb;
    border: 1px solid #eef0f4;
    border-radius: 8px;
    padding: 11px 6px;
    text-align: center;
}

.stat b {
    display: block;
    font-size: 21px;
    color: #4338ca;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.stat span {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-top: 3px;
}

/* ================= 记录区 ================= */
.record-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

.record-title {
    font-size: 14px;
    font-weight: 700;
    color: #374151;
}

.record-clear {
    padding: 4px 10px;
    font-size: 12px;
}

.record-box {
    border: 1px solid #f0f1f3;
    border-radius: 9px;
    background: #fff;
    min-height: 96px;
    max-height: 280px;
    overflow: auto;
}

.record-box .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 84px;
    padding: 20px;
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
}

.record-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.record-table th {
    position: sticky;
    top: 0;
    background: #f9fafb;
    color: #6b7280;
    font-weight: 600;
    padding: 8px 6px;
    border-bottom: 1px solid #eef0f4;
    white-space: nowrap;
    z-index: 1;
}

.record-table td {
    padding: 8px 6px;
    text-align: center;
    color: #4b5563;
    border-bottom: 1px solid #f3f4f6;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.record-table tr:last-child td {
    border-bottom: none;
}

.record-table tbody tr:hover td {
    background: #fafbff;
}

.record-table .row-ok .res { color: #16a34a; }
.record-table .row-fail .res { color: #ef4444; }
.record-table .row-abort .res { color: #9ca3af; }

@keyframes pop {
    0%   { transform: scale(0.6); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

@keyframes winPop {
    0%   { transform: scale(0.5) rotate(-6deg); opacity: 0; }
    60%  { transform: scale(1.15) rotate(2deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ================= 状态栏 ================= */
.status-bar {
    border: 1px dashed #d8dce4;
    background: #fbfcfe;
}

/* ================= 响应式 ================= */
@media (max-width: 600px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 420px) {
    .board {
        grid-template-columns: repeat(var(--n), 54px);
        grid-template-rows: repeat(var(--n), 54px);
        gap: 8px;
        padding: 8px;
    }
    .stage-hint {
        font-size: 12px;
    }
    .tile {
        font-size: 24px;
    }
    .tile.big {
        font-size: 19px;
    }
    .tile.xl {
        font-size: 16px;
    }
    .board-stage {
        padding: 12px;
    }
}

/* ================= 底部 SEO 文案卡片 ================= */
.seo-article {
    display: block;
    margin-top: 28px;
    padding: 22px 26px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 30px -18px rgba(51, 65, 85, 0.18);
    color: #374151;
    font-size: 15.5px;
    line-height: 1.85;
}

.seo-article > h2 {
    margin: 18px 0 10px;
    padding-left: 12px;
    border-left: 4px solid #667eea;
    background: linear-gradient(90deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 19px;
    line-height: 1.4;
}

.seo-article > h2:first-child {
    margin-top: 2px;
}

.seo-article p:first-of-type {
    margin-top: 6px;
}

.seo-article ul {
    padding-left: 20px;
}

.seo-article li {
    position: relative;
    list-style: none;
    margin: 9px 0;
    padding-left: 22px;
}

.seo-article li::before {
    content: '◆';
    position: absolute;
    left: 0;
    top: 1px;
    color: #667eea;
    font-size: 0.7em;
}

.seo-article strong {
    color: #4c5bd4;
    font-weight: 700;
}

@media (max-width: 420px) {
    .seo-article {
        padding: 16px 14px;
        font-size: 14.5px;
    }
}