/* Layout: one reading column (max 46rem) inside a felt-green header band; tools sit on ivory "tile" cards. */
:root {
  --paper: #f6f2e7;
  --card: #fffdf7;
  --ink: #1d2721;
  --muted: #56645b;
  --line: #ddd5c1;
  --felt: #1e5a42;
  --felt-deep: #143f2e;
  --felt-ink: #f4efe2;
  --accent: #1e5a42;
  --accent-ink: #ffffff;
  --crak: #a8241c;
  --good: #1f7a46;
  --bad: #a8241c;
  --good-bg: #e3f2e8;
  --bad-bg: #f8e3df;
  --sel: #f2c14e;
  /* Tile colours stay the same in both themes: tiles are physical objects. */
  --tile-face: #fffaf0;
  --tile-edge: #e7dfcb;
  --tile-back: #2f7a5a;
  --t-red: #b3261e;
  --t-green: #1d7a45;
  --t-blue: #1f4e8c;
  --t-ink: #1d2a3a;
  --t-pink: #d1567a;
  --t-gold: #e0a526;

  --f-display: "Young Serif", Georgia, "Times New Roman", serif;
  --f-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-cjk: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f241b; --card: #163126; --ink: #efe9da; --muted: #a8b8ad; --line: #2b4a3c;
    --felt: #0b1d15; --felt-deep: #08150f; --felt-ink: #efe9da;
    --accent: #7fc7a0; --accent-ink: #0b1d15; --crak: #ec8077;
    --good: #7fd19e; --bad: #f08a80; --good-bg: #173d29; --bad-bg: #432019;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f241b; --card: #163126; --ink: #efe9da; --muted: #a8b8ad; --line: #2b4a3c;
  --felt: #0b1d15; --felt-deep: #08150f; --felt-ink: #efe9da;
  --accent: #7fc7a0; --accent-ink: #0b1d15; --crak: #ec8077;
  --good: #7fd19e; --bad: #f08a80; --good-bg: #173d29; --bad-bg: #432019;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 1.125rem;
  line-height: 1.6;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--felt); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--sel); outline-offset: 2px; border-radius: 4px; }
img, svg { max-width: 100%; }

.wrap {
  max-width: 62rem; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.read { max-width: 44rem; }

/* Header */
.site-head { background: var(--felt); color: var(--felt-ink); position: relative; z-index: 5; box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.site-head .wrap { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--felt-ink); text-decoration: none; font-family: var(--f-display); font-size: 1.3rem; }
.brand .mini { display: flex; gap: 2px; }
.brand .mini svg { width: 18px; height: 24px; }
.nav { display: flex; gap: 4px 16px; flex-wrap: wrap; margin-left: auto; font-size: 1rem; }
@media (min-width: 761px) { .site-head { position: sticky; top: env(safe-area-inset-top, 0px); } }
@media (max-width: 760px) {
  .nav { flex-wrap: nowrap; overflow-x: auto; margin-left: 0; width: 100%; scrollbar-width: none; gap: 18px; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }
}
.nav a { color: var(--felt-ink); text-decoration: none; padding: 4px 2px; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a[aria-current="page"] { border-bottom-color: var(--sel); }

/* Type */
h1, h2, h3 { font-family: var(--f-display); font-weight: 400; line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.75rem); }
h2 { font-size: clamp(1.45rem, 3vw, 1.85rem); }
h3 { font-size: 1.25rem; }
p { margin: 0; }
.lede { font-size: 1.25rem; color: var(--muted); max-width: 40rem; }
.eyebrow { font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.small { font-size: .95rem; color: var(--muted); }

main { padding-block: 28px 56px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 40px; }
.prose { display: flex; flex-direction: column; gap: 14px; }
.prose h2 { margin-top: 20px; }
.prose h3 { margin-top: 8px; }
.prose ul, .prose ol { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }

/* Tile-style buttons: ivory face with a green underside, like a real tile. */
.btn {
  appearance: none; font: inherit; font-weight: 700; cursor: pointer;
  background: var(--tile-face); color: var(--t-ink);
  border: 1px solid var(--tile-edge); border-radius: 9px;
  box-shadow: 0 4px 0 var(--tile-back), 0 6px 10px rgba(0,0,0,.12);
  padding: 10px 18px; min-height: 48px; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--tile-back), 0 8px 14px rgba(0,0,0,.14); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--tile-back), 0 2px 4px rgba(0,0,0,.12); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--felt); color: #fff; border-color: var(--felt-deep); box-shadow: 0 4px 0 var(--felt-deep), 0 6px 10px rgba(0,0,0,.18); }
:root[data-theme="dark"] .btn.primary { background: #2f7a5a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { background: #2f7a5a; } }
.btn-row { display: flex; flex-wrap: wrap; gap: 14px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 18px; }
.tool { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; transition: border-color .15s, transform .15s; }
.tool:hover { border-color: var(--accent); transform: translateY(-2px); }
.tool .tiles-row svg { width: 30px; height: 40px; }
.tool .go { margin-top: auto; color: var(--accent); font-weight: 700; }
.tag { display: inline-block; font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--good-bg); color: var(--good); }
.tag.soon { background: var(--line); color: var(--muted); }

/* Felt play area */
.felt {
  background: radial-gradient(ellipse at 50% 30%, #2a7556 0%, #1e5a42 60%, #164433 100%);
  border-radius: 16px; padding: 22px; color: #f4efe2;
  box-shadow: inset 0 0 0 6px #6b4a2b, inset 0 0 0 8px #8a6440, 0 10px 24px rgba(0,0,0,.18);
}
.felt .small, .felt .eyebrow { color: #cfe3d6; }
.tiles-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tile { display: inline-block; line-height: 0; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.tile svg { display: block; }
button.tile { appearance: none; background: none; border: 0; padding: 0; cursor: pointer; border-radius: 8px; transition: transform .12s; }
button.tile:hover { transform: translateY(-3px); }
button.tile[aria-pressed="true"] { transform: translateY(-10px); }
button.tile[aria-pressed="true"] svg { outline: 3px solid var(--sel); outline-offset: 1px; border-radius: 8px; }
button.tile[disabled] { cursor: not-allowed; }
button.tile.new svg { outline: 2px dashed #f2c14e; outline-offset: 1px; border-radius: 8px; }

/* Quiz */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: 14px; }
.choice { justify-content: flex-start; text-align: left; }
.choice.right { background: var(--good-bg); color: var(--good); border-color: var(--good); }
.choice.wrong { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.feedback { border-radius: var(--radius); padding: 14px 16px; }
.feedback.ok { background: var(--good-bg); color: var(--ink); border-left: 5px solid var(--good); }
.feedback.no { background: var(--bad-bg); color: var(--ink); border-left: 5px solid var(--bad); }
.scorebar { display: flex; gap: 10px 22px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.scorebar b { font-size: 1.3rem; }
.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.seg button { font: inherit; font-size: 1rem; padding: 8px 14px; min-height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--felt); color: #fff; border-color: var(--felt); }

/* Slots */
.slot { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.signup { display: flex; flex-wrap: wrap; gap: 10px; }
.signup input { font: inherit; padding: 10px 12px; min-height: 48px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); flex: 1 1 14rem; min-width: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 1rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 700; }

/* Glossary */
.prose dl { margin: 0; display: grid; gap: 4px 0; }
.prose dt { font-weight: 700; margin-top: 12px; scroll-margin-top: 80px; }
.prose dd { margin: 0 0 0 0; color: var(--ink); }

/* Footer */
.site-foot { border-top: 1px solid var(--line); padding-block: 26px 40px; color: var(--muted); font-size: .95rem; }
.site-foot .wrap { display: flex; flex-direction: column; gap: 10px; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-foot a { color: var(--muted); }

.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; align-items: center; }
.hero > * { min-width: 0; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } }

/* Charleston diagram */
.table-diagram { width: 100%; max-width: 360px; aspect-ratio: 1; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media print {
  .site-head, .site-foot, .no-print, .slot { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card { border: 1px solid #999; break-inside: avoid; }
  main { padding: 0; }
}
