/* Play2048Base — Figma Design Style Board (scoped).
   System UI stack only — zero webfont bytes on the critical path (play surface already used this). */

[data-theme="p8b"],
.p8b-root {
  --p8b-amber: #d97706;
  --p8b-amber-deep: #b45309;
  --background: #e8ecf2;
  --foreground: #1b2430;
  --card: #f4f6fa;
  --card-foreground: #1b2430;
  --secondary: #e1e6ed;
  --secondary-foreground: #1b2430;
  --muted: #edf1f5;
  --muted-foreground: #5c6b7a;
  --accent: #d97706;
  --accent-foreground: #fffaf0;
  --border: #c5cdd8;
  --primary: #1b2430;
  --primary-foreground: #f4f6fa;
  --ring: #d97706;
  --rrb-primary: var(--p8b-amber);
  --rrb-on-primary: #1b2430;
  --rrb-text: var(--foreground);
  --rrb-muted: var(--muted-foreground);
  --rrb-border: var(--border);
  --rrb-surface: var(--card);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  background: var(--background);
  color: var(--foreground);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: clip;
  box-sizing: border-box;
}

[data-theme="p8b"] .p8b-mono,
.p8b-root .p8b-mono {
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

[data-theme="p8b"] *,
.p8b-root * {
  box-sizing: border-box;
}

.p8b-root a {
  color: inherit;
  text-decoration: none;
}

/*
 * First fold — #play = 100svh − hero (via --p8b-hero-h on <html>).
 * Do not set this var as inline style on .p8b-root (React-owned → hydration mismatch).
 * Landmarks: header sibling of main; #play + #how both inside main (SOP §0.7).
 * Tall PC: see comfort-cluster block below (SOP §0.16 超高屏).
 */
html {
  --p8b-hero-h: 7.5rem;
  --p8b-board-max: 560px;
  --p8b-board-max-ads: 520px;
}

@media (min-width: 640px) {
  html {
    --p8b-hero-h: 6.75rem;
  }
}

.p8b-root .p8b-main > #play.p8b-play-fold {
  height: calc(100svh - var(--p8b-hero-h));
  max-height: calc(100svh - var(--p8b-hero-h));
  min-height: 0;
  overflow: hidden;
}

/*
 * Tall PC comfort cluster (SOP §0.16):
 * Do NOT stretch #play to 100svh — pack score→board→controls→ad to content
 * height so #how (SEO) peeks into the viewport. Avoid a huge empty band under
 * the board. Threshold: lg + taller than a typical 1080p content window.
 */
@media (min-width: 1024px) and (min-height: 1100px) {
  .p8b-root .p8b-main > #play.p8b-play-fold {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .p8b-root .p8b-main > #play.p8b-play-fold > .p8b-play-cluster {
    height: auto;
    flex: 0 1 auto;
  }

  .p8b-root .p8b-main > #play.p8b-play-fold > .p8b-play-cluster > .p8b-play-row {
    flex: 0 1 auto;
  }

  .p8b-root .p8b-main > #play.p8b-play-fold .p8b-play-column {
    flex: 0 1 auto;
  }

  .p8b-root .p8b-main > #play.p8b-play-fold .p8b-board-slot {
    flex: 0 0 auto;
    width: 100%;
    max-width: var(--p8b-board-max);
    /* Avoid cqh circular sizing when the slot no longer has a flex-stolen height. */
    container-type: inline-size;
  }

  .p8b-root .p8b-main > #play.p8b-play-fold .p8b-board-fit {
    width: min(100%, var(--p8b-board-max));
  }

  .p8b-root[data-ads="on"] .p8b-main > #play.p8b-play-fold .p8b-board-slot {
    max-width: var(--p8b-board-max-ads);
  }

  .p8b-root[data-ads="on"] .p8b-main > #play.p8b-play-fold .p8b-board-fit {
    width: min(100%, var(--p8b-board-max-ads));
  }
}

/* Below-fold SEO: skip paint until near viewport (HTML stays for crawlers). */
.p8b-root #how {
  content-visibility: auto;
  contain-intrinsic-size: auto 3200px;
  /* Cover .play-surface gradient so the article reads as page chrome, not the board band. */
  background: var(--background);
}

.p8b-root .article-section {
  content-visibility: auto;
  contain-intrinsic-size: auto 360px;
}

/* Text + SVG figure stagger — stack on narrow; alternate sides from md up */
.p8b-root .p8b-split {
  display: grid;
  gap: 1.15rem;
  margin: 0.25rem 0 0.35rem;
  align-items: start;
}

.p8b-root .p8b-split-copy > p:first-child,
.p8b-root .p8b-split-copy > ul:first-child,
.p8b-root .p8b-split-copy > ol:first-child {
  margin-top: 0;
}

.p8b-root .p8b-split-copy > p + p {
  margin-top: 0.9rem;
}

@media (min-width: 800px) {
  .p8b-root .p8b-split {
    grid-template-columns: minmax(0, 1fr) minmax(12.5rem, 17.5rem);
    gap: 1.5rem 2rem;
    align-items: center;
  }

  .p8b-root .p8b-split--figure-end .p8b-article-figure {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    margin-top: 0.45rem;
  }

  .p8b-root .p8b-split--figure-end .p8b-split-copy {
    grid-column: 1;
    grid-row: 1;
  }

  .p8b-root .p8b-split--figure-start {
    grid-template-columns: minmax(12.5rem, 17.5rem) minmax(0, 1fr);
  }

  .p8b-root .p8b-split--figure-start .p8b-article-figure {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    margin-top: -0.2rem;
  }

  .p8b-root .p8b-split--figure-start .p8b-split-copy {
    grid-column: 2;
    grid-row: 1;
  }

  /* Slight vertical stagger so blocks don’t feel like a uniform table */
  .p8b-root .article-section:nth-of-type(odd) .p8b-split--figure-start .p8b-article-figure {
    margin-top: 0.85rem;
  }

  .p8b-root .article-section:nth-of-type(even) .p8b-split--figure-end .p8b-article-figure {
    margin-top: -0.35rem;
  }
}

.p8b-root .p8b-article-figure {
  margin: 0;
  width: 100%;
  max-width: 22.5rem;
  justify-self: start;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #faf8ef;
}

.p8b-root .p8b-article-figure-img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 320px;
  aspect-ratio: 320 / 168;
  background: #faf8ef;
}

.p8b-root .p8b-article-figure-cap {
  margin: 0;
  padding: 0.55rem 0.7rem 0.65rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted-foreground);
  background: color-mix(in srgb, var(--card) 70%, transparent);
}

/* Status line: reserve 2 mobile lines so worker copy swap does not shove the board. */
.p8b-root #play .p8b-game-status {
  min-height: 2.5rem;
}

@media (min-width: 640px) {
  .p8b-root #play .p8b-game-status {
    min-height: 1.5rem;
  }
}

.play-surface {
  background:
    radial-gradient(130% 100% at 100% 0%, rgba(94, 122, 155, 0.08), transparent 50%),
    linear-gradient(180deg, #ebeef3 0%, #e5e9ef 100%);
  /* 首屏用国内同款浑厚无衬线，避免 DM Sans 偏细 */
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
}

.play-surface h1 {
  font-weight: 800 !important;
  letter-spacing: -0.5px;
}

/* 分数块：浅底 + 顶条点缀 + 暖色数字（喜庆但不抢棋盘） */
.play-surface .score-box {
  position: relative;
  overflow: hidden;
  border: 1px solid #e6ddd0;
  border-radius: 10px;
  background: #fffdf8;
  box-shadow: 0 2px 6px rgba(27, 36, 48, 0.06);
  text-align: center;
}

.play-surface .score-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.play-surface .score-box-score::before {
  background: linear-gradient(90deg, #edc22e 0%, #f0cb45 100%);
}

.play-surface .score-box-best::before {
  background: linear-gradient(90deg, #f59563 0%, #f67c5f 100%);
}

.play-surface .score-box-score {
  color: #8f7a66;
}

.play-surface .score-box-best {
  color: #8f7a66;
}

.play-surface .score-value,
.play-surface #scoreDisplay,
.play-surface #bestScoreDisplay {
  font-family: inherit !important;
  font-weight: 800 !important;
  font-size: 20px !important;
  line-height: 1.15 !important;
  letter-spacing: -0.5px;
}

@media (min-width: 640px) {
  .play-surface .score-value,
  .play-surface #scoreDisplay,
  .play-surface #bestScoreDisplay {
    font-size: 24px !important;
  }
}

.play-surface .score-box-score .score-value,
.play-surface .score-box-score #scoreDisplay {
  color: #b45309 !important;
}

.play-surface .score-box-best .score-value,
.play-surface .score-box-best #bestScoreDisplay {
  color: #e85d3a !important;
}

.play-surface .score-label {
  font-family: inherit !important;
  font-weight: 800 !important;
  font-size: 11px !important;
  letter-spacing: 0.08em;
  opacity: 0.9;
  color: inherit;
}

.play-surface #newGameBtn,
.play-surface #hintBtn,
.play-surface #demoBtn,
.play-surface #dailyBtn,
.play-surface #undoBtn {
  font-family: inherit;
  font-weight: 800 !important;
}

.play-surface #gameStatus {
  font-weight: 700;
}

/* 右侧栏：轻暖点缀，不抢棋盘 */
.play-surface .side-rail {
  font-family: inherit;
}

.play-surface .side-rail-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #3a4452;
}

.play-surface .side-card {
  border: 1px solid #d7dde6;
  border-radius: 12px;
  background: #f7f9fc;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(27, 36, 48, 0.04);
}

.play-surface .side-card-daily {
  border-color: #e5d5b8;
  background: #fbf8f2;
}

.play-surface .side-card-heading {
  font-size: 0.95rem;
  font-weight: 800;
  color: #7a5a28;
}

.play-surface .side-card-desc {
  font-size: 0.8125rem;
  line-height: 1.45;
  font-weight: 600;
  color: #6b7280;
}

.play-surface .side-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  font-weight: 700;
}

.play-surface .side-stat span {
  color: #6b7280;
}

.play-surface .side-stat strong {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #1b2430;
}

.play-surface .side-card-daily .side-stat strong {
  color: #b45309;
}

.play-surface .side-history-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #d7dde6;
  border-radius: 10px;
  background: #f7f9fc;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: none;
}

.play-surface .side-history-row .h-score {
  font-weight: 800;
  color: #1b2430;
}

.play-surface .side-history-row .h-max {
  font-weight: 800;
  color: #b45309;
}

.play-surface .side-history-row .h-time {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #6b7280;
}

.play-surface .side-clear-btn {
  margin-top: 12px;
  border: 1px solid #d7dde6;
  border-radius: 10px;
  background: #eef2f6;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #4a5564;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.play-surface .side-clear-btn:hover {
  background: #e5ebf1;
  color: #1b2430;
}

.play-surface .side-clear-btn:active {
  transform: scale(0.98);
}

.play-surface .side-stat-divider {
  border-bottom: 1px solid #e5e9ef;
}

.play-surface .side-stat-divider-top {
  border-top: 1px solid #ebe4d6;
}

/*
 * First-fold board: fill leftover space after scores / status / buttons / ad.
 * Container queries shrink the square board so the ad never covers controls.
 */
.p8b-board-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
  container-type: size;
}

/* Leave a few px so the tray border is not clipped by #play overflow / cqh rounding. */
.p8b-board-fit {
  width: min(100cqw, calc(100cqh - 10px), var(--p8b-board-max));
  max-width: 100%;
}

.p8b-root[data-ads="on"] .p8b-board-fit {
  width: min(100cqw, calc(100cqh - 10px), var(--p8b-board-max-ads));
}

/* Legacy class kept for any remaining call sites */
.mobile-board-scale {
  width: 100%;
  max-width: min(100%, 560px);
}

@media (min-width: 1024px) and (max-height: 820px) {
  .desktop-history {
    display: none;
  }
}

/* Canvas board — matches Figma tray chrome.
   Shadow on .canvas-shell; canvas is inset so top/right/bottom/left tray padding stay equal. */
.canvas-shell {
  width: 100%;
  filter: drop-shadow(0 10px 16px rgba(68, 56, 44, 0.2));
}

.canvas-wrap {
  --tray-pad: 8px;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  min-width: 0;
  border-radius: 14px;
  background: #bbada0;
  overflow: hidden;
  box-sizing: border-box;
}

@media (min-width: 640px) {
  .canvas-wrap {
    --tray-pad: 12px;
    border-radius: 18px;
  }
}

/* Canvas is a replaced element — auto width/height keeps intrinsic 400px and leaves a tray gap. */
#gameCanvas {
  position: absolute;
  top: var(--tray-pad);
  left: var(--tray-pad);
  width: calc(100% - 2 * var(--tray-pad));
  height: calc(100% - 2 * var(--tray-pad));
  max-width: none;
  min-width: 0;
  display: block;
  border-radius: 10px;
  touch-action: none;
  background: #bbada0;
  /* Chrome mobile would otherwise wash the whole grid blue on every swipe start. */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.game-overlay {
  position: absolute;
  inset: var(--tray-pad);
  border-radius: 10px;
  background: rgba(232, 236, 242, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 5;
  padding: 20px 16px;
  text-align: center;
}

@media (min-width: 640px) {
  .game-overlay {
    gap: 14px;
  }
}

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

.overlay-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--foreground);
  animation: p8b-overlay-in 320ms ease-out both;
}

.overlay-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted-foreground);
  animation: p8b-overlay-in 320ms ease-out 60ms both;
}

/* Game-over / win primary CTA — solid amber, hard to ignore */
.p8b-root .overlay-cta,
.play-surface .overlay-cta {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.7rem 1.35rem 0.7rem 1.25rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 55%, #b45309 100%);
  color: #fffaf0;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 250, 240, 0.28) inset,
    0 8px 18px rgba(180, 83, 9, 0.28),
    0 2px 0 #92400e;
  transform: translateZ(0);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
  animation:
    p8b-overlay-in 360ms ease-out 120ms both,
    p8b-cta-breathe 1.8s ease-in-out 500ms infinite;
}

.p8b-root .overlay-cta::after,
.play-surface .overlay-cta::after {
  content: "→";
  font-weight: 700;
  transition: transform 160ms ease;
}

.p8b-root .overlay-cta:hover,
.play-surface .overlay-cta:hover {
  animation-play-state: paused;
  filter: brightness(1.05);
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 1px 0 rgba(255, 250, 240, 0.34) inset,
    0 12px 24px rgba(180, 83, 9, 0.34),
    0 3px 0 #92400e;
}

.p8b-root .overlay-cta:hover::after,
.play-surface .overlay-cta:hover::after {
  transform: translateX(3px);
}

.p8b-root .overlay-cta:active,
.play-surface .overlay-cta:active {
  transform: translateY(1px) scale(0.98);
  filter: brightness(0.98);
  box-shadow:
    0 1px 0 rgba(255, 250, 240, 0.2) inset,
    0 4px 10px rgba(180, 83, 9, 0.22),
    0 1px 0 #92400e;
  animation: none;
}

.p8b-root .overlay-cta.overlay-cta-pop,
.play-surface .overlay-cta.overlay-cta-pop {
  animation:
    p8b-cta-pop 420ms cubic-bezier(0.22, 1.2, 0.36, 1) both,
    p8b-cta-breathe 1.8s ease-in-out 480ms infinite;
}

@keyframes p8b-overlay-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes p8b-cta-pop {
  0% {
    opacity: 0;
    transform: scale(0.86);
  }
  70% {
    opacity: 1;
    transform: scale(1.06);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes p8b-cta-breathe {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 1px 0 rgba(255, 250, 240, 0.28) inset,
      0 8px 18px rgba(180, 83, 9, 0.28),
      0 2px 0 #92400e;
  }
  50% {
    transform: scale(1.045);
    box-shadow:
      0 1px 0 rgba(255, 250, 240, 0.34) inset,
      0 14px 28px rgba(180, 83, 9, 0.38),
      0 2px 0 #92400e;
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay-title,
  .overlay-text,
  .p8b-root .overlay-cta,
  .play-surface .overlay-cta,
  .p8b-root .overlay-cta.overlay-cta-pop,
  .play-surface .overlay-cta.overlay-cta-pop {
    animation: none;
  }

  .p8b-root .overlay-cta:hover,
  .play-surface .overlay-cta:hover,
  .p8b-root .overlay-cta:hover::after,
  .play-surface .overlay-cta:hover::after {
    transform: none;
  }
}

/* Sound glyph — one SVG; waves vs mute slash toggled by aria-pressed. */
.p8b-root .sound-toggle[aria-pressed="false"] .sound-icon-on,
.p8b-root .sound-toggle[aria-pressed="true"] .sound-icon-off {
  display: none !important;
}

/* Header PWA install → match Figma icon button */
.p8b-root .p8b-pwa-install {
  display: inline-flex;
  line-height: 0;
}

.p8b-root .p8b-pwa-install > span {
  display: inline-flex;
}

.p8b-root .p8b-pwa-install > span > button {
  box-sizing: border-box !important;
  display: inline-grid !important;
  place-items: center !important;
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  gap: 0 !important;
  border-radius: 12px !important;
  border: 1px solid var(--border) !important;
  background: var(--card) !important;
  color: var(--muted-foreground) !important;
  box-shadow: none !important;
  opacity: 1 !important;
}

.p8b-root .p8b-pwa-install > span > button:hover {
  color: var(--foreground) !important;
}

.p8b-root .p8b-pwa-install > span > button > span {
  display: none !important;
}

.p8b-root .p8b-pwa-install > span > button > svg {
  width: 17px;
  height: 17px;
}

/* Mobile action strip: match min-h-9 controls */
.p8b-root .p8b-action-strip .p8b-pwa-install > span > button {
  width: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  height: 36px !important;
  border-radius: 8px !important;
}

.p8b-root .p8b-pwa-install [role="dialog"] {
  width: min(19rem, calc(100vw - 2rem)) !important;
  max-width: calc(100vw - 2rem);
  box-sizing: border-box;
  border-color: var(--border) !important;
  background: var(--card) !important;
  color: var(--foreground);
}

/* Ad labels */
.ad-label-mobile {
  display: none;
}

@media (max-width: 767px) {
  .ad-label-desktop {
    display: none;
  }
  .ad-label-mobile {
    display: block;
  }
}

/* Footer language */
.p8b-root .footer-lang {
  display: flex;
  align-items: center;
  gap: 12px;
}

.p8b-root .footer-lang-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.p8b-root .footer-lang-picker {
  position: relative;
}

.p8b-root .footer-lang-static {
  display: inline-flex;
  align-items: center;
  height: 36px;
  min-width: 132px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--background);
  padding: 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
}

.p8b-root .footer-lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  min-width: 132px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--background);
  padding: 0 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.p8b-root .footer-lang-trigger:hover,
.p8b-root .footer-lang-trigger.is-open {
  border-color: #a8b4c4;
  box-shadow: 0 1px 3px rgb(27 36 48 / 8%);
}

.p8b-root .footer-lang-trigger-text {
  flex: 1;
  text-align: left;
}

.p8b-root .footer-lang-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted-foreground);
  transition: transform 0.15s ease;
}

.p8b-root .footer-lang-trigger.is-open .footer-lang-chevron {
  transform: rotate(180deg);
}

.p8b-root .footer-lang-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 40;
  width: min(220px, calc(100vw - 40px));
  max-height: min(320px, 52vh);
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 6px;
  box-shadow:
    0 10px 28px rgb(27 36 48 / 14%),
    0 2px 8px rgb(27 36 48 / 8%);
  scrollbar-width: thin;
  scrollbar-color: #9aa8b8 transparent;
}

.p8b-root .footer-lang-menu::-webkit-scrollbar {
  width: 6px;
}

.p8b-root .footer-lang-menu::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #9aa8b8;
}

.p8b-root .footer-lang-option {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--foreground);
  text-align: left;
  cursor: pointer;
}

.p8b-root .footer-lang-option:hover:not(.is-disabled):not(.is-selected) {
  background: var(--muted);
}

.p8b-root .footer-lang-option.is-selected {
  background: var(--accent);
  color: var(--accent-foreground);
}

/* Homepage article TOC — sticks while scrolling long SEO body (desktop) */
@media (min-width: 1024px) {
  .p8b-root .article-toc {
    position: sticky;
    top: 1.25rem;
    align-self: start;
    max-height: calc(100dvh - 2.5rem);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #9aa8b8 transparent;
  }

  .p8b-root .article-toc::-webkit-scrollbar {
    width: 5px;
  }

  .p8b-root .article-toc::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: #9aa8b8;
  }
}

/* Tool-page / home article blocks inside Figma shell */
.p8b-root .article-content .article-section + .article-section {
  margin-top: 2.75rem;
}

.p8b-root .article-content .article-section h2 {
  margin-top: 0;
  margin-bottom: 0.85rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--foreground);
}

@media (min-width: 640px) {
  .p8b-root .article-content .article-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
  }
}

.p8b-root .article-content .article-section > h2:first-child {
  margin-top: 0;
}

.p8b-root .article-content .article-section p,
.p8b-root .article-content .article-section li {
  margin-top: 0.75rem;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--muted-foreground);
}

.p8b-root .article-content .article-section h2 + p,
.p8b-root .article-content .article-section h2 + ol,
.p8b-root .article-content .article-section h2 + ul,
.p8b-root .article-content .article-section h2 + dl,
.p8b-root .article-content .article-section h2 + div > p:first-child {
  margin-top: 0;
}

.p8b-root .article-content .article-section ul,
.p8b-root .article-content .article-section ol {
  margin-top: 0.25rem;
  padding-left: 1.25rem;
}

/* padding-top avoids margin collapse under the FAQ h2 */
.p8b-root .faq-list {
  margin-top: 0;
  padding-top: 0.35rem;
  display: grid;
  gap: 0.85rem;
}

.p8b-root .faq-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 14px 16px;
}

.p8b-root .faq-item dt {
  font-weight: 700;
  color: var(--foreground);
}

.p8b-root .faq-item dd {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted-foreground);
}

.p8b-root details summary::-webkit-details-marker {
  display: none;
}

.p8b-root .history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.p8b-root .history-item[hidden],
.p8b-root .history-empty[hidden] {
  display: none !important;
}

/* Demo / Daily active */
.p8b-root #demoBtn[aria-pressed="true"],
.p8b-root #demoBtn.active {
  border-color: rgba(217, 119, 6, 0.55);
  background: #fff8ed;
  color: var(--p8b-amber-deep);
}

.p8b-root #dailyBtn.active,
.p8b-root #dailyBtn[aria-pressed="true"] {
  border-color: rgba(217, 119, 6, 0.65);
  background: #fff8ed;
  color: var(--p8b-amber-deep);
  box-shadow: 0 0 0 2px rgba(237, 194, 46, 0.35);
}

.play-surface .daily-difficulty-badge {
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid #e8c96a;
  background: #fff8e8;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #b45309;
}

.play-surface .side-card-daily .side-stat strong#dailyTarget {
  font-size: 1.125rem;
  color: #e85d3a;
}

/* Undo practice landing — highlight the control without neon glow spam */
.play-surface #undoBtn.emphasize-undo {
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.45);
  border-color: #d97706;
}

/* Dark landing (/2048-dark-mode): dim chrome; classic tile colors stay in canvas */
.p8b-root[data-p8b-mode="dark"] {
  --background: #12161c;
  --foreground: #e8eef4;
  --card: #1a212b;
  --card-foreground: #e8eef4;
  --secondary: #242c38;
  --secondary-foreground: #e8eef4;
  --muted: #1e2630;
  --muted-foreground: #9aa8b8;
  --accent: #f59e0b;
  --accent-foreground: #1b2430;
  --border: #3a4656;
  --primary: #e8eef4;
  --primary-foreground: #12161c;
  --p8b-amber: #f59e0b;
  --p8b-amber-deep: #fbbf24;
  color-scheme: dark;
}

.p8b-root[data-p8b-mode="dark"] .play-surface {
  background: #12161c;
}

.p8b-root[data-p8b-mode="dark"] .article-content {
  color: var(--foreground);
}

.p8b-root[data-p8b-mode="dark"] #dailyBtn[aria-pressed="true"] {
  background: #2a2214;
  border-color: rgba(245, 158, 11, 0.65);
  color: #fbbf24;
}

.p8b-root[data-p8b-mode="dark"] .play-surface .daily-difficulty-badge {
  border-color: #8a6a28;
  background: #2a2214;
  color: #fbbf24;
}
