:root {
  color-scheme: dark;
  --ink: #f6f3ed;
  --muted: #aaa69e;
  --night: #100e0d;
  --panel: #191614;
  --line: #3b342e;
  --lime: #c9f45b;
  --amber: #ffbf69;
  --display: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-width: 280px; background: var(--night); }
body { min-height: 100vh; margin: 0; color: var(--ink); background: radial-gradient(circle at 82% 6%, rgba(255, 191, 105, 0.12), transparent 30rem), var(--night); font-family: var(--body); line-height: 1.5; }
a { color: inherit; }
button { color: inherit; font: inherit; }
.site-header, main, footer { width: min(1040px, calc(100% - 40px)); margin-inline: auto; }
.site-header { display: flex; align-items: center; justify-content: space-between; min-height: 80px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 850; text-decoration: none; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; color: var(--night); background: var(--lime); border-radius: 9px; font-family: var(--display); }
.site-header p { margin: 0; color: var(--muted); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.site-header p span, .eyebrow { color: var(--amber); }
.intro { display: grid; grid-template-columns: 1fr minmax(250px, 390px); gap: 60px; align-items: end; padding: 66px 0 42px; }
.intro > p { margin-bottom: 5px; color: var(--muted); }
.eyebrow { margin: 0 0 10px; font-size: 0.72rem; font-weight: 850; letter-spacing: 0.18em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: var(--display); font-size: clamp(3.4rem, 8vw, 6.5rem); line-height: 0.82; letter-spacing: -0.075em; }
.game-shell { max-width: 680px; margin-inline: auto; padding: clamp(16px, 4vw, 34px); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.game-toolbar { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; margin-bottom: 18px; }
.score { display: grid; padding: 10px 14px; background: #221e1a; border: 1px solid var(--line); border-radius: 9px; }
.score span { color: var(--muted); font-size: 0.62rem; font-weight: 850; letter-spacing: 0.12em; text-transform: uppercase; }
.score strong { color: var(--amber); font: 850 1.55rem/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.game-toolbar button, .overlay button { min-height: 48px; padding: 0 18px; background: transparent; border: 1px solid #5a5048; border-radius: 9px; font-weight: 800; cursor: pointer; }
.game-toolbar button:hover, .game-toolbar button:focus-visible, .overlay button:hover, .overlay button:focus-visible { color: var(--night); background: var(--lime); border-color: var(--lime); }
.board-panel { position: relative; }
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(7px, 2vw, 12px); width: 100%; aspect-ratio: 1; padding: clamp(8px, 2.4vw, 14px); background: #090807; border: 1px solid #443c35; border-radius: 14px; touch-action: none; user-select: none; }
.tile { display: grid; min-width: 0; place-items: center; background: #29241f; border: 1px solid #3d352f; border-radius: 10px; font-family: var(--display); font-size: clamp(1.3rem, 6vw, 3rem); letter-spacing: -0.06em; }
.tile--empty { color: transparent; }
.tile--2 { color: #17140f; background: #e7dfcb; }
.tile--4 { color: #17140f; background: #eacb91; }
.tile--8 { color: #17100a; background: #ffad61; }
.tile--16 { color: #1b0a08; background: #ff846b; }
.tile--32 { color: #1e070c; background: #ff668f; }
.tile--64 { color: #f9f5ec; background: #be416d; }
.tile--128 { color: #0e1712; background: #a5df8b; font-size: clamp(1.15rem, 5vw, 2.6rem); }
.tile--256 { color: #0c1711; background: #73d6ac; font-size: clamp(1.15rem, 5vw, 2.6rem); }
.tile--512 { color: #0b1410; background: #c9f45b; font-size: clamp(1.15rem, 5vw, 2.6rem); }
.tile--1024, .tile--2048, .tile--4096 { color: #f8f5ed; background: #6955d9; font-size: clamp(0.9rem, 4vw, 2.1rem); box-shadow: 0 0 24px rgba(105, 85, 217, 0.36); }
.tile--2048, .tile--4096 { background: #9b50c8; }
.overlay { position: absolute; inset: 0; display: grid; place-content: center; padding: 24px; background: rgba(12, 9, 8, 0.91); border-radius: 14px; text-align: center; }
.overlay[hidden] { display: none; }
.overlay > p:first-child { margin-bottom: 8px; color: var(--amber); font-size: 0.7rem; font-weight: 850; letter-spacing: 0.15em; text-transform: uppercase; }
.overlay h2 { margin: 0; font: clamp(3rem, 12vw, 6rem)/1 var(--display); letter-spacing: -0.07em; }
.overlay > p { color: var(--muted); }
.overlay > div { display: flex; justify-content: center; gap: 8px; }
.game-note { display: flex; justify-content: space-between; gap: 20px; margin-top: 18px; color: var(--muted); font-size: 0.75rem; }
.game-note p { margin: 0; }
.game-note p:last-child { text-align: right; }
.game-note span { color: var(--amber); font-weight: 900; }
.rules { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(50px, 9vw, 110px); padding: 96px 0; }
.rules h2 { margin-bottom: 0; font-family: var(--display); font-size: clamp(2rem, 4vw, 3.8rem); line-height: 0.98; letter-spacing: -0.05em; }
.rules ol { margin: 0; padding: 0; list-style: none; }
.rules li { display: grid; grid-template-columns: 40px 1fr; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.rules li span { color: var(--amber); font: 800 0.7rem var(--display); }
.rules li p { margin: 0; color: var(--muted); }
footer { display: flex; justify-content: space-between; padding: 28px 0 42px; color: var(--muted); border-top: 1px solid var(--line); font-size: 0.8rem; }
footer a { color: var(--ink); font-weight: 750; text-decoration: none; }
footer p { margin: 0; }

@media (max-width: 700px) {
  .site-header, main, footer { width: min(100% - 24px, 600px); }
  .intro, .rules { grid-template-columns: 1fr; gap: 24px; }
  .intro { padding-top: 50px; }
}
@media (max-width: 480px) {
  .site-header { min-height: 68px; }
  .intro { padding: 44px 0 32px; }
  .game-shell { padding: 10px; }
  .game-toolbar { grid-template-columns: 1fr 1fr; }
  .game-toolbar button { grid-column: 1 / -1; }
  .game-note { display: block; }
  .game-note p:last-child { margin-top: 7px; text-align: left; }
  .rules { padding: 72px 0 82px; }
  footer { display: block; }
  footer p { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
