:root {
  --bg: #f8f5ee;
  --ink: #3a3835;
  --muted: #8c867d;
  --panel: #fffdf8;
  --line: #e8e2d7;
  --board: #b5aa99;
  --empty: #c8beae;
  --accent: #d86b42;
  --accent-dark: #a84f2f;
  --tile-2: #eee5d8;
  --tile-4: #e4d5bd;
  --tile-8: #d98b5b;
  --tile-16: #d57548;
  --tile-32: #c9573b;
  --tile-64: #c43f2f;
  --tile-high: #604b43;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(1060px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 24px; }
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
.brand-row { display: flex; align-items: baseline; gap: 18px; }
.brand { font-size: clamp(4.2rem, 11vw, 7.1rem); line-height: .78; font-weight: 900; letter-spacing: -5px; color: #38332f; }
.tagline { color: var(--muted); font-size: 14px; font-weight: 600; letter-spacing: .05em; }
.top-actions { display: flex; align-items: stretch; gap: 10px; }
.score-card { min-width: 88px; padding: 9px 14px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); text-align: center; box-shadow: 0 4px 10px #574c3e0b; }
.score-card span { display: block; color: var(--muted); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.score-card strong { display: block; margin-top: 2px; font-size: 23px; line-height: 1; }
.icon-btn { width: 52px; border: 0; border-radius: 12px; color: white; font-size: 27px; font-weight: 700; box-shadow: 0 6px 12px #b94d2b2b; transition: transform .15s ease, background .15s ease; }
.icon-btn.primary { background: var(--accent); }
.icon-btn:hover { transform: translateY(-2px); background: var(--accent-dark); }
.game-layout { display: grid; grid-template-columns: minmax(420px, 620px) minmax(250px, 1fr); gap: 34px; align-items: start; }
.board-wrap { position: relative; width: 100%; aspect-ratio: 1; padding: 13px; border-radius: 18px; background: var(--board); box-shadow: 0 16px 35px #574c3e23, inset 0 1px #ffffff32; touch-action: none; }
.grid { position: absolute; inset: 13px; display: grid; gap: 10px; }
.grid-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.grid-cell { border-radius: 11px; background: var(--empty); box-shadow: inset 0 2px 3px #6f62543d; }
.tiles { position: absolute; inset: 13px; }
.tile { position: absolute; width: calc((100% - 30px) / 4); height: calc((100% - 30px) / 4); display: grid; place-items: center; border-radius: 11px; font-size: clamp(28px, 7vw, 52px); font-weight: 800; color: #685d54; transition: transform .13s ease-in-out; animation: appear .16s ease; box-shadow: 0 5px 8px #66554614; }
.tile[data-value="2"] { background: var(--tile-2); } .tile[data-value="4"] { background: var(--tile-4); } .tile[data-value="8"] { background: var(--tile-8); color: white; } .tile[data-value="16"] { background: var(--tile-16); color: white; } .tile[data-value="32"] { background: var(--tile-32); color: white; } .tile[data-value="64"] { background: var(--tile-64); color: white; } .tile.high { background: var(--tile-high); color: white; font-size: clamp(22px, 5vw, 40px); }
@keyframes appear { from { opacity: 0; transform: scale(.65); } to { opacity: 1; transform: scale(1); } }
.status-overlay { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; border-radius: 18px; background: #faf7f0d9; backdrop-filter: blur(3px); }
.status-overlay[hidden] { display: none; }
.status-card { width: min(340px, calc(100% - 36px)); padding: 28px; border: 1px solid #ffffffaa; border-radius: 16px; background: #fffdf8f2; text-align: center; box-shadow: 0 16px 30px #574c3e1e; }
.status-card h2 { margin: 0; font-size: 28px; } .status-card p { margin: 9px 0 20px; color: var(--muted); font-size: 14px; }
.status-actions { display: flex; justify-content: center; gap: 9px; } .btn { border: 0; border-radius: 9px; padding: 10px 13px; font-weight: 700; font-size: 13px; } .btn.ghost { background: #ece7de; color: #665c52; } .btn.accent { background: var(--accent); color: white; }
.controls-row { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.control-btn { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; background: var(--panel); color: #6f665e; font-size: 12px; font-weight: 700; box-shadow: 0 4px 9px #574c3e0b; transition: border-color .15s, color .15s, transform .15s; }
.control-btn:hover { border-color: #d2c6b6; color: var(--accent-dark); transform: translateY(-1px); } .control-icon { font-size: 18px; line-height: 1; }
.side-panel { display: grid; gap: 14px; } .panel-block { padding: 19px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 7px 18px #574c3e0a; }
.section-kicker { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; } .field-label { display: block; margin: 12px 0 7px; font-size: 13px; font-weight: 700; }
.name-entry { display: flex; gap: 8px; } .name-entry input { min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; outline: none; background: #fffefa; color: var(--ink); } .name-entry input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #d86b4222; }
.save-name { border: 0; border-radius: 8px; padding: 0 13px; background: #393530; color: white; font-size: 12px; font-weight: 700; } .save-name:hover { background: #5a5047; } .player-note { margin-top: 8px; min-height: 16px; color: var(--muted); font-size: 11px; }
.section-heading { display: flex; justify-content: space-between; align-items: start; } .section-heading h2 { margin: 5px 0 0; font-size: 22px; } .trophy { color: var(--accent); font-size: 27px; }
.leaderboard { display: grid; gap: 6px; margin: 16px 0 0; padding: 0; list-style: none; counter-reset: rank; } .leaderboard li { display: grid; grid-template-columns: 27px 1fr auto; gap: 8px; align-items: center; padding: 9px 8px; border-radius: 8px; background: #f7f3eb; font-size: 13px; counter-increment: rank; } .leaderboard li::before { content: counter(rank, decimal-leading-zero); color: var(--muted); font-size: 11px; font-weight: 800; } .leaderboard .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; } .leaderboard .points { color: var(--accent-dark); font-variant-numeric: tabular-nums; font-weight: 800; }
.empty-board { margin-top: 16px; color: var(--muted); font-size: 12px; line-height: 1.6; } .mini-help { display: grid; gap: 10px; background: #f1ede5; box-shadow: none; } .mini-row { display: flex; align-items: center; gap: 5px; color: #746b62; font-size: 11px; } .keycap { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1px solid #d7cec1; border-radius: 5px; background: #fffdf8; color: #655b53; font-size: 12px; font-weight: 800; } .swipe-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px #d86b421a; }
.footer { margin-top: 28px; color: #aaa297; text-align: center; font-size: 11px; }
@media (max-width: 820px) { .app-shell { width: min(620px, calc(100% - 28px)); padding-top: 25px; } .topbar { align-items: center; margin-bottom: 22px; } .tagline { display: none; } .brand { font-size: 4.8rem; } .game-layout { grid-template-columns: 1fr; gap: 18px; } .side-panel { grid-template-columns: 1fr 1fr; } .player-block, .leaderboard-block { min-width: 0; } .mini-help { grid-column: 1 / -1; } }
@media (max-width: 520px) { .app-shell { width: calc(100% - 22px); padding-top: 20px; } .topbar { gap: 10px; } .brand { font-size: 4.3rem; letter-spacing: -4px; } .top-actions { gap: 5px; } .score-card { min-width: 58px; padding-inline: 8px; } .score-card strong { font-size: 19px; } .icon-btn { width: 44px; } .board-wrap { padding: 9px; border-radius: 14px; } .grid, .tiles { inset: 9px; } .grid, .grid-row { gap: 7px; } .tile { width: calc((100% - 21px) / 4); height: calc((100% - 21px) / 4); border-radius: 8px; } .controls-row { gap: 5px; } .control-btn { padding: 8px 9px; } .control-btn span:last-child { display: none; } .side-panel { grid-template-columns: 1fr; } .mini-help { grid-column: auto; } }
