:root {
  --g2048-page-bg: #faf8ef;
  --g2048-text: #776e65;
  --g2048-muted: #776e65;
  --g2048-board-bg: #a89989;
  --g2048-cell-bg: #c8b9a5;
  --g2048-button-bg: #8f7f70;
  --g2048-button-bg-hover: #7d6f62;
  --g2048-board-size: min(78vw, 492px);
  --g2048-board-gap: 12px;
  --g2048-board-pad: 12px;
  --g2048-board-radius: 20px;
  --g2048-tile-radius: 9px;
  --g2048-move-duration: 118ms;
  --g2048-viewport-height: 100vh;
  --g2048-viewport-width: 100vw;
}

* {
  box-sizing: border-box;
}

html,
body.game2048-theme {
  margin: 0;
  min-height: 100%;
  background: var(--g2048-page-bg);
  color: var(--g2048-text);
}

body.game2048-theme {
  min-height: var(--g2048-viewport-height);
  overflow-x: hidden;
  overscroll-behavior-x: none;
  font-family: Arial, Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Keep typography native to each script without loading third-party fonts. */
html[lang^="ja"] body.game2048-theme { font-family: "Yu Gothic", Meiryo, Arial, sans-serif; }
html[lang^="ko"] body.game2048-theme { font-family: "Malgun Gothic", Arial, sans-serif; }
html[lang="zh-CN"] body.game2048-theme { font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif; }
html[lang="zh-TW"] body.game2048-theme { font-family: "Microsoft JhengHei", "PingFang TC", Arial, sans-serif; }
html[lang^="th"] body.game2048-theme { font-family: Tahoma, Arial, sans-serif; }

body.game2048-theme button,
body.game2048-theme input,
body.game2048-theme textarea,
body.game2048-theme select {
  font: inherit;
}

body.game2048-theme button,
body.game2048-theme select,
body.game2048-theme a {
  -webkit-tap-highlight-color: transparent;
}

body.game2048-theme button,
body.game2048-theme select,
.g2048-mode-btn,
.g2048-language-links-list a {
  touch-action: manipulation;
}

.g2048-app-shell {
  width: 100%;
  min-height: var(--g2048-viewport-height);
  display: flex;
  flex-direction: column;
  padding: 23px max(clamp(15px, 2.8vw, 28px), env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(clamp(15px, 2.8vw, 28px), env(safe-area-inset-left));
}

.admin-bar .g2048-app-shell {
  min-height: calc(100dvh - 32px);
}

.g2048-topbar {
  position: relative;
  z-index: 40;
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  align-items: center;
  gap: 18px;
}

.g2048-brand-wrap {
  justify-self: start;
}

.g2048-brand {
  display: inline-block;
  color: #77695c;
  font-size: clamp(45px, 4.2vw, 54px);
  font-weight: 700;
  line-height: .94;
  letter-spacing: -2.5px;
}

.g2048-score-wrap {
  justify-self: center;
  display: flex;
  align-items: stretch;
  gap: 14px;
}

.g2048-score-card {
  position: relative;
  min-width: 72px;
  height: 54px;
  padding: 7px 12px 6px;
  border-radius: 14px;
  background: #ebe6d8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.g2048-score-card--best {
  background: rgba(255, 255, 255, .22);
  border: 2px solid #e8e2d4;
}

.g2048-score-label {
  color: #6f655c;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .01em;
}

.g2048-score-value {
  margin-top: 4px;
  color: #6f655c;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.g2048-score-card.is-bumped {
  animation: g2048-score-bump 180ms ease-out;
}

.g2048-actions {
  position: relative;
  z-index: 2;
  justify-self: end;
  pointer-events: auto;
}

.g2048-new-game-btn {
  position: relative;
  z-index: 1;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--g2048-button-bg);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(82, 68, 57, .14);
  transition: background-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.g2048-new-game-btn:hover {
  background: var(--g2048-button-bg-hover);
  box-shadow: 0 5px 14px rgba(82, 68, 57, .18);
}

.g2048-new-game-btn:active {
  transform: translateY(1px);
}

.g2048-new-game-btn:focus-visible,
.g2048-primary-btn:focus-visible,
.g2048-secondary-btn:focus-visible {
  outline: 3px solid #665d55;
  outline-offset: 3px;
}

.g2048-game-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(38px, 7vh, 82px) 0 clamp(24px, 4vh, 42px);
}

.g2048-board {
  position: relative;
  width: var(--g2048-board-size);
  height: var(--g2048-board-size);
  padding: var(--g2048-board-pad);
  overflow: hidden;
  border-radius: var(--g2048-board-radius);
  background: var(--g2048-board-bg);
  box-shadow: 0 14px 30px rgba(82, 68, 57, .15), 0 2px 5px rgba(82, 68, 57, .19);
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  isolation: isolate;
  contain: layout paint;
  overscroll-behavior: contain;
  -webkit-touch-callout: none;
}

.g2048-board:focus-visible {
  outline: 3px solid rgba(119, 110, 101, .35);
  outline-offset: 5px;
}

.g2048-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(var(--g2048-grid-size, 4), minmax(0, 1fr));
  grid-template-rows: repeat(var(--g2048-grid-size, 4), minmax(0, 1fr));
  gap: var(--g2048-board-gap);
}

.g2048-cell {
  min-width: 0;
  min-height: 0;
  border-radius: var(--g2048-tile-radius);
  background: var(--g2048-cell-bg);
}

.g2048-tiles {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.g2048-tile {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--g2048-tile-radius);
  color: #776e65;
  font-size: clamp(30px, 4.4vw, 50px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1.6px;
  font-variant-numeric: tabular-nums;
  will-change: auto;
  transition: transform var(--g2048-move-duration) cubic-bezier(.25, .62, .35, 1);
}

.g2048-tile[data-value="2"] { background: #eee4da; }
.g2048-tile[data-value="4"] { background: #ede0c8; }
.g2048-tile[data-value="8"] { background: #f2b179; color: #f9f6f2; }
.g2048-tile[data-value="16"] { background: #f59563; color: #f9f6f2; }
.g2048-tile[data-value="32"] { background: #f67c5f; color: #f9f6f2; }
.g2048-tile[data-value="64"] { background: #f65e3b; color: #f9f6f2; }
.g2048-tile[data-value="128"] { background: #edcf72; color: #f9f6f2; font-size: clamp(26px, 4vw, 44px); }
.g2048-tile[data-value="256"] { background: #edcc61; color: #f9f6f2; font-size: clamp(26px, 4vw, 44px); }
.g2048-tile[data-value="512"] { background: #edc850; color: #f9f6f2; font-size: clamp(26px, 4vw, 44px); }
.g2048-tile[data-value="1024"] { background: #edc53f; color: #f9f6f2; font-size: clamp(22px, 3.5vw, 38px); }
.g2048-tile[data-value="2048"] { background: #edc22e; color: #f9f6f2; font-size: clamp(22px, 3.5vw, 38px); box-shadow: 0 0 16px rgba(237, 194, 46, .2); }
.g2048-tile[data-value="4096"],
.g2048-tile[data-value="8192"] {
  background: #3c3a32;
  color: #f9f6f2;
  font-size: clamp(19px, 3.1vw, 34px);
}
.g2048-tile[data-value="16384"],
.g2048-tile[data-value="32768"],
.g2048-tile[data-value="65536"] {
  background: #2f2d27;
  color: #f9f6f2;
  font-size: clamp(16px, 2.7vw, 30px);
}

.g2048-tile--moving {
  will-change: transform;
}

.g2048-tile--spawn {
  animation: g2048-tile-spawn 155ms 55ms ease-out both;
}

.g2048-tile--merge {
  z-index: 3;
  animation: g2048-tile-merge 185ms 15ms ease-out both;
}

.g2048-controls-hint {
  margin: 21px 0 0;
  min-height: 20px;
  color: var(--g2048-muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

.g2048-mobile-hint {
  display: none;
}

.g2048-game-message[hidden] {
  display: none;
}

.g2048-game-message {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-radius: inherit;
  background: rgba(250, 248, 239, .86);
  animation: g2048-overlay-in 140ms ease-out both;
}

@supports (backdrop-filter: blur(2px)) {
  .g2048-game-message {
    backdrop-filter: blur(2px);
  }
}

.g2048-game-message__panel {
  width: min(100%, 350px);
  max-height: calc(100% - 2px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  touch-action: pan-y;
  padding: 23px;
  border: 1px solid rgba(151, 135, 119, .12);
  border-radius: 17px;
  background: #fffaf2;
  box-shadow: 0 15px 34px rgba(82, 68, 57, .15);
  text-align: center;
}

.g2048-game-message__title {
  margin: 0;
  color: #6f6358;
  font-size: clamp(29px, 5vw, 40px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -1px;
}

.g2048-game-message__text {
  margin: 10px 0 19px;
  color: var(--g2048-muted);
  font-size: 14px;
  line-height: 1.5;
}

.g2048-game-message__actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
}

.g2048-primary-btn,
.g2048-secondary-btn {
  min-height: 44px;
  padding: 0 15px;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 140ms ease, transform 140ms ease;
}

.g2048-primary-btn {
  border: 0;
  background: var(--g2048-button-bg);
  color: #fff;
}

.g2048-primary-btn:hover {
  background: var(--g2048-button-bg-hover);
}

.g2048-secondary-btn {
  border: 2px solid #d9d0c2;
  background: transparent;
  color: var(--g2048-text);
}

.g2048-secondary-btn:hover {
  background: rgba(217, 208, 194, .22);
}

.g2048-primary-btn:active,
.g2048-secondary-btn:active {
  transform: translateY(1px);
}

.g2048-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;
}

.g2048-content-shell {
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: 60px 0;
}

.g2048-content-card {
  padding: clamp(24px, 5vw, 48px);
  border-radius: 18px;
  background: #fffaf2;
}

.g2048-content-title {
  margin-top: 0;
}

.g2048-content-body {
  line-height: 1.7;
}

@keyframes g2048-tile-spawn {
  0% { opacity: 0; transform: scale(.55); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes g2048-tile-merge {
  0% { transform: scale(1); }
  52% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes g2048-score-bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.055); }
  100% { transform: scale(1); }
}

@keyframes g2048-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 782px) {
  .admin-bar .g2048-app-shell {
    min-height: calc(100dvh - 46px);
  }
}

@media (max-width: 700px) {
  :root {
    --g2048-board-size: min(
      calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)),
      470px
    );
    --g2048-board-gap: clamp(7px, 2.2vw, 10px);
    --g2048-board-pad: clamp(8px, 2.3vw, 11px);
    --g2048-board-radius: 17px;
    --g2048-tile-radius: 8px;
  }

  .g2048-app-shell {
    min-height: var(--g2048-viewport-height);
    padding-top: max(13px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .g2048-topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand action"
      "scores scores";
    gap: 12px 10px;
  }

  .g2048-brand-wrap {
    grid-area: brand;
  }

  .g2048-brand {
    font-size: clamp(42px, 13vw, 50px);
  }

  .g2048-score-wrap {
    grid-area: scores;
    justify-self: center;
    gap: 8px;
  }

  .g2048-score-card {
    min-width: 68px;
    height: 49px;
    padding-inline: 9px;
    border-radius: 12px;
  }

  .g2048-score-value {
    font-size: 18px;
  }

  .g2048-actions {
    grid-area: action;
  }

  .g2048-new-game-btn {
    min-height: 40px;
    padding-inline: 15px;
  }

  .g2048-game-area {
    justify-content: flex-start;
    padding: clamp(24px, 6vh, 40px) 0 12px;
  }

  .g2048-tile {
    font-size: clamp(29px, 10.5vw, 46px);
  }

  .g2048-tile[data-value="128"],
  .g2048-tile[data-value="256"],
  .g2048-tile[data-value="512"] {
    font-size: clamp(24px, 8.5vw, 38px);
  }

  .g2048-tile[data-value="1024"],
  .g2048-tile[data-value="2048"] {
    font-size: clamp(20px, 7.3vw, 33px);
  }

  .g2048-tile[data-value="4096"],
  .g2048-tile[data-value="8192"] {
    font-size: clamp(18px, 6.4vw, 29px);
  }

  .g2048-controls-hint {
    margin-top: 16px;
    font-size: 12.5px;
  }

  .g2048-desktop-hint {
    display: none;
  }

  .g2048-mobile-hint {
    display: inline;
  }
}

@media (max-width: 360px) {
  .g2048-brand {
    font-size: 40px;
  }

  .g2048-new-game-btn {
    padding-inline: 13px;
    font-size: 14px;
  }

  .g2048-score-card {
    min-width: 62px;
  }
}

@media (max-height: 720px) and (min-width: 701px) {
  :root {
    --g2048-board-size: min(66vh, 460px);
  }

  .g2048-game-area {
    padding-top: 24px;
    padding-bottom: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --g2048-move-duration: 0ms;
  }

  .g2048-app-shell *,
  .g2048-app-shell *::before,
  .g2048-app-shell *::after {
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
    animation-delay: 0ms !important;
  }
}

/* =========================================================
 * Step 3 — compact game controls
 * ======================================================= */
.g2048-control-zone {
  position: relative;
  z-index: 20;
  margin-top: 18px;
}

.g2048-control-dock {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(119, 110, 101, .08);
  border-radius: 18px;
  background: #ece7d9;
  box-shadow: 0 8px 22px rgba(82, 68, 57, .08);
}

.g2048-tool-btn {
  min-width: 0;
  height: 58px;
  padding: 5px 4px 4px;
  border: 0;
  border-radius: 12px;
  background: #fffaf2;
  color: #6f655c;
  box-shadow: inset 0 0 0 1px rgba(111, 101, 92, .14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: background-color 140ms ease, transform 140ms ease, opacity 140ms ease;
}

.g2048-tool-btn:hover:not(:disabled),
.g2048-tool-btn[aria-expanded="true"] {
  background: #f3eee3;
}

.g2048-tool-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.g2048-tool-btn:disabled {
  opacity: .43;
  cursor: not-allowed;
}

.g2048-tool-icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.g2048-tool-label {
  color: #6f655c;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.g2048-tool-btn:hover:not(:disabled) .g2048-tool-label,
.g2048-tool-btn[aria-expanded="true"] .g2048-tool-label {
  color: #5f564e;
}

.g2048-tool-btn:focus-visible,
.g2048-icon-close:focus-visible,
.g2048-help-close:focus-visible,
.g2048-setting-row input:focus-visible + .g2048-switch-ui {
  outline: 3px solid rgba(119, 110, 101, .28);
  outline-offset: 3px;
}

.g2048-options-panel[hidden],
.g2048-help-dialog[hidden] {
  display: none;
}

.g2048-options-panel {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  width: min(310px, calc(100vw - 28px));
  padding: 12px;
  border: 1px solid rgba(119, 110, 101, .12);
  border-radius: 16px;
  background: #fffaf2;
  box-shadow: 0 18px 44px rgba(82, 68, 57, .17);
  transform: translateX(-50%);
  animation: g2048-options-in 130ms ease-out both;
}

.g2048-options-panel::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #fffaf2;
  border-right: 1px solid rgba(119, 110, 101, .12);
  border-bottom: 1px solid rgba(119, 110, 101, .12);
  transform: translateX(-50%) rotate(45deg);
}

.g2048-options-head {
  min-height: 34px;
  padding: 0 2px 7px 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #6f6358;
  font-size: 15px;
}

.g2048-icon-close,
.g2048-help-close {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #948779;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.g2048-icon-close:hover,
.g2048-help-close:hover {
  background: rgba(151, 135, 119, .1);
  color: #6f6358;
}

.g2048-setting-row {
  min-height: 61px;
  padding: 9px 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-radius: 10px;
  cursor: pointer;
}

.g2048-setting-row:hover {
  background: rgba(236, 231, 217, .42);
}

.g2048-setting-row > span:first-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.g2048-setting-row strong {
  color: #776e65;
  font-size: 13.5px;
  line-height: 1.2;
}

.g2048-setting-row small {
  color: #a09386;
  font-size: 11px;
  line-height: 1.35;
}

.g2048-switch {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
}

.g2048-switch input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.g2048-switch-ui {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #d7d0c2;
  transition: background-color 150ms ease;
}

.g2048-switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(82, 68, 57, .2);
  transition: transform 150ms ease;
}

.g2048-switch input:checked + .g2048-switch-ui {
  background: #8f7f70;
}

.g2048-switch input:checked + .g2048-switch-ui::after {
  transform: translateX(18px);
}

.g2048-switch input:disabled + .g2048-switch-ui {
  opacity: .48;
}

.g2048-setting-row:has(input:disabled) {
  cursor: default;
  opacity: .72;
}

.g2048-help-dialog {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.g2048-help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(73, 63, 54, .34);
  animation: g2048-overlay-in 140ms ease-out both;
}

@supports (backdrop-filter: blur(3px)) {
  .g2048-help-backdrop {
    backdrop-filter: blur(3px);
  }
}

.g2048-help-panel {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: min(680px, calc(100dvh - 40px));
  overflow: auto;
  padding: 28px;
  border: 1px solid rgba(119, 110, 101, .12);
  border-radius: 20px;
  background: #fffaf2;
  box-shadow: 0 24px 65px rgba(82, 68, 57, .23);
  animation: g2048-help-in 160ms ease-out both;
}

.g2048-help-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.g2048-help-kicker {
  margin: 0 0 4px;
  color: #a09386;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
}

.g2048-help-panel h2 {
  margin: 0;
  color: #6f6358;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -.5px;
}

.g2048-help-intro {
  margin: 10px 0 20px;
  color: #8f8276;
  font-size: 14px;
  line-height: 1.55;
}

.g2048-help-grid {
  display: grid;
  gap: 10px;
}

.g2048-help-item {
  min-height: 92px;
  padding: 13px;
  border-radius: 14px;
  background: #f3eee3;
  display: grid;
  grid-template-columns: 82px 1fr;
  align-items: center;
  gap: 14px;
}

.g2048-help-item strong {
  color: #776e65;
  font-size: 14px;
}

.g2048-help-item p {
  margin: 4px 0 0;
  color: #978a7e;
  font-size: 12px;
  line-height: 1.45;
}

.g2048-key-cluster {
  display: grid;
  grid-template-columns: repeat(3, 22px);
  gap: 3px;
  justify-content: center;
}

.g2048-key-cluster kbd {
  width: 22px;
  height: 22px;
  border: 1px solid #cfc5b6;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #fffaf2;
  color: #786d62;
  display: grid;
  place-items: center;
  font: 700 12px/1 Arial, sans-serif;
  box-shadow: none;
}

.g2048-swipe-demo {
  width: 58px;
  height: 58px;
  margin: 0 auto;
  border-radius: 15px;
  background: #e5ddcf;
  color: #8b7c6e;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 700;
}

.g2048-help-tip {
  margin: 13px 0 0;
  padding: 11px 13px;
  border-left: 3px solid #c9bca9;
  border-radius: 0 9px 9px 0;
  background: rgba(236, 231, 217, .48);
  color: #8e8175;
  font-size: 12px;
  line-height: 1.5;
}

.g2048-help-done {
  width: 100%;
  margin-top: 17px;
}

.g2048-no-animations .g2048-tile {
  transition: none !important;
}

.g2048-no-animations .g2048-tile--spawn,
.g2048-no-animations .g2048-tile--merge,
.g2048-no-animations .g2048-score-card.is-bumped {
  animation: none !important;
}

body.g2048-dialog-open {
  overflow: hidden;
}

@keyframes g2048-options-in {
  from { opacity: 0; transform: translate(-50%, 5px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes g2048-help-in {
  from { opacity: 0; transform: translateY(7px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 700px) {
  .g2048-control-zone {
    margin-top: 14px;
  }

  .g2048-control-dock {
    grid-template-columns: repeat(3, 68px);
    padding: 6px;
    border-radius: 16px;
  }

  .g2048-tool-btn {
    height: 54px;
    border-radius: 11px;
  }

  .g2048-tool-icon {
    width: 22px;
    height: 22px;
  }

  .g2048-controls-hint {
    margin-top: 10px;
  }

  .g2048-help-panel {
    padding: 24px 18px 20px;
    border-radius: 18px;
  }

  .g2048-help-item {
    grid-template-columns: 72px 1fr;
  }
}

@media (max-width: 360px) {
  .g2048-control-dock {
    grid-template-columns: repeat(3, 64px);
  }

  .g2048-tool-label {
    font-size: 9.5px;
  }
}

/* =========================================================
 * Step 4 — persistent personal statistics
 * ======================================================= */
.g2048-stats {
  width: min(560px, calc(100vw - 30px));
  margin-top: 22px;
  padding: 15px;
  border: 1px solid rgba(119, 110, 101, .09);
  border-radius: 18px;
  background: rgba(255, 250, 242, .5);
}

.g2048-stats-head {
  min-height: 38px;
  padding: 0 3px 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.g2048-stats-kicker {
  margin: 0 0 3px;
  color: #a3978b;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .11em;
}

.g2048-stats h2 {
  margin: 0;
  color: #776e65;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.g2048-stats-note {
  margin: 0 0 1px;
  color: #aa9e92;
  font-size: 10.5px;
  white-space: nowrap;
}

.g2048-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

.g2048-stat-card {
  min-width: 0;
  min-height: 66px;
  padding: 9px 7px 8px;
  border-radius: 12px;
  background: #eee9dc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.g2048-stat-card--goal {
  background: #e9dfc7;
}

.g2048-stat-label {
  min-height: 24px;
  color: #9a8d80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.2;
}

.g2048-stat-value {
  max-width: 100%;
  overflow: hidden;
  color: #776e65;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g2048-stat-card--goal .g2048-stat-value {
  color: #8b754b;
}

@media (max-width: 700px) {
  .g2048-stats {
    width: min(100%, 470px);
    margin-top: 18px;
    padding: 12px;
    border-radius: 16px;
  }

  .g2048-stats-head {
    padding: 0 2px 9px;
  }

  .g2048-stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  .g2048-stat-card {
    min-height: 61px;
    padding: 8px 6px;
  }

  .g2048-stat-card:nth-child(4),
  .g2048-stat-card:nth-child(5) {
    grid-column: span 1;
  }

  .g2048-stat-label {
    min-height: 22px;
    font-size: 9px;
  }

  .g2048-stat-value {
    font-size: 17px;
  }
}

@media (max-width: 390px) {
  .g2048-stats-note {
    display: none;
  }

  .g2048-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .g2048-stat-card--goal {
    grid-column: 1 / -1;
    min-height: 54px;
  }

  .g2048-stat-card--goal .g2048-stat-label {
    min-height: 0;
  }
}

/* =========================================================
 * Step 5 — focused mode switcher: Classic 4×4 + 5×5
 * ======================================================= */
.g2048-mode-switcher {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 264px);
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid rgba(119, 110, 101, .10);
  border-radius: 14px;
  background: #eee9dd;
  box-shadow: 0 5px 14px rgba(82, 68, 57, .05);
}

.g2048-mode-btn {
  min-width: 0;
  text-decoration: none;
  min-height: 48px;
  padding: 6px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #95887b;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.g2048-mode-btn strong {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.g2048-mode-btn span {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  opacity: .82;
}

.g2048-mode-btn:hover:not(.is-active) {
  color: #796d62;
  background: rgba(255, 255, 255, .34);
}

.g2048-mode-btn.is-active,
.g2048-mode-btn[aria-pressed="true"] {
  background: #fffaf2;
  color: #776e65;
  box-shadow: 0 2px 8px rgba(82, 68, 57, .09);
}

.g2048-mode-btn:active {
  transform: translateY(1px);
}

.g2048-mode-btn:focus-visible {
  outline: 3px solid rgba(119, 110, 101, .24);
  outline-offset: 2px;
}

.g2048-board.is-size-5 {
  --g2048-board-gap: 9px;
  --g2048-board-pad: 11px;
  --g2048-tile-radius: 8px;
}

.g2048-board.is-size-5 .g2048-tile {
  font-size: clamp(27px, 3.6vw, 39px);
  letter-spacing: -1.2px;
}

.g2048-board.is-size-5 .g2048-tile[data-value="128"],
.g2048-board.is-size-5 .g2048-tile[data-value="256"],
.g2048-board.is-size-5 .g2048-tile[data-value="512"] {
  font-size: clamp(23px, 3.15vw, 34px);
}

.g2048-board.is-size-5 .g2048-tile[data-value="1024"],
.g2048-board.is-size-5 .g2048-tile[data-value="2048"] {
  font-size: clamp(19px, 2.7vw, 29px);
}

.g2048-board.is-size-5 .g2048-tile[data-value="4096"],
.g2048-board.is-size-5 .g2048-tile[data-value="8192"] {
  font-size: clamp(17px, 2.35vw, 25px);
}

@media (max-width: 700px) {
  .g2048-mode-switcher {
    width: min(100%, 246px);
    margin-bottom: 15px;
  }

  .g2048-mode-btn {
    min-height: 44px;
    padding-inline: 9px;
  }

  .g2048-board.is-size-5 {
    --g2048-board-gap: clamp(5px, 1.7vw, 8px);
    --g2048-board-pad: clamp(7px, 2vw, 9px);
    --g2048-tile-radius: 7px;
  }

  .g2048-board.is-size-5 .g2048-tile {
    font-size: clamp(23px, 7.6vw, 35px);
  }

  .g2048-board.is-size-5 .g2048-tile[data-value="128"],
  .g2048-board.is-size-5 .g2048-tile[data-value="256"],
  .g2048-board.is-size-5 .g2048-tile[data-value="512"] {
    font-size: clamp(20px, 6.6vw, 30px);
  }

  .g2048-board.is-size-5 .g2048-tile[data-value="1024"],
  .g2048-board.is-size-5 .g2048-tile[data-value="2048"] {
    font-size: clamp(17px, 5.6vw, 26px);
  }
}



/* =========================================================
 * Viewport, safe-area and touch UX
 * ======================================================= */
@supports (height: 100dvh) {
  :root {
    --g2048-viewport-height: 100dvh;
    --g2048-viewport-width: 100dvw;
  }
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-bottom: env(safe-area-inset-bottom);
}

.g2048-new-game-btn,
.g2048-mode-btn,
.g2048-tool-btn,
.g2048-primary-btn,
.g2048-secondary-btn,
.g2048-icon-close,
.g2048-help-close,
.g2048-switch {
  touch-action: manipulation;
}

.g2048-orientation-note {
  display: none;
  margin: 0;
  color: #95887b;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

body.g2048-dialog-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

@media (max-width: 700px) {
  .g2048-game-area {
    width: 100%;
  }

  .g2048-board {
    max-width: 100%;
  }

  .g2048-control-dock {
    max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  .g2048-options-panel {
    position: fixed;
    z-index: 9998;
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
    max-height: calc(var(--g2048-viewport-height) - max(24px, env(safe-area-inset-top)) - max(24px, env(safe-area-inset-bottom)));
    overflow: auto;
    transform: none;
    animation: g2048-mobile-sheet-in 150ms ease-out both;
    -webkit-overflow-scrolling: touch;
  }

  .g2048-options-panel::after {
    display: none;
  }

  .g2048-help-dialog {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .g2048-help-panel {
    max-height: calc(
      var(--g2048-viewport-height)
      - max(24px, env(safe-area-inset-top))
      - max(24px, env(safe-area-inset-bottom))
    );
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .g2048-game-message {
    padding: clamp(10px, 3.2vw, 18px);
  }

  .g2048-game-message__panel {
    padding: clamp(15px, 4.5vw, 21px);
  }

  .g2048-game-message__title {
    font-size: clamp(25px, 8vw, 34px);
  }
}

/* Short portrait screens: keep the entire play loop above the browser toolbar. */
@media (max-width: 700px) and (max-height: 720px) and (orientation: portrait) {
  .g2048-app-shell {
    padding-top: max(9px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .g2048-topbar {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand scores action";
    gap: 6px;
  }

  .g2048-brand {
    font-size: clamp(36px, 11vw, 42px);
    letter-spacing: -2px;
  }

  .g2048-score-wrap {
    justify-self: center;
    gap: 4px;
  }

  .g2048-score-card {
    min-width: clamp(52px, 17vw, 60px);
    height: 42px;
    padding: 5px 6px 4px;
    border-radius: 10px;
  }

  .g2048-score-label {
    font-size: 9px;
  }

  .g2048-score-value {
    margin-top: 3px;
    font-size: 16px;
  }

  .g2048-new-game-btn {
    min-height: 44px;
    padding-inline: 10px;
    border-radius: 9px;
    font-size: 13px;
  }

  .g2048-game-area {
    padding-top: 11px;
    padding-bottom: 8px;
  }

  .g2048-mode-switcher {
    width: min(100%, 322px);
    margin-bottom: 8px;
    padding: 3px;
    border-radius: 12px;
  }

  .g2048-mode-btn {
    min-height: 44px;
    padding: 5px 7px;
  }

  .g2048-mode-btn strong {
    font-size: 13px;
  }

  .g2048-mode-btn span {
    font-size: 10px;
  }

  .g2048-control-zone {
    margin-top: 8px;
  }

  .g2048-control-dock {
    grid-template-columns: repeat(3, 64px);
    padding: 5px;
    border-radius: 14px;
  }

  .g2048-tool-btn {
    height: 49px;
    border-radius: 10px;
  }

  .g2048-tool-icon {
    width: 20px;
    height: 20px;
  }

  .g2048-controls-hint {
    display: none;
  }

  .g2048-stats {
    margin-top: 14px;
  }
}

@media (max-width: 340px) and (max-height: 720px) and (orientation: portrait) {
  .g2048-brand {
    font-size: 35px;
  }

  .g2048-score-card {
    min-width: 50px;
  }

  .g2048-new-game-btn {
    padding-inline: 8px;
    font-size: 12px;
  }

  .g2048-control-dock {
    grid-template-columns: repeat(3, 61px);
  }
}

/* Phone landscape: playable side-by-side surface + non-blocking rotate hint. */
@media (min-width: 480px) and (max-width: 950px) and (max-height: 500px) and (orientation: landscape) {
  :root {
    --g2048-board-size: min(
      calc(var(--g2048-viewport-height) - 76px),
      calc(100vw - 250px - env(safe-area-inset-left) - env(safe-area-inset-right)),
      330px
    );
  }

  .g2048-app-shell {
    padding-top: max(7px, env(safe-area-inset-top));
    padding-bottom: max(9px, env(safe-area-inset-bottom));
  }

  .g2048-topbar {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand scores action";
    gap: 8px;
  }

  .g2048-brand {
    font-size: 36px;
  }

  .g2048-score-wrap {
    gap: 5px;
  }

  .g2048-score-card {
    min-width: 58px;
    height: 39px;
    padding: 4px 7px;
  }

  .g2048-score-label {
    font-size: 9px;
  }

  .g2048-score-value {
    margin-top: 2px;
    font-size: 15px;
  }

  .g2048-new-game-btn {
    min-height: 37px;
    padding-inline: 11px;
    font-size: 13px;
  }

  .g2048-game-area {
    display: grid;
    grid-template-columns: var(--g2048-board-size) minmax(184px, 210px);
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas:
      "board mode"
      "board control"
      "board note"
      "stats stats";
    justify-content: center;
    align-items: start;
    column-gap: 14px;
    row-gap: 8px;
    padding: 7px 0 9px;
  }

  .g2048-board {
    grid-area: board;
    align-self: start;
  }

  .g2048-mode-switcher {
    grid-area: mode;
    width: 100%;
    margin: 0;
  }

  .g2048-control-zone {
    grid-area: control;
    margin: 0;
  }

  .g2048-control-dock {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 5px;
  }

  .g2048-tool-btn {
    height: 49px;
  }

  .g2048-orientation-note {
    grid-area: note;
    display: block;
    align-self: start;
    padding: 4px 5px 0;
  }

  .g2048-controls-hint {
    display: none;
  }

  .g2048-stats {
    grid-area: stats;
    justify-self: center;
    margin-top: 5px;
  }
}

@keyframes g2048-mobile-sheet-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
 * Step 7 — homepage SEO content (game-first, content below)
 * ======================================================= */
.g2048-seo-content {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: clamp(44px, 7vw, 72px) 0 clamp(48px, 8vw, 84px);
  border-top: 1px solid rgba(119, 110, 101, .13);
  color: var(--g2048-text);
}

.g2048-seo-intro {
  max-width: 700px;
}

.g2048-seo-kicker {
  margin: 0 0 8px;
  color: #a09183;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .12em;
}

.g2048-seo-title {
  margin: 0;
  color: #6f6359;
  font-size: clamp(30px, 4.5vw, 42px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -1.2px;
}

.g2048-seo-intro > p:last-child {
  max-width: 680px;
  margin: 15px 0 0;
  color: #887b70;
  font-size: 16px;
  line-height: 1.72;
}

.g2048-seo-section {
  margin-top: clamp(38px, 6vw, 58px);
}

.g2048-seo-section h2 {
  margin: 0 0 18px;
  color: #776a5f;
  font-size: clamp(21px, 3vw, 26px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.35px;
}

.g2048-how-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: g2048-how;
}

.g2048-how-list li {
  position: relative;
  min-height: 54px;
  padding: 16px 0 16px 52px;
  border-top: 1px solid rgba(119, 110, 101, .11);
  counter-increment: g2048-how;
}

.g2048-how-list li:last-child {
  border-bottom: 1px solid rgba(119, 110, 101, .11);
}

.g2048-how-list li::before {
  content: counter(g2048-how);
  position: absolute;
  top: 16px;
  left: 0;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #ebe4d6;
  color: #827568;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.g2048-how-list strong,
.g2048-how-list span {
  display: block;
}

.g2048-how-list strong {
  color: #75695e;
  font-size: 15px;
  line-height: 1.35;
}

.g2048-how-list span {
  margin-top: 5px;
  color: #918478;
  font-size: 14px;
  line-height: 1.65;
}

.g2048-tip-list {
  display: grid;
  gap: 0;
}

.g2048-tip-list p {
  margin: 0;
  padding: 14px 0;
  border-top: 1px solid rgba(119, 110, 101, .11);
  color: #8c7f73;
  font-size: 14.5px;
  line-height: 1.7;
}

.g2048-tip-list p:last-child {
  border-bottom: 1px solid rgba(119, 110, 101, .11);
}

.g2048-tip-list strong {
  color: #75695e;
  font-weight: 700;
}

.g2048-mode-compare > p {
  margin-bottom: 18px;
}

.g2048-mode-compare-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.g2048-mode-compare-card {
  min-height: 142px;
  padding: 15px;
  border: 1px solid rgba(119, 110, 101, .13);
  border-radius: 14px;
  background: rgba(255, 250, 242, .55);
  color: #897d72;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}

.g2048-mode-compare-card:hover {
  border-color: rgba(119, 110, 101, .26);
  background: #fffaf2;
  transform: translateY(-1px);
}

.g2048-mode-compare-card:focus-visible {
  outline: 3px solid rgba(119, 110, 101, .22);
  outline-offset: 3px;
}

.g2048-mode-compare-card.is-current {
  border-color: rgba(119, 110, 101, .22);
  background: #f1ecdf;
}

.g2048-mode-compare-card strong {
  color: #75695e;
  font-size: 15px;
  line-height: 1.35;
}

.g2048-mode-compare-card span {
  font-size: 12.5px;
  line-height: 1.4;
}

.g2048-mode-compare-card small {
  margin-top: auto;
  color: #94877c;
  font-size: 12px;
  line-height: 1.45;
}

.g2048-faq-list {
  border-top: 1px solid rgba(119, 110, 101, .13);
}

.g2048-faq-item {
  border-bottom: 1px solid rgba(119, 110, 101, .13);
}

.g2048-faq-item summary {
  position: relative;
  padding: 17px 40px 17px 0;
  color: #75695e;
  cursor: pointer;
  list-style: none;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
}

.g2048-faq-item summary::-webkit-details-marker {
  display: none;
}

.g2048-faq-item summary::after {
  content: "+";
  position: absolute;
  top: 50%;
  right: 4px;
  width: 24px;
  height: 24px;
  margin-top: -12px;
  border-radius: 50%;
  background: #ece6da;
  color: #827568;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 500;
  line-height: 1;
}

.g2048-faq-item[open] summary::after {
  content: "−";
}

.g2048-faq-item summary:focus-visible {
  outline: 3px solid rgba(119, 110, 101, .22);
  outline-offset: 3px;
  border-radius: 4px;
}

.g2048-faq-answer {
  padding: 0 44px 17px 0;
}

.g2048-faq-answer p {
  margin: 0;
  color: #918478;
  font-size: 14.5px;
  line-height: 1.7;
}

@media (max-width: 700px) {
  .g2048-seo-content {
    padding-top: 38px;
    padding-bottom: max(54px, env(safe-area-inset-bottom));
  }

  .g2048-seo-title {
    font-size: clamp(28px, 9vw, 36px);
    letter-spacing: -.8px;
  }

  .g2048-seo-intro > p:last-child {
    margin-top: 12px;
    font-size: 15px;
    line-height: 1.68;
  }

  .g2048-seo-section {
    margin-top: 36px;
  }

  .g2048-seo-section h2 {
    margin-bottom: 14px;
    font-size: 21px;
  }

  .g2048-how-list li {
    padding-left: 46px;
  }

  .g2048-how-list li::before {
    width: 30px;
    height: 30px;
  }

  .g2048-mode-compare-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .g2048-mode-compare-card {
    min-height: 132px;
    padding: 13px;
  }

  .g2048-faq-item summary {
    padding-top: 15px;
    padding-bottom: 15px;
    font-size: 14.5px;
  }

  .g2048-faq-answer {
    padding-right: 32px;
  }
}

@media (max-width: 430px) {
  .g2048-mode-compare-grid { grid-template-columns: 1fr; }
  .g2048-mode-compare-card { min-height: 0; }
}

/* JS-disabled fallback: keep the game surface understandable instead of showing an empty board. */
.g2048-noscript {
  position: absolute;
  inset: var(--g2048-board-pad);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  border-radius: calc(var(--g2048-board-radius) - 8px);
  background: rgba(250, 248, 239, .94);
  color: #776e65;
  text-align: center;
}

.g2048-noscript strong {
  font-size: 17px;
}

.g2048-noscript span {
  max-width: 300px;
  color: #988b7e;
  font-size: 13px;
  line-height: 1.5;
}

/* =========================================================
 * v1.8.0+ — language preference
 * ======================================================= */
.g2048-language-row {
  cursor: default;
}

.g2048-language-select {
  flex: 0 0 auto;
  width: min(168px, 48vw);
  min-height: 38px;
  padding: 0 30px 0 10px;
  border: 1px solid rgba(119, 110, 101, .18);
  border-radius: 9px;
  background-color: #f5f0e5;
  color: #776e65;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}

.g2048-language-select:hover {
  border-color: rgba(119, 110, 101, .32);
  background-color: #f1ebdf;
}

.g2048-language-select:focus-visible {
  outline: 3px solid rgba(119, 110, 101, .28);
  outline-offset: 2px;
}

@media (max-width: 390px) {
  .g2048-language-row {
    align-items: flex-start;
  }

  .g2048-language-select {
    width: min(150px, 48vw);
    min-height: 36px;
  }
}

/* v2.2.0: crawlable language navigation stays intentionally quiet below SEO content. */
.g2048-language-links {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(119, 110, 101, 0.16);
}

.g2048-language-links-label {
  display: block;
  margin-bottom: 10px;
  color: var(--g2048-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.g2048-language-links-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
}

.g2048-language-links-list a {
  color: var(--g2048-muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
  text-decoration: none;
  text-underline-offset: 3px;
}

.g2048-language-links-list a:hover,
.g2048-language-links-list a:focus-visible {
  color: var(--g2048-text);
  text-decoration: underline;
}

.g2048-language-links-list a[aria-current="page"] {
  color: var(--g2048-text);
  font-weight: 700;
}

@media (max-width: 520px) {
  .g2048-language-links {
    margin-top: 22px;
    padding-top: 16px;
  }

  .g2048-language-links-list {
    gap: 8px 11px;
  }
}

/* =========================================================
 * v2.5.0 — board modes 4×4 / 5×5 / 6×6 / 8×8 / 10×10
 * ======================================================= */
.g2048-mode-switcher {
  width: min(100%, 430px);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.g2048-mode-btn {
  min-width: 0;
  min-height: 44px;
  padding: 0 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.g2048-board.is-size-6 {
  --g2048-board-gap: 7px;
  --g2048-board-pad: 10px;
  --g2048-tile-radius: 7px;
}
.g2048-board.is-size-6 .g2048-tile { font-size: clamp(21px, 3vw, 32px); letter-spacing: -1px; }
.g2048-board.is-size-6 .g2048-tile[data-value="1024"],
.g2048-board.is-size-6 .g2048-tile[data-value="2048"],
.g2048-board.is-size-6 .g2048-tile[data-value="4096"],
.g2048-board.is-size-6 .g2048-tile[data-value="8192"] { font-size: clamp(15px, 2.15vw, 23px); }

.g2048-board.is-size-8 {
  --g2048-board-gap: 5px;
  --g2048-board-pad: 8px;
  --g2048-tile-radius: 5px;
}
.g2048-board.is-size-8 .g2048-tile { font-size: clamp(15px, 2.2vw, 24px); letter-spacing: -.7px; }
.g2048-board.is-size-8 .g2048-tile[data-value="128"],
.g2048-board.is-size-8 .g2048-tile[data-value="256"],
.g2048-board.is-size-8 .g2048-tile[data-value="512"],
.g2048-board.is-size-8 .g2048-tile[data-value="1024"],
.g2048-board.is-size-8 .g2048-tile[data-value="2048"],
.g2048-board.is-size-8 .g2048-tile[data-value="4096"],
.g2048-board.is-size-8 .g2048-tile[data-value="8192"] { font-size: clamp(11px, 1.65vw, 18px); }

.g2048-board.is-size-10 {
  --g2048-board-gap: 3px;
  --g2048-board-pad: 7px;
  --g2048-tile-radius: 4px;
}
.g2048-board.is-size-10 .g2048-tile { font-size: clamp(11px, 1.65vw, 18px); letter-spacing: -.4px; }
.g2048-board.is-size-10 .g2048-tile[data-value="128"],
.g2048-board.is-size-10 .g2048-tile[data-value="256"],
.g2048-board.is-size-10 .g2048-tile[data-value="512"],
.g2048-board.is-size-10 .g2048-tile[data-value="1024"],
.g2048-board.is-size-10 .g2048-tile[data-value="2048"],
.g2048-board.is-size-10 .g2048-tile[data-value="4096"],
.g2048-board.is-size-10 .g2048-tile[data-value="8192"] { font-size: clamp(8px, 1.18vw, 13px); letter-spacing: -.2px; }

@media (max-width: 700px) {
  .g2048-mode-switcher { width: min(100%, 360px); gap: 4px; margin-bottom: 13px; }
  .g2048-mode-btn { min-height: 44px; padding: 0 3px; font-size: clamp(10.5px, 3.4vw, 12.5px); }

  .g2048-board.is-size-6 { --g2048-board-gap: 5px; --g2048-board-pad: 7px; --g2048-tile-radius: 6px; }
  .g2048-board.is-size-6 .g2048-tile { font-size: clamp(17px, 5.8vw, 27px); }
  .g2048-board.is-size-6 .g2048-tile[data-value="1024"],
  .g2048-board.is-size-6 .g2048-tile[data-value="2048"],
  .g2048-board.is-size-6 .g2048-tile[data-value="4096"],
  .g2048-board.is-size-6 .g2048-tile[data-value="8192"] { font-size: clamp(12px, 4.1vw, 19px); }

  .g2048-board.is-size-8 { --g2048-board-gap: 3px; --g2048-board-pad: 6px; --g2048-tile-radius: 4px; }
  .g2048-board.is-size-8 .g2048-tile { font-size: clamp(12px, 4vw, 19px); }
  .g2048-board.is-size-8 .g2048-tile[data-value="128"],
  .g2048-board.is-size-8 .g2048-tile[data-value="256"],
  .g2048-board.is-size-8 .g2048-tile[data-value="512"],
  .g2048-board.is-size-8 .g2048-tile[data-value="1024"],
  .g2048-board.is-size-8 .g2048-tile[data-value="2048"],
  .g2048-board.is-size-8 .g2048-tile[data-value="4096"],
  .g2048-board.is-size-8 .g2048-tile[data-value="8192"] { font-size: clamp(9px, 3vw, 14px); }

  .g2048-board.is-size-10 { --g2048-board-gap: 2px; --g2048-board-pad: 5px; --g2048-tile-radius: 3px; }
  .g2048-board.is-size-10 .g2048-tile { font-size: clamp(9px, 3vw, 14px); }
  .g2048-board.is-size-10 .g2048-tile[data-value="128"],
  .g2048-board.is-size-10 .g2048-tile[data-value="256"],
  .g2048-board.is-size-10 .g2048-tile[data-value="512"],
  .g2048-board.is-size-10 .g2048-tile[data-value="1024"],
  .g2048-board.is-size-10 .g2048-tile[data-value="2048"],
  .g2048-board.is-size-10 .g2048-tile[data-value="4096"],
  .g2048-board.is-size-10 .g2048-tile[data-value="8192"] { font-size: clamp(7px, 2.25vw, 10px); }
}

@media (max-width: 340px) {
  .g2048-mode-switcher { gap: 3px; }
  .g2048-mode-btn { min-height: 44px; font-size: 10px; }
}

/* v2.5.0 keeps the v2.4.2 editorial typography pass. */
.g2048-seo-kicker,
.g2048-seo-title,
.g2048-seo-section h2,
.g2048-faq-item summary,
.g2048-language-links-label {
  font-weight: 700;
}

.g2048-seo-title {
  letter-spacing: -0.45px;
}

.g2048-seo-section h2 {
  letter-spacing: 0;
}

.g2048-seo-section > p {
  max-width: 700px;
  margin: 0;
  color: #897d72;
  font-size: 15px;
  line-height: 1.76;
}

.g2048-faq-item summary {
  letter-spacing: 0;
}


/* v2.5.1 — New Game confirmation */
.g2048-confirm-panel {
  width: min(390px, 100%);
  max-height: none;
  overflow: visible;
  padding: 26px;
}

.g2048-confirm-panel h2 {
  margin: 0;
  color: #6f6358;
  font-size: 25px;
  line-height: 1.2;
}

.g2048-confirm-panel .g2048-help-intro {
  margin: 10px 0 22px;
}

.g2048-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.g2048-confirm-actions .g2048-primary-btn,
.g2048-confirm-actions .g2048-secondary-btn {
  min-height: 44px;
  width: 100%;
}

@media (max-width: 420px) {
  .g2048-confirm-dialog {
    padding: 14px;
  }

  .g2048-confirm-panel {
    padding: 22px 18px 18px;
    border-radius: 18px;
  }
}

/* =========================================================
 * v2.6.2 — focused size selector, linked logo and site footer
 * ======================================================= */
.g2048-brand {
  text-decoration: none;
  transition: color 140ms ease, opacity 140ms ease;
}

.g2048-brand:hover {
  color: #665b51;
}

.g2048-brand:focus-visible {
  outline: 3px solid rgba(119, 110, 101, .25);
  outline-offset: 5px;
  border-radius: 5px;
}


/* Classic is a ruleset, not a board size. Undo still stays hidden there. */
.g2048-control-zone.is-no-undo .g2048-control-dock {
  grid-template-columns: repeat(2, 72px);
}

.g2048-site-footer {
  border-top: 1px solid rgba(119, 110, 101, .13);
  background: #f1ede3;
  color: #776e65;
}

.g2048-footer-inner {
  width: min(1080px, calc(100% - 36px));
  margin: 0 auto;
  padding: 42px 0 24px;
}

.g2048-footer-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.25fr) minmax(110px, .65fr) minmax(150px, .8fr) minmax(260px, 1.35fr);
  gap: 30px 38px;
  align-items: start;
}

.g2048-footer-logo {
  display: inline-block;
  color: #77695c;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1.5px;
  text-decoration: none;
}

.g2048-footer-logo:hover,
.g2048-footer-logo:focus-visible {
  color: #665b51;
}

.g2048-footer-tagline {
  margin: 10px 0 7px;
  color: #655b52;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.g2048-footer-note {
  max-width: 330px;
  margin: 0;
  color: #8a7d71;
  font-size: 13px;
  line-height: 1.65;
}

.g2048-footer-nav h2,
.g2048-footer-languages h2 {
  margin: 2px 0 13px;
  color: #655b52;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .055em;
  line-height: 1.3;
  text-transform: uppercase;
}

.g2048-footer-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
}

.g2048-footer-nav a,
.g2048-footer-language-list a,
.g2048-footer-bottom a {
  color: #807469;
  font-size: 13px;
  line-height: 1.45;
  text-decoration: none;
  text-underline-offset: 3px;
}

.g2048-footer-nav a:hover,
.g2048-footer-nav a:focus-visible,
.g2048-footer-language-list a:hover,
.g2048-footer-language-list a:focus-visible,
.g2048-footer-bottom a:hover,
.g2048-footer-bottom a:focus-visible {
  color: #5f564e;
  text-decoration: underline;
}

.g2048-footer-language-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
}

.g2048-footer-language-list a[aria-current="page"] {
  color: #5f564e;
  font-weight: 700;
}

.g2048-footer-bottom {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid rgba(119, 110, 101, .12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #978a7f;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .g2048-footer-grid {
    grid-template-columns: 1.25fr .75fr .9fr;
  }

  .g2048-footer-languages {
    grid-column: 1 / -1;
    padding-top: 2px;
  }
}

@media (max-width: 700px) {
  .g2048-footer-inner {
    width: min(100% - 30px, 620px);
    padding-top: 34px;
  }

  .g2048-footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 28px 24px;
  }

  .g2048-footer-brand,
  .g2048-footer-languages {
    grid-column: 1 / -1;
  }

  .g2048-footer-note {
    max-width: 520px;
  }
}

@media (max-width: 420px) {
  .g2048-footer-grid {
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .g2048-footer-brand,
  .g2048-footer-languages {
    grid-column: auto;
  }

  .g2048-footer-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 16px;
  }

  .g2048-footer-nav h2 {
    grid-column: 1 / -1;
  }

  .g2048-footer-bottom {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* v2.8 — result sharing + deterministic friend challenge */
.g2048-challenge-banner {
  width: min(100%, var(--g2048-board-size, 500px));
  margin: 0 auto 12px;
  padding: 11px 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid rgba(143, 127, 112, .16);
  border-radius: 12px;
  background: #f3eee3;
  color: #776e65;
}

.g2048-challenge-banner[hidden] { display: none; }

.g2048-challenge-banner__badge {
  flex: 0 0 auto;
  margin-top: 1px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #8f7f70;
  color: #fffaf2;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .04em;
  white-space: nowrap;
}

.g2048-challenge-banner strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
  line-height: 1.35;
}

.g2048-challenge-banner p {
  margin: 0;
  color: #8f8276;
  font-size: 12px;
  line-height: 1.45;
}

.g2048-result-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 10px;
}

.g2048-result-summary > div {
  min-width: 0;
  padding: 8px 5px;
  border-radius: 9px;
  background: #f3eee3;
}

.g2048-result-summary span,
.g2048-result-summary strong {
  display: block;
}

.g2048-result-summary span {
  min-height: 25px;
  color: #70665d;
  font-size: 10px;
  line-height: 1.25;
}

.g2048-result-summary strong {
  margin-top: 2px;
  color: #6f6358;
  font-size: 16px;
  line-height: 1.15;
}

.g2048-challenge-result {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: #eee4d2;
  color: #776e65;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.g2048-game-message__share-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 8px;
}

.g2048-game-message__share-actions .g2048-secondary-btn {
  width: 100%;
  min-height: 39px;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.2;
}

@media (max-width: 420px) {
  .g2048-challenge-banner {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }
  .g2048-challenge-banner__badge { align-self: flex-start; }
  .g2048-game-message { padding: 13px; }
  .g2048-game-message__panel { padding: 16px; }
  .g2048-game-message__title { font-size: clamp(24px, 8vw, 31px); }
  .g2048-game-message__text { margin-bottom: 11px; }
}

@media (max-width: 350px) {
  .g2048-game-message__share-actions { grid-template-columns: 1fr; }
  .g2048-result-summary span { min-height: 0; }
}

/* v2.8.1 — visible feedback for sharing/copying. */
.g2048-toast[hidden] {
  display: none;
}

.g2048-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom, 0px) + 18px));
  z-index: 10020;
  width: max-content;
  max-width: min(420px, calc(100vw - 28px));
  padding: 11px 14px;
  border: 1px solid rgba(91, 78, 66, .12);
  border-radius: 10px;
  background: #51483f;
  box-shadow: 0 10px 26px rgba(54, 45, 37, .22);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  transform: translateX(-50%);
}

.g2048-toast.is-error {
  background: #7a5148;
}

@media (max-width: 520px) {
  .g2048-toast {
    bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px));
    max-width: calc(100vw - 24px);
    font-size: 12px;
  }
}

/* v2.8.2 — result controls must remain real interactive targets inside the swipe board. */
.g2048-game-message,
.g2048-game-message__panel,
.g2048-game-message button {
  pointer-events: auto;
}

.g2048-game-message button {
  touch-action: manipulation;
}

/* =========================================================
 * v2.8.4 — one retention action: Challenge + Play again
 * ======================================================= */
.g2048-game-message__actions--result {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  gap: 8px;
}

.g2048-game-message__actions--result .g2048-primary-btn,
.g2048-game-message__actions--result .g2048-secondary-btn {
  width: 100%;
  min-height: 44px;
  padding-inline: 10px;
}

.g2048-game-message__actions--result #g2048-continue-game:not([hidden]) {
  grid-column: 1 / -1;
}

@media (max-width: 350px) {
  .g2048-game-message__actions--result {
    grid-template-columns: 1fr;
  }

  .g2048-game-message__actions--result #g2048-continue-game:not([hidden]) {
    grid-column: auto;
  }
}


/* =========================================================
 * v2.8.6 — ultra-simple 2048 Classic layout
 * ======================================================= */
.g2048-app-shell.is-original-classic .g2048-topbar {
  width: min(500px, 100%);
  grid-template-columns: 1fr auto;
  grid-template-areas: "brand scores" "brand actions";
  align-items: start;
  gap: 10px 16px;
}

.g2048-app-shell.is-original-classic .g2048-brand-wrap { grid-area: brand; }
.g2048-app-shell.is-original-classic .g2048-score-wrap {
  grid-area: scores;
  justify-self: end;
  gap: 6px;
}
.g2048-app-shell.is-original-classic .g2048-actions {
  grid-area: actions;
  justify-self: end;
}
.g2048-app-shell.is-original-classic .g2048-brand {
  font-size: clamp(64px, 11vw, 80px);
  line-height: .9;
  letter-spacing: -4px;
}
.g2048-app-shell.is-original-classic .g2048-score-card,
.g2048-app-shell.is-original-classic .g2048-score-card--best {
  min-width: 82px;
  height: 54px;
  padding: 7px 10px 5px;
  border-radius: 4px;
  background: #776e65;
  border: 0;
  box-shadow: none;
}
.g2048-app-shell.is-original-classic .g2048-score-label {
  color: #f9f6f2;
  font-size: 12px;
}
.g2048-app-shell.is-original-classic .g2048-score-value {
  color: #fff;
  font-size: 20px;
}
.g2048-app-shell.is-original-classic .g2048-new-game-btn {
  min-width: 130px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 4px;
  box-shadow: none;
}
.g2048-app-shell.is-original-classic .g2048-board {
  width: min(82vw, 500px);
  height: min(82vw, 500px);
  border-radius: 6px;
  box-shadow: none;
}
.g2048-app-shell.is-original-classic .g2048-game-area {
  gap: 16px;
  padding-top: 32px;
}
.g2048-app-shell.is-original-classic .g2048-orientation-note,
.g2048-app-shell.is-original-classic .g2048-mode-switcher,
.g2048-app-shell.is-original-classic #g2048-challenge-banner,
.g2048-app-shell.is-original-classic #g2048-control-zone,
.g2048-app-shell.is-original-classic .g2048-controls-hint,
.g2048-app-shell.is-original-classic .g2048-stats,
.g2048-app-shell.is-original-classic .g2048-seo-content {
  display: none !important;
}
@media (max-width: 480px) {
  .g2048-app-shell.is-original-classic .g2048-topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand scores" "actions actions";
  }
  .g2048-app-shell.is-original-classic .g2048-actions {
    justify-self: start;
  }
  .g2048-app-shell.is-original-classic .g2048-brand {
    font-size: clamp(58px, 15vw, 74px);
  }
  .g2048-app-shell.is-original-classic .g2048-score-card,
  .g2048-app-shell.is-original-classic .g2048-score-card--best {
    min-width: 70px;
    height: 50px;
    padding: 6px 8px 4px;
  }
  .g2048-app-shell.is-original-classic .g2048-score-label { font-size: 11px; }
  .g2048-app-shell.is-original-classic .g2048-score-value { font-size: 18px; }
  .g2048-app-shell.is-original-classic .g2048-new-game-btn { min-width: 118px; }
  .g2048-app-shell.is-original-classic .g2048-board {
    width: min(94vw, 500px);
    height: min(94vw, 500px);
  }
}


/* =========================================================
 * v2.8.7 — mobile mode switcher in a single row
 * ======================================================= */
@media (max-width: 700px) {
  .g2048-app-shell:not(.is-original-classic) .g2048-mode-switcher {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    width: min(100%, 430px);
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px;
  }

  .g2048-app-shell:not(.is-original-classic) .g2048-mode-switcher::-webkit-scrollbar {
    display: none;
  }

  .g2048-app-shell:not(.is-original-classic) .g2048-mode-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding: 0 6px;
    white-space: nowrap;
  }
}

@media (max-width: 420px) {
  .g2048-app-shell:not(.is-original-classic) .g2048-mode-switcher {
    width: min(100%, 360px);
    gap: 5px;
    padding: 3px;
  }

  .g2048-app-shell:not(.is-original-classic) .g2048-mode-btn {
    min-height: 44px;
    font-size: 11px;
    padding: 0 4px;
  }
}


/* =========================================================
 * v2.9.0 — stability cleanup
 * - old Classic override layers removed
 * - mobile mode bar has one source of truth
 * ======================================================= */
.g2048-site-footer .g2048-footer-nav a[aria-current="page"] {
  color: #5f564e;
  font-weight: 700;
}

/* =========================================================
 * v3.0.0 — lightweight PWA install prompt
 * ======================================================= */
.g2048-install-prompt {
  position: fixed;
  z-index: 9999;
  left: 50%;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
  width: min(430px, calc(100% - 28px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 14px 14px 16px;
  border: 1px solid rgba(119, 110, 101, .16);
  border-radius: 16px;
  background: rgba(250, 248, 239, .98);
  color: #776e65;
  box-shadow: 0 14px 34px rgba(82, 68, 57, .18);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.g2048-install-prompt__copy {
  min-width: 0;
}

.g2048-install-prompt__copy strong {
  display: block;
  margin: 0 0 3px;
  color: #665b51;
  font-size: 14px;
  line-height: 1.35;
}

.g2048-install-prompt__copy p {
  margin: 0;
  color: #8a7d71;
  font-size: 12px;
  line-height: 1.45;
}

.g2048-install-prompt__actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.g2048-install-prompt__actions .g2048-primary-btn,
.g2048-install-prompt__actions .g2048-secondary-btn {
  min-height: 38px;
  padding: 0 12px;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .g2048-install-prompt {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px;
  }

  .g2048-install-prompt__actions {
    justify-content: flex-end;
  }
}

/* =========================================================
 * v3.1.0 — recent games + personal records
 * ======================================================= */
.g2048-history {
  width: min(560px, calc(100vw - 30px));
  margin-top: 16px;
  padding: 15px;
  border: 1px solid rgba(119, 110, 101, .09);
  border-radius: 18px;
  background: rgba(255, 250, 242, .58);
}

.g2048-history-head {
  padding: 0 3px 10px;
}

.g2048-history h2,
.g2048-recent-head h3 {
  margin: 0;
  color: #776e65;
  font-weight: 700;
  line-height: 1.25;
}

.g2048-history h2 {
  font-size: 15px;
}

.g2048-record-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.g2048-record-card {
  min-width: 0;
  min-height: 74px;
  padding: 10px 8px;
  border-radius: 12px;
  background: #eee9dc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.g2048-record-card span {
  color: #9a8d80;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.25;
}

.g2048-record-card strong {
  max-width: 100%;
  overflow: hidden;
  color: #776e65;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g2048-record-card:last-child {
  background: #e9dfc7;
}

.g2048-record-card:last-child strong {
  color: #8b754b;
  font-size: 15px;
}

.g2048-recent-games {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid rgba(119, 110, 101, .10);
}

.g2048-recent-head {
  padding: 0 3px 8px;
}

.g2048-recent-head h3 {
  font-size: 13px;
}

.g2048-recent-head p {
  margin: 3px 0 0;
  color: #a19589;
  font-size: 10px;
  line-height: 1.4;
}

.g2048-recent-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.g2048-recent-item {
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(238, 233, 220, .72);
}

.g2048-recent-item__top,
.g2048-recent-item__metrics {
  display: flex;
  align-items: center;
  gap: 8px;
}

.g2048-recent-item__top {
  justify-content: space-between;
}

.g2048-recent-item__top strong {
  color: #776e65;
  font-size: 11px;
  line-height: 1.3;
}

.g2048-recent-item__top time {
  flex: 0 0 auto;
  color: #a19589;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.g2048-recent-item__metrics {
  margin-top: 5px;
  flex-wrap: wrap;
  color: #8e8175;
  font-size: 9.5px;
  line-height: 1.35;
}

.g2048-recent-item__metrics span:not(:last-child)::after {
  content: "·";
  margin-left: 8px;
  color: #b4a89c;
}

.g2048-recent-empty {
  margin: 0;
  padding: 12px 10px;
  border-radius: 10px;
  background: rgba(238, 233, 220, .55);
  color: #9b8f84;
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

@media (max-width: 700px) {
  .g2048-history {
    width: min(100%, 470px);
    margin-top: 14px;
    padding: 12px;
    border-radius: 16px;
  }

  .g2048-record-grid {
    gap: 6px;
  }

  .g2048-record-card {
    min-height: 68px;
    padding: 9px 6px;
  }
}

@media (max-width: 390px) {
  .g2048-record-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .g2048-record-card:last-child {
    grid-column: 1 / -1;
    min-height: 58px;
  }

  .g2048-recent-item__top {
    align-items: flex-start;
  }
}

/* v3.7.0 — trust links in the shared footer. */
.g2048-footer-trust-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
/* v3.8.0: keep the first game screen cheap to paint on mobile. */
@supports (content-visibility: auto) {
  .g2048-stats,
  .g2048-history,
  .g2048-seo-content {
    content-visibility: auto;
    contain-intrinsic-size: auto 720px;
  }
}


/* =========================================================
 * v3.9.0 — mobile UX + accessibility hardening
 * ======================================================= */
.g2048-mode-btn {
  color: #70665d;
}

.g2048-board:focus-visible,
.g2048-mode-btn:focus-visible,
.g2048-tool-btn:focus-visible,
.g2048-icon-close:focus-visible,
.g2048-help-close:focus-visible,
.g2048-new-game-btn:focus-visible,
.g2048-primary-btn:focus-visible,
.g2048-secondary-btn:focus-visible,
.g2048-footer-nav a:focus-visible,
.g2048-footer-language-list a:focus-visible,
.g2048-footer-bottom a:focus-visible {
  outline: 3px solid #665d55;
  outline-offset: 3px;
}

.g2048-game-message__actions--result .g2048-primary-btn,
.g2048-game-message__actions--result .g2048-secondary-btn {
  min-height: 44px;
  padding-block: 8px;
  line-height: 1.2;
  white-space: normal;
}

.g2048-help-kicker,
.g2048-seo-kicker,
.g2048-recent-item__top time,
.g2048-recent-item__metrics,
.g2048-footer-note,
.g2048-footer-nav a,
.g2048-footer-language-list a,
.g2048-footer-bottom {
  color: #70665d;
}

@media (max-width: 700px) {
  .g2048-new-game-btn,
  .g2048-app-shell:not(.is-original-classic) .g2048-mode-btn {
    min-height: 44px;
  }

  .g2048-app-shell:not(.is-original-classic) .g2048-mode-switcher {
    gap: 4px;
  }
}

@media (max-width: 360px) {
  .g2048-app-shell:not(.is-original-classic) .g2048-mode-switcher {
    gap: 3px;
    padding-inline: 3px;
  }

  .g2048-app-shell:not(.is-original-classic) .g2048-mode-btn {
    padding-inline: 2px;
    font-size: 10px;
  }

  .g2048-game-message {
    padding: 8px;
  }

  .g2048-game-message__panel {
    padding: 13px;
  }
}

@media (min-width: 480px) and (max-width: 950px) and (max-height: 500px) and (orientation: landscape) {
  .g2048-game-message {
    padding: 5px;
  }

  .g2048-game-message__panel {
    width: 100%;
    padding: 10px;
    border-radius: 12px;
  }

  .g2048-game-message__title {
    font-size: 21px;
  }

  .g2048-game-message__text {
    margin: 5px 0 8px;
    font-size: 12px;
  }

  .g2048-result-summary {
    margin-bottom: 7px;
    gap: 4px;
  }
}

@media (prefers-contrast: more) {
  .g2048-board,
  .g2048-mode-switcher,
  .g2048-control-dock,
  .g2048-options-panel,
  .g2048-game-message__panel {
    border-color: #665d55;
  }

  .g2048-cell {
    outline: 1px solid rgba(95, 86, 78, .42);
  }
}

@media (forced-colors: active) {
  .g2048-board,
  .g2048-cell,
  .g2048-tile,
  .g2048-score-card,
  .g2048-mode-btn,
  .g2048-tool-btn,
  .g2048-new-game-btn,
  .g2048-primary-btn,
  .g2048-secondary-btn {
    border: 1px solid CanvasText;
    forced-color-adjust: auto;
  }

  .g2048-tile {
    color: CanvasText;
    background: Canvas;
  }
}

/* =========================================================
 * v4.5.3 — homepage founder / trust profile
 * ======================================================= */
.g2048-founder {
  padding-top: 2px;
}

.g2048-founder-heading {
  margin-bottom: 18px;
}

.g2048-founder-heading h2 {
  margin-bottom: 0;
}

.g2048-founder-card {
  padding: clamp(18px, 3vw, 24px);
  border: 1px solid rgba(119, 110, 101, .13);
  border-radius: 18px;
  background: #fffaf2;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.g2048-founder-avatar {
  width: 92px;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 18px;
  background: #edc53f;
  color: #f9f6f2;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(119, 110, 101, .08);
}

.g2048-founder-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.g2048-founder-avatar span {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.8px;
}

.g2048-founder-body {
  min-width: 0;
}

.g2048-founder-identity h3 {
  margin: 0;
  color: #75695e;
  font-size: 19px;
  line-height: 1.3;
}

.g2048-founder-identity p {
  margin: 4px 0 0;
  color: #a09183;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.45;
}

.g2048-founder-bio {
  max-width: 610px;
  margin: 13px 0 0;
  color: #887b70;
  font-size: 14.5px;
  line-height: 1.72;
}

.g2048-founder-links {
  margin-top: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.g2048-founder-links a {
  color: #776e65;
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(119, 110, 101, .32);
  text-underline-offset: 3px;
}

.g2048-founder-links a:hover {
  color: #5f574f;
  text-decoration-color: currentColor;
}

.g2048-founder-links a:focus-visible {
  outline: 3px solid rgba(119, 110, 101, .22);
  outline-offset: 3px;
  border-radius: 3px;
}

@media (max-width: 600px) {
  .g2048-founder-card {
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
    border-radius: 16px;
  }

  .g2048-founder-avatar {
    width: 68px;
    border-radius: 14px;
  }

  .g2048-founder-avatar span {
    font-size: 17px;
  }

  .g2048-founder-identity h3 {
    font-size: 17px;
  }

  .g2048-founder-bio,
  .g2048-founder-links {
    grid-column: 1 / -1;
  }

  .g2048-founder-bio {
    margin-top: 2px;
    font-size: 14px;
  }

  .g2048-founder-links {
    margin-top: 2px;
  }
}
