.capsa.table {
  height: 100vh;
  height: var(--app-h);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: 'bar' 'seats' 'felt' 'me';
  gap: 6px;
  padding: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  overflow: hidden;
}
.capsa .topbar { grid-area: bar; }
.capsa .timer { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.capsa .timer-fill { height: 100%; width: 0; background: var(--amber); }
.capsa .timer-fill.low { background: var(--danger); }

.capsa-seats {
  grid-area: seats;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
}
.capsa-seats .seat {
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.capsa-seats .seat.is-active {
  background: rgba(255, 179, 71, .15);
  border-color: var(--amber);
}
.capsa-seats .seat-name {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.capsa-seats .seat-info-line {
  font-size: 11px;
  color: var(--ink-2);
}
.capsa-seats .seat-score {
  color: var(--amber);
  font-weight: 700;
}

.felt {
  grid-area: felt;
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: 18px;
  background: radial-gradient(85% 85% at 50% 45%, #182b49, #0d1627);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05), inset 0 0 40px rgba(0, 0, 0, .5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 42px 12px 12px;
}
.capsa .status {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(10, 20, 35, .85);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
}
.capsa .status.mine {
  background: var(--amber);
  color: #1a1612;
  font-weight: 700;
}

.trick-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.trick-meta {
  font-size: 12px;
  font-weight: 700;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.trick-cards {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.trick-card-item {
  width: 58px;
  animation: drop-in .2s ease-out;
}
@keyframes drop-in {
  from { transform: translateY(-16px) scale(1.15); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.card-svg { display: block; width: 100%; height: auto; overflow: visible; }
.card-body { fill: #fffdf7; stroke: #cbbb9c; stroke-width: 1.2; }

.me {
  grid-area: me;
  display: grid;
  gap: 6px;
}
.me-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 13px;
}
.action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
}
.action-hint {
  font-size: 12px;
  color: var(--amber);
  font-weight: 700;
}

/* Deret Kartu di Tangan */
.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2px;
  padding: 4px 0 10px;
  min-height: 105px;
  overflow-x: auto;
}
.hand::-webkit-scrollbar { display: none; }
.card-select-btn {
  background: none;
  border: none;
  padding: 0;
  width: 48px;
  flex: none;
  cursor: pointer;
  position: relative;
  transition: transform .18s ease, filter .18s ease;
}
.card-select-btn:hover {
  transform: translateY(-8px);
}
.card-select-btn.is-selected {
  transform: translateY(-20px);
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .5));
}
.card-select-btn.is-selected::after {
  content: '✓';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--amber);
  color: #1a1612;
  font-size: 11px;
  font-weight: 900;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, .75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.result {
  background: #141f33;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 16px;
  padding: 20px;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .6);
}
.result h2 {
  margin: 0;
  font-size: 20px;
}
.result-sub {
  color: var(--ink-2);
  font-size: 13px;
  margin: 2px 0 0;
}
.result-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
  font-size: 14px;
}
.result-row.win {
  background: rgba(255, 179, 71, .15);
  border: 1px solid var(--amber);
  font-weight: 700;
}
.result-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

/* 13 kartu lebih lebar dari layar HP: tetap di tengah kalau muat, tapi kalau tidak,
   mulai dari kiri supaya kartu pertama bisa dijangkau dengan menggeser. */
.capsa .hand { justify-content: flex-start; }
.capsa .hand > :first-child { margin-left: auto; }
.capsa .hand > :last-child { margin-right: auto; }

/* HP sempit: 13 kartu di tangan dikipas (ditumpuk sebagian) supaya semua terlihat tanpa digeser.
   Jarak antar kartu dihitung dari lebar deret dan jumlah kartu (--n). */
@media (max-width: 640px) {
  .capsa .hand { container-type: inline-size; overflow-x: visible; gap: 0; }
  .capsa .hand > .card-select-btn + .card-select-btn { margin-left: min(2px, calc((100cqw - var(--n, 13) * 48px) / (var(--n, 13) - 1))); }
  .capsa .hand:has(> :nth-child(13)) { --n: 13; }
  .capsa .hand:has(> :nth-child(12):last-child) { --n: 12; }
  .capsa .hand:has(> :nth-child(11):last-child) { --n: 11; }
  .capsa .hand:has(> :nth-child(10):last-child) { --n: 10; }
  .capsa .hand:has(> :nth-child(9):last-child) { --n: 9; }
  .capsa .hand:has(> :nth-child(8):last-child) { --n: 8; }
  .capsa .card-select-btn { filter: drop-shadow(-2px 0 3px rgba(0, 0, 0, .35)); }
  .capsa .card-select-btn.is-selected { z-index: 2; }
}
