/* New to Mahj — "the rack" design.
   Colors (named for the set):
     Bone    #FBF6EA  page, like a tile face          Ink      #1D1B16  body text (16:1 on Bone)
     Felt    #16442F  header, the green back of a tile Jade     #1A4D39 links (9:1), #1F5A43 buttons (7.5:1)
     Lacquer #9B2A22  Crak red, labels (7:1)          Indigo   #22396B  Dot blue, focus ring
     Brass   #A8792A  rack ledge and trim (decorative only, never text)
   Type: Literata (headings) + Atkinson Hyperlegible (body, numerals that can't be confused). */
:root {
  --bone: #FBF6EA; --paper: #FFFDF7; --ink: #1D1B16; --ink-soft: #3B372E;
  --felt: #16442F; --jade: #1A4D39; --jade-btn: #1F5A43; --lacquer: #9B2A22;
  --indigo: #22396B; --brass: #A8792A; --line: #D3C5A6; --wash: #F3EAD3;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Atkinson Hyperlegible", Verdana, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bone); color: var(--ink); font-family: var(--sans); font-size: 1.25rem; line-height: 1.6; }
img, svg { max-width: 100%; }
a { color: var(--jade); text-decoration: underline; text-underline-offset: .15em; text-decoration-thickness: .08em; }
a:hover { text-decoration-thickness: .14em; }
:focus-visible { outline: 3px solid var(--indigo); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; color: var(--ink); font-weight: 700; }
h1 { font-size: 2.35rem; margin: .4em 0 .35em; }
h2 { font-size: 1.65rem; margin: 1.8em 0 .5em; }
h3 { font-size: 1.3rem; margin: 1.4em 0 .4em; }
p, ul, ol, dl { margin: 0 0 1em; }
li { margin-bottom: .35em; }
.wrap { max-width: 68rem; margin: 0 auto; padding: 0 1rem; }
.narrow { max-width: 44rem; }
.small { font-size: 1rem; }
.muted { color: var(--ink-soft); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--paper); padding: .6rem 1rem; z-index: 10; }

/* ---- header: a rack with a brass ledge ---- */
.site-header { background: var(--felt); color: var(--bone); }
.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1.5rem; padding-top: .7rem; padding-bottom: .5rem; }
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--bone); text-decoration: none; min-height: 48px; }
.brand-tiles { display: inline-flex; gap: 3px; }
.brand-tiles svg { width: 30px; height: auto; display: block; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.65rem; letter-spacing: .01em; }
.nav { display: flex; flex-wrap: wrap; gap: 0 1.1rem; }
.nav a { color: var(--bone); font-weight: 700; font-size: 1.1rem; display: inline-flex; align-items: center; min-height: 48px; text-decoration-thickness: .1em; }
.nav a[aria-current="page"] { text-decoration-thickness: .2em; }
.nav a:focus-visible, .brand:focus-visible { outline-color: #F3D27A; }
.ledge { height: 12px; background: linear-gradient(var(--brass), #8E6520); box-shadow: 0 3px 0 rgba(22, 68, 47, .35); }

/* ---- buttons look like buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: .55em 1.1em; border-radius: 10px;
  background: var(--jade-btn); color: #FFFCF3; border: 2px solid var(--jade-btn); font: 700 1.1rem/1.25 var(--sans);
  text-decoration: none; cursor: pointer; box-shadow: 0 4px 0 var(--felt); margin: 0 .5rem .6rem 0; text-align: center; }
.btn:hover { background: #18503B; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--felt); }
.btn-quiet { background: var(--paper); color: var(--jade); border-color: var(--jade); box-shadow: 0 4px 0 var(--line); }
.btn-quiet:hover { background: var(--wash); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---- home ---- */
.hero { padding: 1.6rem 0 1rem; }
.hero h1 { font-size: 2.8rem; max-width: 24ch; margin-top: .3em; }
.hero .lede { max-width: 40rem; }
.lede { font-size: 1.35rem; }
.hero-actions { margin: 1.2rem 0 1.6rem; }
.rack { margin: .5rem 0 0; max-width: 46rem; }
.rack-tiles { display: flex; gap: 4px; padding: 0 .6rem; overflow: hidden; }
.rack-tiles svg { width: 52px; height: auto; flex: 0 0 auto; display: block; }
.rack::after { content: ""; display: block; height: 16px; border-radius: 3px 3px 8px 8px; background: linear-gradient(var(--brass), #8E6520); box-shadow: 0 5px 0 var(--felt); }
.section-lede { max-width: 44rem; }
.suit-grid { display: grid; grid-template-columns: 1fr; gap: 1rem 1.6rem; }
@media (min-width: 62rem) { .suit-grid { grid-template-columns: repeat(3, 1fr); } }
.suit-h { margin: .8em 0 .6em; display: flex; flex-direction: column; }
.suit-name { font-size: 1.5rem; }
.suit-theme { font-family: var(--sans); font-weight: 400; font-size: 1.1rem; color: var(--ink-soft); }
.lesson-list { list-style: none; padding: 0; margin: 0; }
.lesson-list li { margin: 0 0 1rem; }
.lesson-card { display: flex; gap: .9rem; align-items: flex-start; background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: .8rem .9rem; box-shadow: 0 5px 0 var(--felt); text-decoration: none; color: var(--ink); }
.lesson-card:hover { background: #FFFFFF; border-color: var(--jade); }
.lesson-card svg { width: 46px; height: auto; flex: 0 0 auto; }
.lc-text { display: flex; flex-direction: column; }
.lc-title { color: var(--jade); font-weight: 700; text-decoration: underline; text-underline-offset: .15em; font-size: 1.2rem; }
.lc-desc { font-size: 1.05rem; color: var(--ink-soft); margin-top: .15rem; }
.practice-list { display: grid; grid-template-columns: 1fr; gap: 0 1.6rem; }
@media (min-width: 52rem) { .practice-list { grid-template-columns: 1fr 1fr; } }

/* ---- lessons ---- */
.crumb { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
.lesson-badge { display: flex; align-items: center; gap: .8rem; margin: .8rem 0 0; font-weight: 700; line-height: 1.35; }
.lesson-badge svg { width: 50px; height: auto; }
.lesson-badge .muted { font-weight: 400; }
.checked { color: var(--ink-soft); font-size: 1.05rem; margin-top: -.2rem; }
.prose ul, .prose ol { padding-left: 1.4em; }
figure.tiles { margin: 1.2rem 0 1.4rem; }
.tile-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; }
.tile-row svg.tile { width: 58px; height: auto; display: block; filter: drop-shadow(0 2px 1px rgba(29, 27, 22, .18)); }
figcaption { font-size: 1.05rem; color: var(--ink-soft); margin-top: .5rem; }
.house { background: var(--wash); border-left: 6px solid var(--brass); border-radius: 0 10px 10px 0; padding: .9rem 1.1rem .2rem; margin: 1.6rem 0; }
.house-label { font-weight: 700; color: var(--lacquer); margin-bottom: .3rem; }
table.counts { border-collapse: collapse; width: 100%; margin: 1rem 0 1.4rem; font-size: 1.1rem; background: var(--paper); }
table.counts caption { text-align: left; font-weight: 700; margin-bottom: .4rem; }
table.counts th, table.counts td { border: 1px solid var(--line); padding: .45rem .6rem; text-align: left; vertical-align: top; }
table.counts thead th { background: var(--wash); }
@media (max-width: 30rem) { table.counts { font-size: 1rem; } table.counts th, table.counts td { padding: .4rem .35rem; overflow-wrap: anywhere; } } /* 4 columns fit a phone */
.sources { border-top: 2px solid var(--line); margin-top: 2.5rem; }
.sources h2 { font-size: 1.35rem; }
.sources li { font-size: 1.1rem; }
.lesson-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; margin-top: 1rem; margin-bottom: 2.5rem; }
dl.glossary dt { font-weight: 700; font-family: var(--serif); font-size: 1.25rem; margin-top: 1rem; }
dl.glossary dd { margin: .15rem 0 0 0; }

/* ---- the tile chart ---- */
.chart { margin: 1rem 0 1.6rem; }
.chart-label { font-weight: 700; margin: 1rem 0 .4rem; }
.chart-row { list-style: none; padding: 0 !important; margin: 0; display: flex; flex-wrap: wrap; gap: .6rem .5rem; }
.chart-row li { width: 5.2rem; text-align: center; font-size: 1rem; line-height: 1.25; margin: 0; }
.chart-row svg { width: 54px; height: auto; display: block; margin: 0 auto .3rem; }

/* ---- the practice card: deliberately unlike a real card ---- */
.practice-card { background: var(--paper); border: 3px double var(--jade); border-radius: 12px; padding: .2rem 1rem .6rem; margin: 1.2rem 0 1.6rem; }
.pc-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .8rem; font-family: var(--serif); font-weight: 700; font-size: 1.4rem; margin: .7rem 0 .4rem; }
.pc-not { font-family: var(--sans); font-size: 1.05rem; color: var(--lacquer); border: 2px solid var(--lacquer); border-radius: 6px; padding: 0 .4rem; text-transform: uppercase; letter-spacing: .04em; }
.pc-hand { border-top: 1px solid var(--line); padding: .7rem 0 .3rem; }
.pc-name { margin: 0 0 .4rem; }
.pc-tag { display: inline-block; font-size: .98rem; background: var(--wash); border-radius: 6px; padding: 0 .45rem; margin-left: .3rem; }
.pc-tiles { display: flex; flex-wrap: wrap; gap: .45rem .9rem; margin-bottom: .4rem; }
.pc-group .tile-row { gap: 2px; }
.pc-group svg.tile, .pc-tiles svg.tile { width: 34px; }
.pc-text { font-size: 1.05rem; margin: 0 0 .3rem; }
.pc-foot { font-size: 1rem; color: var(--ink-soft); margin: .6rem 0 0; }
.pc-warning { background: var(--wash); border-left: 6px solid var(--lacquer); padding: .7rem 1rem; border-radius: 0 10px 10px 0; }

/* ---- tools ---- */
.tool-wrap { max-width: 60rem; }
.tool { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 1rem; margin: 1rem 0 1.5rem; box-shadow: 0 6px 0 var(--felt); }
.note { background: var(--wash); padding: .7rem 1rem; border-radius: 8px; }
.seg { border: 0; padding: 0; margin: 0 1.5rem .8rem 0; display: inline-flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.seg legend { font-weight: 700; padding: 0; margin-right: .6rem; float: left; }
.seg label, .field { display: inline-flex; align-items: center; gap: .4rem; min-height: 48px; font-weight: 700; }
.seg input { width: 1.3rem; height: 1.3rem; accent-color: var(--jade-btn); }
.field select { font: inherit; font-size: 1.1rem; min-height: 48px; padding: .3rem .5rem; border: 2px solid var(--jade); border-radius: 8px; background: #fff; color: var(--ink); }
.fc-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.fc-card { text-align: center; padding: .5rem 0 1rem; }
.fc-card svg.tile { width: 150px; height: auto; filter: drop-shadow(0 3px 2px rgba(29, 27, 22, .25)); }
.fc-name { font-family: var(--serif); font-size: 2rem; font-weight: 700; min-height: 2.6rem; margin: .6rem 0 .2rem; }
.fc-tip { max-width: 36rem; margin: 0 auto 1rem; }
.fc-options { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; max-width: 34rem; margin: 0 auto 1rem; }
.fc-options .btn { margin: 0; width: 100%; }
.fc-score { font-weight: 700; }
.ok { color: var(--jade); font-weight: 700; }
.no { color: var(--lacquer); font-weight: 700; }
.btn.is-right { background: var(--jade-btn); color: #fff; border-color: var(--jade-btn); }
.btn.is-wrong { background: #F6DEDA; color: var(--lacquer); border-color: var(--lacquer); }

.rackzone { background: var(--wash); border-radius: 12px; padding: .7rem .6rem .2rem; margin: .6rem 0 .3rem; }
.rackzone-label { font-weight: 700; margin: 0 0 .4rem; }
.rackrow { display: flex; flex-wrap: wrap; gap: 4px 3px; min-height: 70px; }
.tilebtn { background: none; border: 0; padding: 3px; border-radius: 8px; cursor: pointer; min-height: 48px; position: relative; }
.tilebtn svg.tile { width: 50px; height: auto; display: block; transition: transform .08s; }
.tilebtn[aria-pressed="true"] { outline: 4px solid var(--lacquer); outline-offset: 1px; background: #F6DEDA; }
.tilebtn[aria-pressed="true"] svg { transform: translateY(-6px); }
.tilebtn.fits::after { content: ""; position: absolute; left: 9px; right: 9px; bottom: -3px; height: 5px; border-radius: 3px; background: var(--indigo); }
.tilebtn.is-new { outline: 3px dashed var(--indigo); outline-offset: 1px; }
.tilebtn:disabled { cursor: default; }
.ledge-sm { height: 10px; background: linear-gradient(var(--brass), #8E6520); border-radius: 2px 2px 6px 6px; margin: 4px 0 .6rem; }
.exposed { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: .3rem; }
.exposed .tile-row svg.tile { width: 40px; }
.status { font-size: 1.2rem; font-weight: 700; margin: .4rem 0 .6rem; }
.explain { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .7rem 1rem .2rem; margin: .8rem 0; }
.explain h3 { margin-top: .3rem; font-size: 1.2rem; }
.explain li { margin-bottom: .5rem; }
.mini svg.tile { width: 34px; vertical-align: middle; display: inline-block; margin: 0 2px; }
.hands-table { width: 100%; border-collapse: collapse; font-size: 1.05rem; margin: .5rem 0 1rem; }
.hands-table th, .hands-table td { border-bottom: 1px solid var(--line); padding: .35rem .4rem; text-align: left; }
.hands-table tr.best td { background: #E6F0EA; font-weight: 700; }
.discards { display: flex; flex-wrap: wrap; gap: 3px; }
.discards svg.tile { width: 30px; }
.actions { display: flex; flex-wrap: wrap; gap: .2rem; margin: .4rem 0; }
.toggle { display: inline-flex; align-items: center; gap: .5rem; min-height: 48px; font-weight: 700; }
.toggle input { width: 1.3rem; height: 1.3rem; accent-color: var(--jade-btn); }

.quiz-list { padding-left: 0 !important; list-style: none; }
.quiz-q { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem .4rem; margin: 0 0 1rem; }
.quiz-num { font-weight: 700; font-family: var(--serif); }
.quiz-q .tile-row { margin: .2rem 0 .8rem; }
.quiz-options { display: flex; flex-wrap: wrap; }
.quiz-reveal summary { cursor: pointer; color: var(--jade); text-decoration: underline; font-weight: 700; min-height: 48px; display: flex; align-items: center; }
.quiz-feedback { margin-top: .2rem; }
.quiz-score { font-size: 1.35rem; font-weight: 700; font-family: var(--serif); }

.cheat { display: grid; grid-template-columns: 1fr; gap: 0 1.6rem; }
@media (min-width: 46rem) { .cheat { grid-template-columns: 1fr 1fr; } }
.cheat section { break-inside: avoid; }
.cheat h2 { font-size: 1.3rem; margin: 1rem 0 .3rem; border-bottom: 3px solid var(--brass); padding-bottom: .15rem; }
.cheat ul { padding-left: 1.1em; }
.affiliate { background: var(--wash); padding: .5rem .9rem; border-radius: 8px; }
.aff-note { font-size: 1rem; }
.nf { text-align: left; padding: 2rem 1rem 3rem; }
.nf .tile-row svg { width: 70px; }
.print-url { display: none; }

/* ---- footer ---- */
.site-footer { background: var(--felt); color: #F4EEDD; margin-top: 3rem; padding: 2rem 0 1.5rem; border-top: 12px solid var(--brass); }
.site-footer a { color: #FFFCF3; }
.foot-cols { display: grid; grid-template-columns: 1fr; gap: .5rem 2rem; font-size: 1.05rem; }
@media (min-width: 56rem) { .foot-cols { grid-template-columns: 1.3fr 1fr 1fr 1fr 1fr; } }
.foot-brand { font-family: var(--serif); font-weight: 700; font-size: 1.4rem; margin-bottom: .3rem; }
.foot-h { font-family: var(--sans); font-size: 1.05rem; color: #F3D27A; margin: .6rem 0 .3rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0 0 .6rem; }
.site-footer li { margin: 0; }
.site-footer li a { display: inline-block; padding: .3rem 0; }
.copyright { grid-column: 1 / -1; border-top: 1px solid #3F6B57; padding-top: 1rem; margin-top: .6rem; }

@media (max-width: 40rem) {
  h1, .hero h1 { font-size: 2rem; }
  h2 { font-size: 1.45rem; }
  .brand-name { font-size: 1.4rem; }
  .tile-row svg.tile { width: 46px; }
  .tilebtn svg.tile { width: 42px; }
  .fc-options { grid-template-columns: 1fr; }
  .lede { font-size: 1.25rem; }
  .rack-tiles svg:nth-child(n+7) { display: none; }
  .rack { max-width: 24rem; }
}

.print-ref, .print-links { display: none; }

/* ---- Print: the site's green and gold on white, big type, the brand at the top, lines no longer
   than on screen, outside web addresses listed at the end (print-links.js), no filled bands ---- */
@page { size: letter portrait; margin: .6in .65in .7in;
  @bottom-left { content: "newtomahj.com"; font: 9pt "Atkinson Hyperlegible", Verdana, sans-serif; color: #555; }
  @bottom-right { content: "Page " counter(page) " of " counter(pages); font: 9pt "Atkinson Hyperlegible", Verdana, sans-serif; color: #555; } }
/* The cheat sheet is one page of its own, with no page numbers. */
@page cheat { margin: .4in .55in .3in; @bottom-left { content: none; } @bottom-right { content: none; } }
@media print {
  html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; color: #000; font-size: 15pt; line-height: 1.5; }
  .site-footer, .nav, .ledge, .crumb, .lesson-nav, .hero-actions, .btn, .skip, .tool-wrap, .print-btn-wrap, .rack,
  .adsbygoogle, .ad-slot, .quiz-options, .quiz-feedback, .quiz-score, .quiz-again, .lesson-badge, noscript { display: none !important; }
  .site-header { background: none; color: var(--felt); border-bottom: 2.5pt solid var(--felt); margin-bottom: 14pt; }
  .site-header::after { content: ""; display: block; height: 1.5pt; background: var(--brass); margin-top: 2pt; }
  .head-row { display: block; padding: 0 0 4pt; }
  .brand { color: var(--felt); min-height: 0; gap: 8pt; }
  .brand-tiles { gap: 3pt; }
  .brand-tiles svg { width: 22pt; }
  .brand-name { font-size: 17pt; }
  a { color: inherit; text-decoration: none; }
  .print-ref { display: inline; font: 700 9pt/1 var(--sans); color: var(--lacquer); margin-left: 1pt; vertical-align: super; }
  .print-links { display: block; margin-top: 20pt; padding-top: 6pt; border-top: 1pt solid var(--line); font: 11pt/1.35 var(--sans); max-width: 6.4in; break-inside: avoid; }
  .print-links h2 { font: 700 12pt var(--sans); margin: 0 0 4pt; border: 0; padding: 0; }
  .print-links ol { margin: 0; padding-left: 2.2em; }
  .print-links li { margin: 0 0 2pt; overflow-wrap: anywhere; }
  .wrap, .narrow { max-width: 6.6in; margin: 0; padding: 0; }
  h1 { font-size: 28pt; margin: 0 0 8pt; }
  h2 { font-size: 20pt; margin: 18pt 0 6pt; }
  h3 { font-size: 16pt; margin: 14pt 0 4pt; }
  .lede { font-size: 16pt; }
  .checked, .small, figcaption { font-size: 11.5pt; }
  h2, h3 { break-after: avoid; }
  p, li { orphans: 3; widows: 3; }
  .house, .pc-warning, .note, .affiliate { background: none; border-left: 4pt solid var(--brass); border-radius: 0; padding-top: 2pt; padding-bottom: 0; }
  .house-label { color: var(--lacquer); }
  .lesson-card, .tool, .quiz-q, .practice-card, table.counts { box-shadow: none; background: #fff; border-color: var(--line); }
  table.counts th { background: none; border-bottom: 2pt solid var(--felt); }
  /* Tile pictures are vector drawings: they print at full sharpness, and never split across a page. */
  .tile-row svg.tile, .chart-row svg { filter: none; }
  svg, figure.tiles, .tile-row, .chart-group, .pc-hand, .quiz-q, table, li { break-inside: avoid; }
  figure.tiles { margin: 10pt 0 12pt; }
  figure.tiles figcaption { break-before: avoid; }
  .tile-row svg.tile { width: .62in; }
  .print-url { display: block; margin-top: 18pt; font-size: 11pt; color: #555; }

  /* The cheat sheet: one letter page, in large type, in two columns. */
  body.cheat-print { page: cheat; }
  .cheat-page { max-width: none; }
  .cheat-page .no-print, .cheat-page .sources { display: none !important; }
  body.cheat-print .print-url { position: fixed; left: 0; bottom: 0; margin: 0; font-size: 10.5pt; }
  .cheat-page h1 { font-size: 19pt; margin: 0 0 1pt; white-space: nowrap; }
  body.cheat-print .site-header { margin-bottom: 8pt; }
  .cheat-page .checked { font-size: 11pt; margin: 0 0 6pt; }
  .cheat { display: block; columns: 2; column-gap: .35in; column-rule: 1pt solid var(--brass); font-size: var(--cheat-pt, 12.4pt); line-height: 1.22; column-fill: balance; height: var(--cheat-h, 8.95in); }
  .cheat section { break-inside: avoid; margin: 0 0 8pt; }
  .cheat h2 { font-size: 1.22em; margin: 0 0 3pt; color: var(--felt); border-bottom: 1.5pt solid var(--brass); padding-bottom: 1pt; }
  .cheat ul { margin: 0; padding-left: 1.15em; }
  .cheat li { margin-bottom: 2.5pt; }
}
