@charset "UTF-8";
:root {
  color-scheme: light;
  --bg: #edf4fc;
  --ink: #203c65;
  --muted: #586e8d;
  --panel: #fff;
  --line: #becfe5;
  --blue: #345fbb;
  --board: #b8cce5;
  --cell: #d4e1f1;
  --accent: #bb4a32;
  font-family: 'Trebuchet MS', 'Microsoft YaHei', sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; background: var(--bg); color: var(--ink); }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:hover, a:hover { filter: brightness(.92); }
button:focus-visible, a:focus-visible, #board:focus-visible { outline: 3px solid var(--accent); outline-offset: 5px; }
[hidden] { display: none !important; }
.topbar { max-width: 1240px; height: 88px; padding: 0 36px; margin: auto; display: flex; align-items: center; justify-content: space-between; }
.back-link, .quiet-button { font-size: 13px; }
.back-link { padding: 12px 0; }
.wordmark { display: flex; align-items: center; gap: 9px; font-size: 24px; font-weight: 900; letter-spacing: -1px; }
.wordmark span { font-size: 11px; font-weight: 500; letter-spacing: 0; }
.quiet-button { border: 1px solid var(--line); border-radius: 24px; background: transparent; padding: 10px 15px; min-height: 42px; white-space: nowrap; }
.game-layout { max-width: 1120px; padding: 0 30px; margin: 50px auto 0; display: grid; grid-template-columns: minmax(180px, 1fr) minmax(300px, 440px) 220px; align-items: start; gap: 46px; }
.intro { padding-top: 32px; }
.intro-label { font-size: 12px; color: var(--muted); margin: 0 0 20px; }
h1 { font-size: 83px; letter-spacing: -7px; line-height: 1; margin: 0; }
h1 span { display: block; font-size: 30px; letter-spacing: -1px; line-height: 1.5; margin-top: 19px; }
.tagline { font-size: 15px; line-height: 1.9; color: var(--muted); margin: 20px 0 28px; }
.merge-demo { display: flex; align-items: center; gap: 8px; }
.merge-demo span { display: grid; place-items: center; width: 44px; height: 48px; background: #d8e8fc; color: #254a78; border-radius: 9px; font-size: 26px; font-weight: bold; transform: rotate(-6deg); box-shadow: 0 4px 0 #aabed9; }
.merge-demo span:last-child { background: #bbd9f7; transform: rotate(6deg); }
.merge-demo b { font-size: 14px; font-weight: 400; color: var(--muted); }
.intro-note { font-size: 11px; line-height: 1.9; color: var(--muted); margin-top: 26px; }
.text-button { background: transparent; border: 0; padding: 13px 0; min-height: 44px; font-size: 13px; }
.text-button span { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--line); border-radius: 50%; margin-left: 10px; }
.play-area { min-width: 0; }
.scorebar { min-height: 83px; display: flex; align-items: center; gap: 25px; padding: 0 4px 18px; }
.scorebar > div { position: relative; min-width: 70px; }
.scorebar span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.scorebar strong { font-size: 28px; font-variant-numeric: tabular-nums; }
#score { color: var(--blue); }
#best { font-size: 24px; }
.scorebar button { margin-left: auto; }
#gain { position: absolute; left: 0; top: 35px; color: var(--accent); font-size: 17px; font-weight: bold; pointer-events: none; opacity: 0; }
.board-shell { position: relative; aspect-ratio: 1; padding: 12px; border-radius: 22px; background: var(--board); box-shadow: 0 8px 0 #8ea7ca, 0 20px 32px #203c6510; }
#board { display: grid; grid-template-rows: repeat(4, 1fr); gap: 10px; width: 100%; height: 100%; border-radius: 12px; touch-action: none; user-select: none; -webkit-user-select: none; }
.board-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cell { border-radius: 12px; background: var(--cell); }
.tile-layer { position: absolute; inset: 12px; pointer-events: none; }
.tile { position: absolute; display: grid; place-items: center; width: calc((100% - 30px) / 4); height: calc((100% - 30px) / 4); border-radius: 12px; background: #d8e8fc; color: #254a78; font-size: clamp(24px, 4vw, 44px); line-height: 1; font-weight: bold; font-variant-numeric: tabular-nums; box-shadow: inset 0 -4px 0 #00000008; }
.tile-4 { background: #bbd9f7; }
.tile-8 { background: #89bbed; color: #173c65; }
.tile-16 { background: #467dbf; color: #fff; }
.tile-32 { background: #315d9b; color: #fff; }
.tile-64 { background: #244678; color: #fff; }
.tile-128 { background: #f9c98e; color: #6a3b19; font-size: 35px; }
.tile-256 { background: #f6a86b; color: #623115; font-size: 35px; }
.tile-512 { background: #ed865a; color: #4b2414; font-size: 35px; }
.tile-1024 { background: #d75a40; color: #fff; font-size: 29px; }
.tile-2048 { background: #b94734; color: #fff; font-size: 29px; box-shadow: inset 0 -4px 0 #00000014, 0 0 20px #bb4a3240; }
.tile-super { background: #34366f; color: #fff; font-size: 24px; }
.board-meta { display: flex; justify-content: space-between; gap: 12px; margin: 26px 3px 0; font-size: 11px; color: var(--muted); }
.board-meta b { font-weight: 500; font-variant-numeric: tabular-nums; }
.controls { font-size: 12px; text-align: center; margin: 22px 0 13px; color: var(--muted); }
.direction-pad { display: flex; justify-content: center; gap: 10px; }
.direction-pad button { width: 48px; height: 44px; font-size: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 3px 0 var(--line); }
.direction-pad button:active { transform: translateY(2px); box-shadow: none; }
.guide { padding-top: 112px; }
.goal-tile { width: 86px; height: 86px; display: grid; place-items: center; background: #b94734; color: #fff; border-radius: 17px; font-size: 26px; font-weight: bold; transform: rotate(8deg); box-shadow: 0 6px 0 #913827; margin: 0 0 30px 6px; }
.guide h2 { font-size: 19px; margin: 0; }
.guide > p { font-size: 12px; line-height: 1.9; color: var(--muted); }
.progress-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; margin-top: 29px; }
.progress-label strong { color: var(--blue); font-size: 17px; }
progress { width: 100%; height: 7px; border: 0; border-radius: 5px; overflow: hidden; display: block; margin-top: 10px; background: var(--line); accent-color: var(--blue); }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--blue); border-radius: 5px; }
progress::-moz-progress-bar { background: var(--blue); }
.tip { margin-top: 31px; padding-top: 20px; border-top: 1px solid var(--line); }
.tip h3 { font-size: 12px; margin: 0 0 10px; }
.tip p, .guide .rule-note { font-size: 11px; line-height: 1.9; color: var(--muted); }
.guide .rule-note { margin-top: 24px; }
footer { max-width: 1120px; margin: 65px auto 0; padding: 22px 30px; display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
dialog { width: calc(100% - 40px); max-width: 400px; padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); color: var(--ink); text-align: center; max-height: calc(100svh - 40px); overflow: auto; }
dialog::backdrop { background: #19385888; backdrop-filter: blur(5px); }
.dialog-number { color: var(--accent); font-size: 30px; font-weight: bold; letter-spacing: -2px; }
dialog h2 { font-size: 26px; margin: 16px 0 12px; }
dialog > p { font-size: 14px; line-height: 1.8; color: var(--muted); white-space: pre-line; }
#help-content { font-size: 12px; line-height: 1.9; text-align: left; color: var(--muted); }
.primary-button { width: 100%; border: 0; border-radius: 12px; background: var(--blue); color: #fff; padding: 14px; min-height: 48px; font-weight: bold; margin-top: 10px; }
#dialog-secondary { display: block; margin: 7px auto 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
html[data-theme="dark"] { color-scheme: dark; --bg: #17283f; --ink: #e1ebfa; --muted: #adbed7; --panel: #223853; --line: #486181; --blue: #a5c7ff; --board: #354f70; --cell: #263e5c; --accent: #ffac8c; }
html[data-theme="dark"] .board-shell { box-shadow: 0 8px 0 #223752, 0 20px 32px #00000018; }
html[data-theme="dark"] .primary-button { color: #17283f; }
@media (max-width: 1050px) {
  .game-layout { gap: 28px; grid-template-columns: minmax(150px, 1fr) minmax(300px, 420px) 180px; }
  h1 { font-size: 70px; }
  h1 span { font-size: 25px; }
  .merge-demo { gap: 5px; }
  .merge-demo span { width: 37px; height: 42px; }
}
@media (max-width: 820px) {
  .topbar { height: 68px; padding: 0 24px; }
  .game-layout { max-width: 660px; margin-top: 15px; padding: 0 24px; grid-template-columns: minmax(280px, 420px) 170px; gap: 20px; }
  .intro { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 0; }
  h1 { font-size: 34px; letter-spacing: -2px; }
  h1 span { display: inline; font-size: 13px; letter-spacing: 0; margin-left: 15px; }
  h1 br, .intro-label, .tagline, .merge-demo, .intro-note { display: none; }
  .guide { padding-top: 90px; }
  .scorebar { min-height: 70px; gap: 18px; }
  .scorebar .quiet-button { font-size: 11px; padding: 8px 10px; }
  .tile { font-size: 36px; }
  .tile-128, .tile-256, .tile-512 { font-size: 29px; }
  .tile-1024, .tile-2048 { font-size: 24px; }
  .tile-super { font-size: 20px; }
  footer { max-width: 660px; margin-top: 35px; padding: 22px 24px; }
}
@media (max-width: 580px) {
  .topbar { height: 60px; padding: 0 18px; }
  .wordmark { font-size: 20px; }
  .wordmark span { display: none; }
  .back-link, .quiet-button { font-size: 11px; }
  .quiet-button { padding: 8px 11px; }
  .game-layout { display: flex; flex-direction: column; gap: 8px; max-width: 460px; margin-top: 12px; padding: 0 18px; }
  .intro, .play-area { width: 100%; }
  h1 { font-size: 32px; }
  h1 span { display: none; }
  .scorebar { min-height: 73px; gap: 20px; padding-bottom: 16px; }
  .scorebar strong { font-size: 27px; }
  .scorebar > div { min-width: 60px; }
  #best { font-size: 23px; }
  .tile { font-size: clamp(28px, 9vw, 40px); }
  .tile-128, .tile-256, .tile-512 { font-size: clamp(24px, 7vw, 32px); }
  .tile-1024, .tile-2048 { font-size: clamp(20px, 6vw, 28px); }
  .tile-super { font-size: clamp(16px, 5vw, 22px); }
  .controls { font-size: 11px; margin: 19px 0 13px; }
  .guide { width: 100%; padding-top: 28px; }
  .goal-tile, .guide > h2, .guide > p, .tip { display: none; }
  .progress-label { margin-top: 0; }
  footer { max-width: 460px; margin-top: 20px; padding: 20px 18px; font-size: 9px; }
}
@media (min-width: 821px) and (max-height: 800px) { .game-layout { margin-top: 10px; } footer { margin-top: 25px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
