/* Gin Rummy UI. Only garden.css tokens; layout + a few gin-only states. */

.gr-main { padding-block: 10px 28px; }
.gr-screen { animation: gg-rise var(--gg-dur-lg) var(--gg-ease-out) both; }
.gr-screen[hidden] { display: none; }
.gr-help-btn { font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-lg); }
.gr-suit-r { color: var(--gg-suit-red); }

/* ---------- start screen ---------- */
.gr-start { display: grid; gap: 28px; padding-top: 8px; }
.gr-start__copy { display: grid; gap: 18px; align-content: start; }
.gr-start__copy h1 { margin-top: -6px; }
.gr-start__copy .gg-lede { margin-top: -6px; }
.gr-field { display: grid; gap: 6px; }
.gr-field__label { font-weight: 700; font-size: var(--gg-text-sm); color: var(--gg-ink-2); }
.gr-field__hint { font-size: var(--gg-text-sm); color: var(--gg-ink-3); min-height: 1.4em; line-height: 1.4; }
.gr-field .gg-seg { width: 100%; }
.gr-field .gg-seg button { padding: 0 8px; }
.gr-how { padding: 16px 18px; display: grid; gap: 6px; box-shadow: var(--gg-shadow); }
.gr-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); }
.gr-how li::marker { color: var(--gg-green-600); }
.gr-start__art { display: none; }

/* ---------- game screen (phone first) ---------- */
.gr-game { display: grid; gap: 10px; }
.gr-side { display: contents; }

.gr-handinfo__won { font-weight: 600; color: rgba(255, 250, 240, .72); margin-top: 2px; }
.gr-goal { display: block; position: relative; width: 100%; height: 8px; margin-top: 6px; border: 2px solid var(--gg-ink); border-radius: var(--gg-r-pill); background: var(--gg-sand); overflow: hidden; }
.gr-goal > i { position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); background: var(--gg-green-600); transition: width var(--gg-dur-xl) var(--gg-ease-out); }
.gr-sheet__score + .gr-sheet__score .gr-goal > i { inset: 0 0 0 auto; }

/* the lawn: bot row, piles, your hand */
.gr-table {
  --gg-card-w: 64px;
  margin-inline: -10px;
  padding: 10px 3px 8px; border-radius: var(--gg-r-lg);
  display: grid; gap: 4px;
}
.gr-botrow { display: grid; gap: 2px; padding-inline: 11px; }
.gr-botrow__body { display: flex; align-items: flex-end; justify-content: center; gap: 10px; min-width: 0; }
.gr-botrow__body > .gr-bothand { flex: 1 1 auto; min-width: 0; margin-inline: 0; }
/* what the bot picked up from the pile: public, so it gets its own readable row */
.gr-took { flex: none; display: flex; align-items: center; gap: 6px; padding: 4px 6px 6px 8px; margin-bottom: 2px; border-radius: var(--gg-r-sm); background: rgba(14, 44, 14, .28); }
.gr-took[hidden] { display: none; }
.gr-took__label { font-weight: 700; font-size: var(--gg-text-xs); letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 250, 240, .86); line-height: 1.2; }
.gr-took__cards { display: flex; --gg-card-w: 40px; }
.gr-took__cards > .gg-card { box-shadow: 0 0 0 2px var(--gg-butter), 1.5px 1.5px 0 rgba(14, 44, 14, .85); border-width: 1.2px; }
.gr-took__cards > .gg-card + .gg-card { margin-left: -12px; }

.gr-botrow__head { display: flex; align-items: baseline; gap: 10px; min-height: 20px; }
.gr-botrow__sub { font-size: var(--gg-text-xs); font-weight: 700; color: rgba(255, 250, 240, .86); }
.gr-bothand {
  --gg-card-w: 40px;
  max-width: 300px; margin-inline: auto; padding: 4px 0 6px; min-height: calc(var(--gg-card-w) * 1.4 + 10px);
}
.gr-bothand > .gg-card { box-shadow: 1.5px 1.5px 0 rgba(14, 44, 14, .85); border-width: 1.2px; }
/* a card the bot picked up from the discard pile stays face up: everyone saw it */
.gr-bothand > .gg-card:not(.is-back) { box-shadow: 0 0 0 2px var(--gg-butter), 1.5px 1.5px 0 rgba(14, 44, 14, .85); }

.gr-piles { display: grid; grid-template-columns: 1fr auto auto 1fr; align-items: center; gap: 18px; padding: 4px 11px 2px; }
.gr-pilewrap { display: grid; justify-items: center; gap: 6px; }
.gr-pile {
  position: relative; display: block; width: var(--gg-card-w); height: calc(var(--gg-card-w) * 1.4);
  padding: 0; border: 0; background: none; border-radius: calc(var(--gg-card-w) * .11);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; cursor: default;
}
.gr-pile:focus:not(:focus-visible) { outline: none; }
.gr-pile::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  border: 2px dashed rgba(255, 250, 240, .32); background: rgba(14, 44, 14, .18);
}
.gr-pile > .gg-card { position: absolute; left: 0; top: 0; }
.gr-stock > .gg-card:nth-last-child(2) { transform: translate(-2px, 2px); }
.gr-stock > .gg-card:nth-last-child(3) { transform: translate(-4px, 4px); }
.gr-stock > .gg-card:not(:nth-last-child(-n+3)) { visibility: hidden; }
.gr-discard > .gg-card { --r: var(--tilt, 0deg); }
.gr-discard > .gg-card:not(:nth-last-child(-n+3)) { visibility: hidden; }
.gr-pile__label { white-space: nowrap; font-weight: 700; font-size: var(--gg-text-xs); letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 250, 240, .86); line-height: 1.2; }
.gr-pile__label b { font-family: var(--gg-font-display); font-size: var(--gg-text-sm); letter-spacing: 0; color: var(--gg-cream); }

/* a pile you may draw from: lime ring + lift on hover/press */
.gr-pile.is-live { cursor: pointer; }
.gr-pile.is-live::after {
  content: ""; position: absolute; inset: -7px; border-radius: calc(var(--gg-card-w) * .11 + 6px);
  border: 3px solid var(--gg-lime); pointer-events: none;
  animation: gr-ring calc(1800ms * var(--gg-time)) ease-in-out infinite;
}
@keyframes gr-ring { 0%, 100% { opacity: .55; transform: scale(1); } 50% { opacity: 1; transform: scale(1.03); } }
.gr-pile.is-live > .gg-card:last-child { transition: transform var(--gg-dur-sm) var(--gg-ease-spring); }
@media (hover: hover) {
  .gr-pile.is-live:hover > .gg-card:last-child { --lift: 10px; }
}
.gr-pile.is-live:active > .gg-card:last-child { --lift: 6px; --s: .97; }

.gr-handinfo { display: grid; gap: 2px; align-content: center; min-width: 0; }
.gr-handinfo__sub { font-size: var(--gg-text-xs); font-weight: 700; color: rgba(255, 250, 240, .86); line-height: 1.25; }

/* your hand: a near-flat fan so the meld underline reads straight */
.gr-me { display: grid; gap: 2px; }
.gr-hand { --gg-card-w: 68px; --fan-deg: 1.4deg; --fan-drop: 2px; --gapw: 4px; padding: 26px 0 12px; min-height: calc(var(--gg-card-w) * 1.4 + 38px); }
.gr-hand > .gg-card {
  --step: min(calc(var(--gg-card-w) * .78), calc((100cqw - var(--gg-card-w) - 3px - var(--gaps, 0) * var(--gapw)) / max(var(--n, 1) - 1, 1)));
}
.gr-hand > .gg-card.gr-gap { margin-left: calc(var(--step) - var(--gg-card-w) + var(--gapw)); }
/* meld membership: a lime bar along the bottom of the card */
.gg-card.gr-meld::before {
  content: ""; position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; height: 7px;
  background: var(--gg-lime); border-top: 1.5px solid var(--gg-ink); pointer-events: none;
}
.gg-card.gr-new { box-shadow: 0 0 0 3px var(--gg-butter), 3px 4px 0 rgba(14, 44, 14, .85); }
.gg-card.is-selected.gr-new { box-shadow: 0 0 0 3px var(--gg-lime), 3px 5px 0 rgba(14, 44, 14, .85); }
.gr-hand > .gg-card { cursor: default; }
.gr-hand > .gg-card.is-playable { cursor: pointer; }

.gr-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 9px 2px; flex-wrap: wrap; }
/* the knock slam: your cards snap into one pile for a beat */
.gr-hand.gr-slam > .gg-card { --r: 0deg; --y: 0px; }
.gr-hand.gr-slam > .gg-card + .gg-card { margin-left: calc(var(--gg-card-w) * -.9); }
/* hint: a butter ring that blinks a few times */
.gr-hint-pulse { outline: 3px solid transparent; outline-offset: 3px; animation: gr-hint calc(520ms * var(--gg-time)) ease-in-out 4; }
@keyframes gr-hint { 0%, 100% { outline-color: transparent; } 50% { outline-color: var(--gg-butter); } }
.gr-hint { font-size: var(--gg-text-sm); }
.gr-hint:disabled { box-shadow: none; background: none; }
.gr-pile > .gr-hint-pulse { outline-width: 4px; outline-offset: 12px; }
.gr-dw { min-height: 36px; padding: 6px 14px; font-size: var(--gg-text-sm); box-shadow: 2px 2px 0 var(--gg-green-950); border-color: var(--gg-green-950); color: var(--gg-ink); }
.gr-dw b { font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-md); display: inline-block; min-width: 1.2ch; font-variant-numeric: tabular-nums; }
.gr-dw.is-low { background: var(--gg-butter); }
.gr-sort { box-shadow: 2px 2px 0 var(--gg-green-950); border-color: var(--gg-green-950); }
.gr-sort { color: var(--gg-ink); }
.gr-sort button { padding: 0 11px; font-size: var(--gg-text-xs); color: var(--gg-ink); }
.gr-sort button[aria-pressed="true"] { color: var(--gg-cream); }

.gr-prompt { margin-top: 2px; }
.gr-prompt .gg-prompt__text { font-size: var(--gg-text-sm); }
.gr-actions { display: flex; gap: 10px; min-height: 56px; align-items: center; }
.gr-actions > .gg-btn { flex: 1 1 0; min-width: 0; padding-inline: 12px; white-space: nowrap; }
.gr-actions > .gg-btn small { font-size: var(--gg-text-sm); font-family: var(--gg-font-body); font-weight: 700; }
.gr-actions > .gg-btn.gr-act-in { animation: gr-btn-in var(--gg-dur-md) var(--gg-ease-spring) both; }
@keyframes gr-btn-in { from { transform: translateY(10px) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.gr-actions__hint { flex: 1; text-align: center; font-size: var(--gg-text-sm); font-weight: 600; color: var(--gg-ink-3); }
.gr-controls { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.gr-controls__gap { flex: 1; }
.gr-tip { display: none; }
.gr-tip__text { font-size: var(--gg-text-sm); color: var(--gg-ink-2); line-height: 1.45; margin-top: 6px; }

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

/* ---------- reveal sheet (end of a hand) ---------- */
.gr-sheet-modal { padding: 12px; }
.gr-sheet { position: relative; width: min(760px, 100%); text-align: left; padding: 18px 16px 16px; display: grid; gap: 10px; max-height: calc(100dvh - 24px); }
.gr-sheet__title { font-size: var(--gg-text-2xl); }
.gr-sheet__line { font-size: var(--gg-text-sm); color: var(--gg-ink-2); margin-top: -4px; }
.gr-stamp {
  position: absolute; z-index: 2; top: 10px; right: 14px; padding: 2px 12px; border: var(--gg-border); border-radius: var(--gg-r-md);
  background: var(--gg-butter); box-shadow: var(--gg-shadow);
  font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-lg); line-height: 1.15; letter-spacing: -.01em;
  transform: rotate(-4deg); pointer-events: none;
}
.gr-stamp[hidden] { display: none; }
.gr-reveal { display: grid; gap: 8px; --gg-card-w: 38px; min-width: 0; }
.gr-reveal > * { min-width: 0; }
.gr-rrow { display: grid; gap: 4px; padding: 8px 10px 10px; border: 2px solid var(--gg-line); border-radius: var(--gg-r-md); background: var(--gg-cream); }
.gr-rrow.is-knocker { border-color: var(--gg-ink); background: var(--gg-paper); }
.gr-rrow__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.gr-rrow__who { font-weight: 800; font-size: var(--gg-text-sm); }
.gr-rrow__who small { font-weight: 600; font-size: var(--gg-text-xs); color: var(--gg-ink-3); margin-left: 4px; }
.gr-rrow__dw { font-weight: 700; font-size: var(--gg-text-xs); color: var(--gg-ink-3); white-space: nowrap; }
.gr-rrow__dw b { font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-lg); color: var(--gg-ink); margin-left: 4px; display: inline-block; font-variant-numeric: tabular-nums; }
.gr-groups { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; min-height: calc(var(--gg-card-w) * 1.4 + 8px); padding-top: 4px; }
.gr-group { display: flex; align-items: flex-end; padding-bottom: 6px; position: relative; }
.gr-group > .gg-card { box-shadow: var(--gg-shadow-sm); }
.gr-group > .gg-card + .gg-card { margin-left: calc(var(--gg-card-w) * -.46); }
.gr-group--meld::after { content: ""; position: absolute; left: 2px; right: 2px; bottom: 0; height: 4px; border-radius: 2px; background: var(--gg-green-500); }
.gr-group--dead > .gg-card { --y: 0px; }
.gr-group--dead .gg-card::after { opacity: .28; }
.gr-group--dead { padding: 3px 5px 6px; margin: -5px 0 0; border: 2px dashed rgba(17, 17, 17, .22); border-radius: var(--gg-r-sm); }
.gr-group__tag { display: none; align-self: center; margin-left: 6px; font-size: var(--gg-text-xs); font-weight: 700; color: var(--gg-ink-3); }
.gg-card.gr-laid { box-shadow: 0 0 0 3px var(--gg-butter), var(--gg-shadow-sm); }
.gr-breakdown { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.gr-breakdown li { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 6px 12px; border-radius: var(--gg-r-sm); background: var(--gg-sand); font-weight: 700; font-size: var(--gg-text-sm); }
.gr-breakdown li b { font-family: var(--gg-font-display); font-weight: 800; font-size: var(--gg-text-lg); }
.gr-breakdown li.is-big { background: var(--gg-butter); border: 2px solid var(--gg-ink); }
.gr-breakdown li.is-total { background: none; border-top: 2px solid var(--gg-ink); border-radius: 0; padding-top: 8px; }
.gr-breakdown li.gr-in { animation: gg-rise var(--gg-dur-md) var(--gg-ease-out) both; }
.gr-sheet__scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gr-sheet__score { display: grid; gap: 2px; padding: 8px 12px 10px; border: var(--gg-border); border-radius: var(--gg-r-md); background: var(--gg-cream); }
.gr-sheet__score.is-up { background: var(--gg-butter-100); }
.gr-sheet__score span { font-size: var(--gg-text-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gg-ink-3); }
.gr-sheet__score b { font-family: var(--gg-font-display); font-weight: 800; font-size: 30px; line-height: 1.05; display: inline-block; justify-self: start; font-variant-numeric: tabular-nums; }
.gr-sheet__score .gr-goal { margin-top: 2px; }

/* ---------- result + rules ---------- */
.gr-badge__disc { fill: var(--gg-butter); }
.gr-badge--soft .gr-badge__disc { fill: var(--gg-sand); }
.gr-bonus { list-style: none; margin: -6px 0 16px; padding: 0; display: grid; gap: 4px; text-align: left; font-size: var(--gg-text-sm); color: var(--gg-ink-2); }
.gr-bonus li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 2px; border-bottom: 1px solid var(--gg-line); }
.gr-bonus li b { color: var(--gg-ink); white-space: nowrap; }
.gr-record { margin: 0 0 18px; font-size: var(--gg-text-sm); font-weight: 700; color: var(--gg-ink-3); }
.gr-rules { text-align: left; display: grid; gap: 14px; width: min(520px, 100%); }
.gr-rules__title { font-size: var(--gg-text-2xl); }
.gr-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); }
.gr-rules__list b { color: var(--gg-ink); }
.gr-rules__list li::marker { color: var(--gg-green-600); }

/* ---------- desktop: lawn on the left, side panel on the right ---------- */
@media (min-width: 900px) {
  .gr-main { padding-block: 22px 40px; }
  .gr-start { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 56px; padding-top: 24px; }
  .gr-start__copy { max-width: 480px; }
  .gr-start__art { display: block; }
  .gr-start__table { padding: 40px 28px 28px; transform: rotate(1.5deg); }
  .gr-art-hand { --gg-card-w: 104px; --fan-deg: 4deg; --fan-drop: 5px; pointer-events: none; }

  .gr-game { grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "table score" "table side"; grid-template-rows: auto 1fr; gap: 16px 28px; align-items: start; }
  .gr-score { grid-area: score; }
  .gr-table { grid-area: table; --gg-card-w: 88px; margin-inline: 0; padding: 20px 28px 18px; gap: 10px; min-height: min(calc(100dvh - 120px), 800px); align-content: space-evenly; }
  .gr-bothand { --gg-card-w: 60px; max-width: 560px; }
  .gr-took__cards { --gg-card-w: 54px; }
  .gr-took__cards > .gg-card + .gg-card { margin-left: -16px; }
  .gr-hand { --gapw: 9px; --gg-card-w: 88px; }
  .gr-score .gg-scorestrip__num { font-size: 40px; }
  .gr-piles { gap: 36px; padding-block: 8px; }
  .gr-hand { padding-top: 30px; }
  .gr-side { grid-area: side; display: flex; flex-direction: column; gap: 14px; }
  .gr-prompt { margin-top: 0; border-radius: var(--gg-r-lg); padding-block: 14px; align-items: flex-start; }
  .gr-prompt .gg-prompt__dot { margin-top: 3px; }
  .gr-prompt .gg-prompt__text { font-size: var(--gg-text-md); }
  .gr-actions { flex-direction: column; align-items: stretch; min-height: 0; }
  .gr-actions:empty { display: none; }
  .gr-actions > .gg-btn { flex: none; }
  .gr-tip { display: block; padding: 16px 18px; box-shadow: var(--gg-shadow); }

  .gr-sheet-modal { padding: 20px; }
  .gr-sheet { padding: 24px 26px 22px; gap: 12px; }
  .gr-reveal { --gg-card-w: 56px; }
  .gr-group__tag { display: inline; }
  .gr-stamp { top: 20px; right: 24px; font-size: var(--gg-text-3xl); padding: 6px 22px; }
}
@media (min-width: 900px) and (max-height: 760px) {
  .gr-table, .gr-hand { --gg-card-w: 76px; }
}
