:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101e23;
  color: #f7f2e8;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, .board:focus-visible { outline: 3px solid #d8f795; outline-offset: 4px; }
[hidden] { display: none !important; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 82% 18%, #25413b 0, transparent 36%), radial-gradient(circle at 12% 90%, #1d3330 0, transparent 34%);
  opacity: .8;
}

.page-shell { position: relative; max-width: 1250px; min-height: 100vh; margin: auto; padding: 0 48px; display: flex; flex-direction: column; }
.site-header { height: 96px; border-bottom: 1px solid #ffffff1e; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: #f7f2e8; text-decoration: none; font-size: 15px; font-weight: 800; letter-spacing: -.04em; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: #dbf69c; color: #142620; font-size: 22px; font-weight: 900; line-height: 1; position: relative; }
.brand-mark span { position: absolute; font-size: 11px; right: 2px; top: 1px; }
.brand-accent { color: #d6f293; }
.header-note { color: #98aaa8; font-size: 12px; letter-spacing: .03em; }

.main-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(390px, 510px); gap: clamp(48px, 7vw, 100px); align-items: center; flex: 1; padding: 46px 0 58px; }
.intro { max-width: 515px; }
.eyebrow { display: flex; align-items: center; gap: 13px; color: #d4ef94; font-size: 11px; font-weight: 800; letter-spacing: .23em; }
.eyebrow-line { height: 1px; width: 28px; background: #d4ef94; }
h1 { font-size: clamp(56px, 6.3vw, 94px); line-height: .99; letter-spacing: -.08em; font-weight: 760; margin: 30px 0 23px; }
h1 em { font-style: normal; color: #d8f599; }
.intro-copy { color: #aebdb7; max-width: 405px; font-size: 16px; line-height: 1.75; margin: 0; }
.score-row { display: flex; gap: 12px; margin-top: 37px; }
.score-card { min-width: 142px; min-height: 84px; background: #ffffff0a; border: 1px solid #ffffff1d; border-radius: 13px; padding: 14px 18px 10px; display: flex; flex-direction: column; justify-content: space-between; }
.score-label { color: #9caba4; font-size: 10px; letter-spacing: .15em; font-weight: 800; }
.score-card strong { font-variant-numeric: tabular-nums; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.new-game-button { min-width: 190px; height: 54px; display: inline-flex; align-items: center; justify-content: space-between; gap: 30px; margin-top: 22px; border: 0; border-radius: 9px; padding: 0 18px 0 23px; background: #d9f59b; color: #1c2d25; font-size: 14px; font-weight: 800; transition: transform .18s, background .18s; }
.new-game-button:hover { transform: translateY(-2px); background: #e8ffb4; }
.new-game-button span { font-size: 21px; font-weight: 400; }
.how-to { margin-top: 55px; display: flex; gap: 14px; color: #98aaa3; max-width: 380px; }
.how-to-icon { color: #d9f59b; font-size: 23px; line-height: 1.2; }
.how-to p { margin: 0; font-size: 13px; line-height: 1.7; }
.how-to strong { color: #f3f0e5; font-size: 14px; }

.game-area { width: 100%; max-width: 510px; justify-self: end; }
.board-topline, .board-bottomline { display: flex; justify-content: space-between; align-items: center; color: #b5c4b8; font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.board-topline { padding: 0 4px 17px; }
.board-bottomline { padding: 16px 4px 0; color: #7f9790; }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 9px; background: #d9f59b; border-radius: 50%; box-shadow: 0 0 0 4px #d9f59b20; }
.board-frame { position: relative; padding: 12px; border-radius: 24px; background: #3b5147; box-shadow: 0 25px 70px #06110e6b, inset 0 1px #ffffff2b; }
.board { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; aspect-ratio: 1; outline: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.cell { min-width: 0; min-height: 0; background: #20362f99; border-radius: 12px; display: grid; place-items: stretch; overflow: hidden; }
.tile-layer { position: absolute; inset: 0; pointer-events: none; }
.tile-position { position: absolute; will-change: transform; }
.tile { width: 100%; height: 100%; border-radius: 12px; position: relative; overflow: hidden; background: #ecdfc7; color: #25392f; display: grid; place-items: center; box-shadow: inset 0 -4px #00000016; }
.tile-image { width: 100%; height: 100%; display: block; object-fit: cover; position: absolute; inset: 0; }
.tile-label { display: none; font-size: clamp(20px, 4vw, 42px); font-weight: 900; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.tile.asset-failed .tile-label { display: block; }
.tile.asset-failed .tile-image { display: none; }
.tile-4 { background: #e8d5ae; }.tile-8 { background: #f4a76d; }.tile-16 { background: #ef9167; }.tile-32 { background: #e97f67; }.tile-64 { background: #e46658; }
.tile-128 { background: #e6c66d; }.tile-256 { background: #dbba5d; }.tile-512 { background: #d7ad51; }.tile-1024 { background: #a7cb80; }.tile-2048 { background: #d9f59b; }

.controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 29px; }
.controls-label { font-size: 10px; letter-spacing: .18em; color: #9dafaa; font-weight: 800; }
.direction-pad { display: flex; gap: 7px; }
.direction-button { width: 43px; height: 43px; border: 1px solid #ffffff24; border-radius: 9px; color: #e5ede1; background: #ffffff0c; font-size: 22px; line-height: 1; transition: background .15s, transform .15s; }
.direction-button:hover { background: #d9f59b24; transform: translateY(-2px); }
.direction-button:active { transform: scale(.94); }

.overlay { position: absolute; inset: 12px; z-index: 2; border-radius: 13px; background: #13261fe8; display: grid; place-items: center; padding: 20px; backdrop-filter: blur(7px); }
.overlay-card { width: min(100%, 350px); text-align: center; }
.overlay-sparkle { font-size: 36px; color: #d9f59b; }
.overlay h2 { font-size: clamp(26px, 4vw, 37px); letter-spacing: -.05em; margin: 10px 0; }
.overlay p { color: #bacac0; line-height: 1.6; margin: 0 0 27px; }
.overlay-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; }
.overlay-actions button { border-radius: 8px; padding: 12px 17px; font-size: 13px; font-weight: 800; }
.overlay-primary { border: 1px solid #d9f59b; background: #d9f59b; color: #203028; }
.overlay-secondary { border: 1px solid #b6c5ba6e; background: #ffffff0d; color: #f6f3e8; }

.site-footer { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid #ffffff1e; padding: 21px 0 27px; color: #81958e; font-size: 11px; }
.site-footer span:first-child { font-weight: 800; letter-spacing: .15em; }
.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; }

@media (max-width: 850px) {
  .page-shell { padding: 0 28px; }
  .main-content { grid-template-columns: 1fr; gap: 48px; padding-top: 46px; }
  .intro { max-width: none; }
  h1 { font-size: clamp(58px, 10vw, 82px); }
  .how-to { margin-top: 30px; }
  .game-area { justify-self: center; }
}
@media (max-width: 520px) {
  .page-shell { padding: 0 16px; }
  .site-header { height: 68px; }
  .header-note { display: none; }
  .main-content { gap: 32px; padding: 37px 0 45px; }
  h1 { font-size: clamp(48px, 12vw, 65px); margin: 22px 0 16px; }
  .intro-copy { font-size: 14px; }
  .score-row { margin-top: 24px; }
  .score-card { flex: 1; min-width: 0; min-height: 75px; }
  .score-card strong { font-size: 27px; }
  .new-game-button { margin-top: 16px; }
  .how-to { margin-top: 25px; }
  .board-frame { padding: 8px; border-radius: 17px; }
  .board { gap: 8px; }
  .cell, .tile { border-radius: 8px; }
  .overlay { inset: 8px; }
  .site-footer { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
