/* NSNEKO adaptation of the classic 2048. Local system fonts only. */
.puzzle-page { padding-bottom: 28px; }
.puzzle-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 40px 0 35px; }
.puzzle-back { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 23px; font-size: 11px; color: var(--muted); }
.puzzle-back:hover { color: var(--accent); }
.puzzle-intro .eyebrow { font-size: 9px; }
.puzzle-intro h1 { display: flex; align-items: baseline; margin: 7px 0 8px; font: 550 clamp(55px, 7vw, 79px)/1.15 var(--font); letter-spacing: -.065em; }
.puzzle-subtitle { display: inline-block; color: var(--warm); font-size: 23px; font-weight: 400; margin-left: 24px; letter-spacing: -.04em; }
.puzzle-lead { color: var(--muted); font-size: 12px; line-height: 1.85; }
.puzzle-intro-note { display: flex; flex-direction: column; align-items: flex-end; gap: 13px; color: var(--muted-low); font: 8px var(--mono); letter-spacing: .1em; padding-bottom: 5px; }
.puzzle-arithmetic { font: 400 28px/1 var(--mono); color: var(--accent); letter-spacing: -.04em; }
.puzzle-arithmetic i { font: normal 18px var(--font); color: var(--muted-low); margin: 0 6px; }
.puzzle-layout { display: grid; grid-template-columns: minmax(0, 1fr) 303px; gap: 35px; align-items: stretch; max-width: 920px; margin-inline: auto; padding: 26px; border: 1px solid #c5f2d526; border-radius: 17px; background: linear-gradient(135deg, #13201b88, #11171c 48%, #141d2088); }
.board-column { min-width: 0; }
.board-caption { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 13px; color: var(--muted-low); }
.board-caption .mono { font-size: 8px; letter-spacing: .1em; }
.board-caption-right { color: var(--muted); font-size: 9px; }
.game-container { --gap: 12px; position: relative; width: 100%; aspect-ratio: 1; padding: var(--gap); border: 1px solid #c5f2d530; border-radius: 13px; background: #0c1418; outline-offset: 5px; touch-action: none; user-select: none; -webkit-user-select: none; }
.game-container:focus-visible { outline: 2px solid var(--accent); }
.grid-container { position: absolute; inset: var(--gap); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.grid-cell { background: #1a252b; border: 1px solid #ffffff04; border-radius: 8px; }
.tile-container { position: absolute; inset: var(--gap); }
.tile { --x: 0; --y: 0; position: absolute; width: calc((100% - 3 * var(--gap)) / 4); height: calc((100% - 3 * var(--gap)) / 4); transform: translate(calc(var(--x) * (100% + var(--gap))), calc(var(--y) * (100% + var(--gap)))); transition: transform 100ms ease-in-out; z-index: 2; }
.tile-inner { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; border-radius: 8px; background: #c5f2d5; color: #14241b; font: 650 clamp(24px, 3.5vw, 44px)/1 var(--font); letter-spacing: -.055em; }
.tile-position-1-1 { --x: 0; --y: 0; }
.tile-position-1-2 { --x: 0; --y: 1; }
.tile-position-1-3 { --x: 0; --y: 2; }
.tile-position-1-4 { --x: 0; --y: 3; }
.tile-position-2-1 { --x: 1; --y: 0; }
.tile-position-2-2 { --x: 1; --y: 1; }
.tile-position-2-3 { --x: 1; --y: 2; }
.tile-position-2-4 { --x: 1; --y: 3; }
.tile-position-3-1 { --x: 2; --y: 0; }
.tile-position-3-2 { --x: 2; --y: 1; }
.tile-position-3-3 { --x: 2; --y: 2; }
.tile-position-3-4 { --x: 2; --y: 3; }
.tile-position-4-1 { --x: 3; --y: 0; }
.tile-position-4-2 { --x: 3; --y: 1; }
.tile-position-4-3 { --x: 3; --y: 2; }
.tile-position-4-4 { --x: 3; --y: 3; }
.tile-2 .tile-inner { color: #d7e8df; background: #2a4339; box-shadow: inset 0 1px 0 #c5f2d510; }
.tile-4 .tile-inner { color: #edf2e8; background: #43594b; }
.tile-8 .tile-inner { color: #30241c; background: #e5b696; }
.tile-16 .tile-inner { color: #35271e; background: #e6a783; }
.tile-32 .tile-inner { color: #301f19; background: #e9967a; }
.tile-64 .tile-inner { color: #2b1714; background: #eb876e; }
.tile-128 .tile-inner { color: #182a20; background: #b0ddbc; font-size: clamp(23px, 3vw, 37px); }
.tile-256 .tile-inner { color: #172a1e; background: #abe8bf; font-size: clamp(23px, 3vw, 37px); }
.tile-512 .tile-inner { color: #14291c; background: #9ce9b8; box-shadow: 0 0 20px #9ce9b815; font-size: clamp(23px, 3vw, 37px); }
.tile-1024 .tile-inner { color: #12291b; background: #8aecb0; box-shadow: 0 0 25px #8aecb020; font-size: clamp(18px, 2.7vw, 31px); }
.tile-2048 .tile-inner { color: #0e2819; background: #c5f2d5; box-shadow: 0 0 25px #c5f2d533, inset 0 0 0 1px #ffffff55; font-size: clamp(18px, 2.7vw, 31px); }
.tile-super .tile-inner { color: #dcefe1; background: #315b46; border: 1px solid #c5f2d54a; font-size: clamp(16px, 2.5vw, 29px); }
.tile-new .tile-inner { animation: tile-appear 170ms ease 80ms backwards; }
.tile-merged { z-index: 3; }
.tile-merged .tile-inner { animation: tile-merge 170ms ease backwards; }
@keyframes tile-appear { from { opacity: 0; transform: scale(.45); } to { opacity: 1; transform: scale(1); } }
@keyframes tile-merge { 0% { transform: scale(.75); } 55% { transform: scale(1.13); } 100% { transform: scale(1); } }
.game-message { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; border-radius: 12px; text-align: center; background: #0b1513eb; backdrop-filter: blur(5px); }
.game-message h3 { margin: 0 0 12px; font-size: clamp(25px, 3.3vw, 38px); font-weight: 550; color: var(--accent); letter-spacing: -.05em; }
.game-message p { max-width: 280px; font-size: 12px; line-height: 1.8; color: var(--muted); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }
.result-actions .button { min-height: 44px; }
.game-status { min-height: 20px; margin-top: 14px; color: var(--muted); font-size: 10px; line-height: 1.7; overflow-wrap: anywhere; }
.board-footnote { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; color: var(--muted-low); margin-top: 12px; font-size: 10px; }
.board-footnote .mono { font-size: 7px; letter-spacing: .05em; }
.puzzle-sidebar { min-width: 0; display: flex; flex-direction: column; padding: 2px 0 0 27px; border-left: 1px solid var(--line); }
.sidebar-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--accent); }
.sidebar-label .eyebrow { font-size: 8px; color: var(--muted-low); }
.sidebar-label > span:last-child { font: 20px/1 var(--mono); }
.scores-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 24px; }
.score-card { min-width: 0; }
.score-label { display: block; margin-bottom: 10px; font-size: 10px; color: var(--muted); }
.score-container, .best-container { position: relative; font: 400 clamp(24px, 2.5vw, 33px)/1.2 var(--mono); letter-spacing: -.07em; color: var(--accent); overflow-wrap: anywhere; }
.best-container { color: var(--text); }
.score-addition { position: absolute; z-index: 4; left: 0; top: 0; color: var(--warm); font: 500 16px var(--mono); animation: score-rise 550ms ease-in both; pointer-events: none; }
@keyframes score-rise { from { opacity: 1; transform: translateY(-4px); } to { opacity: 0; transform: translateY(-35px); } }
.largest-readout { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 24px 0 20px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.largest-readout > span { color: var(--muted); font-size: 10px; }
.largest-readout strong { font: 400 21px/1 var(--mono); letter-spacing: -.05em; color: var(--warm); }
.puzzle-sidebar .restart-button { min-height: 44px; justify-content: space-between; width: 100%; font-size: 11px; padding-inline: 14px; }
.puzzle-controls { padding-top: 28px; }
.puzzle-controls h2 { font-size: 14px; font-weight: 500; letter-spacing: -.03em; margin-bottom: 9px; }
.puzzle-controls p { color: var(--muted); font-size: 11px; line-height: 1.9; }
.direction-pad { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); justify-content: center; gap: 6px; margin: 20px auto 22px; }
.direction-pad button { border: 1px solid #c5f2d532; border-radius: 7px; background: #c5f2d506; color: var(--accent); font: 24px/1 var(--font); min-width: 44px; min-height: 44px; transition: background .15s, border-color .15s; }
.direction-pad button:hover { background: #c5f2d511; border-color: #c5f2d562; }
.direction-pad button:active { background: #c5f2d526; }
.direction-pad [data-direction="0"] { grid-column: 2; grid-row: 1; }
.direction-pad [data-direction="1"] { grid-column: 3; grid-row: 2; }
.direction-pad [data-direction="2"] { grid-column: 2; grid-row: 3; }
.direction-pad [data-direction="3"] { grid-column: 1; grid-row: 2; }
.direction-center { grid-column: 2; grid-row: 2; display: grid; place-items: center; color: #c5f2d53f; font-size: 20px; }
.puzzle-storage-note { padding-top: 17px; margin-top: auto; border-top: 1px solid var(--line); font-size: 9px; color: var(--muted-low); line-height: 1.85; }
.puzzle-guide { display: grid; grid-template-columns: 275px minmax(0, 1fr); gap: 44px; padding: 35px 0 32px; }
.puzzle-guide .eyebrow { font-size: 8px; }
.puzzle-guide h2 { font-size: 17px; letter-spacing: -.03em; font-weight: 500; margin-top: 10px; }
.puzzle-guide > p { font-size: 11px; line-height: 1.95; color: var(--muted); padding-top: 2px; }
.puzzle-noscript { padding: 18px; color: var(--warm); border: 1px solid #e5b69650; border-radius: 8px; font-size: 12px; }
.puzzle-footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; padding-top: 23px; border-top: 1px solid var(--line); color: var(--muted-low); font-size: 9px; }
.puzzle-footer > div { display: flex; flex-direction: column; gap: 5px; }
.puzzle-footer .puzzle-credit { align-items: flex-end; }
.puzzle-credit a { color: var(--muted); font-size: 10px; }
.puzzle-credit a:hover { color: var(--accent); }
.puzzle-credit a + a { margin-left: 17px; }
.puzzle-credit a > span { color: var(--accent); margin-left: 4px; }
@media (max-width: 1000px) {
  .puzzle-layout { grid-template-columns: minmax(0, 1fr) 260px; padding: 22px; gap: 25px; }
  .puzzle-sidebar { padding-left: 21px; }
  .game-container { --gap: 10px; }
  .puzzle-guide { grid-template-columns: 240px minmax(0, 1fr); gap: 28px; }
}
@media (max-width: 760px) {
  .puzzle-intro { padding-top: 30px; }
  .puzzle-intro-note { display: none; }
  .puzzle-layout { grid-template-columns: minmax(0, 1fr); gap: 25px; padding: 20px; }
  .board-column { width: 100%; max-width: 480px; margin-inline: auto; }
  .puzzle-sidebar { width: 100%; padding: 22px 0 0; border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 22px; }
  .sidebar-label { grid-column: 1 / -1; }
  .scores-panel { margin-top: 18px; grid-column: 1; }
  .largest-readout { grid-column: 2; grid-row: 2; margin: 18px 0 0; border: 0; padding: 0; flex-direction: column; justify-content: flex-start; align-items: flex-end; gap: 10px; }
  .largest-readout strong { font-size: 28px; }
  .puzzle-sidebar .restart-button { grid-column: 1; margin-top: 22px; align-self: start; }
  .puzzle-controls { grid-column: 1 / -1; padding-top: 23px; }
  .puzzle-controls h2 { font-size: 13px; }
  .direction-pad { margin-block: 15px 18px; }
  .puzzle-storage-note { grid-column: 1 / -1; }
  .puzzle-guide { grid-template-columns: 1fr; gap: 15px; padding-top: 29px; }
  .tile-inner { font-size: clamp(25px, 7vw, 44px); }
  .tile-128 .tile-inner, .tile-256 .tile-inner, .tile-512 .tile-inner { font-size: clamp(22px, 6vw, 37px); }
  .tile-1024 .tile-inner, .tile-2048 .tile-inner { font-size: clamp(18px, 5.3vw, 31px); }
  .tile-super .tile-inner { font-size: clamp(16px, 4.6vw, 29px); }
}
@media (max-width: 480px) {
  .puzzle-page { padding-inline: 16px; }
  .puzzle-intro { padding-top: 25px; padding-bottom: 25px; }
  .puzzle-back { margin-bottom: 18px; }
  .puzzle-intro .eyebrow { font-size: 7px; letter-spacing: .1em; }
  .puzzle-intro h1 { font-size: 62px; }
  .puzzle-subtitle { margin-left: 18px; font-size: 19px; }
  .puzzle-lead { font-size: 11px; }
  .puzzle-layout { padding: 13px; border-radius: 12px; gap: 19px; }
  .game-container { --gap: 8px; border-radius: 9px; }
  .grid-cell, .tile-inner { border-radius: 5px; }
  .board-caption { gap: 8px; margin-bottom: 10px; }
  .board-caption .mono { font-size: 7px; }
  .board-caption-right { font-size: 8px; }
  .board-footnote { font-size: 9px; gap: 6px; }
  .board-footnote .mono { font-size: 6px; letter-spacing: .015em; }
  .game-status { font-size: 9px; margin-top: 11px; }
  .puzzle-sidebar { column-gap: 16px; padding-top: 18px; }
  .scores-panel { gap: 10px; }
  .score-label { font-size: 9px; margin-bottom: 8px; }
  .score-container, .best-container { font-size: 25px; }
  .largest-readout > span { font-size: 9px; }
  .largest-readout strong { font-size: 25px; }
  .puzzle-sidebar .restart-button { grid-column: 1 / -1; margin-top: 19px; }
  .puzzle-controls p { font-size: 10px; }
  .game-message { padding: 18px; }
  .game-message h3 { font-size: 26px; }
  .game-message p { font-size: 11px; }
  .result-actions { gap: 7px; margin-top: 17px; }
  .result-actions .button { font-size: 11px; padding-inline: 13px; gap: 12px; }
  .puzzle-footer { flex-direction: column; gap: 16px; }
  .puzzle-footer .puzzle-credit { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .puzzle-page *, .puzzle-page *::before, .puzzle-page *::after { animation: none !important; transition: none !important; }
  .score-addition { display: none; }
}

@media (min-width: 1001px) {
  .puzzle-layout { max-width: none; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); }
  .board-column { width: 100%; max-width: clamp(500px, calc(100dvh - 180px), 720px); margin-inline: auto; }
  .puzzle-sidebar { padding-left: 32px; }
}
