:root {
  --bg: #0d1110;
  --surface: #161c1a;
  --surface-2: #1e2623;
  --border: #2b3632;
  --text: #eef2f0;
  --muted: #8d9c95;
  --accent: #3ecf8e;
  --felt: #1f6b49;
  --felt-dark: #0f3d29;
  --rail: #3a2618;
  --best: #3ecf8e;
  --correct: #a3d95b;
  --inaccuracy: #f0b429;
  --mistake: #ef5350;
  --spade: #262b31;
  --heart: #d33a3a;
  --diamond: #2d6bd3;
  /* Dark enough for white letters on small cards (5.4:1). */
  --club: #1f7a3a;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; }
button, select, input { font: inherit; color: inherit; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
kbd { font-size: 11px; padding: 0 5px; border-radius: 4px; border: 1px solid currentColor; opacity: 0.55; margin-left: 8px; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; }
.brand span { color: var(--accent); }
.spacer { flex: 1; }
.topbar select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; max-width: 260px;
}
.ghost {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; color: var(--muted);
}
.ghost:hover { color: var(--text); border-color: var(--muted); }
a.ghost { text-decoration: none; display: inline-flex; align-items: center; }
.upload-btn[hidden] { display: none; }
/* Account menu: your name; opens Admin panel (admins) and Sign out. */
.account { position: relative; }
.account summary { list-style: none; display: flex; align-items: center; gap: 6px; }
.account summary::-webkit-details-marker { display: none; }
.account summary::after { content: '▾'; font-size: 11px; }
.account-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 170px;
  display: flex; flex-direction: column; padding: 6px; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.account-menu.left { left: 0; right: auto; }
.account-menu a, .account-menu button {
  background: none; border: none; border-radius: 6px; padding: 8px 10px; text-align: left;
  color: var(--text); text-decoration: none; cursor: pointer; font: inherit; font-size: 14px;
}
.account-menu a:hover, .account-menu button:hover, .account-menu a:focus-visible, .account-menu button:focus-visible { background: var(--surface-2); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: none; padding: 6px 10px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-checked='true'] { background: var(--surface-2); color: var(--text); font-weight: 700; }
.toggle[aria-pressed='true'] { color: var(--text); border-color: var(--accent); }
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: var(--accent); color: #05281a; border: none; border-radius: 10px;
  padding: 10px 18px; font-weight: 700;
}

.notice { max-width: 1140px; margin: 12px auto 0; padding: 10px 14px; border-radius: 8px; background: var(--surface-2); }
.notice.error { box-shadow: inset 3px 0 var(--mistake); }

main { max-width: 1140px; margin: 0 auto; padding: 20px 16px 40px; }
.empty { text-align: center; padding: 60px 0; color: var(--muted); }
.empty h2 { color: var(--text); }

/* ---- table ---- */
.table {
  background: var(--rail); border-radius: 999px; padding: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.06);
}
.felt {
  position: relative; border-radius: 999px; aspect-ratio: 2 / 1.12;
  background: radial-gradient(ellipse at 50% 45%, var(--felt) 0%, var(--felt-dark) 100%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45);
}

.seat { position: absolute; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; z-index: 2; }
.seat.top { top: -6%; }
.seat.bottom { bottom: -6%; }
.plate {
  background: #111715; border: 2px solid #33423c; border-radius: 12px; padding: 4px 16px;
  display: flex; flex-direction: column; align-items: center; min-width: 110px; line-height: 1.2;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}
.seat.acting .plate { border-color: var(--accent); }
.plate .pos { font-weight: 700; font-size: 14px; }
.plate .stack { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dealer {
  position: absolute; left: -34px; width: 24px; height: 24px; border-radius: 50%;
  background: #f4f4f4; color: #222; font-size: 12px; font-weight: 800;
  display: grid; place-items: center; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
.dealer { bottom: 4px; z-index: 2; }

.hole { display: flex; gap: 4px; margin-bottom: -10px; }
.seat.bottom .hole { gap: 6px; }
.plate { position: relative; z-index: 1; }

.card {
  width: 30px; height: 42px; border-radius: 5px;
  background: repeating-linear-gradient(45deg, #7a1f2b 0 4px, #8d2733 4px 8px); border: 2px solid #f1e9e0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}
.card.face {
  width: 58px; height: 80px; border: none; color: #fff; font-weight: 700; line-height: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.card.face .r { font-size: 30px; }
.card.face .s { font-size: 20px; margin-top: 3px; }
.s-s { background: var(--spade); }
.s-h { background: var(--heart); }
.s-d { background: var(--diamond); }
.s-c { background: var(--club); }
.card.face.dealt { animation: deal 0.25s ease-out both; }
@keyframes deal { from { transform: translateY(12px); opacity: 0; } }

.bubble {
  position: absolute; white-space: nowrap; background: #f4f4f4; color: #1b1b1b;
  font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 999px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35); animation: pop 0.2s ease-out;
}
.seat.top .bubble { left: calc(100% + 12px); top: 50%; }
.seat.bottom .bubble { left: calc(100% + 12px); bottom: 50%; }
.bubble.fold { background: #5a5f63; color: #eee; }
.bubble.raise, .bubble.allin { background: #f0b429; }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } }

.bet {
  position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px;
  transition: top 0.35s ease, bottom 0.35s ease, opacity 0.35s ease; z-index: 1;
}
.bet.top { top: 30%; }
.bet.bottom { bottom: 30%; }
.bet .amt { font-weight: 700; font-size: 14px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); font-variant-numeric: tabular-nums; }
.chips { position: relative; width: 22px; height: 22px; }
.chips i {
  position: absolute; left: 0; width: 22px; height: 7px; border-radius: 50%;
  background: #e8b53b; border: 1px solid #8c6414; box-shadow: 0 1px 0 #8c6414;
}
.bet.pulse .chips { animation: slide 0.3s ease-out; }
@keyframes slide { from { transform: translateY(var(--from, 0)); opacity: 0.2; } }
.bet.top.pulse { --from: -30px; }
.bet.bottom.pulse { --from: 30px; }

.center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; }
.pot-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: #bfe0cf; opacity: 0.8; }
.pot-amt { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
/* How the hand ended ("Street ends: to the turn"), in the action row until the next hand. */
.hand-end { flex: 1 0 100%; text-align: center; color: var(--muted); font-size: 14px; font-weight: 600; align-self: center; }
.act.next { background: var(--accent); border-color: var(--accent); color: #05281a; flex: 0 1 220px; }
.act.next:hover:not(:disabled) { border-color: var(--text); }

/* ---- layout: table + actions left, feedback right; stacked (table, actions, feedback) on phones ---- */
.game {
  display: grid; gap: 18px 24px; align-items: start;
  grid-template-columns: minmax(0, 1fr) 310px;
  grid-template-areas: "table side" "actions side";
}
.table-area { grid-area: table; }
.actions { grid-area: actions; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 900px) {
  /* The action buttons right under the table, where they stay put while the feedback below them changes. */
  .game { grid-template-columns: 1fr; grid-template-areas: "table" "actions" "side"; }
  .side { display: contents; }
  .feedback { grid-area: side; }
  .side > .panel:not(.feedback) { grid-row: 4; }
  .recent { max-height: 180px; }
}


/* ---- actions ---- */
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 26px; min-height: 52px; }
.act {
  position: relative; min-width: 140px; flex: 1 1 0; max-width: 220px;
  padding: 13px 14px; border-radius: 12px; cursor: pointer; text-align: center;
  background: var(--surface-2); border: 2px solid var(--border); font-weight: 700; font-size: 16px;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}
.act:active:not(:disabled) { transform: scale(0.97); }
.act:hover:not(:disabled) { border-color: var(--muted); }
.act.fold { border-bottom-color: #6b7075; }
.act.call { border-bottom-color: var(--accent); }
.act.raise, .act.allin { border-bottom-color: var(--inaccuracy); }
.act:disabled { cursor: default; opacity: 0.5; }
.act.good { border-color: var(--best); background: rgba(62, 207, 142, 0.18); opacity: 1; }
.act.wrong { border-color: var(--mistake); background: rgba(239, 83, 80, 0.16); opacity: 0.7; animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---- side panels ---- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.panel h3 { margin: 0; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.link { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0; }
.link:hover { color: var(--text); }
.placeholder { color: var(--muted); margin: 0; font-size: 14px; }

.feedback { transition: border-color 0.2s; }
.feedback.bad { border-color: var(--mistake); }
.fb-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fb-title { width: 100%; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.fb-text.muted { color: var(--muted); font-size: 13px; }
.tag { font-weight: 800; padding: 2px 9px; border-radius: 999px; color: #0b1410; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.tag.best { background: var(--best); }
.tag.correct { background: var(--correct); }
.tag.inaccuracy { background: var(--inaccuracy); }
.tag.mistake { background: var(--mistake); }
.fb-spot { color: var(--muted); font-size: 13px; }
.fb-hand { display: flex; gap: 3px; margin: 10px 0 8px; }
.mini { width: 26px; height: 34px; border-radius: 4px; color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; line-height: 1; }
.fb-text { font-size: 14px; margin: 0 0 10px; }
.fb-text.prompt { color: var(--mistake); font-weight: 600; }
.bars { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; align-items: center; font-size: 13px; }
.bars .name { white-space: nowrap; }
.bars .name.chosen { font-weight: 700; }
.bars .track { height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; min-width: 40px; }
.bars .fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bars .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bars .num small { color: var(--muted); margin-left: 6px; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; }
.stats span { display: block; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats label { font-size: 11px; color: var(--muted); }
.recent { list-style: none; margin: 12px 0 0; padding: 0 6px; display: flex; flex-direction: column; gap: 5px; max-height: 240px; overflow-y: auto; overflow-x: hidden; }
.recent li { font-size: 12px; }
.recent-row {
  display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 3px 6px; margin: 0 -6px;
  background: none; border: none; border-radius: 6px; font: inherit; color: inherit; text-align: left;
  box-sizing: content-box;
}
button.recent-row { cursor: pointer; }
button.recent-row:hover { background: var(--surface-2); }
button.recent-row:hover .muted::after { content: ' ›'; }
.recent .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.recent .muted { color: var(--muted); white-space: nowrap; }

/* ---- solutions dialog ---- */
dialog {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; width: min(460px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h3 { margin: 0; }
.solutions { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 10px; }
.solutions li { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.solutions .meta { color: var(--muted); font-size: 12px; }
.solutions .meta.provenance { font-size: 11px; opacity: 0.85; overflow-wrap: anywhere; }
.solutions .none { color: var(--muted); }
.dialog-foot { display: flex; justify-content: space-between; align-items: center; }

@media (max-width: 560px) {
  .felt { aspect-ratio: 1 / 0.95; }
  .card.face { width: 46px; height: 64px; }
  .card.face .r { font-size: 24px; }
  .dealer { left: -30px; }
  .act { min-width: 0; font-size: 14px; padding: 12px 6px; white-space: nowrap; }
  .actions { gap: 8px; margin-top: 0; }
  .topbar select { max-width: 46vw; }
  /* Phones: the account buttons share the first row with the logo instead of taking a row of their own. */
  .topbar { gap: 8px; padding: 8px 12px; }
  .brand { order: 0; flex: 1; }
  #open-solutions, #account { order: 1; }
  #open-solutions, #account summary { padding: 5px 9px; font-size: 13px; }
  .account-name { max-width: 90px; }
  .topbar .spacer { display: none; }
  #mode { order: 2; }
  #solution, #spot, #position, #reveal, #auto-deal { order: 3; }
}
@media (hover: none) { .act kbd { display: none; } }

/* ---- browse ---- */
.muted { color: var(--muted); }
.browse { display: flex; flex-direction: column; gap: 14px; }
.br-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.br-path { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 14px; }
.br-path button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.br-path button:hover { color: var(--text); background: var(--surface-2); }
.br-path button[aria-current] { color: var(--text); font-weight: 700; cursor: default; background: none; }
.br-path .sep { color: var(--border); }
.br-top select, .br-tools select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}

.br-summary { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.br-actor { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.br-actor b { color: var(--text); }
.stack-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface-2); }
.stack-bar span { height: 100%; transition: width 0.25s; }
.br-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 14px; }
.br-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.br-legend b { font-variant-numeric: tabular-nums; }
.br-legend small { color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }

.br-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.br-filter { flex: 1 1 320px; display: flex; gap: 6px; }
.br-filter input {
  flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 14px;
}
.br-filter input:focus { outline: none; border-color: var(--accent); }
.br-filter input.invalid { border-color: var(--mistake); }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; cursor: pointer; }
.br-filterinfo { font-size: 13px; color: var(--muted); margin-top: -4px; }
.br-filterinfo.error { color: var(--mistake); }
.br-filterinfo b { color: var(--text); }

.br-cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 12px; overflow-x: auto; }
.br-col { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; min-width: 0; }
.br-col-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); border-top: 4px solid var(--col); border-radius: 12px 12px 0 0;
  background: none; border-left: none; border-right: none; text-align: left; width: 100%; font: inherit;
}
button.br-col-head { cursor: pointer; }
button.br-col-head:hover .go { color: var(--text); }
.br-col-head .name { font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px; font-size: 13px; }
.br-col-head .pct { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.br-col-head .go { color: var(--muted); font-size: 12px; margin-left: 4px; }
.br-rows { overflow-y: auto; max-height: 62vh; }
.br-row {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center;
  padding: 5px 12px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.br-row:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
.br-row .hand { display: flex; gap: 2px; }
.br-row .mini { width: 22px; height: 28px; font-size: 12px; }
.br-row .freq { text-align: right; font-weight: 600; }
.br-row .ev { text-align: right; color: var(--muted); min-width: 64px; }
.br-row .cmb { text-align: right; color: var(--muted); min-width: 22px; font-size: 12px; }
.br-row .bar { height: 4px; border-radius: 2px; background: var(--col); opacity: 0.8; }
.br-more { margin: 8px 12px 12px; }
.br-empty { padding: 14px 12px; color: var(--muted); font-size: 13px; }

.syntax { width: min(640px, calc(100vw - 32px)); }
.syntax table { width: 100%; border-collapse: collapse; font-size: 13px; }
.syntax th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; padding: 12px 0 4px; }
.syntax td { padding: 5px 8px 5px 0; vertical-align: top; border-top: 1px solid var(--border); }
.syntax td:first-child { white-space: nowrap; }
.syntax p { font-size: 13px; }

/* ---- browse: mini table ---- */
.br-overview { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: stretch; }
@media (max-width: 760px) { .br-overview { grid-template-columns: 1fr; } }
.br-game { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.mini-table {
  position: relative; aspect-ratio: 16 / 10; border-radius: 999px; border: 8px solid var(--rail);
  background: radial-gradient(ellipse at 50% 45%, var(--felt) 0%, var(--felt-dark) 100%);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.45);
}
.mt-seat {
  position: absolute; left: 50%; transform: translate(-50%, -50%); z-index: 2;
  background: #111715; border: 2px solid #33423c; border-radius: 10px; padding: 2px 10px;
  display: flex; flex-direction: column; align-items: center; line-height: 1.15; min-width: 74px;
}
.mt-seat.top { top: 0; }
.mt-seat.bottom { top: 100%; }
.mt-seat.acting { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(62, 207, 142, 0.2); }
.mt-seat.folded { opacity: 0.45; }
.mt-seat .pos { font-weight: 700; font-size: 12px; }
.mt-seat .stack { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mt-seat .btn {
  position: absolute; left: -24px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; border-radius: 50%;
  background: #f4f4f4; color: #222; font-size: 10px; font-weight: 800; display: grid; place-items: center;
}
.mt-bet { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mt-bet.top { top: 17%; }
.mt-bet.bottom { bottom: 17%; }
.mt-bet small { font-weight: 500; opacity: 0.75; }
.mt-bet .chip { width: 14px; height: 14px; border-radius: 50%; background: #e8b53b; border: 2px dashed #8c6414; }
.mt-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mt-board { display: flex; gap: 3px; }
.mt-board .slot { width: 20px; height: 27px; border-radius: 4px; border: 1px dashed rgba(255, 255, 255, 0.22); }
.mt-board .mini { width: 20px; height: 27px; font-size: 11px; }
.mt-pot { font-size: 12px; font-weight: 700; background: rgba(0, 0, 0, 0.35); padding: 1px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.mt-street { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; color: #bfe0cf; opacity: 0.75; }
.br-line { font-size: 13px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 10px; }
.br-line b { color: var(--text); }
.br-line .arrow { margin: 0 6px; opacity: 0.6; }

/* ---- library picker ---- */
.library { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.lib-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lib-row .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); width: 56px; }
.chip-btn {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px;
  cursor: pointer; font-size: 13px; color: var(--text);
}
.chip-btn:hover { border-color: var(--muted); }
.chip-btn[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: #05281a; font-weight: 700; }
.chip-btn.empty { color: var(--muted); }
.chip-btn .n { margin-left: 6px; font-size: 11px; opacity: 0.7; font-variant-numeric: tabular-nums; }
.chip-btn.folder::before { content: '📁 '; }
.lib-list { display: flex; flex-wrap: wrap; gap: 8px; }
.lib-sol {
  display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 10px; cursor: pointer; font-size: 13px; color: var(--text); text-align: left;
}
.lib-sol:hover { border-color: var(--muted); }
.lib-sol[aria-current='true'] { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(62, 207, 142, 0.2); }
.lib-sol .where { color: var(--muted); font-size: 11px; }
.lib-sol .mini { width: 18px; height: 24px; font-size: 10px; }
.lib-sol .board { display: flex; gap: 2px; }
.lib-empty { color: var(--muted); font-size: 13px; }

/* ---- solutions dialog: edit form ---- */
.sol-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; width: 100%; }
.sol-edit label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.sol-edit .wide { grid-column: 1 / -1; }
.sol-edit input, .sol-edit select { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; color: var(--text); }
.sol-edit .row-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.sol-edit .err { color: var(--mistake); font-size: 12px; margin-right: auto; }
.solutions li { flex-wrap: wrap; }
.solutions .btns { display: flex; gap: 6px; }
.primary-btn.small { padding: 6px 12px; font-size: 13px; }

/* ---- several bet sizes ---- */
.act-group {
  display: flex; flex-direction: column; gap: 6px; padding: 6px; cursor: default;
  flex: 3 1 0; max-width: 480px; border-bottom-color: var(--inaccuracy);
}
.act-group:hover { border-color: var(--border); border-bottom-color: var(--inaccuracy); }
.grp-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); font-weight: 700; }
.grp-sizes { display: flex; gap: 4px; }
.act-size {
  flex: 1 1 0; min-width: 0; padding: 8px 4px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 15px;
  background: var(--bg); border: 2px solid var(--border); white-space: nowrap;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}
.act-size:hover:not(:disabled) { border-color: var(--muted); }
.act-size:active:not(:disabled) { transform: scale(0.97); }
.act-size kbd { margin-left: 4px; font-size: 10px; padding: 0 3px; }
.act-size:disabled { cursor: default; opacity: 0.5; }
.act-size.good { border-color: var(--best); background: rgba(62, 207, 142, 0.18); opacity: 1; }
.act-size.wrong { border-color: var(--mistake); background: rgba(239, 83, 80, 0.16); opacity: 0.7; animation: shake 0.3s; }
@media (hover: none) { .act-size kbd { display: none; } }

.br-col-head .name small.sizes { display: block; font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); margin-top: 2px; }
.br-row .bar.mix { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: rgba(255, 255, 255, 0.06); opacity: 1; width: 100%; }
.br-row .bar.mix span { height: 100%; }
#br-sizes button { font-size: 13px; }

/* ---- board on the trainer table ---- */
.board { display: flex; gap: 5px; justify-content: center; margin-bottom: 8px; }
.board .card.face { width: 44px; height: 60px; }
.board .card.face .r { font-size: 22px; }
.board .card.face .s { font-size: 15px; }
@media (max-width: 560px) { .board .card.face { width: 34px; height: 48px; } .board .card.face .r { font-size: 17px; } }

/* ---- relative EVs ---- */
.ev-pos { color: var(--best) !important; }
.ev-neg { color: #e7837f !important; }

/* ---- browser: action buttons to step through the tree ---- */
.br-nav { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }
.br-nav .act { min-width: 0; flex: 1 1 auto; max-width: none; padding: 8px 10px; font-size: 13px; border-radius: 10px; }
.br-nav .act.back { flex: 0 0 auto; color: var(--muted); font-weight: 600; }
.br-nav .act-group { flex: 2 1 auto; padding: 4px 6px 6px; gap: 4px; }
.br-nav .grp-title { font-size: 10px; }
.br-nav .act-size { padding: 6px 4px; font-size: 13px; }
.br-nav .act:disabled, .br-nav .act-size:disabled { opacity: 0.4; }

/* ---- upload progress and results ---- */
.upload-status { max-width: 1140px; margin: 12px auto 0; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.upload-status.error { border-color: var(--mistake); }
.upload-status .ghost { align-self: flex-end; padding: 4px 10px; font-size: 13px; }
.up-text { font-size: 14px; font-weight: 600; }
.up-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.up-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.up-fill.busy { animation: up-pulse 1.2s ease-in-out infinite; }
@keyframes up-pulse { 50% { opacity: 0.45; } }
.up-list { margin: 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.up-list .ok { color: var(--best); }
.up-list .skip { color: var(--muted); }
.up-list .err { color: #e7837f; }

/* ---- password and sign-ins ---- */
.stack-form { display: flex; flex-direction: column; gap: 10px; }
.stack-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.stack-form input { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; color: var(--text); }
.stack-form p { margin: 0; }
.stack-form .row-actions { display: flex; justify-content: flex-end; }
.form-msg { font-size: 13px; min-height: 1em; }
.form-msg.ok { color: var(--best); }
.form-msg.err { color: #e7837f; }

/* Read by screen readers, not shown. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Keyboard focus is always visible, also inside the segmented controls (which clip what sticks out). */
:focus-visible { outline: 3px solid #88cfff; outline-offset: 2px; }
.seg button:focus-visible, .br-path button:focus-visible { outline-offset: -3px; }
.br-filter input:focus-visible { outline: none; }

/* Less motion when the system asks for it: no dealing, shaking or pulsing. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Touch screens: controls at least 36px tall, so they can be hit with a thumb (desktop layout unchanged). */
@media (pointer: coarse) {
  .ghost, .seg button, .chip-btn, .br-path button, button.recent-row, .primary-btn.small, .account-menu a, .account-menu button { min-height: 36px; }
  .check { min-height: 36px; }
  .check input { width: 18px; height: 18px; }
  .link { min-height: 36px; padding: 0 8px; margin-right: -8px; }
  .lb-scoring summary { padding: 8px 0; }
}
