:root {
  --felt: #1d4a3e;
  --felt-deep: #11312a;
  --felt-hi: #2b6552;
  --on-felt: #f3ecd8;
  --on-felt-muted: #b7cbbd;

  --bone: #fbf6ea;
  --bone-shade: #e7dcc1;
  --tile-back: #2f8063;
  --tile-back-deep: #1d5a43;

  --bamboo-hi: #f0d48e;
  --bamboo: #d1a352;
  --bamboo-deep: #94661f;

  --paper: #fdfdf9;
  --paper-line: #e3e0d4;
  --ink: #1d2540;
  --ink-muted: #5b6275;
  --ink-green: #1f8a3b;
  --ink-red: #c8322b;

  --gold: #e3b74e;

  --tw: 60px;
  --radius: 10px;
  --font: "Jost", "Futura", "Avenir Next", system-ui, sans-serif;
  --display: "Shippori Mincho B1", "Hiragino Mincho ProN", Georgia, serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  color: var(--on-felt);
  background-color: var(--felt);
  background-image:
    radial-gradient(ellipse at 50% 20%, rgba(255, 255, 255, .07), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, .35), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed;
  min-height: 100vh;
}

button { font: inherit; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

/* ------------------------------------------------------------ masthead */
.masthead {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 4px;
}

.sprig { width: 44px; height: 66px; flex: none; }

h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.1rem, 4vw, 2.9rem);
  line-height: 1;
  margin: 0;
  letter-spacing: .01em;
  color: var(--bone);
}

.tagline { margin: 6px 0 0; color: var(--on-felt-muted); }

/* ------------------------------------------------------------ tiles */
.tile {
  --w: var(--tw);
  display: inline-block;
  width: var(--w);
  aspect-ratio: 42 / 56;
  padding: 0;
  border: 0;
  border-radius: calc(var(--w) * .13);
  background: linear-gradient(170deg, #fffdf6 0%, var(--bone) 55%, var(--bone-shade) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(120, 100, 60, .18),
    0 calc(var(--w) * .07) 0 0 var(--tile-back),
    0 calc(var(--w) * .1) 0 0 var(--tile-back-deep),
    0 calc(var(--w) * .14) calc(var(--w) * .16) rgba(0, 0, 0, .35);
  vertical-align: top;
  flex: none;
}

.tile svg { display: block; width: 100%; height: 100%; }

.tile .ix { font: 700 10.5px var(--font); }
.tile .cn {
  font-family: "Hiragino Mincho ProN", "Songti SC", "Noto Serif SC", "Noto Serif CJK SC", serif;
  font-weight: 700;
  text-anchor: middle;
}
.tile .jk { font: 700 8.6px var(--font); text-anchor: middle; letter-spacing: .02em; }

button.tile { cursor: pointer; transition: transform .12s ease; }
button.tile:hover:not(:disabled) { transform: translateY(-4px); }
button.tile:disabled { cursor: not-allowed; opacity: .35; }

/* ------------------------------------------------------------ rack */
.table {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 24px 8px;
}

.rack-wrap { position: relative; padding: 0 10px; }

.rack-tiles {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: flex-end;
  min-height: calc(var(--tw) * 1.42);
  padding: 0 18px;
  position: relative;
  z-index: 1;
}

.rack-tiles.is-picking .tile { cursor: pointer; }
.rack-tiles.is-picking .tile:hover { transform: translateY(-6px); filter: brightness(.94); }

.rack-empty { align-self: center; color: var(--on-felt-muted); margin: 0; }

/* A bamboo stalk the tiles stand on. */
.rack-bar {
  height: 30px;
  margin-top: -2px;
  border-radius: 15px;
  background:
    repeating-linear-gradient(90deg,
      transparent 0 150px,
      rgba(90, 55, 10, .55) 150px 152px,
      rgba(255, 240, 200, .65) 152px 154px,
      rgba(90, 55, 10, .3) 154px 156px,
      transparent 156px 220px),
    linear-gradient(180deg, var(--bamboo-hi) 0%, var(--bamboo) 38%, var(--bamboo-deep) 100%);
  box-shadow: 0 10px 18px rgba(0, 0, 0, .35), inset 0 2px 0 rgba(255, 255, 255, .35);
}

.rack-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  justify-content: center;
}

.rack-count { color: var(--on-felt-muted); font-size: .95rem; }

.btn {
  border: 1.5px solid rgba(243, 236, 216, .55);
  background: transparent;
  color: var(--on-felt);
  padding: 9px 18px;
  border-radius: 999px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: rgba(255, 255, 255, .08); }

.btn-primary {
  background: linear-gradient(180deg, var(--bamboo-hi), var(--bamboo));
  color: #3a2508;
  border-color: var(--bamboo-deep);
  font-weight: 600;
}
.btn-primary:hover { background: linear-gradient(180deg, #f6dda0, #d8ad60); }

.btn-small { padding: 5px 14px; font-size: .9rem; }

/* ------------------------------------------------------------ picker */
.picker {
  margin: 20px auto 0;
  max-width: 900px;
  padding: 16px 18px 18px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, .22);
  border: 1px solid rgba(255, 255, 255, .08);
}
.picker-help { margin: 0 0 12px; color: var(--on-felt-muted); }

.palette-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.palette-label { color: var(--on-felt-muted); font-size: .92rem; }
.palette-tiles { display: flex; flex-wrap: wrap; gap: 6px; --tw: 38px; padding-bottom: 4px; }
.palette-tiles .tile { --w: 38px; }

/* ------------------------------------------------------------ board */
.board {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 28px;
  align-items: start;
}

h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  margin: 0 0 6px;
  line-height: 1.2;
}

.picks > h2 { color: var(--bone); }
.behind-h { margin-top: 30px !important; }
.how { margin: 0 0 16px; max-width: 64ch; font-size: .95rem; }
.on-felt { color: var(--on-felt-muted); }
.quiet { color: var(--ink-muted); font-size: .93rem; }
.quiet.on-felt { color: var(--on-felt-muted); }

/* Paper panels look like the laminated card. */
.paper,
.slip,
.paper-list {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 12px 28px rgba(0, 0, 0, .28);
}

.paper { padding: 18px 20px; }
.side { display: grid; gap: 22px; }
.side h2 { color: var(--ink); }

.ink-green { color: var(--ink-green); }
.ink-red { color: var(--ink-red); }
.ink-black { color: var(--ink); }

/* ------------------------------------------------------------ result slips */
.slip { padding: 20px 22px 18px; margin-bottom: 18px; }

.slip-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.rank {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--bone);
  background: var(--felt);
  box-shadow: inset 0 0 0 2px var(--bamboo);
}

.line {
  font-weight: 700;
  letter-spacing: .01em;
  word-spacing: .18em;
}
.line.big { font-size: 1.55rem; line-height: 1.2; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 6px 0 0;
  font-size: .92rem;
  color: var(--ink-muted);
}
.section-name { font-weight: 600; color: var(--ink); }
.value { font-weight: 700; color: var(--ink); white-space: nowrap; }
.version { font-style: italic; }

.away {
  white-space: nowrap;
  font-weight: 700;
  font-size: .95rem;
  padding: 4px 12px;
  border-radius: 999px;
}
.away-win { background: var(--gold); color: #3a2508; }
.away-near { background: #d8efe0; color: #11603a; }
.away-mid { background: #f6ebcd; color: #7a5410; }
.away-far { background: #ececec; color: #5d5d5d; }

.overlay {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 12px;
  margin: 18px 0 14px;
  padding: 16px 14px 18px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--felt-hi), var(--felt));
  --tw: 40px;
}
.blk { display: inline-flex; gap: 3px; }

.tile.is-need {
  opacity: .38;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .9);
  filter: grayscale(.35);
  outline: 1.5px dashed rgba(255, 255, 255, .75);
  outline-offset: 2px;
}
.tile.is-joker { box-shadow: inset 0 0 0 2px var(--gold), 0 calc(var(--w) * .07) 0 0 var(--tile-back), 0 calc(var(--w) * .1) 0 0 var(--tile-back-deep); }

.why,
.needs { list-style: none; padding: 0; margin: 0; }
.why li { padding: 3px 0 3px 18px; position: relative; }
.why li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: .72em;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--bamboo);
  transform: rotate(45deg);
}

.still { margin: 12px 0 6px; font-weight: 600; }
.needs li.need {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 6px 0;
  border-top: 1px solid var(--paper-line);
}
.tile.mini { --w: 30px; }

/* ------------------------------------------------------------ rows (whole card, close behind) */
.paper-list { padding: 6px 18px; }

.row { border-top: 1px solid var(--paper-line); }
.paper-list .row:first-child,
.card-section h3 + .row { border-top: 0; }

.row summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  cursor: pointer;
  list-style: none;
}
.row summary::-webkit-details-marker { display: none; }
.row summary .line { font-size: 1.02rem; }
.row summary .away { font-size: .82rem; padding: 2px 10px; }
.row summary .value { font-size: .85rem; color: var(--ink-muted); }
.row[open] summary { border-bottom: 1px dashed var(--paper-line); }
.row-body { padding: 4px 0 14px; }
.row-body .overlay { --tw: 26px; gap: 10px 8px; padding: 12px 10px 14px; }
.row-body .why { font-size: .93rem; }
.row-body .needs { font-size: .9rem; }
.row-body .tile.mini { --w: 24px; }

.card-section h3 {
  font-family: var(--font);
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .06em;
  text-align: center;
  margin: 18px 0 2px;
  color: var(--ink);
}
.card-section:first-child h3 { margin-top: 6px; }

.whole .row summary .line { font-size: .95rem; }

/* ------------------------------------------------------------ charleston */
.charleston p { margin: 6px 0 10px; }
.tile-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; --tw: 34px; }

/* ------------------------------------------------------------ smaller screens */
@media (max-width: 1040px) {
  .board { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  :root { --tw: calc((100vw - 48px - 12 * 3px) / 13.4); }
  .masthead, .table, .board { padding-left: 16px; padding-right: 16px; }
  .rack-wrap { padding: 0; }
  .rack-tiles { gap: 3px; padding: 0 4px; }
  .rack-bar { height: 20px; }
  .line.big { font-size: 1.2rem; }
  .slip { padding: 16px 14px; }
  .slip-head { grid-template-columns: auto minmax(0, 1fr); }
  .slip-head .away { grid-column: 2; justify-self: start; }
  .overlay { --tw: 30px; gap: 10px 8px; }
  .palette-row { grid-template-columns: 1fr; gap: 4px; }
  .palette-tiles .tile { --w: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  button.tile { transition: none; }
}

/* ------------------------------------------------------------ page switcher */
.pages {
  margin-left: auto;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .22);
  align-self: center;
}
.pages a {
  color: var(--on-felt-muted);
  text-decoration: none;
  padding: 7px 16px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
}
.pages a:hover { color: var(--on-felt); }
.pages a[aria-current="page"] {
  background: linear-gradient(180deg, var(--bamboo-hi), var(--bamboo));
  color: #3a2508;
  font-weight: 600;
}

/* ------------------------------------------------------------ cheat sheet */
.rules { padding: 4px 20px; }

.rule { border-top: 1px solid var(--paper-line); }
.rule:first-child { border-top: 0; }

.rule > summary {
  display: grid;
  gap: 6px;
  padding: 16px 0;
  cursor: pointer;
  list-style: none;
}
.rule > summary::-webkit-details-marker { display: none; }

.rule-sec {
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink);
}
.rule-text { color: var(--ink-muted); }
.rule.is-pointed .rule-text { color: var(--ink); font-weight: 500; }
.fit { text-align: right; font-weight: 600; font-size: .92rem; color: var(--ink-muted); }
.rule.is-pointed .fit { color: #11603a; }

.rule-body { padding: 2px 0 18px; }
.rule-body .tile-row { margin: 4px 0 10px; }
.rule-note { margin: 0 0 4px; }

.paper-list.nested {
  padding: 0 12px;
  box-shadow: none;
  border: 1px solid var(--paper-line);
  border-radius: 8px;
}

.pointed { margin: 4px 0 10px; }
.verdict-call {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0 0 4px;
}
.verdict-call.is-hit { color: #11603a; }
.verdict-call.is-miss { color: #8a5a10; }

@media (max-width: 760px) {
  .masthead { flex-wrap: wrap; }
  .pages { margin-left: 0; width: 100%; justify-content: center; }
  .rules { padding: 4px 14px; }
  .rule-plain > summary { grid-template-columns: minmax(0, 1fr) auto; }
  .rule-plain .rule-say { grid-column: 1 / -1; grid-row: 2; }
}

/* ------------------------------------------------------------ drill */
.drill {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 24px 64px;
}

.drill-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.pips { display: flex; gap: 6px; }
.pips i {
  width: 14px;
  height: 19px;
  border-radius: 3px;
  background: rgba(0, 0, 0, .25);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}
.pips i.is-now { box-shadow: inset 0 0 0 2px var(--bamboo); }
.pips i.is-right { background: linear-gradient(180deg, #5cbf8a, #2f8063); }
.pips i.is-wrong { background: linear-gradient(180deg, #e0846f, #b8442c); }

.drill-table { padding: 18px 0 0; }

/* Family colors: a bar under each tile. */
.tile[class*="fam-"] { position: relative; }
.tile[class*="fam-"]::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  top: calc(var(--w) * -.2);
  height: 5px;
  border-radius: 3px;
}
.fam-even::after, .sw.fam-even { background: #5fc3d6; }
.fam-odd::after, .sw.fam-odd { background: #e48bb4; }
.fam-honor::after, .sw.fam-honor { background: var(--gold); }
.fam-flower::after, .sw.fam-flower { background: #b48ee0; }

.drill .rack-tiles { padding-top: 14px; }
.drill .rack-tiles .tile { transition: transform .2s ease, opacity .2s ease; }
.rack-tiles.is-revealed .tile:not(.is-tell) { opacity: .4; }
.rack-tiles.is-revealed .tile.is-tell { transform: translateY(-10px); }

.legend {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px 8px;
  flex-wrap: wrap;
  margin: 16px 0 0;
  color: var(--on-felt-muted);
  font-size: .9rem;
}
.legend[hidden] { display: none; }
.sw { display: inline-block; width: 18px; height: 5px; border-radius: 3px; margin-left: 10px; }

.prompt {
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--bone);
  margin: 26px 0 14px;
}
.prompt[hidden] { display: none; }

.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}
.prompt:not([hidden]) + .choices { margin-top: 0; }

.choice {
  position: relative;
  padding: 16px 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--paper-line), 0 10px 18px rgba(0, 0, 0, .22);
  transition: transform .1s ease;
}
.choice:hover:not(:disabled) { transform: translateY(-2px); }
.choice:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--paper-line); }
.choice:disabled { cursor: default; opacity: .55; }
.choice .key {
  position: absolute;
  left: 10px;
  top: 8px;
  font-size: .75rem;
  font-weight: 500;
  color: var(--ink-muted);
}
.choice.is-answer { opacity: 1; box-shadow: inset 0 0 0 3px #2f8063, 0 4px 0 #1d5a43; }
.choice.is-good { opacity: 1; box-shadow: inset 0 0 0 2px #7cc59c; }
.choice.is-wrong { opacity: 1; box-shadow: inset 0 0 0 3px #b8442c; }

.feedback { margin-top: 22px; }
.feedback p { margin: 4px 0 8px; }
.feedback .btn-primary { margin-top: 16px; }
.tip {
  padding: 10px 14px;
  border-radius: 8px;
  background: #f6ebcd;
  color: #5a3d08;
}
.summary {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--paper-line);
}

.drill-lower {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-top: 30px;
  align-items: start;
}
.drill-lower h2 { color: var(--ink); }
.pref-label { margin: 12px 0 6px; font-weight: 600; }

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: #efece2;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 500;
}
.seg button[aria-pressed="true"] { background: var(--felt); color: var(--bone); }

.section-stats { list-style: none; padding: 0; margin: 10px 0 0; font-size: .92rem; }
.section-stats li {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 4px 0;
}
.section-stats .bar { height: 8px; border-radius: 4px; background: var(--paper-line); overflow: hidden; }
.section-stats .bar i { display: block; height: 100%; background: linear-gradient(90deg, #4fa77a, var(--tile-back)); }

.btn-link {
  margin-top: 12px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink-muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: .9rem;
}

@media (max-width: 760px) {
  .drill { padding-left: 16px; padding-right: 16px; }
  .choice { padding: 14px 8px; font-size: .92rem; }
  .choice .key { display: none; }
  .drill-lower { grid-template-columns: 1fr; }
  .section-stats li { grid-template-columns: 110px 1fr auto; }
  .seg button { padding: 6px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .drill .rack-tiles .tile, .choice { transition: none; }
}

/* ------------------------------------------------------------ card on the drill page */
.drill:has(.card-ref) {
  max-width: 1280px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 26px;
  align-items: start;
}
.drill .rack-tiles { --tw: 54px; }

.card-ref {
  position: sticky;
  top: 16px;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .28);
}

.card-ref summary {
  padding: 14px 18px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-ref summary::-webkit-details-marker { display: none; }
.card-ref summary::after {
  content: "Hide";
  font-family: var(--font);
  font-weight: 500;
  font-size: .85rem;
  color: var(--ink-muted);
}
.card-ref details:not([open]) summary::after { content: "Show"; }

.card-help { margin: -6px 18px 8px; font-size: .85rem; color: var(--ink-muted); }

.card-sheet {
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 0 14px 14px;
  border-top: 1px solid var(--paper-line);
}

.card-sec {
  margin-top: 14px;
  padding: 0 6px 6px;
  border-radius: 8px;
  transition: background-color .2s ease, box-shadow .2s ease;
}
.card-sec ul { list-style: none; margin: 0; padding: 0; }
/* Section names are bands, like the printed card, and stay pinned while you scroll
   through their section. */
.card-sec h3 {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 0 4px;
  padding-top: 6px;
  background: inherit;
}
.card-sec-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
  border: 0;
  padding: 7px 12px;
  border-radius: 6px;
  background: var(--felt);
  box-shadow: inset 0 -2px 0 var(--bamboo);
  font: 700 .9rem var(--font);
  letter-spacing: .06em;
  color: var(--bone);
  text-align: left;
  cursor: pointer;
}
.card-sec-count { font-weight: 500; font-size: .75rem; letter-spacing: 0; color: var(--on-felt-muted); }
.card-sec-h:hover:not(:disabled) { background: var(--felt-hi); }
.card-sec-h:disabled { cursor: default; }

.card-sec.is-peek { background: #f3f0e4; }
.card-sec.is-answer { background: #e3f3e9; box-shadow: inset 0 0 0 2px #2f8063; }
.card-sec.is-answer .card-sec-h { background: #2f8063; }
.card-sec.is-wrong { background: #fbeae5; box-shadow: inset 0 0 0 2px #b8442c; }
.card-sec.is-wrong .card-sec-h { background: #b8442c; box-shadow: none; }
.card-sec.is-wrong .card-sec-count { color: #f6d9d1; }

.card-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 8px;
  padding: 5px 4px;
  border-top: 1px solid var(--paper-line);
  font-size: .86rem;
}
.card-sec h3 + ul .card-line:first-child { border-top: 0; }
.card-line .line { font-size: .92rem; word-spacing: .12em; }
.card-line .or { font-weight: 400; color: var(--ink-muted); font-size: .8rem; }
.card-line .value { font-size: .8rem; }
.card-rule { grid-column: 1; color: var(--ink-muted); font-size: .78rem; line-height: 1.3; }
.card-away { grid-column: 2; justify-self: end; }
.card-away .away { font-size: .72rem; padding: 1px 8px; }
.card-line.is-closest { background: #fff6dc; border-radius: 6px; box-shadow: inset 3px 0 0 var(--gold); }

@media (max-width: 1100px) {
  .drill:has(.card-ref) { grid-template-columns: 1fr; max-width: 980px; }
  /* Let the card sit right under the section buttons. */
  .drill-main { display: contents; }
  .drill-bar { order: 1; }
  .drill-table { order: 2; }
  .prompt { order: 3; }
  .choices { order: 4; }
  .guide { order: 3; }
  .card-ref { order: 5; position: static; }
  .feedback { order: 6; }
  .drill-lower { order: 7; margin-top: 0; }
  .card-sheet { max-height: 60vh; }
  .drill .rack-tiles { --tw: 60px; }
}
@media (max-width: 760px) {
  .drill .rack-tiles { --tw: calc((100vw - 48px - 12 * 3px) / 13.4); }
}

@media (prefers-reduced-motion: reduce) {
  .card-sec { transition: none; }
}

/* ------------------------------------------------------------ easy-mode guide */
.guide { margin-top: 20px; }
.guide h2 { color: var(--ink); margin-bottom: 2px; }
.guide > p { margin: 0 0 12px; }
.guide-step { margin: 0 0 4px !important; font-size: .85rem; color: var(--ink-muted); }

.signals { display: grid; gap: 6px; }
.signal {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--paper-line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.signal:hover { background: #f6f4ec; }
.signal[aria-pressed="true"] {
  background: #eef7f1;
  border-color: #2f8063;
  box-shadow: inset 0 0 0 1px #2f8063;
}
.guide .rule-note { margin: 10px 2px 0; }
.signals.is-asking .signal { grid-template-columns: minmax(0, 1fr); }
.guide .verdict-call { margin: 12px 2px 0; }
.guess-why { margin: 4px 2px 0; }

.guide-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.guide-nav .btn-link { margin: 0 0 0 auto; }
.btn-quiet { color: var(--ink); border-color: var(--paper-line); }
.btn-quiet:hover { background: #f3f0e4; }

@media (max-width: 760px) {
  .signal { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; }
  .signal-slots { grid-column: 1 / -1; grid-row: 2; }
}

/* ------------------------------------------------------------ look-here marks and verdicts */
.fit { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 2px; line-height: 1.15; }
.fit-label { white-space: nowrap; }
.verdict {
  font-size: .72rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.verdict-strong { background: #d8efe0; color: #11603a; }
.verdict-worth-a-look { background: #e6f2ea; color: #2a6b47; }
.verdict-close { background: #f6ebcd; color: #7a5410; }
.verdict-more { background: #efece2; color: #4e5567; }
.verdict-long-shot { background: #ececec; color: #5d5d5d; }
.verdict-out { background: #f1eee6; color: #6b7080; }

.rule-odds { margin: 2px 0 6px; color: var(--ink-muted); font-size: .93rem; }
.signal-foot { margin: 12px 0 8px; font-size: .85rem; color: var(--ink-muted); }

/* ------------------------------------------------------------ difficulty icon */
.diff {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  padding: 2px 3px;
  border-radius: 4px;
  cursor: help;
  vertical-align: middle;
}
.diff i { width: 4px; border-radius: 1px; background: var(--paper-line); }
.diff i:nth-child(1) { height: 6px; }
.diff i:nth-child(2) { height: 9px; }
.diff i:nth-child(3) { height: 12px; }
.diff-1 i:nth-child(-n + 1) { background: #3f9a6b; }
.diff-2 i:nth-child(-n + 2) { background: #d39b2a; }
.diff-3 i:nth-child(-n + 3) { background: #c2502f; }
.diff:hover, .diff:focus-visible { background: #efece2; }

.diff-tip {
  position: absolute;
  z-index: 50;
  width: 280px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #f2f0e8;
  font-size: .85rem;
  line-height: 1.4;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
  pointer-events: none;
}
.diff-tip[hidden] { display: none; }
.diff-tip ul { margin: 6px 0 0; padding-left: 16px; }
.diff-tip li { margin: 3px 0; }

.card-meta { display: inline-flex; align-items: center; gap: 4px; }
.meta .diff { margin-left: -6px; }

/* ------------------------------------------------------------ tile chips and slots */
.chip {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  width: 22px;
  height: 28px;
  padding-top: 6px;
  box-sizing: border-box;
  border-radius: 4px;
  background: linear-gradient(170deg, #fffdf6, #f1e8d2);
  box-shadow: inset 0 0 0 1px rgba(120, 100, 60, .28), 0 2px 0 var(--tile-back);
  font: 700 13px/1 var(--font);
  flex: none;
}
.chip small { font-size: 8px; font-weight: 600; }
.chip .chip-cjk { font-family: "Hiragino Mincho ProN", "Songti SC", "Noto Serif SC", serif; font-size: 13px; }
.chip .chip-soap {
  display: block;
  width: 9px;
  height: 14px;
  margin-top: -2px;
  border: 2px solid #1f5aa6;
  border-radius: 2px;
  box-sizing: border-box;
}
.chip.is-empty {
  background: transparent;
  box-shadow: none;
  outline: 1.5px dashed #c9c3b2;
  outline-offset: -1.5px;
}
.chip.is-soap { box-shadow: inset 0 0 0 2px var(--gold), 0 2px 0 var(--tile-back); }
.slot-extra { font-weight: 700; font-size: .9rem; color: #11603a; }
.chip.is-faded { opacity: .35; }

.slots { display: inline-flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.slot-line {
  align-self: stretch;
  width: 2px;
  margin: 0 5px;
  border-radius: 1px;
  background: var(--bamboo-deep);
}
.slot-count { margin-left: 14px; font-size: .9rem; color: var(--ink-muted); white-space: nowrap; }
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }

/* ------------------------------------------------------------ cheat sheet rows */
.rule-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.rule .rule-sec { font-size: 1.12rem; }
.rule-say { color: var(--ink); }
.rule-slots { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 0; margin-top: 4px; }

.no-target {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--paper-line);
  font: 600 .95rem var(--font);
  color: var(--ink-muted);
}
.no-target + .rule { border-top: 0; }
.rule-plain > summary {
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 12px 0;
}
.rule-plain .rule-sec { font-size: 1rem; }
.rule-plain .rule-say { color: var(--ink-muted); }
.rule.is-out .rule-sec { color: #8a8f9e; }
.rule.is-out .rule-say { color: var(--ink-muted); }

.verdict { font-size: .78rem; padding: 2px 10px; }
.verdict-long-shot { background: transparent; color: #5d5d5d; outline: 1.5px dashed #b9b4a4; outline-offset: -1.5px; }

/* ------------------------------------------------------------ drill guide rows */
.signal-name { display: grid; gap: 1px; }
.signal-tag { font-size: .82rem; color: var(--ink-muted); }
.signal-slots { min-width: 0; }
.signal.is-out .rule-sec, .signal.is-longshot .rule-sec { color: #8a8f9e; }

/* ------------------------------------------------------------ rules page */
.rules-page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 24px 64px;
}

.topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.topics button {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 18px;
  border: 1.5px solid rgba(243, 236, 216, .35);
  border-radius: 999px;
  background: transparent;
  color: var(--on-felt);
  font-weight: 600;
  cursor: pointer;
}
.topics button:hover { background: rgba(255, 255, 255, .08); }
.topics button[aria-selected="true"] {
  background: linear-gradient(180deg, var(--bamboo-hi), var(--bamboo));
  border-color: var(--bamboo-deep);
  color: #3a2508;
}
.topic-count { font-size: .8rem; font-weight: 500; opacity: .8; }

.rules-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.reference { position: sticky; top: 16px; }
.reference h2 { color: var(--ink); }
.ref-intro { margin: 0 0 12px; color: var(--ink-muted); }
.ref-rules li { padding: 6px 0 6px 18px; line-height: 1.45; }

.practice { padding: 22px 24px; }
.practice h2 { color: var(--ink); margin-top: 2px; }
.practice-head { display: flex; justify-content: space-between; align-items: center; }
.level {
  font-size: .78rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: #efece2;
  color: var(--ink-muted);
}
.practice-intro { margin: 0 0 12px; font-size: 1.05rem; }

.scene {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 22px 16px 16px;
  border-radius: 10px;
  background: radial-gradient(ellipse at 50% 30%, var(--felt-hi), var(--felt));
  color: var(--bone);
}
.scene-tiles { display: flex; gap: 6px; --tw: 58px; }
.scene-label { margin: 8px 0 0; color: var(--on-felt-muted); font-size: .92rem; }
.scene-mark { font-size: 3rem; line-height: 1; color: var(--bamboo-hi); }

.mini-rack { --tw: 40px; }
.mini-rack .rack-tiles { min-height: 0; justify-content: flex-start; flex-wrap: wrap; padding: 0 6px; gap: 3px; }
.mini-rack .rack-bar { height: 16px; margin-top: -2px; }
.tile.is-new { position: relative; box-shadow: inset 0 0 0 2px var(--gold), 0 calc(var(--w) * .07) 0 0 var(--tile-back); }
.tile.is-new::before {
  content: "New";
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font: 600 10px var(--font);
  color: var(--bone);
  background: var(--tile-back-deep);
  padding: 0 5px;
  border-radius: 4px;
}
.mini-rack button.tile:disabled { opacity: .5; }
.mini-rack button.tile.is-right:disabled, .mini-rack button.tile.is-wrong:disabled { opacity: 1; }
.mini-rack .tile.is-right { box-shadow: inset 0 0 0 3px #2f8063, 0 calc(var(--w) * .07) 0 0 var(--tile-back); }
.mini-rack .tile.is-wrong { box-shadow: inset 0 0 0 3px #b8442c, 0 calc(var(--w) * .07) 0 0 var(--tile-back); }

.practice-goal {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f6f4ec;
}
.practice-q { margin: 18px 0 10px; font-size: 1.1rem; }

.answers { display: grid; gap: 8px; }
.answer {
  text-align: left;
  padding: 12px 16px;
  border: 1.5px solid var(--paper-line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
}
.answer:hover:not(:disabled) { border-color: #b9b4a4; background: #f6f4ec; }
.answer:disabled { cursor: default; opacity: .6; }
.answer.is-right { opacity: 1; border-color: #2f8063; background: #eef7f1; box-shadow: inset 0 0 0 1px #2f8063; }
.answer.is-wrong { opacity: 1; border-color: #b8442c; background: #fbeae5; }

.hint-line { margin: 12px 0 0; }
.hint { display: block; padding: 10px 14px; border-radius: 8px; background: #f6ebcd; color: #5a3d08; }
.rule-feedback { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--paper-line); }
.rule-feedback .btn-primary { margin-top: 8px; }

@media (max-width: 960px) {
  .rules-layout { grid-template-columns: 1fr; }
  .reference { position: static; }
}
@media (max-width: 760px) {
  .rules-page { padding-left: 16px; padding-right: 16px; }
  .practice { padding: 18px 16px; }
  .scene-tiles { --tw: 46px; }
  .mini-rack { --tw: calc((100vw - 32px - 32px - 14 * 3px) / 14.6); }
}

/* ------------------------------------------------------------ rules: the card line a question is about */
.drill-bar { flex-wrap: wrap; }
.card-q-line {
  margin: 4px 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--paper-line);
  border-radius: 8px;
}
.card-q-line .still { margin: 0 0 4px; }
.card-q-line .line.big { font-size: 1.4rem; }

/* ------------------------------------------------------------ my rack: quick read */
.picks > #quick { margin-bottom: 0; }
.connect {
  margin: 14px 0 30px;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .2);
  color: var(--on-felt);
  max-width: 70ch;
}
.connect:empty { display: none; }
.connect strong { color: var(--bone); }
.more-signals { border-top: 1px solid var(--paper-line); }
.more-signals > summary {
  padding: 12px 0;
  cursor: pointer;
  font-weight: 600;
  color: #2a6b47;
}
.more-signals > .rule:first-of-type { border-top: 0; }
.practice a { color: #2a6b47; }

.flower-note {
  margin: 10px 0 4px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #f3edfb;
  color: #4a3470;
}
.slot-run {
  display: inline-flex;
  gap: 3px;
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px dashed #c9c3b2;
}

/* ------------------------------------------------------------ card lines marked against the rack */
.ch-have {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
.ch-joker {
  text-decoration: underline dotted var(--gold);
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
}
.ch-need { opacity: .3; }

.your-version {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  margin-top: 3px;
  font-size: .82rem;
  font-weight: 500;
  letter-spacing: 0;
  word-spacing: normal;
}
.yv-label { color: var(--ink-muted); font-weight: 500; }
.yv-line { font-weight: 700; word-spacing: .15em; letter-spacing: .02em; }
.yv-suits { color: var(--ink-muted); }
.slip-title .your-version { font-size: .95rem; margin: 4px 0 2px; }
.card-help .ch-have, .card-help .ch-need, .card-help .ch-joker,
.whole .quiet .ch-have, .whole .quiet .ch-need, .whole .quiet .ch-joker { font-weight: 700; color: var(--ink); }
.row-body > .your-version { margin: 4px 0 8px; font-size: .9rem; }

/* ------------------------------------------------------------ folds on My rack */
details.slip > summary { list-style: none; cursor: pointer; }
details.slip > summary::-webkit-details-marker { display: none; }
.slip-open { grid-column: 2 / -1; font-size: .88rem; font-weight: 600; color: #2a6b47; }
.slip[open] .slip-open { display: none; }
.slip[open] > summary { margin-bottom: 12px; }
.slip:not([open]) { padding-bottom: 14px; }

.fold > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary h2 { margin: 0; }
.fold > summary::after { content: "Show"; font-size: .85rem; font-weight: 500; color: var(--ink-muted); }
.fold[open] > summary::after { content: "Hide"; }
.fold[open] > summary { margin-bottom: 10px; }
.on-felt-fold { margin-top: 30px; }
.on-felt-fold > summary::after { color: var(--on-felt-muted); }
.on-felt-fold .behind-h { margin-top: 0 !important; }
