:root {
  --bg: #e7e1d4;
  --bg-deep: #d9d2c3;
  --ink: #1e1a16;
  --ink-soft: #514a42;
  --paper: #f6f1e7;
  --paper-2: #fffdf8;
  --line: #d4cbbd;
  --felt: #1c4334;
  --felt-2: #16382b;
  --gold: #8d6a2f;
  --cinnabar: #a33b24;
  --red-suit: #9d1c2c;
  --focus: #a33b24;
  --shadow: 0 18px 40px rgba(48, 36, 22, 0.12);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Noto Serif", Georgia, serif;
  --sans: Inter, "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --card-w: 86px;
  --card-h: 120px;
  --show: 26px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(255, 252, 245, 0.7), transparent 55%),
    linear-gradient(180deg, #efe8db 0%, var(--bg) 220px);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.5;
}
img, svg { max-width: 100%; }
a { color: var(--cinnabar); text-underline-offset: 0.16em; }
a:hover { color: #7d2b1a; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--paper);
  padding: 8px 12px;
  z-index: 5;
}
.skip:focus { top: 12px; }

.site-header, .site-footer, .hero, .game-grid, .prose, .page-intro {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 0 8px;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}
.brand strong { display: block; font-family: var(--serif); font-size: 1.35rem; letter-spacing: -0.02em; }
.brand small { color: var(--ink-soft); }
.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--felt);
  color: #f6f1e7;
  font-family: var(--serif);
  font-size: 1.35rem;
}
.site-nav { display: flex; gap: 16px; align-items: center; }
.site-nav a { color: var(--ink); font-weight: 650; text-decoration: none; }
.site-nav a:hover { color: var(--cinnabar); }

.hero { padding: 28px 0 8px; }
.hero h1 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
}
.hero p { max-width: 42rem; font-size: 1.12rem; color: var(--ink-soft); margin: 0; }
.eyebrow { margin: 0 0 8px; color: var(--gold); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.78rem; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 22px 0 10px;
}
.game-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.game-card-link { color: inherit; text-decoration: none; display: block; }
.game-card h2 { font-family: var(--serif); font-size: 1.55rem; margin: 12px 16px 4px; letter-spacing: -0.02em; }
.game-card p { margin: 0 16px 12px; color: var(--ink-soft); }
.game-card .text-link { margin: 0 16px 16px; font-weight: 700; }
.illu { display: block; width: 100%; height: 132px; background: var(--felt); }

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: min(1120px, calc(100% - 32px));
  margin: 8px auto 24px;
}
.page-intro { width: auto; margin: 12px 0 14px; }
.crumbs { margin: 0 0 6px; color: var(--ink-soft); font-size: 0.92rem; }
.crumbs a { color: var(--ink-soft); }
.page-intro h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}
.lede { margin: 0 0 8px; max-width: 42rem; color: var(--ink-soft); font-size: 1.08rem; }
.rule-link { margin: 0; font-weight: 700; }

/* Empty ad slots collapse. A later unit placed inside one is kept 150px from the table. */
.ad-slot:empty { display: none; }
.ad-slot-top:not(:empty),
.ad-slot-bottom:not(:empty) {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
}
.ad-slot-top:not(:empty) { margin-bottom: 150px; }
.ad-slot-bottom:not(:empty) { margin-top: 150px; }
@media (min-width: 1280px) {
  .page-grid:has(.ad-slot-left:not(:empty)) { grid-template-columns: minmax(160px, 300px) minmax(0, 1fr); column-gap: 150px; }
  .page-grid:has(.ad-slot-right:not(:empty)) { grid-template-columns: minmax(0, 1fr) minmax(160px, 300px); column-gap: 150px; }
  .page-grid:has(.ad-slot-left:not(:empty)):has(.ad-slot-right:not(:empty)) {
    grid-template-columns: minmax(160px, 300px) minmax(0, 1fr) minmax(160px, 300px);
    column-gap: 150px;
  }
}

.play-stage {
  background:
    radial-gradient(900px 280px at 50% -20%, rgba(255, 255, 255, 0.08), transparent 50%),
    linear-gradient(180deg, var(--felt), var(--felt-2));
  border-radius: 22px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  border-radius: 999px;
  min-height: 44px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}
.btn.primary { background: var(--cinnabar); color: white; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn[aria-pressed="true"] { background: #f3efe4; color: var(--felt); box-shadow: inset 0 0 0 2px var(--gold); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.deal-label { display: flex; align-items: center; gap: 6px; color: #f6f1e7; font-weight: 650; }
.deal-label input {
  width: 7.2rem;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.18);
  color: white;
  font: inherit;
  padding: 0 8px;
}
.stat { color: #f3ecdf; font-variant-numeric: tabular-nums; }
.stat b { font-size: 1.05rem; }
.status { min-height: 1.5em; margin: 0 0 10px; color: #f6f1e7; }

.board-scroll, .mine-scroll { overflow-x: auto; max-width: 100%; padding-bottom: 6px; }
.solitaire { width: max(100%, calc(var(--cols) * (var(--card-w) + var(--gap, 8px)))); }
.sol-row { display: flex; align-items: flex-start; gap: var(--gap, 8px); }
.row-top { margin-bottom: 14px; }
.spacer { flex: 1 1 16px; min-width: 8px; }
.pile { position: relative; }
.slot, .card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 9px;
  flex: 0 0 auto;
}
.slot {
  border: 1.5px dashed rgba(246, 241, 231, 0.45);
  background: rgba(0, 0, 0, 0.12);
  color: rgba(246, 241, 231, 0.8);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.watermark { font-family: var(--serif); font-size: 1.4rem; opacity: 0.7; }
.recycle-icon { width: 46%; height: 46%; }
.card {
  position: relative;
  display: block;
  padding: 0;
  border: 1px solid #e4d9c8;
  background: linear-gradient(180deg, #fffefb, #f7f1e6);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 8px 14px rgba(12, 20, 16, 0.18);
  cursor: pointer;
  touch-action: none;
}
.card.red { color: var(--red-suit); }
.card.down {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.18), transparent 42%),
    repeating-linear-gradient(135deg, #245443 0 7px, #1b4033 7px 14px);
  border-color: #143328;
  box-shadow: 0 8px 14px rgba(12, 20, 16, 0.18);
}
.card .corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-family: var(--sans);
}
.card .corner b { font-size: calc(var(--card-w) * 0.22); letter-spacing: -0.04em; }
.card .corner i { font-style: normal; font-size: calc(var(--card-w) * 0.16); }
.card .corner.tl { top: 5px; left: 6px; }
.card .corner.br { right: 6px; bottom: 5px; transform: rotate(180deg); }
.pips { position: absolute; inset: 0; }
.pip {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: calc(var(--card-w) * 0.22);
  line-height: 1;
}
.pip.flip { transform: translate(-50%, -50%) rotate(180deg); }
.face-rank {
  position: absolute;
  inset: 18% 10%;
  display: grid;
  place-items: center;
  border: 1.5px solid currentColor;
  border-radius: 8px;
  opacity: 0.9;
}
.face-rank b { font-family: var(--serif); font-size: calc(var(--card-w) * 0.42); line-height: 0.8; }
.face-rank i { font-style: normal; font-size: calc(var(--card-w) * 0.2); }
.pile.tableau { display: flex; flex-direction: column; align-items: center; min-height: var(--card-h); }
.pile.tableau .card + .card { margin-top: calc(var(--show) - var(--card-h)); }
.pile.tableau .card.down + .card { margin-top: calc(var(--show-down, 12px) - var(--card-h)); }
.pile.waste { display: flex; min-width: var(--card-w); min-height: var(--card-h); }
.pile.waste .card + .card { margin-left: calc(var(--card-w) * -0.62); }
.card.selected, .tile.selected { outline: 3px solid #f0c36a; outline-offset: 1px; transform: translateY(-6px); z-index: 5; }
.card.cursor, .slot.cursor, .mine.cursor, .cell.selected { box-shadow: 0 0 0 3px #f0c36a; }
.drag-ghost {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.28));
}
.drag-ghost .card + .card { margin-top: calc(var(--show) - var(--card-h)); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
}
.shake { animation: shake 0.22s linear; }

.sudoku-grid {
  width: min(100%, 440px);
  aspect-ratio: 1;
  display: grid;
  grid-template-rows: repeat(9, 1fr);
  background: #1e1a16;
  border: 2px solid #1e1a16;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
}
.sudoku-row { display: grid; grid-template-columns: repeat(9, 1fr); }
.cell {
  border: 0;
  border-right: 1px solid #ddd4c6;
  border-bottom: 1px solid #ddd4c6;
  background: var(--paper-2);
  color: #234e78;
  font: inherit;
  font-weight: 700;
  font-size: clamp(1rem, 3.6vw, 1.45rem);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.sudoku-row .cell:nth-child(3n) { border-right-width: 2px; border-right-color: #1e1a16; }
.sudoku-row:nth-child(3n) .cell { border-bottom-width: 2px; border-bottom-color: #1e1a16; }
.cell.given { color: var(--ink); background: #f3efe6; }
.cell.peer { background: #f8f1e4; }
.cell.selected { background: #f6d7c6; color: var(--ink); }
.cell.conflict, .cell.wrong { background: #f6d0cc; color: #8d1d28; }
.cell.hinted { background: #f6e3a8; }
.notes {
  width: 86%;
  height: 86%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  font-size: clamp(0.45rem, 1.5vw, 0.68rem);
  font-weight: 650;
  color: #5c564e;
  line-height: 1;
}
.notes i { font-style: normal; display: grid; place-items: center; }
.pad { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; width: min(100%, 440px); }
.pad-key { padding-inline: 0; }

.mahjong-fit { width: 100%; overflow: hidden; }
.mahjong-board { position: relative; transform-origin: top left; }
.tile {
  position: absolute;
  width: 56px;
  height: 74px;
  padding: 4px;
  border-radius: 7px;
  border: 1px solid #d9d0c0;
  background: linear-gradient(#fffdf8, #f4ecde);
  box-shadow: 2px 3px 0 rgba(20, 16, 12, 0.16);
  cursor: pointer;
}
.tile.blocked { filter: saturate(0.75) brightness(0.96); cursor: default; }
.tile.hinted { outline: 3px solid #f0c36a; }

.mine-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 34px);
  width: max-content;
  gap: 3px;
  background: transparent;
}
.mine {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid #c9bfae;
  background: #efe6d6;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.mine svg { width: 18px; height: 18px; }
.mine.open { background: #f7f3ea; border-color: #e0d6c6; }
.mine.hit { background: #a33b24; color: white; }
.mine.shown-mine { color: #5c4038; }
.mine.bad-flag { background: #f6d0cc; }
.mine.n1 { color: #1f4e79; }
.mine.n2 { color: #1e4636; }
.mine.n3 { color: #a1262d; }
.mine.n4 { color: #243056; }
.mine.n5 { color: #8d3b1b; }
.mine.n6 { color: #1f6f8b; }
.mine.n7 { color: #1e1a16; }
.mine.n8 { color: #6b6258; }

.modal {
  border: 0;
  border-radius: 18px;
  padding: 22px;
  max-width: min(440px, calc(100% - 32px));
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(24, 20, 16, 0.46); }
.modal h2 { font-family: var(--serif); margin: 0 0 8px; font-size: 1.8rem; }
.modal p { margin: 0 0 16px; }
.modal form { display: flex; flex-wrap: wrap; gap: 8px; }
.keys { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.keys th, .keys td { text-align: left; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); }
.notice, .loading { color: #f6f1e7; margin: 8px 0; }

.prose { padding-bottom: 40px; }
.prose h1 { font-family: var(--serif); font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -0.03em; line-height: 1; }
.prose h2 { font-family: var(--serif); font-size: 1.5rem; margin-top: 1.6em; }
.prose p, .prose li { max-width: 68ch; }
.rule-list { display: grid; gap: 10px; padding: 0; list-style: none; }
.rule-list a { font-weight: 750; }



.game-guide {
  margin: 28px 0 8px;
  max-width: 68ch;
}
.game-guide h2 {
  font-family: var(--serif);
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  margin: 1.4em 0 0.5em;
}
.game-guide h2:first-child { margin-top: 0; }
.game-guide h3 {
  font-family: var(--serif);
  font-size: 1.15rem;
  margin: 1.1em 0 0.35em;
}
.game-guide p { margin: 0 0 0.75em; color: var(--ink); }

.related-games {
  margin: 28px 0 8px;
  padding-top: 8px;
}
.related-games h2 {
  font-family: var(--serif);
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.related-games > p { margin: 0 0 14px; color: var(--ink-soft); max-width: 48rem; }
.related-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.related-list li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px 10px;
}
.related-list a { font-weight: 750; color: inherit; text-decoration: none; }
.related-list a:hover { color: var(--cinnabar); }
.related-list .related-rules { color: var(--cinnabar); font-weight: 650; }
.related-list p { margin: 6px 0 0; color: var(--ink-soft); font-size: 0.95rem; }

.site-footer {
  padding: 28px 0 40px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.site-footer p { max-width: 62ch; }

@media (max-width: 900px) {
  .game-grid { grid-template-columns: 1fr 1fr; }
  .solitaire { --card-w: 68px; --card-h: 96px; --show: 22px; --show-down: 10px; }
}
@media (max-width: 640px) {
  .game-grid { grid-template-columns: 1fr; }
  .site-header { align-items: flex-start; }
  .solitaire { --card-w: 58px; --card-h: 82px; --show: 20px; --show-down: 9px; --gap: 6px; }
  .pad { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .pips { display: none; }
  .card .corner b { font-size: calc(var(--card-w) * 0.26); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .shake { outline: 2px solid #f0c36a; }
}
