/* Cribbage UI. Only garden.css tokens; layout + cribbage-only states (board, pegs, pile, show stage). */

.cb-main { padding-block: 8px 16px; }
.cb-screen { animation: gg-rise var(--gg-dur-lg) var(--gg-ease-out) both; }
.cb-screen[hidden] { display: none; }
.cb-help-btn { font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-lg); }

/* ---------- start screen ---------- */
.cb-start { display: grid; gap: 28px; padding-top: 8px; }
.cb-start__copy { display: grid; gap: 18px; align-content: start; }
.cb-start__copy h1 { margin-top: -6px; }
.cb-start__copy .gg-lede { margin-top: -6px; }
.cb-field { display: grid; gap: 6px; }
.cb-field__label { font-weight: 700; font-size: var(--gg-text-sm); color: var(--gg-ink-2); }
.cb-field .gg-seg { width: 100%; }
.cb-field .gg-seg button { padding: 0 8px; }
.cb-how { padding: 16px 18px; display: grid; gap: 6px; box-shadow: var(--gg-shadow); }
.cb-how ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: var(--gg-text-sm); line-height: 1.4; color: var(--gg-ink-2); }
.cb-how li::marker { color: var(--gg-green-600); }
.cb-start__art { display: none; }
.cb-start__table { padding: 40px 28px 28px; transform: rotate(-1.5deg); display: grid; gap: 18px; justify-items: center; }
.cb-start__hand { display: flex; gap: 8px; --gg-card-w: clamp(64px, 6.4vw, 88px); }
.cb-start__hand .gg-card { box-shadow: 3px 3px 0 var(--gg-green-950); }
.cb-start__hand .gg-card:nth-child(1) { transform: rotate(-6deg) translateY(6px); }
.cb-start__hand .gg-card:nth-child(2) { transform: rotate(-2deg); }
.cb-start__hand .gg-card:nth-child(3) { transform: rotate(2deg); }
.cb-start__hand .gg-card:nth-child(4) { transform: rotate(6deg) translateY(6px); }
.cb-start__hand .cb-is-starter { margin-left: 12px; transform: rotate(3deg) translateY(-10px); }
.cb-start__caption { font-family: var(--gg-font-display); font-weight: 600; font-size: var(--gg-text-lg); text-align: center; color: var(--gg-cream); max-width: 30ch; }
.cb-start__caption b { color: var(--gg-ink); background: var(--gg-butter); padding: 0 8px; border-radius: var(--gg-r-pill); border: 2px solid var(--gg-ink); }

/* ---------- game screen (phone first) ---------- */
.cb-game { display: grid; gap: 8px; }
.cb-play { display: grid; gap: 8px; min-width: 0; }

/* score + board panel */
.cb-boardpanel {
  background: var(--gg-paper); border: var(--gg-border); border-radius: var(--gg-r-lg); box-shadow: var(--gg-shadow);
  padding: 4px 5px 4px; display: grid; gap: 0;
}
.cb-scores { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: 8px; padding: 2px 6px 0; }
.cb-who { display: flex; align-items: baseline; gap: 8px; min-width: 0; border-radius: var(--gg-r-pill); padding: 2px 8px; transition: background-color var(--gg-dur-md) ease; }
.cb-who--bot { justify-content: flex-end; }
.cb-who__name { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: var(--gg-text-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--gg-ink-3); }
.cb-who__num { font-family: var(--gg-font-display); font-weight: 800; font-size: 26px; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; display: inline-block; min-width: 1.6ch; }
.cb-who--bot .cb-who__num { text-align: right; order: -1; }
.cb-who--bot .cb-who__name { order: 0; }
.cb-who__sub { display: none; }
.cb-who.is-turn { background: var(--gg-butter-100); }
.cb-pegdot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--gg-ink); flex: none; display: inline-block; }
.cb-pegdot--you { background: var(--gg-lime); }
.cb-pegdot--bot { background: var(--gg-ink-2); }
.cb-handno { font-weight: 700; font-size: var(--gg-text-xs); color: var(--gg-ink-3); white-space: nowrap; }

/* the board */
.cb-board { display: grid; place-items: center; min-width: 0; }
.cb-board__svg { width: 100%; max-width: var(--w); height: auto; overflow: visible; }
.cb-track-edge { stroke: var(--gg-ink); }
.cb-track { stroke: var(--gg-sand); }
.cb-track-mid { stroke: rgba(17, 17, 17, .1); }
.cb-hole { fill: rgba(17, 17, 17, .42); }
.cb-hole--five { fill: rgba(17, 17, 17, .62); }
.cb-labels { fill: var(--gg-ink-3); font-family: var(--gg-font-body); font-weight: 700; font-variant-numeric: tabular-nums; }
.cb-skunk { stroke: var(--gg-ink); stroke-width: 2.4; stroke-dasharray: 3 2.4; stroke-linecap: round; }
.cb-skunk-label { fill: var(--gg-ink-2); font-style: italic; }
.cb-game-hole__ring { fill: var(--gg-butter); stroke: var(--gg-ink); stroke-width: 1.6; }
.cb-game-label { fill: var(--gg-ink); }
.cb-peg { transition: none; }
.cb-peg__head { stroke: var(--gg-ink); stroke-width: 1.5; }
.cb-peg--you .cb-peg__head { fill: var(--gg-lime); }
.cb-peg--bot .cb-peg__head { fill: var(--gg-ink-2); }
.cb-peg__shine { fill: rgba(255, 255, 255, .55); }
.cb-peg--bot .cb-peg__shine { fill: rgba(255, 255, 255, .3); }
.cb-peg__shadow { fill: rgba(17, 17, 17, .22); }
.cb-peg:not(.is-front) .cb-peg__head { opacity: .82; }

/* the green table: rows for the bot, the middle (deck, count, crib), the cards in play, your hand.
   The show stage sits over the first three rows, so your hand stays visible underneath. */
.cb-table.gg-table { padding: 8px 8px 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; row-gap: 4px; }
.cb-opp { grid-row: 1; grid-column: 1; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; }
.cb-opp__hand { display: flex; justify-content: center; --gg-card-w: 34px; min-height: calc(34px * 1.4); }
.cb-opp__hand .gg-card { box-shadow: 1.5px 1.5px 0 var(--gg-green-950); }
.cb-opp__hand .gg-card + .gg-card { margin-left: -18px; }
.cb-opp__tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: var(--gg-text-xs); letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 250, 240, .85); min-width: 72px; }
.cb-opp__tag.is-thinking { color: var(--gg-cream); }

.cb-mid { grid-row: 2; grid-column: 1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; --gg-card-w: 46px; }
.cb-deckwrap { display: flex; align-items: center; gap: 8px; justify-self: start; padding-left: 4px; }
.cb-deck {
  position: relative; width: calc(var(--gg-card-w) + 6px); height: calc(var(--gg-card-w) * 1.4 + 6px); padding: 0; border: 0; background: none;
  cursor: default; border-radius: 8px; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.cb-deck .gg-card { position: absolute; left: 0; bottom: 0; transform: translate(calc(var(--k, 0) * 2px), calc(var(--k, 0) * -2px)); box-shadow: 1.5px 1.5px 0 var(--gg-green-950); }
.cb-deck.is-target { cursor: pointer; }
.cb-deck.is-target::after {
  content: ""; position: absolute; inset: -7px -3px -3px -7px; border-radius: 12px; border: 3px solid var(--gg-lime);
  box-shadow: 0 0 0 2px var(--gg-ink); animation: cb-ring calc(1500ms * var(--gg-time)) ease-in-out infinite; pointer-events: none;
}
@keyframes cb-ring { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.06); opacity: .75; } }
.cb-startercol { display: grid; justify-items: center; gap: 4px; }
.cb-starter__tag { font-weight: 700; font-size: var(--gg-text-xs); line-height: 1.3; color: rgba(255, 250, 240, .8); white-space: nowrap; }
.cb-deckwrap { align-items: flex-start; }
.cb-starter { width: var(--gg-card-w); height: calc(var(--gg-card-w) * 1.4); border-radius: 7px; position: relative; }
.cb-starter.is-empty { border: 2px dashed rgba(255, 250, 240, .3); }
.cb-starter .gg-card { box-shadow: 2px 2px 0 var(--gg-green-950); }
.cb-starter.is-heels .gg-card { box-shadow: 0 0 0 3px var(--gg-butter), 2px 2px 0 var(--gg-green-950); }

.cb-count { display: grid; justify-items: center; line-height: 1; color: var(--gg-cream); min-width: 84px; transition: opacity var(--gg-dur-md) ease; opacity: .0; }
.cb-count.is-live { opacity: 1; }
.cb-count small { font-size: var(--gg-text-xs); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: rgba(255, 250, 240, .78); margin-bottom: 2px; }
.cb-count__num { font-family: var(--gg-font-display); font-weight: 800; font-size: 54px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; display: inline-block; }
.cb-count.is-hit .cb-count__num { color: var(--gg-butter); }

.cb-crib { justify-self: end; display: grid; justify-items: center; gap: 4px; padding-right: 4px; }
.cb-crib__stack { position: relative; width: calc(var(--gg-card-w) + 8px); height: calc(var(--gg-card-w) * 1.4 + 4px); border-radius: 8px; }
.cb-crib__stack:empty { border: 2px dashed rgba(255, 250, 240, .3); }
.cb-crib__stack .gg-card { position: absolute; left: 0; bottom: 0; transform: translate(calc(var(--k, 0) * 2.5px), calc(var(--k, 0) * -1.5px)) rotate(calc(var(--k, 0) * 2deg - 3deg)); box-shadow: 1.5px 1.5px 0 var(--gg-green-950); }
.cb-crib__tag { font-weight: 700; font-size: var(--gg-text-xs); white-space: nowrap; padding: 2px 9px; border-radius: var(--gg-r-pill); background: rgba(14, 44, 14, .4); color: var(--gg-cream); border: 1.5px solid rgba(255, 250, 240, .35); }
.cb-crib__tag.is-yours { background: var(--gg-butter); color: var(--gg-ink); border-color: var(--gg-ink); }

/* cards in the current count: bot's sit a little higher, yours a little lower */
.cb-pile { grid-row: 3; grid-column: 1; display: flex; justify-content: center; align-items: center; --gg-card-w: 50px; min-height: calc(50px * 1.4 + 42px); }
.cb-pile .gg-card { box-shadow: 2px 2px 0 var(--gg-green-950); }
.cb-pile .gg-card + .gg-card { margin-left: -20px; }
.cb-pile .gg-card.cb-by-bot { --y: -7px; --r: -2deg; }
.cb-pile .gg-card.cb-by-you { --y: 7px; --r: 2deg; }

/* your hand */
.cb-hand.gg-hand { grid-row: 4; grid-column: 1; --gg-card-w: 64px; padding: 20px 0 24px; min-height: calc(64px * 1.4 + 44px); }
.cb-hand .gg-card { box-shadow: 2px 2px 0 var(--gg-green-950); }
.cb-hand .gg-card.is-selected { box-shadow: 0 0 0 3px var(--gg-lime), 3px 5px 0 var(--gg-green-950); }

/* ---------- the show stage ---------- */
.cb-stage {
  grid-row: 1 / 4; grid-column: 1; z-index: 4; position: relative; align-self: stretch;
  display: grid; align-content: center; gap: 4px; padding: 6px 6px 8px; margin: 0 -2px;
  background: var(--gg-felt); background-color: var(--gg-green-700); border-radius: var(--gg-r-lg);
  border: 2px solid rgba(255, 250, 240, .18);
  --gg-card-w: 56px;
  cursor: pointer;
}
.cb-stage[hidden] { display: none; }
.cb-stage__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 6px; }
.cb-stage__title { font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-lg); color: var(--gg-cream); letter-spacing: -.01em; line-height: 1.15; }
.cb-stage__total { display: inline-flex; align-items: baseline; gap: 6px; color: var(--gg-cream); }
.cb-stage__total b { font-family: var(--gg-font-display); font-weight: 800; font-size: 34px; line-height: 1; color: var(--gg-butter); display: inline-block; font-variant-numeric: tabular-nums; }
.cb-stage__total small { font-size: var(--gg-text-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 250, 240, .78); }
.cb-stage__cards { display: flex; justify-content: center; align-items: flex-end; gap: 6px; padding: 12px 0 8px; min-height: calc(var(--gg-card-w) * 1.4 + 20px); }
.cb-stage__cards .gg-card { box-shadow: 2px 2px 0 var(--gg-green-950); }
.cb-starterwrap { position: relative; margin-left: 8px; display: grid; justify-items: center; }
.cb-starterwrap__tag { position: absolute; bottom: -9px; z-index: 70; font-size: var(--gg-text-xs); font-weight: 700; line-height: 1; padding: 2px 7px; border-radius: var(--gg-r-pill); background: var(--gg-green-900); color: var(--gg-cream); border: 1.5px solid rgba(255, 250, 240, .4); }
.cb-stage__say { font-family: var(--gg-font-display); font-weight: 600; font-size: var(--gg-text-md); line-height: 1.3; color: var(--gg-cream); text-align: center; min-height: 2.6em; padding: 0 4px; text-wrap: balance; margin-top: 2px; }
.cb-stage__say .gg-mark { color: var(--gg-ink); background: var(--gg-butter); border-radius: 6px; padding: 0 5px; }
.cb-stage__say b { color: var(--gg-butter); }
.cb-stage__say.is-long { font-size: var(--gg-text-sm); }
.cb-stage__headtext { display: grid; gap: 0; min-width: 0; }
.cb-stage__detail { font-size: var(--gg-text-sm); font-weight: 700; color: var(--gg-butter); min-height: 1.35em; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-stage__sum { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; min-height: 0; }
.cb-stage__sum:empty { display: none; }
.cb-chip { font-size: var(--gg-text-xs); font-weight: 700; padding: 3px 10px; border-radius: var(--gg-r-pill); background: rgba(14, 44, 14, .45); color: var(--gg-cream); white-space: nowrap; }
.cb-chip b { color: var(--gg-butter); }
.cb-chip.is-mine { background: var(--gg-paper); color: var(--gg-ink); border: 1.5px solid var(--gg-ink); }
.cb-chip.is-mine b { color: var(--gg-green-700); }
.cb-stage__skip { display: none; }
.cb-stage[data-mode="cutfor"] .cb-stage__cards { gap: 40px; padding-top: 4px; }
.cb-cutfor { display: grid; justify-items: center; gap: 6px; }
.cb-cutfor span { font-size: var(--gg-text-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 250, 240, .85); }

/* counting highlight: the combo lifts with a butter ring, the rest steps back */
.gg-card.cb-hl { --lift: 12px; box-shadow: 0 0 0 3px var(--gg-butter), 2px 4px 0 var(--gg-green-950) !important; z-index: 3; }
.gg-card.cb-dim::after { opacity: .62; }

/* ---------- prompt + controls ---------- */
.cb-prompt { min-height: 50px; padding-block: 6px; font-size: var(--gg-text-sm); }
.cb-controls { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.cb-controls__gap { flex: 1; }
.cb-action { min-width: 168px; }
.cb-action[hidden] { display: none; }
.cb-action.is-soft { opacity: .55; box-shadow: var(--gg-shadow-sm); }

/* the bot is thinking */
.cb-dots { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle; }
.cb-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: cb-dot calc(1050ms * var(--gg-time)) ease-in-out infinite; }
.cb-dots i:nth-child(2) { animation-delay: calc(150ms * var(--gg-time)); }
.cb-dots i:nth-child(3) { animation-delay: calc(300ms * var(--gg-time)); }
@keyframes cb-dot { 0%, 70%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-4px); opacity: 1; } }

/* result + rules */
.cb-badge__disc { fill: var(--gg-butter); }
.cb-badge--soft .cb-badge__disc { fill: var(--gg-sand); }
.cb-skunk-pill { margin: -6px 0 8px; }
.cb-skunk-pill[hidden] { display: none; }
.cb-record { margin-top: -8px; margin-bottom: 18px; font-size: var(--gg-text-sm); font-weight: 700; color: var(--gg-ink-3); }
.cb-rules { text-align: left; display: grid; gap: 14px; width: min(480px, 100%); }
.cb-rules__title { font-size: var(--gg-text-2xl); }
.cb-rules__list { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: var(--gg-text-sm); line-height: 1.45; color: var(--gg-ink-2); }
.cb-rules__list b { color: var(--gg-ink); }
.cb-rules__list li::marker { color: var(--gg-green-600); }
.cb-rules__actions { display: grid; gap: 4px; justify-items: center; }
.cb-rules__actions [hidden] { display: none; }

/* ---------- desktop: the long board beside the table ---------- */
@media (min-width: 900px) {
  .cb-main { padding-block: 20px 28px; }
  .cb-start { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 56px; padding-top: 24px; }
  .cb-start__copy { max-width: 480px; }
  .cb-start__art { display: block; }

  .cb-game { grid-template-columns: 252px minmax(0, 1fr); gap: 28px; align-items: start; }
  .cb-boardpanel { padding: 12px 8px 10px; position: sticky; top: 84px; }
  .cb-scores { grid-template-columns: 1fr 1fr; padding: 0 2px 6px; gap: 4px 6px; border-bottom: 2px solid var(--gg-line); margin-bottom: 6px; }
  .cb-scores__mid { grid-column: 1 / -1; grid-row: 2; text-align: center; line-height: 1.2; }
  .cb-who { flex-direction: column; align-items: flex-start; gap: 0; padding: 4px 10px 6px; border-radius: var(--gg-r-md); }
  .cb-who--bot { align-items: flex-end; }
  .cb-who--bot .cb-who__num { order: 0; }
  .cb-who__num { font-size: 36px; }
  .cb-who__sub { display: block; font-size: var(--gg-text-xs); font-weight: 600; color: var(--gg-ink-3); min-height: 1.3em; line-height: 1.3; }
  .cb-board__svg { width: auto; height: min(calc(var(--h, 690) * 1px), calc(100dvh - 268px)); max-width: 100%; }

  .cb-play { gap: 14px; }
  .cb-table.gg-table { padding: 16px 20px 4px; row-gap: 10px; }
  .cb-opp { min-height: 84px; }
  .cb-opp__hand { --gg-card-w: 54px; min-height: calc(54px * 1.4); }
  .cb-opp__hand .gg-card + .gg-card { margin-left: -26px; }
  .cb-mid { --gg-card-w: 70px; padding-inline: 8px; }
  .cb-count__num { font-size: 72px; }
  .cb-pile { --gg-card-w: 86px; min-height: calc(86px * 1.4 + 20px); }
  .cb-pile .gg-card + .gg-card { margin-left: -34px; }
  .cb-hand.gg-hand { --gg-card-w: 100px; padding: 30px 0 18px; min-height: calc(100px * 1.4 + 48px); }
  .cb-stage { --gg-card-w: 92px; gap: 10px; padding: 14px 16px; }
  .cb-stage__title { font-size: var(--gg-text-xl); }
  .cb-stage__total b { font-size: 44px; }
  .cb-stage__cards { gap: 12px; padding-top: 18px; }
  .cb-starterwrap { margin-left: 16px; }
  .cb-stage__say { font-size: var(--gg-text-xl); }
  .cb-prompt { font-size: var(--gg-text-md); }
  .cb-controls { min-height: 60px; }
  .cb-action { min-width: 200px; min-height: 56px; font-size: var(--gg-text-lg); }
}

/* short desktop windows: tighten the table a little */
@media (min-width: 900px) and (max-height: 860px) {
  .cb-hand.gg-hand { --gg-card-w: 90px; min-height: calc(90px * 1.4 + 44px); }
  .cb-pile { --gg-card-w: 76px; min-height: calc(76px * 1.4 + 16px); }
  .cb-opp { min-height: 74px; }
}
