/* Meja */
.topbar { grid-area: bar; }
.timer { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.timer-fill { height: 100%; width: 0; background: var(--amber); }
.timer-fill.low { background: var(--danger); }

.table {
  height: var(--app-h);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: 'bar bar bar' 'left top right' 'felt felt felt' 'me me me';
  gap: 6px 8px;
  padding: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  overflow: hidden;
}
.seat-slot[data-area='left'] { grid-area: left; }
.seat-slot[data-area='top'] { grid-area: top; }
.seat-slot[data-area='right'] { grid-area: right; }
.seat-slot:empty { display: none; }

.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);
}
#board { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; }
.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;
  pointer-events: none;
}
.status.mine { background: var(--amber); color: var(--amber-ink); font-weight: 700; }
.choices {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; white-space: nowrap;
}
.fresh { animation: slam .28s cubic-bezier(.2, 1.3, .5, 1); transform-box: fill-box; transform-origin: center; }
@keyframes slam { from { transform: scale(1.5); opacity: 0; } }
.board-shadow { fill: rgba(0, 0, 0, .35); }
.ghost { cursor: pointer; }
.ghost-hit { fill: transparent; }
.ghost-outline {
  fill: rgba(242, 169, 59, .22); stroke: var(--amber); stroke-width: 7; stroke-dasharray: 18 12;
  animation: pulse 1.1s ease-in-out infinite alternate;
}
.ghost:hover .ghost-outline { fill: rgba(242, 169, 59, .5); }
@keyframes pulse { to { fill: rgba(242, 169, 59, .45); } }
.empty-hint { fill: rgba(246, 239, 223, .35); font: 600 44px var(--body); text-anchor: middle; }

.me { grid-area: me; display: grid; gap: 6px; }
.is-dealer .me-bar, .is-dealer .timer, .is-dealer .hand { display: none; }
.seat-slot[data-area='bottom'] { justify-self: center; width: 60vw; max-width: 240px; }
.me-bar { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 4px; position: relative; }
.me-bar .avatar { width: 32px; height: 32px; font-size: 15px; }
.me-bar b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-bar .score { margin-left: auto; font-weight: 700; font-size: 15px; color: var(--amber); white-space: nowrap; }
.me-bar .bubble { position: static; animation: none; }
.hand {
  --tile-w: 12.8vw;
  display: flex; justify-content: center; gap: 4px;
  min-height: calc(var(--tile-w) * 2 + 12px); padding-top: 12px;
}
@supports (width: min(1px, 2px)) {
  .hand { --tile-w: min(12.8vw, calc(var(--app-h) * .13), 62px); }
}
.tile-btn {
  flex: none; width: var(--tile-w); padding: 0; border: 0; background: none; cursor: default;
  border-radius: 10%; transition: transform .14s ease, opacity .14s ease;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .45));
}
.tile-btn.can { cursor: pointer; }
@media (hover: hover) {
  .tile-btn.can:hover { transform: translateY(-6px); }
}
.tile-btn.can .tile-body { stroke: var(--amber); stroke-width: 5; }
.tile-btn.selected { transform: translateY(-12px); }
.tile-btn.selected .tile-body { fill: #ffe9bd; stroke-width: 7; }
.tile-btn.dim { opacity: .42; }

/* Layar lebar: lawan duduk mengelilingi meja */
@media (min-width: 900px) and (min-height: 560px) {
  .table {
    max-width: 1400px; margin: 0 auto; padding: 12px 16px 16px; gap: 10px 12px;
    grid-template-columns: 180px minmax(0, 1fr) 180px;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: 'bar bar bar' '. top .' 'left felt right' 'me me me';
  }
  .seat-slot[data-area='top'] { justify-self: center; width: 240px; }
  .seat-slot[data-area='left'], .seat-slot[data-area='right'] { align-self: center; }
  .seat { padding: 12px; }
  .seat-name { font-size: 16px; }
  .me-bar { justify-content: center; }
  .me-bar .score { margin-left: 8px; }
}

/* HP mendatar: tinggi layar sangat terbatas */
@media (max-height: 480px) {
  .table {
    grid-template-columns: 130px minmax(0, 1fr) 130px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: 'bar bar bar' 'left felt right' 'me me me';
  }
  .seat-slot[data-area='top'] {
    grid-area: bar; justify-self: center; width: 180px; z-index: 1;
  }
  .topbar .round { display: none; }
  .seat { padding: 4px 8px; }
  .me-bar { display: none; }
  .hand { --tile-w: 9vw; padding-top: 8px; min-height: 0; }
  @supports (width: min(1px, 2px)) {
    .hand { --tile-w: min(9vw, calc(var(--app-h) * .18), 46px); }
  }
  .seat-slot[data-area='left'], .seat-slot[data-area='right'] { align-self: center; }
}

/* Layar bandar: Sari yang membacakan status, jadi label status di meja disembunyikan. */
@media (min-width: 900px) {
  .is-dealer .felt .status { display: none; }
}
