.cangkul.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;
}
.cangkul .topbar { grid-area: bar; }
.cangkul .timer { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.cangkul .timer-fill { height: 100%; width: 0; background: var(--amber); }
.cangkul .timer-fill.low { background: var(--danger); }

.ck-seats { grid-area: seats; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.ck-seats.many { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.backs { display: flex; flex-wrap: wrap; gap: 2px; min-height: 12px; }
.backs i { width: 6px; height: 10px; border-radius: 2px; background: #7a3b22; border: 1px solid #a2573a; }
.seat .tag-lewat { color: var(--ink-3); }

.felt {
  grid-area: felt; position: relative; min-height: 0; overflow: hidden; border-radius: 18px;
  background: radial-gradient(85% 85% at 50% 45%, var(--felt), var(--felt-deep));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05), inset 0 0 40px rgba(0, 0, 0, .35);
  display: flex; align-items: center; justify-content: center; gap: 18px; padding: 48px 12px 12px;
}
.cangkul .status {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 24px); padding: 6px 14px; border-radius: 999px;
  background: rgba(10, 30, 24, .82); color: var(--ink);
  font-weight: 600; font-size: 14px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
.cangkul .status.mine { background: var(--amber); color: var(--amber-ink); font-weight: 700; }
.suit-icon { width: 14px; height: 16px; flex: none; background: var(--ivory); border-radius: 3px; padding: 1px; }

.card-svg { display: block; width: 100%; height: auto; overflow: visible; }
.card-body { fill: #fffdf7; stroke: #cbbb9c; stroke-width: 1.2; }

.pile { flex: none; width: 54px; text-align: center; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.pile .card-svg { filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .5)); }
.pile.empty .card-svg { opacity: .25; }

.trick { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 8px; max-width: 100%; }
.trick-card { width: 58px; text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-2); animation: drop .22s ease-out; }
.trick-card .card-svg { filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .45)); margin-bottom: 4px; }
.trick-card .who { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trick-card.win .card-svg { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 6px; }
.trick-card.win .who { color: var(--amber); }
.trick-card.wait { opacity: .5; }
.trick-card.wait .slot-empty { height: 76px; border: 2px dashed rgba(246, 239, 223, .3); border-radius: 6px; margin-bottom: 4px; }
@keyframes drop { from { transform: translateY(-14px) scale(1.15); opacity: 0; } }

.me { grid-area: me; display: grid; gap: 6px; }
.me-bar { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 4px; }
.me-bar .avatar { width: 32px; height: 32px; font-size: 15px; }
.me-bar b { font-size: 15px; }
.me-bar .count { margin-left: auto; font-weight: 700; color: var(--amber); }
.draw-btn { width: 100%; }

.hand {
  --card-w: 15vw;
  position: relative;
  display: flex; justify-content: center; padding: 14px 4px 8px; min-height: 0;
  /* Kartu banyak: geser ke kiri-kanan, bukan ditumpuk sampai tak terbaca */
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.hand.scroll { justify-content: flex-start; }
.hand::-webkit-scrollbar { height: 6px; }
.hand::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.me-bar .swipe { font-size: 13px; font-weight: 600; color: var(--ink-3); }
@supports (width: min(1px, 2px)) {
  .hand { --card-w: min(15vw, calc(var(--app-h) * .1), 70px); }
}
.card-btn {
  flex: none; width: var(--card-w); padding: 0; border: 0; background: none;
  margin-left: var(--overlap, 2px); border-radius: 7px;
  transition: transform .14s ease, opacity .14s ease;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .45));
}
.card-btn:first-child { margin-left: 0; }
.card-btn.can { cursor: pointer; transform: translateY(-10px); }
.card-btn.can .card-body { stroke: var(--amber); stroke-width: 3; }
/* Digelapkan, bukan dibuat transparan: kartu yang bertumpuk tidak saling tembus. */
.card-btn.dim { filter: brightness(.5) drop-shadow(0 3px 4px rgba(0, 0, 0, .45)); }
.card-btn.can { position: relative; z-index: 1; }

/* Layar bandar: kursi berjajar di atas, meja besar */
.is-dealer .me { display: none; }
@media (min-width: 900px) {
  .cangkul.table { max-width: 1400px; margin: 0 auto; padding: 12px 16px 16px; gap: 12px; }
  .is-dealer .ck-seats { grid-auto-flow: column; grid-template-columns: none; }
  .is-dealer .seat { padding: 12px; }
  .is-dealer .seat-name { font-size: 17px; }
  .is-dealer .trick-card { width: 104px; font-size: 16px; }
  .is-dealer .trick-card.wait .slot-empty { height: 138px; }
  .is-dealer .pile { width: 92px; font-size: 15px; }
  .is-dealer .trick { gap: 18px; }
  .is-dealer.cangkul .status { font-size: 20px; padding: 8px 20px; }
  .is-dealer .suit-icon { width: 22px; height: 26px; }
  .cangkul .felt { gap: 40px; }
}

/* HP mendatar */
@media (max-height: 480px) {
  .cangkul.table {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: 'bar bar' 'felt seats' 'felt me';
  }
  .cangkul .felt { padding-top: 44px; }
  .ck-seats { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; }
  .me-bar { display: none; }
  .hand { --card-w: 11vw; }
  @supports (width: min(1px, 2px)) {
    .hand { --card-w: min(11vw, calc(var(--app-h) * .2), 60px); }
  }
}

@media (min-width: 900px) {
  .is-dealer.cangkul .status { display: none; }
}
