/* Create By Asking: cribbage calculator (projects/cribbage-calculator.html).
   Loaded after style.css and tools.css; reuses the dark .tool-shell look. Prefix cb-.
   style.css switches off every animation and transition under prefers-reduced-motion. The owner wants
   the small ones here to keep playing, so the few transitions below are marked !important (which, with
   a more specific selector, wins over the site-wide rule) and the card animations use element.animate(). */

.cb { --gold: #FFC93C; --pink: #FF5C99; --soft: #CBBFE8; --dim: #A597CC; --panel: rgba(255, 255, 255, 0.05); --line2: rgba(255, 255, 255, 0.1);
  --card-red: #D3243C; --card-ink: #1C0F3F; scroll-margin-top: 84px; gap: 16px; }
.cb > * { min-width: 0; }
:where(.cb) button { -webkit-tap-highlight-color: transparent; font: inherit; }
.cb button:focus-visible, .cb input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.cb .tool-note { margin: 0; }

/* ---------- mode tabs ---------- */
.cb-top { display: flex; }
.cb-tabs { display: flex; gap: 4px; padding: 4px; background: rgba(255, 255, 255, 0.07); border-radius: 999px; max-width: 100%; }
.cb-tabs button { border: 0; border-radius: 999px; padding: 10px 18px; min-height: 44px; background: none; color: var(--soft); font: 700 1.02rem/1.1 var(--display); cursor: pointer; white-space: nowrap; }
.cb-tabs button:hover { color: #fff; }
.cb-tabs button[aria-selected="true"] { background: var(--gold); color: #1C0F3F; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }

.cb-body { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 18px 24px; align-items: start; }
.cb-left { display: grid; gap: 12px; min-width: 0; container-type: inline-size; }
.cb-right { min-width: 0; background: var(--panel); border-radius: 16px; padding: clamp(14px, 2.4vw, 20px); display: grid; gap: 12px; align-content: start; }

/* ---------- the felt table ---------- */
.cb-felt {
  position: relative; border-radius: 18px; padding: clamp(12px, 2.6vw, 20px) clamp(10px, 2.4vw, 20px) clamp(12px, 2.2vw, 16px);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.10), transparent 60%),
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.035) 0 2px, transparent 2px 5px),
    radial-gradient(circle at 50% 30%, #2C7A57, #1A4D37 70%, #133B2A);
  box-shadow: inset 0 0 0 1px rgba(255, 201, 60, 0.22), inset 0 0 0 7px rgba(0, 0, 0, 0.12), inset 0 4px 18px rgba(0, 0, 0, 0.45), 0 18px 40px -26px rgba(0, 0, 0, 0.9);
  display: grid; gap: 14px;
}
.cb-slots { display: flex; justify-content: center; align-items: flex-end; gap: clamp(10px, 3vw, 22px); }
.cb-group { display: grid; gap: 14px; justify-items: center; min-width: 0; }
.cb-glabel { font: 600 0.66rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: rgba(236, 255, 244, 0.72); }
.cb-row { display: flex; gap: clamp(5px, 1.4vw, 9px); }
.cb-g-cut { padding-left: clamp(10px, 3vw, 22px); border-left: 1px dashed rgba(255, 255, 255, 0.18); }

.cb-slot { --w: clamp(42px, 12.8vw, 76px); --w: clamp(40px, 15.5cqi, 76px); width: var(--w); aspect-ratio: 5 / 7; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 9px; position: relative; display: block; }
.cb-felt[data-mode="keep"] .cb-slot { --w: clamp(36px, 11.2vw, 66px); --w: clamp(34px, 13.5cqi, 66px); }
.cb-empty { position: absolute; inset: 0; border-radius: 9px; border: 2px dashed rgba(255, 255, 255, 0.26); display: grid; place-items: center; color: rgba(255, 255, 255, 0.45); font: 700 0.9rem/1 var(--display); background: rgba(0, 0, 0, 0.12); }
.cb-slot:hover .cb-empty { border-color: rgba(255, 255, 255, 0.5); }
.cb-slot.is-active .cb-empty { border: 2px solid var(--gold); color: var(--gold); background: rgba(255, 201, 60, 0.1); animation: cb-pulse 1.6s ease-in-out infinite !important; }
@keyframes cb-pulse { 50% { box-shadow: 0 0 0 5px rgba(255, 201, 60, 0.18); } }
.cb-slot.is-active.is-full .cb-card { box-shadow: 0 0 0 3px var(--gold), 0 10px 18px -6px rgba(0, 0, 0, 0.6); transform: translateY(-5px); }

/* a playing card, drawn with CSS */
.cb-card {
  position: absolute; inset: 0; border-radius: 9px; color: var(--card-ink); overflow: hidden;
  background: linear-gradient(160deg, #FFFFFF 0%, #FBF7EE 70%, #F1EADB 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 0 0 1px rgba(0, 0, 0, 0.08), 0 6px 12px -5px rgba(0, 0, 0, 0.55);
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease !important;
}
.cb-card.is-red { color: var(--card-red); }
.cb-ix { position: absolute; left: 8%; top: 5%; display: grid; justify-items: center; line-height: 0.95; }
.cb-ix b { font: 800 calc(var(--w) * 0.27)/1 var(--display); letter-spacing: -0.04em; }
.cb-ix i { font-style: normal; font-size: calc(var(--w) * 0.22); line-height: 1; }
.cb-ix2 { left: auto; top: auto; right: 8%; bottom: 5%; transform: rotate(180deg); }
.cb-pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--w) * 0.5); line-height: 1; padding-top: 4%; }
.cb-card.is-face .cb-pip { font-size: calc(var(--w) * 0.24); align-content: center; gap: 0; }
.cb-card.is-face .cb-pip b { font: 800 calc(var(--w) * 0.4)/0.9 var(--display); }
.cb-card.is-face::after { content: ""; position: absolute; inset: 14% 22%; border-radius: 5px; border: 1.5px solid currentColor; opacity: 0.18; }
@media (max-width: 420px) { .cb-ix2 { display: none; } }

/* highlighting cards for a breakdown line */
.cb-felt.is-focus .cb-card { opacity: 0.32; filter: saturate(0.4); }
.cb-felt.is-focus .cb-card.is-lit { opacity: 1; filter: none; transform: translateY(-8px); box-shadow: 0 0 0 3px var(--gold), 0 14px 20px -8px rgba(0, 0, 0, 0.7); }
.cb-felt.is-focus .cb-card.is-thrown { opacity: 0.55; filter: saturate(0.5); transform: translateY(6px) rotate(-3deg); }

/* the tally on the felt */
.cb-tally { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: center; min-height: 52px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.cb-tally-empty { margin: 0; color: rgba(236, 255, 244, 0.8); font-size: var(--step--1); text-align: center; }
.cb-total { display: flex; align-items: center; gap: 10px; }
.cb-total strong { font: 800 clamp(2.5rem, 9vw, 3.3rem)/0.9 var(--display); color: #fff; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); display: inline-block; min-width: 1.2ch; text-align: right; }
.cb-total > span { display: grid; color: #fff; font: 700 1rem/1.1 var(--display); }
.cb-total small { font: 500 0.75rem/1.2 var(--body); color: rgba(236, 255, 244, 0.75); }
.cb-total.is-part strong { color: rgba(255, 255, 255, 0.65); }
.cb-chips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.cb-chip { font: 600 0.72rem/1 var(--mono); padding: 6px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.2); color: rgba(255, 255, 255, 0.5); }
.cb-chip b { color: rgba(255, 255, 255, 0.6); }
.cb-chip.is-on { background: rgba(255, 201, 60, 0.18); color: #FFE7A6; }
.cb-chip.is-on b { color: var(--gold); }
.cb-best { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 6px; font: 700 0.95rem/1 var(--display); color: #fff; }
.cb-best > span { margin: 0 2px; }
.cb-best .cb-mc { font-size: 1rem; }
.cb-best-sub { margin: 0; width: 100%; text-align: center; font-size: 0.78rem; color: rgba(236, 255, 244, 0.78); }

/* ---------- options row ---------- */
.cb-opts { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.cb-opts-btns { display: flex; gap: 6px; margin-left: auto; }
.cb-opts-note { color: var(--dim); font-size: 0.82rem; }
.cb-btn { display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 12px; min-height: 44px; padding: 8px 14px; background: rgba(255, 255, 255, 0.08); color: #fff; font: 600 0.88rem/1 var(--body); cursor: pointer; }
.cb-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cb-btn circle { fill: currentColor; stroke: none; }
.cb-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
.cb-btn:disabled { opacity: 0.35; cursor: default; }
.cb-btn[data-random] { background: var(--gold); color: #1C0F3F; }
.cb-btn[data-random]:hover { background: #FFD65F; }

.cb-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: #fff; font-weight: 600; font-size: 0.92rem; min-height: 44px; }
.cb-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cb-sw { width: 44px; height: 26px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); position: relative; flex: none; transition: background 0.2s !important; }
.cb-sw::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); transition: transform 0.2s cubic-bezier(.3, 1.4, .5, 1) !important; }
.cb-switch input:checked + .cb-sw { background: var(--gold); }
.cb-switch input:checked + .cb-sw::after { transform: translateX(18px); }
.cb-switch input:focus-visible + .cb-sw { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- picker ---------- */
.cb-picker { display: grid; gap: 8px; background: var(--panel); border-radius: 16px; padding: 12px; }
.cb-h { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.cb-h > span { font: 600 0.68rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.cb-h small { font-size: 0.82rem; color: var(--soft); }
.cb-ranks { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 5px; }
.cb-rank { border: 0; min-height: 46px; padding: 0; border-radius: 10px; background: rgba(255, 255, 255, 0.92); color: var(--card-ink); font: 800 1.05rem/1 var(--display); cursor: pointer; box-shadow: inset 0 -3px 0 rgba(28, 15, 63, 0.14); transition: transform 0.12s, background 0.12s !important; letter-spacing: -0.03em; }
@media (hover: hover) { .cb-rank:hover:not(:disabled) { background: #fff; transform: translateY(-2px); } }
.cb-rank:active:not(:disabled) { transform: scale(0.93); }
.cb-rank.is-on { background: var(--gold); box-shadow: 0 0 0 2px #fff, inset 0 -3px 0 rgba(0, 0, 0, 0.18); }
.cb-rank:disabled, .cb-suit:disabled { opacity: 0.25; cursor: default; }
.cb-suits { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.cb-suit { border: 0; min-height: 52px; border-radius: 12px; background: rgba(255, 255, 255, 0.92); color: var(--card-ink); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; box-shadow: inset 0 -3px 0 rgba(28, 15, 63, 0.14); transition: transform 0.12s, background 0.12s !important; }
.cb-suit.is-red { color: var(--card-red); }
.cb-suit i { font-style: normal; font-size: 1.6rem; line-height: 1; }
.cb-suit b { font: 800 1.2rem/1 var(--display); letter-spacing: -0.03em; }
.cb-suit small { font: 600 0.72rem/1 var(--body); color: #5F5580; }
@media (hover: hover) { .cb-suit:hover:not(:disabled) { background: #fff; transform: translateY(-2px); } }
.cb-suit:active:not(:disabled) { transform: scale(0.95); }
.cb-suit.is-on { background: var(--gold); }
.cb-type { display: grid; gap: 6px; margin-top: 4px; }
.cb-type span { font: 600 0.68rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.tool-shell .cb-type input { width: 100%; min-height: 46px; font: 600 1rem/1.2 var(--mono); letter-spacing: 0.02em; }
.tool-shell .cb-type input::placeholder { font: 400 0.8rem/1.2 var(--body); }
.cb-msg { margin: 0; min-height: 1.3em; font-size: 0.82rem; color: #9FE8C6; }
.cb-msg.is-err { color: #FFB4A6; }

/* ---------- results ---------- */
.cb-res-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cb-res-h h3 { font-size: var(--step-1); margin: 0; }
.cb-res-t { color: var(--soft); font-size: 0.9rem; }
.cb-res-t b { color: var(--gold); font: 800 1.3rem/1 var(--display); }
.cb-empty-msg { margin: 0; color: var(--soft); font-size: 0.92rem; line-height: 1.55; }
.cb-empty-msg b { color: #fff; font-family: var(--mono); font-size: 0.85rem; }
.cb-warn { margin: 0; padding: 9px 12px; border-radius: 10px; background: rgba(255, 201, 60, 0.1); color: #FFE7A6; font-size: 0.85rem; }

.cb-grp { display: grid; gap: 4px; }
.cb-grp-h { margin: 0; display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 4px; border-bottom: 1px solid var(--line2); }
.cb-grp-h span { font: 600 0.7rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.cb-grp-h b { font: 800 1.05rem/1 var(--display); color: #fff; }
.cb-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cb-line { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto 34px; gap: 8px; align-items: center; border: 0; text-align: left; padding: 7px 8px; min-height: 42px; border-radius: 10px; background: none; color: #fff; cursor: pointer; transition: background 0.12s !important; }
.cb-line:hover, .cb-line:focus-visible { background: rgba(255, 255, 255, 0.07); }
.cb-line[aria-pressed="true"] { background: rgba(255, 201, 60, 0.14); box-shadow: inset 0 0 0 1.5px rgba(255, 201, 60, 0.5); }
.cb-line-l { display: grid; font-weight: 600; font-size: 0.92rem; line-height: 1.25; }
.cb-line-l small { font-weight: 400; color: var(--dim); font-size: 0.75rem; }
.cb-line-c { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; }
.cb-line > b { font: 800 0.95rem/1 var(--display); color: var(--gold); text-align: right; }

.cb-mc { display: inline-flex; align-items: center; gap: 1px; padding: 3px 5px; border-radius: 5px; background: #FBF7EE; color: var(--card-ink); font: 800 0.82rem/1 var(--display); letter-spacing: -0.03em; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); white-space: nowrap; }
.cb-mc i { font-style: normal; font-size: 0.9em; letter-spacing: 0; }
.cb-mc.is-red { color: var(--card-red); }

.cb-none { margin: 0; color: var(--dim); font-size: 0.84rem; }
.cb-say { margin: 0; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); color: #fff; font-size: 0.9rem; line-height: 1.5; font-style: italic; }
.cb-say span { display: block; font: 600 0.66rem/1.4 var(--mono); font-style: normal; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.cb-notes { display: grid; gap: 6px; }
.cb-notes p { margin: 0; padding: 9px 12px; border-radius: 10px; background: rgba(255, 92, 153, 0.1); color: #FFD6E6; font-size: 0.84rem; line-height: 1.45; }
.cb-notes b { color: #fff; }
.cb-fine { margin: 0; color: var(--dim); font-size: 0.78rem; line-height: 1.5; }
.cb-fine b { color: var(--soft); }

/* ---------- keep helper ---------- */
.cb-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cb-tile { display: grid; gap: 8px; text-align: left; border: 0; border-radius: 14px; padding: 12px; background: rgba(255, 255, 255, 0.06); color: #fff; cursor: pointer; box-shadow: inset 0 0 0 1.5px transparent; transition: background 0.15s, box-shadow 0.15s !important; }
.cb-tile:hover { background: rgba(255, 255, 255, 0.1); }
.cb-tile.is-on { background: rgba(255, 201, 60, 0.12); box-shadow: inset 0 0 0 1.5px var(--gold); }
.cb-tile-h { font: 600 0.66rem/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.cb-tile.is-on .cb-tile-h { color: var(--gold); }
.cb-tile-cards { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cb-tile-k, .cb-tile-t, .cb-opt-k, .cb-opt-t { display: inline-flex; gap: 3px; }
.cb-tile-t, .cb-opt-t { opacity: 0.6; position: relative; padding-left: 9px; }
.cb-tile-t::before, .cb-opt-t::before { content: "\2192"; position: absolute; left: -2px; top: 50%; transform: translateY(-50%); font-size: 0.75rem; color: var(--dim); }
.cb-tile-t .cb-mc, .cb-opt-t .cb-mc { background: #D9D2C3; }
.cb-tile-f { font-size: 0.8rem; color: var(--soft); }
.cb-tile-f b { color: #fff; font: 800 1rem/1 var(--display); }
.cb-rank-h { margin: 4px 0 0; font: 600 0.68rem/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.cb-opts-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.cb-opt { width: 100%; display: grid; grid-template-columns: 22px auto minmax(0, 1fr); gap: 6px 10px; align-items: center; text-align: left; border: 0; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); color: #fff; cursor: pointer; transition: background 0.12s !important; }
.cb-opt:hover { background: rgba(255, 255, 255, 0.08); }
.cb-opt.is-best { background: rgba(255, 201, 60, 0.1); }
.cb-opt[aria-pressed="true"] { box-shadow: inset 0 0 0 1.5px var(--gold); background: rgba(255, 201, 60, 0.16); }
.cb-opt-n { font: 800 0.9rem/1 var(--display); color: var(--dim); text-align: center; }
.cb-opt.is-best .cb-opt-n { color: var(--gold); }
.cb-opt-cards { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cb-opt-s { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; justify-self: end; text-align: right; min-width: 0; width: 100%; max-width: 250px; }
.cb-opt-s > span { display: grid; line-height: 1.1; }
.cb-opt-s b { font: 700 0.92rem/1.1 var(--display); font-variant-numeric: tabular-nums; }
.cb-opt-s small { font-size: 0.64rem; color: var(--dim); white-space: nowrap; }
.cb-opt-net b { color: var(--gold); font-size: 1.02rem; }
.cb-more { justify-self: start; border: 0; background: none; color: var(--soft); font: 600 0.88rem/1.2 var(--body); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 8px 2px; }
.cb-more:hover { color: #fff; }

/* ---------- smaller screens ---------- */
@media (max-width: 1100px) and (min-width: 860px) {
  .cb-opt { grid-template-columns: 22px minmax(0, 1fr); }
  .cb-opt-s { grid-column: 2; justify-self: stretch; max-width: none; }
}
@media (max-width: 859px) {
  .cb-body { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .cb-tabs { width: 100%; }
  .cb-tabs button { flex: 1 1 0; padding: 10px 8px; font-size: 0.95rem; }
  .cb-ranks { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cb-rank { min-height: 44px; }
  .cb-suit small { display: none; }
  .cb-suit i { font-size: 1.7rem; }
  .cb-picker { padding: 10px; }
  .cb-opts-btns { margin-left: 0; flex: 1 1 auto; }
  .cb-opts-btns .cb-btn { flex: 1 1 0; justify-content: center; }
  .cb-felt[data-mode="score"] .cb-opts-btns { flex: 0 1 auto; }
  .cb-tiles { grid-template-columns: 1fr; }
  .cb-opt { grid-template-columns: 22px minmax(0, 1fr); }
  .cb-opt-s { grid-column: 2; justify-self: stretch; max-width: none; text-align: left; }
  .cb-line { grid-template-columns: minmax(0, 1fr) auto 28px; padding: 7px 6px; }
  .cb-line-c .cb-mc { padding: 3px 4px; }
  .cb-best { gap: 4px; font-size: 0.88rem; }
  .cb-best .cb-mc { font-size: 0.88rem; padding: 3px 4px; }
}

/* ---------- the scoring table in the guide ---------- */
.cb-ref-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.cb-ref { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.cb-ref th, .cb-ref td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.cb-ref thead th { font: 600 0.7rem/1.2 var(--mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.cb-ref tbody th { font-weight: 600; white-space: nowrap; }
.cb-ref td:nth-child(2) { font-weight: 700; white-space: nowrap; }
.cb-ref tbody tr:last-child th, .cb-ref tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 600px) { .cb-ref th, .cb-ref td { padding: 8px 10px; } .cb-ref tbody th { white-space: normal; } }
