.congklak.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;
}
.congklak .topbar { grid-area: bar; }
.congklak .timer { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.congklak .timer-fill { height: 100%; width: 0; background: var(--amber); }
.congklak .timer-fill.low { background: var(--danger); }

.congklak-seats {
  grid-area: seats;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.congklak-seats .seat {
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.congklak-seats .seat.is-active {
  background: rgba(255, 179, 71, .15);
  border-color: var(--amber);
}
.congklak-seats .seat-name {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.congklak-seats .seat-store {
  font-size: 12px;
  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%, #251b14, #120c08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05), inset 0 0 40px rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 42px 8px 12px;
}
.congklak .status {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(25, 16, 10, .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;
}
.congklak .status.mine {
  background: var(--amber);
  color: #1a1612;
  font-weight: 700;
}

.board-wrapper {
  width: 100%;
  max-width: 760px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px;
}

/* Papan Congklak Kayu Tradisional */
.congklak-board {
  width: 100%;
  background: linear-gradient(135deg, #7c3f1d, #4d230d 50%, #6e3314);
  border: 4px solid #361708;
  border-radius: 36px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .6), inset 0 2px 4px rgba(255, 255, 255, .2), inset 0 -4px 8px rgba(0, 0, 0, .5);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Lumbung / Store */
.store-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: none;
}
.store-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, .6);
  text-transform: uppercase;
}
.store-pit {
  width: 58px;
  height: 110px;
  background: radial-gradient(circle at 45% 40%, #1f0c05, #0a0402);
  border: 3px solid #3a1a0b;
  border-radius: 28px;
  box-shadow: inset 0 6px 12px rgba(0, 0, 0, .85), 0 2px 4px rgba(255, 255, 255, .05);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 6px 4px;
}

/* Lubang-lubang Anak */
.pits-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.pits-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.pit-btn {
  background: radial-gradient(circle at 45% 40%, #2a1208, #0e0502);
  border: 2px solid #3d1b0d;
  border-radius: 50%;
  height: 48px;
  min-width: 0;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, .9), 0 1px 2px rgba(255, 255, 255, .08);
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.pit-btn:disabled {
  cursor: default;
}
.pit-btn.can-play {
  border-color: var(--amber);
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, .9), 0 0 10px rgba(255, 179, 71, .6);
  cursor: pointer;
  animation: pit-bounce 1.5s infinite alternate ease-in-out;
}
.pit-btn.can-play:hover {
  transform: scale(1.08);
  border-color: #ffd180;
}
@keyframes pit-bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

.seed-count {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
  z-index: 2;
}
.store-pit .seed-count {
  font-size: 20px;
  color: var(--amber);
}

.seeds-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  max-width: 32px;
  margin-top: 1px;
}
.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f7d58b;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .6);
}

.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;
  min-height: 28px;
}
.action-hint {
  font-size: 12px;
  color: var(--amber);
  font-weight: 700;
}

.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: #1e150f;
  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;
}

/* HP sempit: papan 16 lubang harus muat di ~360px, jadi lumbung dan lubang dikecilkan
   dan titik biji disembunyikan (angka sudah cukup). */
@media (max-width: 560px) {
  .felt { padding: 46px 4px 8px; }
  .board-wrapper { padding: 0; }
  .congklak-board { padding: 10px 6px; gap: 4px; border-radius: 24px; border-width: 3px; }
  .store-label { display: none; }
  .store-pit { width: 34px; height: 92px; border-radius: 17px; padding: 4px 2px; }
  .store-pit .seed-count { font-size: 16px; }
  .pits-center { gap: 8px; }
  .pits-row { gap: 3px; }
  .pit-btn { height: 34px; border-width: 2px; }
  .seeds-dots { display: none; }
  .seed-count { font-size: 14px; }
}

/* Papan 3D */
.board-wrapper.is-3d { max-width: none; flex: 1; min-height: 0; align-self: stretch; padding: 0; }
.board3d { width: 100%; height: 100%; min-height: 300px; border-radius: 14px; overflow: hidden; background: radial-gradient(80% 80% at 50% 40%, #3a2818, #130c07); }
.board3d[hidden] { display: none; }
