:root {
  --bg: #fbfaf6;
  --bg-warm: #f4f1e9;
  --ink: #211f1a;
  --ink-soft: #56524a;
  --ink-faint: #8d887d;
  --line: #e4dfd3;
  --card: #fffefb;
  --accent: #1f7d5e;
  --accent-deep: #155f47;
  --gold: #c9a227;
  --bad: #b42318;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(33,31,26,.04), 0 12px 30px -18px rgba(33,31,26,.22);
  --ui: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 78% -8%, var(--bg-warm), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-deep); }
a:hover { color: var(--accent); }
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(251,250,246,.88);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
}
.brand-text { display: grid; line-height: 1.15; }
.brand-name { font-weight: 700; letter-spacing: -.02em; }
.brand-sub { font-size: .75rem; color: var(--ink-faint); }
.top-nav { display: flex; gap: 16px; font-size: .92rem; }
.top-nav a { text-decoration: none; color: var(--ink-soft); }
.top-nav a:hover { color: var(--ink); }
main { flex: 1; width: min(980px, 100%); margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 48px; }
.home .eyebrow, .prose .eyebrow {
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: .75rem;
  color: var(--accent-deep);
  margin: 0 0 8px;
}
h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  letter-spacing: -.02em;
  line-height: 1.2;
  margin: 0 0 12px;
}
.lede { font-size: 1.08rem; color: var(--ink-soft); max-width: 38rem; }
.games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 28px;
}
.game-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.game-card h2 { margin: 0 0 8px; font-size: 1.25rem; }
.game-card p { margin: 0 0 10px; color: var(--ink-soft); }
.game-meta { font-size: .82rem; color: var(--ink-faint); }
.game-card .game-meta { margin-top: auto; margin-bottom: 0; }
.game-card .cta-row { margin-top: 8px; margin-bottom: 0; padding-top: 0; }
.game-card.soon { opacity: .88; }
.cta-row, .tools { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: .95rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  background: transparent;
  touch-action: manipulation;
}
.btn-primary { background: var(--accent); color: #fff !important; }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { border-color: var(--line); color: var(--ink-soft) !important; background: #fff; }
.btn-ghost:hover { border-color: var(--ink-faint); color: var(--ink) !important; }
.btn.on, .btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e7f2ec;
  color: var(--accent-deep) !important;
}
.prose { max-width: 40rem; }
.prose h2 { font-size: 1.15rem; margin: 1.6em 0 .5em; color: var(--accent-deep); }
.foot {
  padding: 24px 20px 36px;
  text-align: center;
  color: var(--ink-faint);
  font-size: .88rem;
}
.foot p { margin: 0 0 6px; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Sudoku */
.play { padding-top: 18px; }
.sudoku { display: grid; gap: 16px; justify-items: center; }
.play-bar { width: min(100%, 28rem); }
.play-bar h1 { font-size: 1.6rem; margin-bottom: 6px; }
.level-line { display: flex; gap: 8px; margin: 0 0 8px; }
.lvl {
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: .88rem;
  font-weight: 600;
}
.lvl.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.meta-line { display: flex; gap: 12px; align-items: baseline; margin: 0; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.status.ok { color: var(--accent-deep); }
.status.bad { color: var(--bad); }
.board-wrap {
  width: min(100%, 28rem);
}
.grid {
  --cell: calc((min(100vw, 28rem) - 32px) / 9);
  width: calc(var(--cell) * 9);
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  border: 3px solid var(--ink);
  background: var(--ink);
  gap: 1px;
  touch-action: manipulation;
}
.cell {
  aspect-ratio: 1;
  border: 0;
  margin: 0;
  padding: 0;
  background: var(--card);
  font-family: var(--display);
  font-size: clamp(1rem, 4.6vw, 1.55rem);
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.cell:nth-child(3n) { border-right: 2px solid var(--ink); }
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid var(--ink); }
.cell.given { color: var(--ink); font-weight: 700; }
.cell:not(.given) { color: #1a5c9e; }
.cell.selected { background: #d8eee4; }
.cell.peer { background: #f3eee2; }
.cell.same { background: #e4f0d8; }
.cell.conflict { color: var(--bad); background: #fde8e6; }
.cell.hinted { background: #fff3c4; }
.cell.win { background: #e7f2ec; }
.notes {
  position: absolute;
  inset: 2px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  font-size: .55rem;
  font-weight: 600;
  font-family: var(--ui);
  color: var(--ink-faint);
  line-height: 1;
  pointer-events: none;
}
.notes span { display: grid; place-items: center; }
.pad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  width: min(100%, 28rem);
}
.pad button {
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.pad button:hover { border-color: var(--accent); }
.tools { width: min(100%, 28rem); justify-content: stretch; }
.tools .btn { flex: 1 1 auto; }

@media (max-width: 640px) {
  .top-nav a:last-child { display: none; }
  .pad button { min-height: 44px; }
  .tools .btn { min-height: 44px; padding: 8px 10px; font-size: .88rem; }
}

/* Mahjong solitaire */
.mahjong { display: grid; gap: 16px; justify-items: center; width: 100%; }
.mahjong .play-bar { width: min(100%, 40rem); }
.mahjong .meta-line { flex-wrap: wrap; }
.mj-board-wrap {
  width: min(100%, 58rem);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.mj-board {
  --half-w: 16px;
  --half-h: 21px;
  --lift: 5px;
  --pad: 14px;
  --maxz: 2;
  position: relative;
  margin: 0 auto;
  background:
    radial-gradient(900px 280px at 50% 0%, rgba(31,125,94,.08), transparent 70%),
    #efe8d6;
  border-radius: 16px;
  border: 1px solid var(--line);
}
.mj-tile {
  position: absolute;
  left: calc(var(--pad) + (var(--maxz) - var(--z)) * var(--lift) + var(--x) * var(--half-w));
  top: calc(var(--pad) + (var(--maxz) - var(--z)) * var(--lift) + var(--y) * var(--half-h));
  width: calc(var(--half-w) * 2);
  height: calc(var(--half-h) * 2);
  padding: 0;
  border: 1px solid #d7ccb4;
  border-radius: 5px;
  background: linear-gradient(180deg, #fffef8 0%, #f4ead6 100%);
  box-shadow:
    1px 1px 0 #c4b89a,
    2px 2px 0 #8d7d5c,
    2px 3px 5px rgba(33, 31, 26, .16);
  cursor: default;
  color: var(--ink);
  font-family: "Noto Sans SC", var(--ui);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.mj-tile.free { cursor: pointer; }
.mj-tile.free:hover { filter: brightness(1.05); }
.mj-tile:not(.free) { filter: saturate(.82) brightness(.96); }
.mj-tile.selected {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  background: #e7f2ec;
}
.mj-tile.hint {
  outline: 2px solid var(--gold);
  outline-offset: -1px;
}
.mj-tile.win { filter: none; }
.mj-face {
  position: absolute;
  inset: 9% 8% 13% 8%;
  border: 1px solid #e4d9c2;
  border-radius: 3px;
  background: #fffdf8;
  display: grid;
  place-items: center;
  font-size: calc(var(--half-h) * .92);
  line-height: 1;
  overflow: hidden;
}
.mj-dots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 78%;
  height: 78%;
}
.mj-dots i {
  width: 62%;
  height: 62%;
  margin: auto;
  border-radius: 50%;
  visibility: hidden;
}
.mj-dots i.on {
  visibility: visible;
  background: #1a5c9e;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}
.mj-bam {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 6%;
  width: 78%;
  height: 82%;
}
.mj-bam-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6%;
  flex: 1;
}
.mj-bam[data-n="1"] .mj-bam-col { flex: 0 0 22%; }
.mj-bam[data-n="2"] .mj-bam-col { flex: 0 0 22%; }
.mj-bam i {
  flex: 1;
  min-height: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, #4a9a64, #246b3c);
  box-shadow: inset 1px 0 0 rgba(255,255,255,.28);
  position: relative;
}
.mj-bam i::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: 42%;
  height: 1px;
  background: rgba(255,255,255,.35);
}
.mj-char {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  position: relative;
}
.mj-wan {
  position: absolute;
  top: 4%;
  right: 7%;
  font-size: .38em;
  font-weight: 700;
  color: #b42318;
}
.mj-num {
  font-weight: 700;
  font-size: 1.05em;
  color: #b42318;
}
.mj-honor {
  font-weight: 700;
  font-size: 1.12em;
}
.mj-honor.red { color: #b42318; }
.mj-honor.green { color: #1f7d5e; }
.mj-honor.ink { color: #211f1a; }
.mj-honor.flower { color: #9b3d6a; }
.mj-honor.season { color: #1a5c9e; }
.mj-white {
  width: 46%;
  height: 58%;
  border: 2px solid #1a5c9e;
  border-radius: 2px;
}

@media (max-width: 640px) {
  .mj-face { inset: 8% 7% 12% 7%; }
}
