/* =============================================
   2048 - 浅色系样式
   ============================================= */

.g2048-layout {
    display: flex;
    gap: 32px;
    padding: 40px 0;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

/* ---- 左侧游戏区 ---- */
.g2048-main { flex: 1; max-width: 460px; }

.g2048-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.g2048-header h1 {
    font-size: 3rem;
    font-weight: 900;
    color: #1e40af;
    margin: 0;
}

.g2048-scores { display: flex; gap: 12px; }

.g2048-score-box {
    background: #fff;
    border: 2px solid #e0e7ff;
    border-radius: 12px;
    padding: 8px 16px;
    text-align: center;
    min-width: 80px;
}

.g2048-score-label {
    display: block;
    font-size: 0.72rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.g2048-score-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 900;
    color: #1e40af;
}

/* ---- 棋盘 ---- */
.g2048-board {
    background: #dde6f5;
    border-radius: 16px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    aspect-ratio: 1 / 1;
    border: 2px solid #c7d7f0;
    touch-action: none; /* 关键：阻止浏览器默认触摸行为 */
    user-select: none;
}

.g2048-cell {
    background: #eef2fb;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 2rem;
    transition: background 0.1s;
    aspect-ratio: 1 / 1;
}

/* 方块颜色 */
.g2048-cell[data-val="2"]    { background: #dbeafe; color: #1e40af; }
.g2048-cell[data-val="4"]    { background: #bfdbfe; color: #1e40af; }
.g2048-cell[data-val="8"]    { background: #93c5fd; color: #fff; }
.g2048-cell[data-val="16"]   { background: #60a5fa; color: #fff; }
.g2048-cell[data-val="32"]   { background: #3b82f6; color: #fff; }
.g2048-cell[data-val="64"]   { background: #2563eb; color: #fff; }
.g2048-cell[data-val="128"]  { background: #1d4ed8; color: #fff; font-size: 1.7rem; }
.g2048-cell[data-val="256"]  { background: #1e40af; color: #fff; font-size: 1.7rem; }
.g2048-cell[data-val="512"]  { background: #1e3a8a; color: #fff; font-size: 1.7rem; }
.g2048-cell[data-val="1024"] { background: #6d28d9; color: #fff; font-size: 1.4rem; }
.g2048-cell[data-val="2048"] { background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff; font-size: 1.4rem; box-shadow: 0 0 16px rgba(245,158,11,0.4); }
.g2048-cell[data-val="super"]{ background: linear-gradient(135deg, #ec4899, #d946ef); color: #fff; font-size: 1.2rem; }

@keyframes pop {
    0%   { transform: scale(0.5); opacity: 0; }
    60%  { transform: scale(1.1); }
    100% { transform: scale(1);   opacity: 1; }
}
.g2048-pop { animation: pop 0.18s ease; }

@keyframes merge {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}
.g2048-merge { animation: merge 0.2s ease; }

/* ---- 按钮区 ---- */
.g2048-actions { display: flex; gap: 12px; margin-top: 20px; }
.g2048-actions .btn { flex: 1; justify-content: center; }

.g2048-hint {
    margin-top: 14px;
    color: #64748b;
    font-size: 0.85rem;
    text-align: center;
    font-weight: 500;
}

/* ---- 虚拟方向键 ---- */
.g2048-dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
}

.g2048-dpad-mid { display: flex; align-items: center; gap: 8px; }

.g2048-dpad-btn {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    border: 2px solid #e0e7ff;
    background: #fff;
    color: #1e40af;
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.g2048-dpad-btn:hover {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(59,130,246,0.25);
}

.g2048-dpad-btn:active { transform: scale(0.94); }

.g2048-dpad-center {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    opacity: 0.18;
}

/* ---- 排行榜 ---- */
.g2048-rankings {
    flex: 1;
    max-width: 360px;
    min-width: 280px;
}

.g2048-rank-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e40af;
    margin-bottom: 12px;
}

.g2048-rank-tabs { display: flex; gap: 8px; margin-bottom: 16px; }

.g2048-rank-tab {
    padding: 6px 16px;
    border-radius: 8px;
    border: 2px solid #e0e7ff;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: all 0.2s;
}

.g2048-rank-tab:hover { border-color: #3b82f6; color: #1e40af; }
.g2048-rank-tab.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }

.g2048-rank-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
}

.g2048-rank-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #fff;
    border: 2px solid #e0e7ff;
    border-radius: 10px;
    transition: all 0.2s;
}

.g2048-rank-item:hover { border-color: #3b82f6; }
.g2048-rank-item.g2048-rank-me { border-color: #3b82f6; background: #eff6ff; }

.g2048-rank-pos { font-size: 1.2rem; font-weight: 900; min-width: 36px; text-align: center; }
.g2048-rank-pos.pos-1 { color: #f59e0b; }
.g2048-rank-pos.pos-2 { color: #94a3b8; }
.g2048-rank-pos.pos-3 { color: #cd7f32; }

.g2048-rank-info { flex: 1; margin-left: 12px; }
.g2048-rank-name { font-weight: 700; font-size: 0.95rem; color: #1e40af; display: block; }
.g2048-rank-date { font-size: 0.75rem; color: #64748b; }
.g2048-rank-score { font-weight: 900; font-size: 1.1rem; color: #1e40af; }

.g2048-rank-tip {
    text-align: center;
    color: #94a3b8;
    padding: 40px 0;
    font-size: 0.9rem;
}

.g2048-my-rank {
    margin-top: 16px;
    padding: 12px 16px;
    background: #eff6ff;
    border: 2px solid #3b82f6;
    border-radius: 10px;
    color: #1e40af;
    font-size: 0.9rem;
    font-weight: 600;
}

.g2048-my-rank strong { color: #2563eb; }

/* ---- 结束弹窗 ---- */
.g2048-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}

.g2048-overlay-card {
    background: #fff;
    border: 2px solid #e0e7ff;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    min-width: 300px;
    box-shadow: 0 20px 60px rgba(59,130,246,0.15);
}

.g2048-overlay-card h2 { font-size: 2rem; color: #1e40af; margin-bottom: 12px; }
.g2048-overlay-card p  { font-size: 1.1rem; color: #64748b; margin-bottom: 8px; }
.g2048-overlay-card #overlayBest { color: #f59e0b; font-weight: 700; font-size: 1.2rem; }
.g2048-overlay-actions { display: flex; gap: 12px; margin-top: 24px; justify-content: center; }

/* ---- 响应式 ---- */
@media (max-width: 860px) {
    .g2048-layout { flex-direction: column; align-items: center; }
    .g2048-main { max-width: 100%; width: 100%; }
    .g2048-board { max-width: 420px; margin: 0 auto; }
    .g2048-rankings { max-width: 100%; width: 100%; }
}

@media (max-width: 480px) {
    .g2048-header h1 { font-size: 2rem; }
    .g2048-cell { font-size: 1.5rem; }
    .g2048-cell[data-val="128"],
    .g2048-cell[data-val="256"],
    .g2048-cell[data-val="512"]  { font-size: 1.3rem; }
    .g2048-cell[data-val="1024"],
    .g2048-cell[data-val="2048"],
    .g2048-cell[data-val="super"]{ font-size: 1.1rem; }
    .g2048-board { gap: 6px; padding: 6px; }
    .g2048-dpad-btn { width: 46px; height: 46px; font-size: 1.2rem; }
    .g2048-dpad-center { width: 46px; height: 46px; }
}
