/* ============================================================================
   blackjack/styles.css

   Two rules from CLAUDE.md's UI conventions drive most of what looks odd here,
   and both are about a phone held in one hand between hands at a table:

     ZERO LAYOUT SHIFT DURING INPUT. Every result lands in a .bj-slot with a
     min-height, so a number arriving never pushes the button you are about to
     tap. The Trainer's Deal button sits ABOVE its feedback for the same
     reason — the feedback is tall and varies with the hand.

     COLOUR IS NEVER THE ONLY SIGNAL. Every grid cell carries its letter
     (S/H/D/P/R) as well as its colour, so the chart is readable in greyscale,
     in sunlight, and by the ~8% of men who would otherwise have to guess
     between the stand and hit columns.

   The palette and the glass tokens come from /site.css; this file consumes them
   rather than redefining them.
   ========================================================================== */

:root {
  --felt: #0b6b3a;
  --felt-dark: #084a28;
  --bg: #0e1116;
  --panel: #171c24;
  --panel-2: #1f2630;
  --ink: #e8edf2;
  --muted: #93a1b0;
  --line: #2a323d;
  --gold: #f0c419;
  --green: #36d07a;
  --red: #ff5d5d;
  --yellow: #ffd24d;
  --accent: #4aa8ff;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  /* The five actions. Stop/go rather than good/bad: a player reads "stand" as
     an instruction, not as a verdict, and colouring it red would suggest the
     cell is a losing one when half the chart's stands are its best hands. */
  --a-stand: #f0a819;
  --a-hit: #36d07a;
  --a-double: #4aa8ff;
  --a-split: #b58bff;
  --a-surrender: #8492a3;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--g-bg, var(--bg));
  color: var(--ink);
  line-height: 1.45;
  padding-bottom: 40px;
}
h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 650; }
h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
code { font-family: var(--mono); font-size: .9em; }
.hidden { display: none !important; }
.ev-pos { color: var(--green); }
.ev-neg { color: var(--red); }
.ev-zero { color: var(--muted); }
kbd {
  font-family: var(--mono); font-size: .78em; padding: 1px 5px;
  border: 1px solid var(--line); border-radius: 4px; background: rgba(255, 255, 255, .05);
}

/* ---------- top bar ---------- */
.topbar {
  text-align: center;
  padding: 22px 16px 14px;
  background: linear-gradient(180deg, rgba(11, 107, 58, .62), rgba(8, 74, 40, .38));
  border-bottom: 2px solid rgba(240, 196, 25, .45);
  box-shadow: var(--g-hi), var(--shadow);
  -webkit-backdrop-filter: var(--g-blur); backdrop-filter: var(--g-blur);
}
.brand { display: flex; gap: .4rem; align-items: center; justify-content: center; flex-wrap: wrap; }
.brand h1 { font-size: 1.6rem; letter-spacing: .3px; }
.brand h1 .muted { font-weight: 400; }
.brand .suit { font-size: 1.25rem; opacity: .92; }
.suit.h, .suit.d { color: #ff6b6b; }
.suit.s, .suit.c { color: #0c0f13; }
.tagline { margin: 6px 0 0; color: #d8efe0; font-size: .9rem; }

/* ---------- layout ---------- */
main { max-width: 1180px; margin: 16px auto; padding: 0 16px; }
main > section { display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: var(--g-sheen), var(--g-base);
  border: 1px solid var(--g-line);
  border-radius: var(--g-r-lg, 16px);
  padding: 14px 16px;
  box-shadow: var(--g-hi), var(--g-lo), var(--shadow);
  -webkit-backdrop-filter: var(--g-blur); backdrop-filter: var(--g-blur);
}
.panel > h2 { font-size: 1.02rem; color: var(--gold); }
.placeholder { padding: 26px 10px; text-align: center; color: var(--muted); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Fixed-height result slots. The whole point is that the thing above them
   never moves when they fill, so the min-heights are generous on purpose. */
.bj-slot { margin-top: 12px; }
.detail-slot { min-height: 210px; }
.solve-slot { min-height: 430px; }
.cost-slot { min-height: 330px; }
.sim-slot { min-height: 150px; }

/* ---------- the rules bar ---------- */
.rulebar {
  max-width: 1180px; margin: 12px auto 0; padding: 8px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: .84rem;
}
.rb-lbl { color: var(--muted); font-weight: 650; }
.rb-note { color: var(--muted); font-family: var(--mono); font-size: .76rem; }
.rb-edge { margin-left: auto; color: var(--muted); }
.rb-edge b { color: var(--gold); font-family: var(--mono); }
.rb-custom { font-style: italic; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.segmented button {
  background: var(--panel-2); color: var(--muted); border: none; padding: 5px 11px;
  border-right: 1px solid var(--line); font-size: .84rem;
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: var(--accent); color: #04121f; font-weight: 650; }
.segmented button .p-sub, .segmented button .adv, .segmented button .rb-sub {
  display: block; font-size: .68rem; opacity: .75; font-weight: 400;
}

/* ---------- the strategy grid ---------- */
.grid-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.rules-echo { font-family: var(--mono); font-size: .74rem; margin: 2px 0 0; }
.bj-check { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); white-space: nowrap; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0 8px; font-size: .78rem; color: var(--muted); }
.legend .lg { display: inline-flex; align-items: center; gap: 5px; }

.act-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 5px; margin-right: 5px;
  font-size: .72rem; font-weight: 800; color: #06090d; flex: 0 0 auto;
}
.act-dot.big { width: 26px; height: 26px; font-size: .95rem; }
.act-dot.stand { background: var(--a-stand); }
.act-dot.hit { background: var(--a-hit); }
.act-dot.double { background: var(--a-double); }
.act-dot.split { background: var(--a-split); }
.act-dot.surrender { background: var(--a-surrender); color: #e8edf2; }
.act-dot.close-mark { background: transparent; border: 1px dashed var(--gold); color: var(--gold); }

.grid-wrap { display: flex; flex-direction: column; gap: 12px; }
.grid-block { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid-block h3 { margin-bottom: 4px; }
/* table-layout:fixed so the ten upcard columns share the width evenly. Left to
   auto, the browser hands all the slack to the row-header column and the grid
   ends up as a narrow strip of cells beside a field of nothing. */
.bj-grid { border-collapse: separate; border-spacing: 2px; width: 100%; min-width: 330px; table-layout: fixed; }
.bj-grid th {
  font-size: .74rem; color: var(--muted); font-weight: 650; padding: 2px 4px; text-align: center;
}
.bj-grid th.rh {
  text-align: right; white-space: nowrap; color: var(--ink); font-family: var(--mono);
  font-size: .76rem; padding-right: 7px; width: 58px;
}
.gcell {
  position: relative; overflow: hidden;
  text-align: center; font-weight: 800; font-size: .8rem; color: #06090d;
  height: 26px; border-radius: 5px; cursor: pointer; user-select: none;
  transition: transform .06s ease, box-shadow .1s ease;
}
.gcell.stand { background: var(--a-stand); }
.gcell.hit { background: var(--a-hit); }
.gcell.double { background: var(--a-double); }
.gcell.split { background: var(--a-split); }
.gcell.surrender { background: var(--a-surrender); color: #f2f5f8; }
.gcell:hover { transform: scale(1.12); box-shadow: 0 2px 10px rgba(0, 0, 0, .5); z-index: 2; }
.gcell.lit { box-shadow: 0 0 0 2px var(--gold), 0 2px 10px rgba(0, 0, 0, .5); z-index: 3; }
/* A near-tie: the corner tick is deliberately subtle. It is information, not a
   warning — the cell's action is still the right one. */
.gcell.close::before {
  content: ''; position: absolute; top: 0; right: 0;
  border-top: 6px solid rgba(0, 0, 0, .45); border-left: 6px solid transparent;
}
.gcell.hasexc::after {
  content: ''; position: absolute; bottom: 2px; left: 2px;
  width: 3px; height: 3px; border-radius: 50%; background: rgba(0, 0, 0, .55);
}
/* The mastery tint: a cell you always get right shows nothing, one you always
   miss is fully reddened, and an UNSEEN cell shows nothing either — so a pale
   grid reads as "not drilled yet" rather than as "passed". */
.gcell.mastered { box-shadow: inset 0 0 0 99px rgba(255, 93, 93, calc((1 - var(--m, 1)) * .62)); }
.gcell.mastered.lit { box-shadow: inset 0 0 0 99px rgba(255, 93, 93, calc((1 - var(--m, 1)) * .62)), 0 0 0 2px var(--gold); }

.grid-wrap.compact .gcell { height: 20px; font-size: .68rem; }
.grid-wrap.compact .bj-grid { border-spacing: 1px; }
.grid-wrap.compact .bj-grid th.rh { font-size: .68rem; width: 46px; }
.grid-wrap.compact h3 { font-size: .82rem; }

.chart-note { margin: 8px 0 0; }
.chart-note.warn { border-left: 2px solid var(--yellow); padding-left: 9px; }
.rule-warn {
  margin: 10px 0; padding: 8px 11px; border-radius: 10px;
  background: rgba(255, 210, 77, .07); border: 1px solid rgba(255, 210, 77, .3);
  border-left-width: 3px; font-size: .86rem;
}
.rule-warn strong { color: var(--yellow); }
.rule-warn p { margin: .35em 0 0; }

/* ---------- the edge strip ---------- */
.edge-strip {
  background: var(--g-in-fill, rgba(255, 255, 255, .055));
  border: 1px solid var(--g-in-line, rgba(255, 255, 255, .1));
  border-radius: var(--g-r-md, 12px);
  padding: 10px 12px; margin: 10px 0 4px;
}
.es-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.es-lbl { color: var(--muted); font-size: .84rem; }
.es-val { font-size: 1.5rem; font-weight: 750; color: var(--gold); font-family: var(--mono); }
.es-note { margin: 4px 0 0; }
.es-you { display: block; margin-top: 3px; }
.linkish {
  background: none; border: none; color: var(--accent); padding: 0;
  font-size: inherit; text-decoration: underline; text-underline-offset: 2px;
}

/* ---------- detail / EV tables ---------- */
/* justify-content is spelled out because .d-head is also the Trainer's panel
   header, which is space-between — without this the hand, the "vs" and the
   verdict get flung to opposite ends of the panel. */
.detail .d-head { display: flex; justify-content: flex-start; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.d-hand, .d-up {
  font-family: var(--mono); font-weight: 750; font-size: 1rem;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 8px;
}
.line { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; border-top: 1px solid var(--line); font-size: .86rem; }
.line .lbl { color: var(--muted); min-width: 108px; flex: 0 0 auto; }

.bj-actions { width: 100%; border-collapse: collapse; margin: 6px 0; }
.bj-actions td { padding: 4px 6px; border-bottom: 1px solid var(--line); font-size: .86rem; }
.bj-actions .a-name { white-space: nowrap; display: flex; align-items: center; }
.bj-actions .a-bar { width: 55%; }
.bj-actions .a-ev { text-align: right; font-family: var(--mono); white-space: nowrap; }
.bj-actions tr.best { background: rgba(54, 208, 122, .1); }
.bj-actions tr.picked td { box-shadow: inset 0 0 0 1px rgba(240, 196, 25, .55); }
.bj-actions .bar { position: relative; display: block; height: 9px; background: rgba(255, 255, 255, .05); border-radius: 5px; overflow: hidden; }
.bj-actions .bar .pos, .bj-actions .bar .neg { position: absolute; top: 0; bottom: 0; }
.bj-actions .bar .pos { background: var(--green); }
.bj-actions .bar .neg { background: var(--red); }
.bj-actions .bar .mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, .3); }

.badge {
  display: inline-block; font-size: .7rem; font-weight: 700; padding: 1px 7px;
  border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.tiny { font-size: .62rem; padding: 0 5px; }
.badge.same { color: var(--green); border-color: rgba(54, 208, 122, .5); background: rgba(54, 208, 122, .1); }
.badge.dev { color: var(--yellow); border-color: rgba(255, 210, 77, .5); background: rgba(255, 210, 77, .1); }
.badge.close { color: var(--gold); border-color: rgba(240, 196, 25, .45); background: rgba(240, 196, 25, .08); }
.deviation-box, .exc-box {
  margin: 8px 0 0; padding: 8px 10px; border-radius: 10px;
  background: rgba(255, 210, 77, .07); border: 1px solid rgba(255, 210, 77, .28); font-size: .85rem;
}
.deviation-box p, .exc-box p { margin: .4em 0 0; }
.exc-box ul { margin: .4em 0 0; padding-left: 1.2em; }

/* ---------- generic tables ---------- */
.bj-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.bj-table th {
  text-align: left; color: var(--muted); font-weight: 650; font-size: .76rem;
  border-bottom: 1px solid var(--line); padding: 4px 6px;
}
.bj-table td { padding: 4px 6px; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.bj-table tbody tr:hover { background: rgba(255, 255, 255, .035); }
.bj-table td .act-dot { vertical-align: -3px; }
.cost-table tr.bad td:first-child { box-shadow: inset 2px 0 0 rgba(255, 93, 93, .55); }
.cost-table tr.good td:first-child { box-shadow: inset 2px 0 0 rgba(54, 208, 122, .55); }
.cost-base { margin: 0 0 8px; font-size: .9rem; }
.cost-base strong { color: var(--gold); font-family: var(--mono); }
.sim-table tr.good td { color: var(--green); }
.sim-table tr.bad td { color: var(--yellow); }

/* ---------- card chips ---------- */
.bj-card {
  display: inline-flex; align-items: center; justify-content: center; gap: 1px;
  min-width: 30px; height: 40px; padding: 0 4px; border-radius: 6px;
  background: #f5f7fa; color: #0c0f13; border: 1px solid #c7ced6;
  font-weight: 750; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); user-select: none;
}
.bj-card b { font-size: .95rem; line-height: 1; }
.bj-card i { font-size: .8rem; line-height: 1; font-style: normal; }
.bj-card.h, .bj-card.d { color: #c1121f; }
.bj-card.big { min-width: 42px; height: 58px; }
.bj-card.big b { font-size: 1.3rem; }
.bj-card.big i { font-size: 1rem; }
.bj-card.back {
  background: repeating-linear-gradient(135deg, #2c4a7c, #2c4a7c 3px, #223a63 3px, #223a63 6px);
  border-color: #3b568c;
}
.slot-empty { display: inline-block; width: 30px; height: 40px; border: 1px dashed #3a4450; border-radius: 6px; }
.slot-empty.big { width: 42px; height: 58px; }

/* ---------- the trainer ---------- */
.d-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.drill-blurb { margin: 8px 0; }
.d-settings { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.d-settings label { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.d-settings select, .inline-controls select, .inline-controls input, .h-context select {
  background: rgba(0, 0, 0, .28); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 6px; font: inherit; font-size: .82rem;
}
.clear { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 2px 9px; font-size: .75rem; }
.clear:hover { color: var(--ink); border-color: var(--muted); }

.d-statline, .d-kinds { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.chip {
  background: var(--g-in-fill, rgba(255, 255, 255, .055));
  border: 1px solid var(--g-in-line, rgba(255, 255, 255, .1));
  border-radius: 999px; padding: 3px 11px; font-size: .78rem; color: var(--muted);
}
.chip strong { color: var(--ink); font-family: var(--mono); }

.trainer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.felt-panel { background: linear-gradient(180deg, rgba(11, 107, 58, .3), rgba(8, 74, 40, .18)), var(--g-base); }
/* The dealt hand and the "hit Deal" placeholder are the same height, so the
   first deal of a session does not shove the action buttons down the page. */
#d-table { min-height: 212px; }
.felt { display: flex; flex-direction: column; gap: 14px; padding: 8px 0; }
.felt-row { display: flex; flex-direction: column; gap: 6px; }
.felt-lbl { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.felt .hand { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tot {
  font-family: var(--mono); font-size: .9rem; font-weight: 700; color: var(--gold);
  background: rgba(0, 0, 0, .3); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; margin-left: 4px;
}

.d-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; min-height: 44px; }
.d-act {
  display: inline-flex; align-items: center; background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-weight: 650;
}
.d-act:hover:not(:disabled) { border-color: var(--gold); }
.d-act:active:not(:disabled) { transform: scale(.96); }
.d-act:disabled { opacity: .4; cursor: default; }
.d-nav { margin: 4px 0 10px; }
button.primary {
  background: linear-gradient(180deg, #ffd955, var(--gold)); color: #241c02;
  border: 1px solid rgba(255, 230, 140, .7); border-radius: 999px; padding: 9px 22px; font-weight: 700;
}
button.primary:active { transform: scale(.97); }

.verdict { font-weight: 700; font-size: .95rem; padding: 7px 10px; border-radius: 9px; margin-bottom: 6px; }
.verdict.perfect { background: rgba(54, 208, 122, .13); border: 1px solid rgba(54, 208, 122, .4); }
.verdict.wrong { background: rgba(255, 93, 93, .12); border: 1px solid rgba(255, 93, 93, .4); }
.cost { margin: .3em 0 .6em; }
.cost.tiny { color: var(--muted); }
.cost.mid { color: var(--yellow); }
.cost.big { color: var(--red); }
.rule-box { border-left: 3px solid var(--line); padding: 4px 0 4px 10px; margin: 8px 0; }
.rule-box.ok { border-left-color: var(--green); }
.rule-box.miss { border-left-color: var(--red); }
.rule-k { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.rule-chart { font-size: .88rem; }

.weak-wrap { margin-top: 12px; }
.weak-table { max-width: 520px; }

/* ---------- the dealer distribution bar ---------- */
.dealer-dist { margin: 8px 0; }
.dd-bar { display: flex; height: 20px; border-radius: 6px; overflow: hidden; background: rgba(0, 0, 0, .3); }
.dd-bar span {
  display: flex; align-items: center; justify-content: center;
  font-size: .66rem; font-weight: 700; color: #06090d; min-width: 0;
}
.d-bust { background: var(--green); }
.d-t17 { background: #7f8fa3; }
.d-t18 { background: #9aa8bb; }
.d-t19 { background: #c3a24a; }
.d-t20 { background: #e08b4a; }
.d-t21 { background: var(--red); }
.dd-legend { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 5px; font-size: .72rem; color: var(--muted); }
.dd-key { display: inline-flex; align-items: center; gap: 4px; }
.dd-key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.dd-key b { color: var(--ink); font-family: var(--mono); }
.dd-key.bj { color: var(--yellow); }

/* ---------- the hand panel ---------- */
.hand-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 6px 12px; font-size: .84rem; }
.ghost:hover { border-color: var(--gold); color: var(--gold); }

.h-zones { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.h-zone {
  flex: 1 1 200px; background: rgba(0, 0, 0, .22); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; cursor: pointer;
}
.h-zone.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(74, 168, 255, .3); }
.h-zone-head { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--muted); margin-bottom: 6px; gap: 8px; }
.h-slots { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-height: 58px; }
.target-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }

.rank-pad { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; margin: 10px 0; }
.rank-key {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #f5f7fa; color: #0c0f13; border: 1px solid #c7ced6; border-radius: 6px;
  height: 44px; font-weight: 750; font-size: .95rem; padding: 0;
}
.rank-key small { font-size: .58rem; font-weight: 500; color: #5b6673; }
.rank-key:hover:not(:disabled) { outline: 2px solid var(--gold); }
.rank-key:disabled { opacity: .3; cursor: default; }
.h-context { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.h-context label { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- the rules editor ---------- */
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.preset {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 12px; font-size: .82rem; text-align: left;
}
.preset .p-sub { display: block; font-size: .68rem; color: var(--muted); font-family: var(--mono); }
.preset:hover { border-color: var(--gold); }
.preset.active { border-color: var(--gold); background: rgba(240, 196, 25, .12); }
.preset.active .p-sub { color: var(--gold); }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin: 12px 0; }
.field {
  background: var(--g-in-fill, rgba(255, 255, 255, .055));
  border: 1px solid var(--g-in-line, rgba(255, 255, 255, .1));
  border-radius: var(--g-r-md, 12px); padding: 9px 11px;
}
.field.edge-only { border-style: dashed; }
.f-head { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.f-label { font-weight: 650; font-size: .88rem; }
/* Individually rounded rather than one joined strip: a segmented control that
   wraps to three lines leaves half-rounded stubs mid-row, and several of these
   fields have four options with long labels. */
.f-seg { max-width: 100%; border: none; gap: 4px; border-radius: 0; }
.f-seg button { border: 1px solid var(--line); border-radius: 7px; }
.f-seg button.active { border-color: rgba(190, 224, 255, .6); }
.f-seg button.good::after { content: ' ✓'; color: var(--green); font-size: .7em; }
.f-seg button.active.good::after { color: #04121f; }
.f-note { margin: 6px 0 0; }
.inline-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.inline-controls label { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.inline-controls input[type=number] { width: 110px; }
.inline-controls button {
  background: var(--accent); color: #04121f; border: 1px solid rgba(190, 224, 255, .6);
  border-radius: 8px; padding: 6px 14px; font-weight: 650;
}
.inline-controls button:disabled { opacity: .5; cursor: default; }

/* ---------- footer ---------- */
footer { max-width: 1180px; margin: 20px auto 0; padding: 0 16px; font-size: .86rem; }
footer summary { cursor: pointer; color: var(--gold); font-weight: 650; }
.foot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 12px; }
.foot-grid h4 { color: var(--gold); font-size: .9rem; }
.foot-grid p { margin: .5em 0; color: #c3cdd8; }

/* ---------- phones ----------
   The grid stays a grid: it is the whole product, and a 10-column table is
   readable at 26px a cell. What changes is that the two-up panels stack and
   the action buttons grow, because those are what a thumb has to hit. */
@media (max-width: 860px) {
  .trainer-grid { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr; }
  main { padding: 0 12px; }
  .rulebar { padding: 8px 12px; }
  .rb-edge { margin-left: 0; }
}
@media (max-width: 520px) {
  .brand h1 { font-size: 1.3rem; }
  .tagline { font-size: .82rem; }
  .panel { padding: 12px 12px; }
  .es-val { font-size: 1.25rem; }
  .d-act { padding: 12px 16px; flex: 1 1 40%; justify-content: center; }
  button.primary { width: 100%; }
  .bj-grid th.rh { width: 44px; font-size: .7rem; padding-right: 4px; }
  .gcell { height: 24px; font-size: .74rem; }
  .rank-pad { grid-template-columns: repeat(5, 1fr); }
  .rank-key { height: 48px; }
  .solve-slot { min-height: 520px; }
  .cost-slot { min-height: 420px; }
}
@media (prefers-reduced-motion: reduce) {
  .gcell:hover { transform: none; }
  .d-act:active, button.primary:active { transform: none; }
}
