:root {
  --bg: #f5efe4;
  --bg-accent: #dce8da;
  --surface: rgba(255, 251, 245, 0.92);
  --surface-strong: #fffaf1;
  --ink: #18212b;
  --muted: #56616b;
  --line: rgba(24, 33, 43, 0.14);
  --brand: #183153;
  --brand-2: #e76f51;
  --ok: #2d7d46;
  --warn: #c67a00;
  --bad: #ad343e;
  --shadow: 0 14px 30px rgba(24, 33, 43, 0.12);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(231, 111, 81, 0.15), transparent 28%),
    radial-gradient(circle at top right, rgba(24, 49, 83, 0.1), transparent 30%),
    linear-gradient(180deg, var(--bg) 0%, #f9f5ed 45%, var(--bg-accent) 100%);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

button,
.button,
.game-cell,
.card-button,
.key-button {
  min-width: 44px;
  min-height: 44px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -52px;
  background: var(--brand);
  color: white;
  padding: 10px 14px;
  border-radius: 12px;
  z-index: 20;
}

.skip-link:focus {
  top: 12px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  background: rgba(245, 239, 228, 0.88);
  border-bottom: 1px solid var(--line);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.brand {
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.menu-toggle,
.button {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  text-decoration: none;
  background: var(--brand);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button-secondary {
  background: rgba(24, 49, 83, 0.08);
  color: var(--ink);
}

.site-nav {
  display: none;
  padding: 0 16px 16px;
  gap: 10px;
  flex-wrap: wrap;
}

.site-nav.is-open {
  display: flex;
}

.site-nav a {
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(24, 49, 83, 0.08);
}

.site-nav a[aria-current="page"] {
  background: var(--brand);
  color: white;
}

main {
  width: min(1120px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 16px 0 80px;
}

.page-heading {
  padding: 12px 0 8px;
}

.eyebrow,
.meta-line {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 7vw, 3.7rem);
  line-height: 0.95;
  margin-top: 4px;
}

h2 {
  font-size: clamp(1.2rem, 4vw, 1.75rem);
}

section,
article {
  min-width: 0;
}

.hero-card,
.panel,
.game-card,
.related-card,
.game-stage,
.game-sidebar section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card,
.panel,
.game-stage {
  padding: 18px;
}

.hero-card,
.stats-grid,
.cards-grid,
.info-grid,
.game-shell,
.related-grid {
  margin-top: 16px;
}

.lede {
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--muted);
}

.cta-row,
.pill-row,
.status-strip,
.toolbar,
.action-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.pill-row {
  list-style: none;
  padding: 0;
}

.pill-row li,
.status-strip span,
.status-strip strong {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(24, 49, 83, 0.08);
}

.stats-grid,
.cards-grid,
.info-grid,
.related-grid {
  display: grid;
  gap: 16px;
}

.stats-grid article {
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(255, 250, 241, 0.76);
  border: 1px solid var(--line);
}

.stats-grid strong {
  display: block;
  font-size: 2rem;
}

.game-card,
.related-card {
  padding: 16px;
  text-decoration: none;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.stack-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 250, 241, 0.8);
}

.game-shell {
  display: grid;
  gap: 16px;
}

.game-sidebar {
  display: none;
}

.compact-shell .game-stage {
  padding: 14px;
}

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 12px;
}

.game-meta span:empty {
  display: none;
}

.game-messages {
  min-height: 24px;
  margin-top: 12px;
  color: var(--brand);
}

.game-hud,
.game-scorebar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.hud-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(24, 49, 83, 0.08);
  color: var(--ink);
}

.hud-pill.is-alert {
  background: rgba(231, 111, 81, 0.16);
}

.game-board-wrap {
  margin-top: 12px;
}

.game-grid {
  display: grid;
  gap: 4px;
  user-select: none;
  touch-action: manipulation;
}

.square-grid {
  width: min(100%, 88vw, 420px);
  aspect-ratio: 1 / 1;
}

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

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

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

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

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

.game-cell {
  border: 1px solid rgba(24, 33, 43, 0.15);
  border-radius: 10px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tile-cell {
  font-weight: 700;
  font-size: clamp(0.95rem, 4vw, 1.4rem);
}

.tile-empty {
  background: rgba(24, 49, 83, 0.08);
}

.jigsaw-piece {
  background-image: var(--piece-image);
  background-size: 300% 300%;
  color: transparent;
}

.word-grid,
.keyboard,
.memory-grid,
.difference-grid {
  display: grid;
  gap: 8px;
}

.word-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: min(100%, 320px);
}

.guess-cell {
  aspect-ratio: 1 / 1;
  border: 2px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  background: white;
}

.guess-hit {
  background: #588157;
  color: white;
}

.guess-near {
  background: #dda15e;
  color: white;
}

.guess-miss {
  background: #7d8597;
  color: white;
}

.keyboard {
  grid-template-columns: repeat(10, minmax(0, 1fr));
  width: min(100%, 480px);
  margin-top: 12px;
}

.keyboard.wide {
  width: min(100%, 560px);
}

.key-button {
  border: 0;
  border-radius: 12px;
  background: rgba(24, 49, 83, 0.08);
  font-size: 0.95rem;
  padding: 10px 6px;
}

.key-button.is-hit {
  background: #588157;
  color: white;
}

.key-button.is-near {
  background: #dda15e;
  color: white;
}

.key-button.is-miss {
  background: #7d8597;
  color: white;
}

.board-row {
  display: grid;
  gap: 4px;
}

.nonogram-wrap,
.sudoku-wrap {
  overflow-x: auto;
  padding-bottom: 6px;
}

.clue-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
}

.clue-column,
.clue-row,
.nonogram-top-clue,
.nonogram-left-clue {
  font-size: 0.75rem;
  color: var(--muted);
}

.nonogram-shell {
  display: grid;
  grid-template-columns: 64px minmax(280px, 420px);
  grid-template-rows: 64px minmax(280px, 420px);
  grid-template-areas:
    "spacer top"
    "left board";
  gap: 6px;
  align-items: start;
  width: max-content;
}

.nonogram-spacer {
  grid-area: spacer;
  width: 64px;
  height: 64px;
}

.nonogram-top-clues {
  grid-area: top;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
  align-items: end;
  height: 64px;
  padding-bottom: 4px;
}

.nonogram-top-clue {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: center;
  line-height: 1;
  gap: 2px;
}

.nonogram-left-clues {
  grid-area: left;
  display: grid;
  grid-template-rows: repeat(10, minmax(0, 1fr));
  gap: 4px;
  align-self: stretch;
  height: min(100%, 420px);
}

.nonogram-left-clue {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: end;
  padding-right: 6px;
  text-align: right;
}

.nonogram-board {
  grid-area: board;
  width: min(100%, 420px);
  aspect-ratio: 1 / 1;
  align-self: start;
}

.nonogram-cell.filled {
  background: var(--brand);
}

.nonogram-cell.marked::after {
  content: "×";
  color: var(--bad);
}

.mine-open {
  background: #f1efe8;
}

.mine-flag {
  background: #ffe0b5;
}

.memory-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(100%, 360px);
}

.memory-card {
  aspect-ratio: 1 / 1;
  font-size: 1.6rem;
}

.merge-grid {
  background: #b9b2a8;
  border-radius: 16px;
  padding: 6px;
}

.merge-cell {
  background: rgba(255, 250, 241, 0.6);
  font-weight: 700;
  font-size: 1.2rem;
}

.merge-cell[data-value="2"] { background: #eee4da; }
.merge-cell[data-value="4"] { background: #ece0c8; }
.merge-cell[data-value="8"] { background: #f2b179; color: white; }
.merge-cell[data-value="16"] { background: #f59563; color: white; }
.merge-cell[data-value="32"] { background: #f67c5f; color: white; }
.merge-cell[data-value="64"] { background: #f65e3b; color: white; }
.merge-cell[data-value="128"],
.merge-cell[data-value="256"],
.merge-cell[data-value="512"],
.merge-cell[data-value="1024"],
.merge-cell[data-value="2048"] {
  background: #edcf72;
  color: #18212b;
}

.block-layout {
  display: grid;
  gap: 16px;
}

.piece-bank {
  display: grid;
  gap: 12px;
}

.piece-card {
  padding: 10px;
  border-radius: 14px;
  background: rgba(24, 49, 83, 0.08);
}

.piece-card.is-active {
  outline: 2px solid var(--brand-2);
}

.piece-mini-grid {
  display: grid;
  gap: 2px;
}

.piece-mini-grid span,
.block-cell.filled,
.block-cell.ghost {
  display: block;
  border-radius: 4px;
}

.piece-mini-grid span {
  width: 18px;
  height: 18px;
  background: var(--brand-2);
}

.block-cell.filled {
  background: var(--brand);
}

.block-cell.ghost {
  background: rgba(231, 111, 81, 0.24);
}

.difference-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 520px);
}

.difference-panel {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, #dbeafe 0%, #fff6da 100%);
  border: 1px solid var(--line);
}

.difference-panel svg {
  width: 100%;
  height: 100%;
  display: block;
}

.difference-button {
  position: absolute;
  border-radius: 999px;
  border: 0;
  background: transparent;
  opacity: 0;
  cursor: pointer;
}

.difference-button.found {
  opacity: 1;
  background: transparent;
  border: 3px solid rgba(45, 125, 70, 0.9);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6);
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 320px);
  margin-top: 12px;
}

.sudoku-cell.is-fixed {
  background: #efe7db;
  font-weight: 700;
}

.sudoku-cell.is-selected {
  outline: 2px solid var(--brand-2);
}

.sudoku-cell.is-conflict {
  background: rgba(173, 52, 62, 0.16);
}

.site-toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(16px);
  background: rgba(24, 33, 43, 0.94);
  color: white;
  padding: 12px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.site-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 33, 43, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

.modal-card {
  width: min(100%, 420px);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-body {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.share-fallback {
  width: 100%;
  min-height: 120px;
  margin-top: 12px;
  padding: 12px;
  font-size: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.site-footer {
  width: min(1120px, calc(100vw - 24px));
  margin: 0 auto 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 480px) {
  main,
  .site-footer {
    width: min(1120px, calc(100vw - 32px));
  }

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

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

@media (min-width: 768px) {
  .topbar {
    padding: 16px 20px 10px;
  }

  .menu-toggle {
    display: none;
  }

  .site-nav {
    display: flex;
    padding: 0 20px 16px;
  }

  .game-shell {
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.7fr);
  }

  .game-sidebar {
    display: grid;
    gap: 16px;
  }

  .cards-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .block-layout {
    grid-template-columns: minmax(0, 1fr) 220px;
  }
}

@media (min-width: 1024px) {
  .cards-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
