/* NV 2048 — a walnut game table with ivory tiles that warm to amber, rosewood and jade. Fonts: IBM Plex (SIL OFL). */
@font-face { font-family: 'Plex Mono'; src: url('./fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Condensed'; src: url('./fonts/ibm-plex-sans-condensed-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Plex Condensed'; src: url('./fonts/ibm-plex-sans-condensed-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
:root {
  --felt: #2a1a10; --walnut: #5a3a24; --walnut-2: #3f2818; --groove: rgba(0, 0, 0, 0.28); --ivory: #f6eedc; --brass: #c9a45c; --text: #f6eedc; --muted: #cbb89a;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Plex Condensed', 'Arial Narrow', system-ui, sans-serif; --mono: 'Plex Mono', ui-monospace, Consolas, monospace;
  --gap: clamp(6px, 1.8vw, 12px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html, body { overscroll-behavior: none; }
body { margin: 0; min-height: 100vh; color: var(--text); font: 500 16px/1.45 var(--sans); background: radial-gradient(110% 70% at 50% 0%, #4a2f1d, var(--felt) 70%) fixed; }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }
a { color: var(--brass); }
.table { width: min(560px, calc(100% - 28px)); margin: clamp(14px, 3vw, 34px) auto; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.head { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.brand { margin: 0; font-size: 12px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--brass); }
.brand span { color: var(--text); font-weight: 600; }
h1 { margin: 0; font: 700 clamp(48px, 12vw, 72px)/0.95 var(--serif); letter-spacing: -0.02em; }
.scores { display: flex; gap: 8px; }
.score { position: relative; min-width: 86px; padding: 6px 12px; border-radius: 10px; background: linear-gradient(var(--walnut), var(--walnut-2)); text-align: center; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 0 rgba(0, 0, 0, 0.4); }
.score span { display: block; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.score output { font: 600 22px var(--serif); }
.plus { position: absolute; left: 0; right: 0; top: 4px; font: normal 600 16px var(--sans); color: var(--brass); opacity: 0; pointer-events: none; }
.plus.show { animation: rise 0.7s ease-out; }
@keyframes rise { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-28px); } }
.bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.goal { margin: 0; color: var(--muted); }
.goal b { color: var(--text); }
.acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.acts select, .btn { min-height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid rgba(201, 164, 92, 0.35); background: var(--walnut-2); cursor: pointer; font-weight: 600; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn--brass { background: linear-gradient(#ddbd78, #9a7a3e); color: #241608; border-color: transparent; }

.board {
  --size: 4; position: relative; aspect-ratio: 1; border-radius: 16px; padding: var(--gap); touch-action: none; user-select: none;
  background: repeating-linear-gradient(95deg, rgba(255, 255, 255, 0.025) 0 3px, transparent 3px 9px), linear-gradient(145deg, #6b4529, var(--walnut-2));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.08), inset 0 -3px 0 rgba(0, 0, 0, 0.35), 0 26px 50px -24px rgba(0, 0, 0, 0.85);
}
.cells { position: absolute; inset: var(--gap); display: grid; grid-template-columns: repeat(var(--size), 1fr); gap: var(--gap); }
.cells i { border-radius: 10px; background: var(--groove); box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35); }
.tiles { position: absolute; inset: 0; }
.tile {
  --r: 0; --c: 0; position: absolute; left: 0; top: 0; display: grid; place-items: center; border-radius: 10px;
  width: calc((100% - (var(--size) + 1) * var(--gap)) / var(--size)); height: calc((100% - (var(--size) + 1) * var(--gap)) / var(--size));
  transform: translate(calc(var(--gap) + var(--c) * (100% + var(--gap))), calc(var(--gap) + var(--r) * (100% + var(--gap))));
  transition: transform 110ms ease-in-out; font: 700 calc(var(--fs, 1) * min(9vw, 46px) * 4 / var(--size)) / 1 var(--serif); color: #3b2a1a;
  background: var(--bgc, var(--ivory)); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.16), inset 0 2px 0 rgba(255, 255, 255, 0.45), 0 3px 6px rgba(0, 0, 0, 0.35);
}
.tile > span { display: block; }
.tile.new > span, .tile.new { animation: appear 160ms ease-out; }
.tile.merged > span { animation: pop 180ms ease-out; }
@keyframes appear { from { opacity: 0; scale: 0.4; } to { opacity: 1; scale: 1; } }
@keyframes pop { 0% { scale: 1; } 50% { scale: 1.18; } 100% { scale: 1; } }
.v2 { --bgc: #f6eedc; } .v4 { --bgc: #efdfbe; } .v8 { --bgc: #f1bd74; color: #3a210c; } .v16 { --bgc: #ec9d52; color: #2f1909; }
.v32 { --bgc: #e47d43; color: #fff7ea; } .v64 { --bgc: #d65a30; color: #fff7ea; } .v128 { --bgc: #d1aa52; color: #2b1c07; --fs: 0.86; }
.v256 { --bgc: #bf8f35; color: #fff7ea; --fs: 0.86; } .v512 { --bgc: #a8702a; color: #fff7ea; --fs: 0.86; } .v1024 { --bgc: #7d3a2a; color: #f6e2c8; --fs: 0.72; }
.v2048 { --bgc: #2f6b57; color: #f2f7ef; --fs: 0.72; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2), 0 0 22px rgba(120, 220, 170, 0.45); }
.vbig { --bgc: #1f3b4d; color: #e9f2f7; --fs: 0.6; }
.overlay { position: absolute; inset: 0; z-index: 3; border-radius: 16px; background: rgba(42, 26, 16, 0.78); display: grid; place-content: center; text-align: center; gap: 8px; animation: fade 0.3s; padding: 16px; }
.overlay p { margin: 0; font: 700 clamp(30px, 7vw, 44px) var(--serif); }
.overlay .overlay__sub { font: 500 16px var(--sans); color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
.hint { margin: 0; text-align: center; font-size: 13px; color: var(--muted); }
kbd { font: 400 11px var(--mono); border: 1px solid rgba(201, 164, 92, 0.35); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; margin: 0 1px; background: var(--walnut-2); }
.foot { text-align: center; font-size: 12px; color: rgba(246, 238, 220, 0.5); }
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } .tile.new, .tile.new > span, .tile.merged > span, .plus.show { animation: none; } }
