/* Jacks or Better Trainer — casino floor styling */
* { box-sizing: border-box; }
:root {
  --bg: #0a0e1c;
  --panel: #131b31;
  --panel2: #1a2440;
  --line: #2a3757;
  --ink: #e8eeff;
  --dim: #8fa0c8;
  --gold: #f5c645;
  --red: #e4483d;
  --green: #35c47f;
  --blue: #4c8dff;
  --felt: #0d3b2e;
}
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.app { max-width: 1400px; margin: 0 auto; padding: 14px 16px 40px; }

/* top bar */
.topbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  padding: 12px 14px; margin-bottom: 14px; background: linear-gradient(120deg, #16204010, #101a34);
  border: 1px solid var(--line); border-radius: 14px; }
.brand { display: flex; gap: 12px; align-items: center; margin-right: auto; }
.brand .logo { font-size: 30px; color: var(--gold); text-shadow: 0 0 18px #f5c64580; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .3px; }
.brand .sub { margin: 0; color: var(--dim); font-size: 12px; }
.modes { display: flex; gap: 6px; background: #0c142a; padding: 5px; border-radius: 11px; border: 1px solid var(--line); }
.modes button { background: transparent; color: var(--dim); border: 0; padding: 8px 13px;
  border-radius: 8px; font-weight: 700; font-size: 13px; cursor: pointer; }
.modes button:hover { color: var(--ink); }
.modes button.on { background: linear-gradient(180deg, #f5c645, #d99f1d); color: #221a04; }
.modeblurb { flex: 1 1 260px; color: var(--dim); font-size: 12.5px; max-width: 340px; }

/* layout */
.grid { display: grid; gap: 14px; grid-template-columns: 290px minmax(430px, 1fr) 380px; align-items: start; }
@media (max-width: 1180px) { .grid { display: flex; flex-wrap: wrap; } .grid > .tablepanel { flex: 1 1 300px; } .grid > .felt { flex: 1 1 420px; } .grid > .sidepanel { flex: 1 1 100%; } .card { width: min(82px, 17.6%); height: auto; aspect-ratio: 5 / 7; } }
@media (max-width: 820px) { .grid > * { flex: 1 1 100%; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 13px; }
.panel h2 { font-size: 13px; margin: 2px 0 9px; text-transform: uppercase; letter-spacing: .09em; color: var(--dim); }
.panel h3 { font-size: 12px; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.tiny { font-size: 11.5px; color: var(--dim); margin: 6px 0; }

/* paytable */
select, input[type=range] { width: 100%; background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; font-size: 13px; }
table.paytable { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.paytable td, .paytable th { padding: 3px 4px; text-align: right; border-bottom: 1px solid #1d2745; }
.paytable td:first-child { text-align: left; color: #cdd8f5; }
.paytable th { color: var(--dim); font-weight: 600; font-size: 11px; }
.paytable tr.win td { background: #16351f; color: #b6f3c8; }
.paytable tr.key td { color: var(--gold); }
.paytable td.cur { background: #2b3a63; color: #fff; font-weight: 700; }
.paytable tr.win td.cur { background: #1f5c33; }
.badge { display: inline-block; padding: 4px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 800; letter-spacing: .04em; }
.badge.good { background: #12401f; color: #7ef0a6; }
.badge.ok { background: #3a3413; color: var(--gold); }
.badge.bad { background: #45171a; color: #ff9d95; }
.statline { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 3px 0; border-bottom: 1px dashed #223055; }
.statline span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }

/* felt / table */
.felt { background: radial-gradient(120% 90% at 50% 0%, #14563f 0%, var(--felt) 55%, #08251d 100%);
  border: 1px solid #1c6b4d; border-radius: 16px; }
.felt .betbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 2px 10px; border-bottom: 1px dashed #2b7a5c; margin-bottom: 12px; }
.pill { background: #05241b; border: 1px solid #2b7a5c; color: #cfeee0; border-radius: 9px; padding: 5px 10px; font-size: 12px; }
.pill b { color: var(--gold); font-variant-numeric: tabular-nums; }
.betbtns { margin-left: auto; display: flex; gap: 5px; }
.betbtns button { background: #05241b; border: 1px solid #2b7a5c; color: #cfeee0; border-radius: 8px;
  padding: 6px 10px; cursor: pointer; font-weight: 700; font-size: 12px; }
.betbtns button.on { background: var(--gold); color: #221a04; border-color: var(--gold); }
.cards { display: flex; gap: 9px; justify-content: center; padding: 6px 0 4px; }
.card { position: relative; width: 82px; height: 116px; border-radius: 9px; background: #f7f8fb; color: #111;
  box-shadow: 0 6px 14px #0008; cursor: pointer; user-select: none; transition: transform .12s, box-shadow .12s;
  display: flex; flex-direction: column; justify-content: space-between; padding: 6px 7px; font-weight: 800; }
.card.back { background: repeating-linear-gradient(45deg, #1b3f8f, #1b3f8f 6px, #16336f 6px, #16336f 12px); }
.card .rk { font-size: 22px; line-height: 1; }
.card .st { font-size: 20px; }
.card.red { color: #c8102e; }
.card .pip { position: absolute; right: 6px; bottom: 5px; font-size: 30px; opacity: .9; }
.card.held { transform: translateY(-11px); box-shadow: 0 10px 18px #000a, 0 0 0 3px var(--gold) inset; }
.card .heldtag { position: absolute; left: 0; right: 0; bottom: -20px; text-align: center; font-size: 10.5px;
  font-weight: 800; color: var(--gold); letter-spacing: .1em; opacity: 0; }
.card.held .heldtag { opacity: 1; }
.card.rec::after { content: '✔ hold'; position: absolute; top: -19px; left: 0; right: 0; text-align: center;
  font-size: 10px; font-weight: 800; color: #7ef0a6; letter-spacing: .06em; }
.card.no { opacity: .45; }
.card.err { box-shadow: 0 0 0 3px var(--red) inset; }
.msgbar { min-height: 34px; margin: 26px 0 8px; text-align: center; font-size: 14px; font-weight: 700; color: #eafff4; }
.msgbar small { display: block; font-weight: 500; color: #a8dcc4; font-size: 12px; margin-top: 3px; }
.winflash { color: var(--gold); font-size: 17px; }
.timerwrap { height: 6px; background: #05241b; border-radius: 4px; overflow: hidden; margin: 0 30px 10px; }
.timerbar { height: 100%; width: 100%; background: linear-gradient(90deg, #35c47f, #f5c645 60%, #e4483d); }
.controls { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
button.act { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 800; font-size: 13.5px; cursor: pointer;
  background: #1d2a4a; color: var(--ink); letter-spacing: .04em; }
button.act:hover { background: #26365c; }
button.act.primary { background: linear-gradient(180deg, #f5c645, #d99f1d); color: #221a04; }
button.act:disabled { opacity: .38; cursor: not-allowed; }
.keys { color: #7fbf9e; font-size: 11px; margin-left: auto; }

/* side panel tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tabs button { flex: 1; background: #0d142a; color: var(--dim); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 4px; font-size: 12px; font-weight: 700; cursor: pointer; }
.tabs button.on { background: var(--panel2); color: var(--ink); border-color: #40557f; }
.tabpane { display: none; }
.tabpane.on { display: block; }
.verdict { padding: 9px 11px; border-radius: 10px; font-weight: 800; margin-bottom: 9px; }
.verdict.perfect { background: #123a24; color: #86f0ae; }
.verdict.good { background: #17304a; color: #9fd0ff; }
.verdict.marginal { background: #3b3313; color: var(--gold); }
.verdict.blunder { background: #45171a; color: #ff9d95; }
.verdict.idle { background: #17203a; color: var(--dim); font-weight: 600; }
.verdict small { display: block; font-weight: 500; font-size: 12px; margin-top: 4px; color: inherit; opacity: .85; }
table.opts { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.opts td, .opts th { padding: 4px; border-bottom: 1px solid #1e2a4a; text-align: left; }
.opts td.n { text-align: right; }
.opts tr.best td { color: #86f0ae; font-weight: 700; }
.opts tr.yours td { color: #9fd0ff; }
ol.ladder { margin: 0; padding-left: 20px; font-size: 12.5px; }
ol.ladder li { margin-bottom: 7px; display: flex; gap: 6px; align-items: baseline; }
ol.ladder li b { color: var(--gold); }
.ltag { flex: 0 0 34px; font-size: 9px; font-weight: 800; letter-spacing: .5px; text-align: center; border-radius: 5px; padding: 1px 2px; color: #062017; }
.ltag.pat { background: #8b93a8; }
.ltag.hold { background: #3ddc97; }
.ltag.draw { background: #ffb63d; }
ol.ladder li.lnote { display: list-item; color: var(--dim); font-size: 11px; margin-top: 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 12.5px; }
.kv div:nth-child(even) { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.note { font-size: 12px; color: var(--dim); }
.note b { color: var(--ink); }
ul.tips { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }
ul.tips li { margin-bottom: 6px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
table.cats { width: 100%; border-collapse: collapse; font-size: 12px; }
.cats td { padding: 3px 4px; border-bottom: 1px solid #1e2a4a; }
.cats td.n { text-align: right; font-variant-numeric: tabular-nums; }
.pct { font-weight: 800; }
.pct.hi { color: #86f0ae; } .pct.mid { color: var(--gold); } .pct.lo { color: #ff9d95; }

/* phone */
@media (max-width: 820px) {
  .app { padding: 8px 8px 30px; }
  .topbar { padding: 9px 10px; gap: 8px; }
  .brand h1 { font-size: 16px; }
  .brand .sub { font-size: 11px; }
  .modes { order: 3; width: 100%; }
  .modes button { flex: 1; padding: 10px 4px; }
  .modeblurb { order: 4; flex-basis: 100%; max-width: none; }
  /* the machine is the app — put it on top */
  .felt { order: 1; } .tablepanel { order: 2; } .sidepanel { order: 3; }
  /* cards fill the row, thumb-sized */
  .cards { gap: 6px; padding-top: 16px; }
  .card { width: min(82px, 17.4%); height: auto; aspect-ratio: 5 / 7; padding: 4px 5px; }
  .card .rk { font-size: clamp(15px, 4.8vw, 22px); }
  .card .st { font-size: clamp(13px, 4.2vw, 20px); }
  .card .pip { font-size: clamp(20px, 6.4vw, 30px); right: 4px; bottom: 3px; }
  .card.held { transform: translateY(-7px); }
  .card .heldtag { bottom: -16px; font-size: 9px; }
  .card.rec::after { top: -14px; font-size: 9px; }
  .msgbar { margin: 22px 0 6px; font-size: 13px; }
  /* paytable breathes */
  .paytable td, .paytable th { padding: 2px 3px; font-size: 11.5px; }
  /* touch targets everywhere */
  .pill { font-size: 11px; padding: 5px 8px; }
  .betbtns { margin-left: auto; }
  .betbtns button { padding: 10px 13px; }
  button.act { flex: 1 1 auto; min-height: 46px; padding: 10px 10px; font-size: 13px; }
  .keys { display: none; }
  .tabs button { padding: 12px 2px; font-size: 12.5px; }
  .panel { padding: 11px; }
  .grid2 { grid-template-columns: 1fr; }
  select { padding: 10px 8px; }
}

/* ============ coach-first layout (panels, chip, pinned row) ============
   Panels in index.html are .rcard; playing tiles stay .card. These later rules
   work with the legacy blocks above. */
.coach.is-hidden { display: none; }
#coachDetail { padding: 0; }
.opts-card .rcard-b { padding: 10px 11px; }
.pinned-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; padding: 7px 9px;
  border: 1px solid rgba(244, 200, 79, .35); border-radius: 8px; background: rgba(244, 200, 79, .08); }
.pinned-row b { color: var(--gold); }
.verdict.idle { border-left-color: var(--line); color: var(--dim); }
.badge.gold { background: rgba(244, 200, 79, .16); color: var(--gold); }
.badge.gray { background: #2a3350; color: #97a0bb; }
.rcard .tabs { padding: 8px 8px 0; }
.rcard h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); margin: 14px 0 6px; }
.rcard .tabpane h3:first-child { margin-top: 0; }

/* winning cards: the five (or four, or two) that actually make the hand */
.cards { padding: 22px 0 4px; }
.card.win { box-shadow: 0 8px 18px #0009, 0 0 0 3px var(--gold) inset, 0 0 20px rgba(244, 200, 79, .4);
  animation: winpulse 1.2s ease-out 2; }
.card .wintag { position: absolute; left: 0; right: 0; top: -18px; text-align: center; font-size: 10px;
  font-weight: 800; letter-spacing: .1em; color: var(--gold); opacity: 0; }
.card.win .wintag { opacity: 1; }
.card.dead { opacity: .46; filter: saturate(.5); }
.rcard.felt .strip { color: #a8dcc4; }
@keyframes winpulse {
  0% { box-shadow: 0 8px 18px #0009, 0 0 0 3px var(--gold) inset, 0 0 0 rgba(244, 200, 79, 0); }
  35% { box-shadow: 0 8px 18px #0009, 0 0 0 4px var(--gold) inset, 0 0 34px rgba(244, 200, 79, .85); }
  100% { box-shadow: 0 8px 18px #0009, 0 0 0 3px var(--gold) inset, 0 0 20px rgba(244, 200, 79, .4); }
}

/* session / data reset buttons */
.resetrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 2px; }
.resetrow button.act { flex: 1 1 180px; background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 700; padding: 10px 12px; text-transform: none; letter-spacing: 0; }
.resetrow button.act:hover { border-color: #40557f; }
.resetrow button.danger { color: #ff9d95; }
.resetrow button.armed { background: #45171a; border-color: #7d2b30; color: #ffd0cb;
  animation: armpulse 1s ease-in-out infinite alternate; }
@keyframes armpulse { from { box-shadow: 0 0 0 0 rgba(255, 120, 110, 0); } to { box-shadow: 0 0 0 4px rgba(255, 120, 110, .25); } }

/* the max-coins rule, stated once, at the bottom */
footer.foot { border-top: 1px solid var(--line); margin-top: 4px; padding: 12px 4px 0; font-size: 12px;
  color: var(--dim); max-width: 90ch; }
footer.foot p { margin: 0 0 6px; }
footer.foot b { color: var(--gold); }

/* verdict chip in the strip under the cards: the answer without scrolling */
.es-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: .02em; border: 1px solid transparent; white-space: nowrap; }
.es-chip span { font-weight: 600; opacity: .82; }
.es-chip.ok { color: var(--good); background: rgba(47, 214, 151, .13); border-color: rgba(47, 214, 151, .5); }
.es-chip.warn { color: #ffd479; background: rgba(245, 197, 66, .13); border-color: rgba(245, 197, 66, .5); }
.es-chip.bad { color: #ff8b7a; background: rgba(255, 111, 94, .13); border-color: rgba(255, 111, 94, .5); }
.es-chip.hint { color: var(--gold); background: rgba(244, 200, 79, .10); border-color: rgba(244, 200, 79, .4); }

@media (max-width: 900px) {
  .app { padding: 6px 8px 30px; gap: 8px; }
  header.topbar { padding: 7px 9px; gap: 8px; }
  .brand .logo { font-size: 20px; }
  .brand h1 { font-size: 15px; letter-spacing: .06em; }
  .brand .sub { font-size: 10px; }
  .modes button { padding: 8px 9px; font-size: 12px; }
  .modeblurb { font-size: 11.5px; }
  .betbar { gap: 6px 8px; }
  .betbar .pill { font-size: 10.5px; padding: 4px 7px; }
  .betbtns { margin-left: auto; }
  .betbtns button { padding: 8px 11px; }
  .betlabel { font-size: 10px; }
  .tablepick { width: 100%; white-space: nowrap; }
  .tablepick select { flex: 1 1 auto; min-width: 0; padding: 8px; font-size: 12px; }

  /* the machine leads: the legacy 820px block sets .tablepanel { order: 2 },
     which would otherwise bury it under the coach and pay table */
  .rail > * { order: 0; }
  .rail > .tablepanel { order: -1; }

  .rcard-h { padding: 7px 10px; font-size: 10.5px; }
  .rcard-b { padding: 10px; }
  .coach { max-height: 52vh; overflow-y: auto; }
  .verdict { font-size: 13px; padding: 8px 10px; }
  .verdict small { font-size: 11.5px; }
  .strip { gap: 4px 10px; margin-top: 7px; }
  .strip .es-chip { white-space: normal; line-height: 1.3; font-size: 12.5px; padding: 3px 9px; }

  .msgbar { margin: 14px 0 6px; font-size: 13px; }
  .msgbar small { font-size: 11.5px; }

  /* cards and the hold/draw row above the fold (wins over the 820px block) */
  .cards { gap: 6px; padding-top: 22px; }
  .card { width: min(84px, 17%); height: 116px; }
  .card .rk { font-size: clamp(15px, 4.6vw, 21px); }
  .card .st { font-size: clamp(12px, 3.8vw, 18px); }
  .card .pip { font-size: clamp(18px, 6vw, 28px); }
  .card.held { transform: translateY(-8px); }
  .card .heldtag { bottom: -17px; }
  .controls { margin-top: 16px; gap: 6px; }
  button.act { padding: 12px 8px; min-height: 46px; font-size: 13px; }
  .timerwrap { margin-top: 6px; }

  .tabs button { padding: 11px 2px; font-size: 12px; }
  .keys { display: none; }
  footer.foot { font-size: 10.5px; padding: 10px 2px 0; }
}

@media (max-width: 640px) {
  .brand .sub { display: none; }
  .card { height: 104px; }
  .modeblurb { display: none; }
}
