/* Gin Rummy table layout (same look as 500 Rummy). Tokens come from shared/theme.css. */
.app { max-width: 1280px; margin: 0 auto; padding: 12px 16px 24px; display: grid; gap: 12px; }

/* ---------- Top bar & scoreboard ---------- */
.topbar { display: flex; align-items: center; gap: 12px; }
.back-link { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-size: 18px; color: var(--text); }
.title { flex: 1; min-width: 0; }
.title h1 { font-size: 22px; margin: 0; }
.meta { font-size: 13px; }
.top-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.scoreboard { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  --pc: var(--p0);
  flex: 1 1 150px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 12px; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; align-items: center;
  transition: border-color .2s, box-shadow .2s;
}
.chip.turn { border-color: var(--pc); box-shadow: 0 0 0 1px var(--pc), 0 0 18px color-mix(in srgb, var(--pc) 35%, transparent); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); }
.chip .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .score { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 18px; }
.chip .bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.chip .bar i { display: block; height: 100%; background: var(--pc); border-radius: 4px; transition: width .4s; }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 1fr 280px; gap: 12px; align-items: start; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

.felt {
  background: radial-gradient(ellipse at 50% 30%, var(--felt) 0%, var(--felt-2) 100%);
  border-radius: 20px; padding: 14px; display: grid; gap: 14px; min-width: 0;
  box-shadow: inset 0 0 0 1px var(--felt-line), inset 0 0 60px rgba(0, 0, 0, .25);
  color: #f4efe6;
}
.zone-label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: rgba(244, 239, 230, .75); margin-bottom: 6px; }
.zone-label .muted { color: rgba(244, 239, 230, .55); text-transform: none; letter-spacing: 0; font-weight: 500; }

/* ---------- Opponents ---------- */
.opponents { display: flex; gap: 10px; flex-wrap: wrap; }
.seat {
  --pc: var(--p1);
  flex: 1 1 200px; min-width: 0; background: rgba(0, 0, 0, .22); border: 1px solid var(--felt-line); border-radius: 14px; padding: 10px 12px;
  transition: box-shadow .2s, border-color .2s;
}
.seat.turn { border-color: var(--pc); box-shadow: 0 0 0 1px var(--pc), 0 0 22px color-mix(in srgb, var(--pc) 30%, transparent); }
.seat-head { display: flex; align-items: center; gap: 8px; }
.seat-head .name { font-weight: 700; color: var(--pc); }
.seat-head .count { margin-left: auto; font-size: 13px; color: rgba(244, 239, 230, .7); }
.seat .backs { position: relative; height: 46px; margin-top: 8px; }
.seat .backs .pcard { --card-w: 32px; position: absolute; top: 0; box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.seat .known { font-size: 12px; color: rgba(244, 239, 230, .7); margin-top: 6px; min-height: 16px; }
.seat .known b { color: #fff; }
.thinking { font-size: 12px; color: var(--pc); font-weight: 700; }
.thinking::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- Stock & discard ---------- */
.piles { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; }
.stock-zone { display: grid; justify-items: center; gap: 4px; }
.stock {
  --card-w: 64px; position: relative; width: 70px; height: 96px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 10px;
}
.stock .pcard { position: absolute; left: 0; top: 0; }
.stock:disabled { cursor: default; }
.stock.ready .pcard:last-child { box-shadow: 0 0 0 3px var(--gold), 0 0 20px rgba(244, 201, 93, .5); }
.stock.empty { border: 2px dashed rgba(255, 255, 255, .25); }
.stock-zone .zone-label { margin: 0; }
.discard { position: relative; height: 92px; --card-w: 62px; }
.discard .pcard { position: absolute; top: 0; cursor: default; }
.discard .pcard.under { filter: brightness(.82); }
.discard.ready .pcard.top { cursor: pointer; }
.discard.ready .pcard.top:hover { transform: translateY(-8px); box-shadow: 0 0 0 3px var(--gold), var(--shadow); }
.discard.ready .pcard.top { box-shadow: 0 0 0 2px rgba(244, 201, 93, .55), var(--shadow); }
.discard.target .pcard.top { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.discard .pcard.blocked::after { content: 'JUST TAKEN'; position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%); background: var(--surface-2); color: var(--muted); font-size: 9px; font-weight: 800; padding: 1px 5px; border-radius: 5px; white-space: nowrap; }
.discard .empty-note { color: rgba(244, 239, 230, .55); font-size: 14px; padding-top: 34px; }

/* ---------- Banner ---------- */
.banner {
  min-height: 44px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: rgba(0, 0, 0, .28); border-radius: 12px; padding: 8px 14px; font-weight: 600;
}
.banner.error { background: color-mix(in srgb, var(--bad) 45%, rgba(0, 0, 0, .4)); }
.banner.you { box-shadow: inset 3px 0 0 var(--p0); }
.banner .btn { padding: 6px 12px; }

/* ---------- Melds ---------- */
.melds { display: flex; flex-wrap: wrap; gap: 10px; min-height: 76px; }
.melds .empty-note { color: rgba(244, 239, 230, .55); font-size: 14px; align-self: center; }
.meld {
  --card-w: 46px; display: flex; padding: 6px 8px 8px; border-radius: 12px; background: rgba(0, 0, 0, .2);
  border: 1px solid transparent; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.meld .pcard + .pcard { margin-left: -24px; }
.meld .pcard { box-shadow: inset 0 -4px 0 var(--owner, transparent), 0 1px 3px rgba(0, 0, 0, .35); }
.meld.dead { background: rgba(0, 0, 0, .1); border: 1px dashed rgba(255, 255, 255, .2); }
.meld .pcard.laid { box-shadow: inset 0 -4px 0 var(--p0), 0 1px 3px rgba(0, 0, 0, .35); }
.meld .pcard .corner.br, .meld .pcard .pip { display: none; }
.meld .pcard .corner { font-size: 13px; left: 5px; }
.meld .pcard .corner .s { font-size: 13px; }
.meld.target { border-color: var(--gold); box-shadow: 0 0 16px rgba(244, 201, 93, .45); cursor: pointer; }
.meld.target:hover { transform: translateY(-3px); }
.legend { margin-left: 8px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.legend span { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Side log ---------- */
.side { position: sticky; top: 12px; }
.log-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.log-box summary { font-weight: 700; cursor: pointer; }
.log { list-style: none; margin: 8px 0 0; padding: 0; max-height: 520px; overflow: auto; font-size: 13.5px; display: grid; gap: 4px; }
.log li { padding: 4px 8px; border-radius: 8px; border-left: 3px solid var(--pc, var(--line)); background: var(--surface-2); }
.log li.round { background: transparent; border-left-color: transparent; color: var(--muted); font-weight: 700; text-align: center; }
@media (max-width: 960px) { .side { position: static; } .log { max-height: 220px; } }

/* ---------- Your hand ---------- */
.play { display: grid; gap: 12px; min-width: 0; }
.me { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px 14px; }
/* Keep the hand in view while scrolling the table, when the screen is tall enough. */
@media (min-height: 760px) {
  .me { position: sticky; bottom: 8px; z-index: 5; box-shadow: 0 -6px 24px rgba(0, 0, 0, .35); }
}
.hand-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hand-title { flex: 1; }
.sorts { display: flex; gap: 6px; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.hand { position: relative; height: 136px; margin-top: 14px; --card-w: 78px; touch-action: pan-y; }
.hand .pcard { position: absolute; top: 18px; cursor: pointer; transition: left .18s ease, transform .15s ease, box-shadow .15s; }
.hand .pcard:hover { transform: translateY(-6px); }
.hand .pcard.selected { transform: translateY(-18px); box-shadow: 0 0 0 3px var(--gold), 0 8px 18px rgba(0, 0, 0, .35); }
.hand .pcard.melded { box-shadow: inset 0 -6px 0 var(--meld), var(--shadow); }
.hand .pcard.locked::after { content: 'KEEP'; position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%); background: var(--surface-2); color: var(--muted); font-size: 9px; font-weight: 800; padding: 1px 5px; border-radius: 5px; white-space: nowrap; }
.hand .pcard.new { box-shadow: 0 0 0 2px var(--p1), var(--shadow); }
.hand .pcard.dragging { transition: none; z-index: 100; transform: translateY(-14px) scale(1.04); box-shadow: 0 12px 24px rgba(0, 0, 0, .4); cursor: grabbing; }
.hand .pcard.hinted { box-shadow: 0 0 0 3px var(--good), var(--shadow); }
.hand.waiting .pcard { cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.sel-info { font-size: 14px; color: var(--muted); }
.sel-info.ok { color: var(--good); font-weight: 700; }

/* ---------- Animation ---------- */
@keyframes flash { 0% { box-shadow: 0 0 0 4px var(--gold), 0 0 26px var(--gold); } 100% { box-shadow: var(--shadow); } }
.pcard.flash { animation: flash 1.1s ease-out; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.shake { animation: shake .35s; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Dialogs ---------- */
.dlg { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); padding: 22px; width: min(520px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(5, 10, 20, .6); backdrop-filter: blur(2px); }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin: 12px 0; }
.field .input { width: 100%; color: var(--text); font-size: 15px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opp-levels { display: grid; gap: 8px; }
.opp-levels .field { margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.score-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-variant-numeric: tabular-nums; }
.score-table th, .score-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.score-table th:first-child, .score-table td:first-child { text-align: left; }
.score-table .neg { color: var(--bad); }
.score-table .pos { color: var(--good); }
.score-table tr.winner td { font-weight: 800; }
.rules ol { padding-left: 20px; display: grid; gap: 8px; }
.dlg.wide { width: min(640px, calc(100vw - 32px)); }

/* ---------- End-of-hand reveal ---------- */
.reveal { display: grid; gap: 10px; margin-top: 8px; }
.reveal-row { background: var(--felt-2); border-radius: 12px; padding: 8px 10px; color: #f4efe6; }
.reveal-row .who { font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--pc); }
.reveal-row .who span { color: rgba(244, 239, 230, .7); font-weight: 500; }
.reveal-row .groups { display: flex; flex-wrap: wrap; gap: 8px; }
.reveal-row .meld { --card-w: 38px; padding: 4px 6px 6px; }
.reveal-row .meld .pcard + .pcard { margin-left: -20px; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .app { padding: 10px 12px 20px; gap: 10px; }
  .topbar { gap: 8px; }
  .back-link { width: 34px; height: 34px; }
  .title h1 { font-size: 18px; white-space: nowrap; }
  .meta { font-size: 12px; white-space: nowrap; }
  .top-actions { gap: 4px; flex-wrap: nowrap; }
  .top-actions .btn { padding: 6px 9px; font-size: 13px; }
  .me { padding: 10px 12px 12px; }
  .hand-title { font-size: 14px; }
  .hand-title .long { display: none; }
  .hand { margin-top: 6px; }
  .actions { gap: 6px; margin-top: 6px; }
  .actions .btn { padding: 7px 12px; font-size: 14px; }
  .sel-info { flex-basis: 100%; font-size: 13px; }
  .felt { padding: 10px; border-radius: 16px; }
  .piles { gap: 12px; }
  .stock { --card-w: 50px; width: 56px; height: 76px; }
  .discard { --card-w: 48px; height: 74px; }
  .meld { --card-w: 38px; padding: 5px 6px 7px; }
  .meld .pcard + .pcard { margin-left: -20px; }
  .hand { --card-w: 58px; height: 108px; }
  .chip { flex-basis: 120px; padding: 6px 10px; }
  .chip .score { font-size: 16px; }
  .field-row { grid-template-columns: 1fr; }
  .reveal-row .meld { --card-w: 32px; }
  .reveal-row .meld .pcard + .pcard { margin-left: -17px; }
}
