/* ===== 2048 · 专属样式 ===== */

/* ---- Hero 区域 ---- */
.g2048-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 24px 32px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #fff7ed 0%, #fffbf5 60%, #faf6ef 100%);
    overflow: hidden;
    margin-bottom: 24px;
    border: 1px solid #f3e7d3;
}

/* 光晕 */
.g2048-glow {
    position: absolute;
    top: -120px;
    left: 50%;
    width: 460px;
    height: 460px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 159, 67, 0.22) 0%, transparent 70%);
    pointer-events: none;
}

/* ---- 顶部信息行 ---- */
.g2048-topbar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: 100%;
    max-width: 480px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.g2048-brand { display: flex; flex-direction: column; gap: 4px; }
.g2048-logo {
    font-size: 34px;
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1;
    color: #776e65;
    background: linear-gradient(135deg, #ff8a3d, #edc22e);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.g2048-tagline {
    font-size: 13px;
    color: #9c8b7a;
    font-weight: 500;
}

/* 分数盒子 */
.g2048-scores { display: flex; gap: 10px; }
.g2048-score-box {
    min-width: 92px;
    padding: 10px 16px;
    border-radius: 12px;
    background: #bbada0;
    color: #fff;
    text-align: center;
    box-shadow: 0 6px 16px rgba(187, 173, 160, 0.35);
}
.g2048-score-box.best { background: #8f7a66; }
.g2048-score-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.78);
    font-weight: 700;
}
.g2048-score-value {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
    margin-top: 2px;
    transition: transform 0.18s ease;
}
.g2048-score-value.bump { transform: scale(1.18); }

/* ---- 操作行 ---- */
.g2048-actions {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 480px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.g2048-btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid #d6c7af;
    background: #fff;
    color: #776e65;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.g2048-btn:hover { background: #faf3e8; transform: translateY(-1px); }
.g2048-btn:active { transform: translateY(0); }
.g2048-btn.primary {
    background: linear-gradient(135deg, #ff8a3d, #f67c5f);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 18px rgba(246, 124, 95, 0.4);
}
.g2048-btn.primary:hover { background: linear-gradient(135deg, #ff7a2d, #f65e3b); }
.g2048-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.g2048-hint {
    margin-left: auto;
    font-size: 12.5px;
    color: #9c8b7a;
}
.g2048-hint kbd {
    display: inline-block;
    padding: 2px 7px;
    margin: 0 1px;
    border-radius: 5px;
    background: #fff;
    border: 1px solid #d6c7af;
    border-bottom-width: 2px;
    font-size: 11px;
    font-family: ui-monospace, monospace;
    color: #776e65;
}

/* ---- 棋盘 ---- */
.g2048-board-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 480px;
}

.g2048-board {
    --g2048-gap: 12px;
    --g2048-cell: calc((100% - var(--g2048-gap) * 3) / 4);
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: var(--g2048-gap);
    background: #bbada0;
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(119, 110, 101, 0.28);
    touch-action: none;
    user-select: none;
}

/* 背景网格 */
.g2048-grid-bg {
    position: absolute;
    inset: var(--g2048-gap);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: var(--g2048-gap);
}
.g2048-cell {
    background: rgba(238, 228, 218, 0.35);
    border-radius: 8px;
}

/* 方块层 */
.g2048-tile-layer {
    position: absolute;
    inset: var(--g2048-gap);
    pointer-events: none;
}

/* 单个方块（绝对定位，靠 transform 移动；视觉在内部 inner 元素上） */
.g2048-tile {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--g2048-cell);
    height: var(--g2048-cell);
    /* transform: translate(x, y) 由 JS 设置，基于父层百分比 */
    transition: transform 0.14s ease;
    will-change: transform;
}

/* 内部视觉元素：负责颜色、字号、缩放动画（与外层 translate 不冲突） */
.g2048-tile-inner {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-weight: 800;
    line-height: 1;
}

/* 方块颜色（经典 2048 配色） */
.g2048-tile[data-v="2"]    .g2048-tile-inner { background: #eee4da; color: #776e65; }
.g2048-tile[data-v="4"]    .g2048-tile-inner { background: #ede0c8; color: #776e65; }
.g2048-tile[data-v="8"]    .g2048-tile-inner { background: #f2b179; color: #fff; }
.g2048-tile[data-v="16"]   .g2048-tile-inner { background: #f59563; color: #fff; }
.g2048-tile[data-v="32"]   .g2048-tile-inner { background: #f67c5f; color: #fff; }
.g2048-tile[data-v="64"]   .g2048-tile-inner { background: #f65e3b; color: #fff; }
.g2048-tile[data-v="128"]  .g2048-tile-inner { background: #edcf72; color: #fff; box-shadow: 0 0 18px rgba(237, 207, 114, 0.55); }
.g2048-tile[data-v="256"]  .g2048-tile-inner { background: #edcc61; color: #fff; box-shadow: 0 0 18px rgba(237, 204, 97, 0.6); }
.g2048-tile[data-v="512"]  .g2048-tile-inner { background: #edc850; color: #fff; box-shadow: 0 0 20px rgba(237, 200, 80, 0.65); }
.g2048-tile[data-v="1024"] .g2048-tile-inner { background: #edc53f; color: #fff; box-shadow: 0 0 22px rgba(237, 197, 63, 0.7); }
.g2048-tile[data-v="2048"] .g2048-tile-inner { background: #edc22e; color: #fff; box-shadow: 0 0 28px rgba(237, 194, 46, 0.85); }
.g2048-tile[data-super="1"] .g2048-tile-inner { background: #3c3a32; color: #fff; }

/* 字号随数值变化 */
.g2048-tile-inner { font-size: clamp(24px, 7vw, 42px); }
.g2048-tile[data-v="16"]  .g2048-tile-inner,
.g2048-tile[data-v="32"]  .g2048-tile-inner,
.g2048-tile[data-v="64"]  .g2048-tile-inner { font-size: clamp(22px, 6.5vw, 38px); }
.g2048-tile[data-v="128"] .g2048-tile-inner,
.g2048-tile[data-v="256"] .g2048-tile-inner,
.g2048-tile[data-v="512"] .g2048-tile-inner { font-size: clamp(20px, 6vw, 34px); }
.g2048-tile[data-v="1024"] .g2048-tile-inner,
.g2048-tile[data-v="2048"] .g2048-tile-inner { font-size: clamp(16px, 5vw, 28px); }
.g2048-tile[data-super="1"] .g2048-tile-inner { font-size: clamp(14px, 4.5vw, 26px); }

/* 出生动画（作用于 inner，不影响外层 translate） */
.g2048-tile.is-new .g2048-tile-inner {
    animation: g2048-pop 0.16s ease 0.06s backwards;
}
@keyframes g2048-pop {
    0% { transform: scale(0); }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* 合并动画（作用于 inner） */
.g2048-tile.is-merged .g2048-tile-inner {
    animation: g2048-merge 0.18s ease 0.1s;
}
@keyframes g2048-merge {
    0% { transform: scale(1); }
    50% { transform: scale(1.22); }
    100% { transform: scale(1); }
}

/* ---- 覆盖层 ---- */
.g2048-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    background: rgba(238, 228, 218, 0.72);
    backdrop-filter: blur(2px);
    border-radius: 14px;
    animation: g2048-fade 0.25s ease;
}
.g2048-overlay[hidden] { display: none; }
@keyframes g2048-fade { from { opacity: 0; } to { opacity: 1; } }

.g2048-overlay-card {
    text-align: center;
    padding: 28px 24px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 14px 40px rgba(119, 110, 101, 0.3);
    max-width: 86%;
}
.g2048-overlay-emoji { font-size: 48px; line-height: 1; margin-bottom: 10px; }
.g2048-overlay-title { font-size: 26px; font-weight: 900; color: #776e65; letter-spacing: -0.02em; }
.g2048-overlay-text { font-size: 14px; color: #9c8b7a; margin: 8px 0 18px; }
.g2048-overlay-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---- 移动端方向键 ---- */
.g2048-dpad {
    position: relative;
    z-index: 1;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
}
.g2048-dpad-row { display: flex; gap: 8px; }
.g2048-dpad-btn {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    border: 1px solid #d6c7af;
    background: #fff;
    color: #776e65;
    font-size: 22px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(119, 110, 101, 0.12);
    transition: transform 0.1s ease, background 0.15s ease;
    user-select: none;
}
.g2048-dpad-btn:active { transform: scale(0.92); background: #faf3e8; }

/* ---- 简介区 ---- */
.g2048-info {
    margin-bottom: 28px;
}
.g2048-info .detail-title-row { margin-bottom: 16px; }
.g2048-info h1 { font-size: 28px; }

/* ---- 响应式 ---- */
@media (max-width: 768px) {
    .g2048-hero { padding: 28px 16px 24px; }
    .g2048-topbar { gap: 14px; }
    .g2048-logo { font-size: 28px; }
    .g2048-tagline { display: none; }
    .g2048-score-box { min-width: 78px; padding: 8px 12px; }
    .g2048-score-value { font-size: 18px; }
    .g2048-hint { display: none; }
    .g2048-actions { gap: 8px; }
    .g2048-btn { padding: 9px 16px; font-size: 13px; }
    .g2048-board { --g2048-gap: 9px; }
    .g2048-dpad { display: flex; }
}

@media (max-width: 420px) {
    .g2048-topbar { flex-direction: column; align-items: stretch; }
    .g2048-scores { justify-content: center; }
    .g2048-actions { justify-content: center; }
}

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .g2048-tile { transition: none; }
    .g2048-tile.is-new, .g2048-tile.is-merged { animation: none; }
}
