/* Card table and playing cards ("Club Classic"). The table fits one phone screen and
   the cards are as large as the width allows. Shared by every card game on the site. */

/* ---------- playing cards ---------- */
.card {
  --w: var(--cw, 90px);
  width: var(--w);
  height: calc(var(--w) * 1.4);
  border-radius: calc(var(--w) * 0.085);
  position: relative;
  padding: 0;
  overflow: hidden;
  background: linear-gradient(160deg, #fff 0%, #fbf7ee 100%);
  color: #16181b;
  border: 0;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), 0 5px 14px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  font-family: var(--font);
  cursor: default;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s;
}
button.card { cursor: pointer; }
.card svg { fill: currentColor; display: block; }
.card.s-H, .card.s-D { color: #b8202b; }
.four-color .card.s-D { color: #1f5fc0; }
.four-color .card.s-C { color: #137a3a; }

.card .idx {
  position: absolute;
  left: calc(var(--w) * 0.06);
  top: calc(var(--w) * 0.045);
  width: calc(var(--w) * 0.42);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.9;
}
.card .rk { font-weight: 700; font-size: calc(var(--w) * 0.39); letter-spacing: -0.03em; }
.card .rk.ten { font-size: calc(var(--w) * 0.33); letter-spacing: -0.07em; }
.card .idx svg { width: calc(var(--w) * 0.26); height: calc(var(--w) * 0.26); margin-top: calc(var(--w) * 0.03); }
.card .br {
  position: absolute;
  right: calc(var(--w) * 0.06);
  bottom: calc(var(--w) * 0.045);
  transform: rotate(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.9;
  opacity: 0.9;
}
.card .br b { font-weight: 700; font-size: calc(var(--w) * 0.19); }
.card .br svg { width: calc(var(--w) * 0.13); height: calc(var(--w) * 0.13); margin-top: 1px; }
.card .pip {
  position: absolute;
  right: calc(var(--w) * 0.14);
  bottom: calc(var(--w) * 0.28);
  width: calc(var(--w) * 0.46);
  height: calc(var(--w) * 0.46);
}
.card .court {
  position: absolute;
  right: calc(var(--w) * 0.13);
  bottom: calc(var(--w) * 0.24);
  width: calc(var(--w) * 0.46);
  height: calc(var(--w) * 0.66);
  border-radius: calc(var(--w) * 0.05);
  border: max(1.5px, calc(var(--w) * 0.018)) solid currentColor;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--w) * 0.02);
  background: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.04) 0 3px, transparent 3px 6px);
}
.card .court span { font: 700 calc(var(--w) * 0.34)/1 var(--display); }
.card .court svg { width: calc(var(--w) * 0.15); height: calc(var(--w) * 0.15); }
/* Small cards: the big index is enough. */
.card.sm .br, .card.xs .br, .card.xs .court, .card.xs .pip { display: none; }

.card.back {
  background:
    radial-gradient(circle at 50% 50%, #e6b85c 0 calc(var(--w) * 0.09), transparent calc(var(--w) * 0.09 + 1px)),
    repeating-linear-gradient(45deg, rgba(230, 184, 92, 0.34) 0 1.5px, transparent 1.5px 8px),
    repeating-linear-gradient(-45deg, rgba(230, 184, 92, 0.34) 0 1.5px, transparent 1.5px 8px),
    #7a1d2a;
  box-shadow: inset 0 0 0 calc(var(--w) * 0.045) #fbf6ea, inset 0 0 0 calc(var(--w) * 0.06) #c8943a, 0 4px 12px rgba(0, 0, 0, 0.32);
}
.card.empty {
  background: transparent;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  box-shadow: none;
}
.card.sm { --w: var(--ow); }
.card.md { --w: var(--pw); }
.card.xs { --w: 46px; }
.card.starter { box-shadow: 0 0 0 3px #e6b85c, 0 5px 14px rgba(0, 0, 0, 0.3); }

/* ---------- table ---------- */
.game-shell { padding: 8px 8px 0; }
.game-rail { max-width: 860px; margin: 0 auto; padding: 7px; border-radius: 22px; }
.game-rail > .felt { border-radius: 16px; }
@media (min-width: 700px) {
  .game-shell { padding: 20px 16px 0; }
  .game-rail { padding: 12px; border-radius: 28px; }
}
.game {
  --cw: clamp(64px, 21vw, 122px);   /* your cards */
  --ow: calc(var(--cw) * 0.5);        /* computer's card backs */
  --pw: calc(var(--cw) * 0.74);       /* pile and starter */
  --you: #5aa2ff;
  --cpu: #ff8a73;
  padding: 10px 10px 14px;
  min-height: calc(100svh - 62px - 30px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 900px) {
  .game { --cw: 118px; min-height: 0; padding: 16px 22px 22px; }
}

.g-title { margin: 0; font: 700 18px/1.2 var(--display); color: #fffaf0; }
.g-title small { font: 400 15px/1.2 var(--font); opacity: 0.85; }

.g-top { display: flex; align-items: stretch; gap: 8px; }
.g-scores { display: flex; gap: 8px; flex: 1; min-width: 0; }
.g-score {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 7px;
  align-items: center;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 6px 12px;
  min-width: 0;
}
.g-score .peg { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 2px #fff; }
.g-score.you .peg { background: var(--you); }
.g-score.cpu .peg { background: var(--cpu); }
.g-score .who { font-size: 15px; font-weight: 700; white-space: nowrap; }
.g-score .pts { grid-column: 1 / -1; font-size: 31px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.05; }
.g-score .pts.bump { animation: bump 0.6s ease; }
@keyframes bump { 30% { transform: scale(1.3); color: #e6b85c; } }

.tool {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 2px solid rgba(230, 184, 92, 0.75);
  background: rgba(0, 0, 0, 0.2);
  color: #e6b85c;
  font: 700 16px/1 var(--font);
  cursor: pointer;
}
.tool:hover { background: rgba(0, 0, 0, 0.34); }
.tool:disabled { opacity: 0.38; cursor: default; }

.g-board { width: 100%; height: auto; display: block; border-radius: 10px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); }

.g-label { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; min-height: 24px; }
.crib-tag {
  display: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  background: #e6b85c;
  color: #3a2805;
  padding: 3px 9px;
  border-radius: 999px;
}
.crib-tag.on { display: inline-block; }

.hand { display: grid; justify-content: center; align-items: end; }
.hand > .card { justify-self: start; }
.hand-opp { min-height: calc(var(--ow) * 1.4); }
.hand-you { min-height: calc(var(--cw) * 1.4 + 16px); padding-top: 16px; }

.g-table {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  background: rgba(0, 0, 0, 0.16);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.25);
  border-radius: 16px;
  padding: 10px;
  min-height: calc(var(--pw) * 1.4 + 20px);
}
.g-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.g-slot-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.85; font-weight: 700; }
.g-play { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pile { display: grid; flex: 1; min-width: 0; justify-content: start; }
.pile > .card { justify-self: start; }
.pile.frozen { opacity: 0.75; }
.count {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #efe7d4);
  color: #1d1a16;
  box-shadow: 0 0 0 4px #e6b85c, 0 6px 14px rgba(0, 0, 0, 0.4);
}
.count span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #5d574d; }
.count b { font-size: 33px; line-height: 1; font-variant-numeric: tabular-nums; }
.count.hidden { visibility: hidden; }

.g-msgwrap { position: relative; }
.g-msg {
  margin: 0;
  min-height: 2.6em;
  font-size: clamp(19px, 4.8vw, 23px);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  text-wrap: balance;
  color: #fffaf0;
}
.g-actions { display: flex; gap: 10px; justify-content: center; }
.btn-primary {
  min-height: 58px;
  min-width: 220px;
  padding: 12px 28px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #f3cd78, #e6b85c 55%, #d9a444);
  color: #2c1d02;
  font: 700 21px/1.1 var(--font);
  box-shadow: 0 4px 0 #9c6c1c, 0 8px 18px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #9c6c1c; }
.btn-primary:disabled { background: rgba(255, 255, 255, 0.22); color: rgba(255, 255, 255, 0.85); box-shadow: none; cursor: default; }
.btn-primary[hidden] { display: none; }

.hand-you .card.selected { transform: translateY(-16px); box-shadow: 0 0 0 4px #e6b85c, 0 10px 18px rgba(0, 0, 0, 0.4); }
.hand-you .card.hint { box-shadow: 0 0 0 4px #7fe0a8, 0 6px 14px rgba(0, 0, 0, 0.3); }
.hand-you .card:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4); }
.hand-you .card.playable:hover { transform: translateY(-8px); }
.card.just-played { animation: land 0.35s ease; }
@keyframes land { from { transform: translateY(-24px) scale(1.05); } }

.toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(13, 42, 28, 0.95);
  border: 2px solid #e6b85c;
  color: #fff;
  padding: 11px 20px;
  border-radius: 14px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 94%;
  z-index: 5;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}
.toast.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast .who-you { color: var(--you); }
.toast .who-cpu { color: var(--cpu); }

/* ---------- dialogs ---------- */
dialog.g-dialog {
  border: 0;
  border-radius: 20px;
  padding: 0;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100svh - 24px);
  color: #1d1a16;
  background: #fffdf8;
  box-shadow: 0 0 0 4px #c8943a, 0 24px 60px rgba(0, 0, 0, 0.5);
}
dialog.g-dialog::backdrop { background: rgba(8, 24, 15, 0.66); }
/* Content scrolls; the action buttons always stay on screen. */
dialog.g-dialog[open] { display: flex; flex-direction: column; }
.dlg-body { padding: 22px 22px 14px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.dlg-actions { flex: none; }
.dlg-body h2 { font: 700 30px/1.15 var(--display); margin: 0 0 4px; }
.dlg-body h3 { font: 700 21px/1.2 var(--display); margin: 14px 0 6px; }
.dlg-total { font-size: 23px; font-weight: 700; margin: 0 0 12px; color: #1c5a3d; }
.dlg-cards { display: flex; gap: 6px; flex-wrap: nowrap; align-items: flex-end; margin: 8px 0 14px; }
.dlg-cards .plus { font-size: 22px; font-weight: 700; color: #5d574d; padding: 0 2px 18px; }
.dlg-cards .card { --w: clamp(46px, 12.5vw, 76px); }
.dlg-items { list-style: none; margin: 0 0 12px; padding: 0; font-size: 19px; }
.dlg-items li { padding: 8px 0; border-bottom: 1px solid #e6dcc6; display: flex; justify-content: space-between; gap: 12px; }
.dlg-items li b { white-space: nowrap; }
.dlg-items .cards { color: #5d574d; font-size: 17px; }
.dlg-spoken { font-family: var(--display); font-style: italic; font-size: 20px; color: #3b3a36; margin: 6px 0 4px; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 10px 22px 20px; flex-wrap: wrap; }
.dlg-actions .btn-primary, .dlg-actions .btn-ghost { min-width: 0; flex: 1; }
.dlg-actions .btn-ghost {
  min-height: 54px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 2px solid #e6dcc6;
  background: #fff;
  font: 700 18px/1.1 var(--font);
  cursor: pointer;
  color: #1d1a16;
}
.set-group { border: 0; padding: 0; margin: 0 0 16px; }
.set-group legend { font-weight: 700; font-size: 19px; margin-bottom: 6px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label {
  flex: 1;
  min-width: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border: 2px solid #e6dcc6;
  border-radius: 12px;
  background: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 10px;
  text-align: center;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { border-color: #c8943a; background: #fbf0d6; box-shadow: inset 0 0 0 1px #c8943a; }
.seg label:has(input:focus-visible) { outline: 3px solid #e6b85c; }
.check { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; min-height: 44px; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: #1c5a3d; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 4px; }
.stats div { background: #fff; border: 1px solid #e6dcc6; border-radius: 12px; padding: 10px; text-align: center; }
.stats b { display: block; font-size: 27px; line-height: 1.1; }
.stats span { font-size: 14px; color: #5d574d; }
.muted-link { color: #5d574d; font-size: 16px; }

@media (max-height: 700px) and (max-width: 600px) {
  .game { --cw: clamp(58px, 16.5vw, 100px); gap: 6px; }
  .count { width: 64px; height: 64px; }
  .count b { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .toast { transition: none; }
  .card.just-played, .g-score .pts.bump { animation: none; }
}

/* ---------- gin rummy ---------- */
.gin { --cw: clamp(60px, 19.5vw, 112px); }
@media (min-width: 900px) { .gin { --cw: 108px; } }
.gin-table {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(20px, 8vw, 56px);
  background: rgba(0, 0, 0, 0.16);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.25);
  border-radius: 16px;
  padding: 12px;
}
.gin-pile { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gin-pile .g-slot-label b { font-weight: 700; opacity: 0.9; }
.pile-btn { padding: 0; border: 0; background: none; border-radius: 12px; cursor: pointer; font: inherit; }
.pile-btn:disabled { cursor: default; }
.pile-btn.stock .card.back { box-shadow: 2px 2px 0 #fbf6ea, 3px 3px 0 #c8943a, 5px 5px 0 #fbf6ea, 6px 6px 0 #c8943a, 0 8px 16px rgba(0, 0, 0, 0.35), inset 0 0 0 calc(var(--w) * 0.045) #fbf6ea, inset 0 0 0 calc(var(--w) * 0.06) #c8943a; }
.pile-btn.can .card { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translateY(-4px); filter: drop-shadow(0 0 10px rgba(230, 184, 92, 0.9)); } }

.dw {
  margin-left: auto;
  font-size: 15px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.dw b { font-size: 18px; }
.dw.ok { background: #e6b85c; color: #2c1d02; }
.dw:empty { display: none; }

.gin .hand-you { min-height: calc(var(--cw) * 1.4 + 14px); padding-top: 14px; }
.gin .hand-you.row2 { margin-top: -4px; }
.card[data-meld]::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: calc(var(--w) * 0.02);
  height: max(4px, calc(var(--w) * 0.055));
  border-radius: 3px;
}
.card[data-meld="0"]::after { background: #d9a444; }
.card[data-meld="1"]::after { background: #1e9e8a; }
.card[data-meld="2"]::after { background: #7c5cff; }
.hand-you .card.locked { filter: saturate(0.6); opacity: 0.8; }
.card.just-drawn { box-shadow: 0 0 0 3px #7fe0a8, 0 5px 14px rgba(0, 0, 0, 0.3); }

.btn-second {
  min-height: 58px;
  padding: 12px 22px;
  border-radius: 14px;
  border: 2px solid rgba(255, 250, 240, 0.65);
  background: rgba(0, 0, 0, 0.18);
  color: #fffaf0;
  font: 700 20px/1.1 var(--font);
  cursor: pointer;
}
.btn-second.knock { border-color: #e6b85c; color: #e6b85c; background: rgba(0, 0, 0, 0.35); box-shadow: 0 0 0 2px rgba(230, 184, 92, 0.35); }
.btn-second[hidden] { display: none; }
.gin .g-actions .btn-primary { min-width: 0; flex: 1; max-width: 340px; }
.gin .g-actions .btn-second { flex: 1; max-width: 260px; }

/* end-of-hand dialog */
.res-side { margin: 12px 0 4px; }
.res-side h3 { margin: 0 0 6px; }
.res-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.res-group { display: flex; gap: 3px; align-items: flex-end; position: relative; padding-bottom: 20px; }
.res-group .card { --w: clamp(34px, 9.5vw, 46px); }
.res-group.m0 { box-shadow: inset 0 -4px 0 #d9a444; }
.res-group.m1 { box-shadow: inset 0 -4px 0 #1e9e8a; }
.res-group.m2 { box-shadow: inset 0 -4px 0 #7c5cff; }
.res-group.laid .card { box-shadow: 0 0 0 2px #1e9e8a; }
.res-label { position: absolute; left: 0; bottom: 0; font-size: 13px; font-weight: 700; color: #5d574d; white-space: nowrap; }
.res-group.dead .res-label { color: #b8202b; }
.res-score { margin: 14px 0 0; font-size: 18px; }
.res-score span { color: #5d574d; }
table.tally { width: 100%; border-collapse: collapse; font-size: 18px; margin: 6px 0 10px; }
table.tally th, table.tally td { padding: 7px 8px; border-bottom: 1px solid #e6dcc6; text-align: right; }
table.tally th { text-align: left; font-weight: 400; color: #5d574d; }
table.tally tr.tot th, table.tally tr.tot td { font-weight: 700; color: #1d1a16; font-size: 20px; border-bottom: 0; }
