/* HP tegak: lawan di atas, papan, aku di bawah, lalu tombol dan catatan langkah. */
.reversi.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 auto;
  grid-template-areas: 'bar' 'top' 'board' 'bottom' 'side';
  gap: 6px;
  padding: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  overflow: hidden;
}
.reversi .topbar { grid-area: bar; }
.player-bar.top { grid-area: top; }
.player-bar.bottom { grid-area: bottom; }
.board-wrap { grid-area: board; min-height: 260px; min-width: 0; display: grid; place-items: center; position: relative; }
#board { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 100%; touch-action: manipulation; }
#board .sq { cursor: pointer; }
#board .pc { transition: transform .18s ease-out; pointer-events: none; }
#board .pc.lift { filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .45)); }

.player-bar {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 6px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
}
.player-bar.is-active { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.pb-dot { width: 22px; height: 22px; border-radius: 50%; flex: none; border: 2px solid var(--ink-3); }
.pb-dot.w { background: #fbf6ea; }
.pb-dot.b { background: #2b231e; border-color: #efe2c8; }
.pb-name { font-weight: 700; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-taken { display: flex; align-items: center; gap: 0; min-width: 0; overflow: hidden; flex: 1; }
.pb-taken svg { width: 18px; height: 18px; flex: none; margin-right: -5px; }
.pb-taken .adv { margin-left: 8px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.clock {
  margin-left: auto; padding: 4px 10px; border-radius: 8px; background: #0f0c09;
  font: 800 20px/1 'Figtree', monospace; font-variant-numeric: tabular-nums; color: var(--ink-2); flex: none;
}
.is-active .clock { background: var(--ivory); color: var(--pip); }
.clock.low { color: #fff !important; background: var(--danger) !important; }

.cc-side { grid-area: side; display: grid; gap: 6px; }
.cc-status { font-weight: 600; font-size: 14px; text-align: center; color: var(--ink-2); }
.cc-status.mine { color: var(--amber); font-weight: 700; }
.cc-actions { display: flex; gap: 8px; }
.cc-actions .btn { flex: 1; min-height: 42px; }
.cc-actions:empty { display: none; }
.history {
  display: flex; gap: 10px; margin: 0; padding: 4px 6px; list-style: none;
  overflow-x: auto; white-space: nowrap; font-size: 13px; color: var(--ink-2);
  scrollbar-width: thin;
}
.history:empty { display: none; }
.history li b { color: var(--ink-3); font-weight: 600; margin-right: 3px; }
.history li:last-child { color: var(--ink); font-weight: 700; }

.promo {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 30;
  display: grid; place-items: center; padding: 16px; background: rgba(10, 8, 5, .7);
}
.promo[hidden] { display: none; }
.promo-box { width: 100%; max-width: 360px; padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 12px; }
.promo-box p { font-family: var(--display); font-weight: 800; font-size: 20px; }
.promo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.promo-grid button { padding: 6px; border: 0; border-radius: 12px; background: #ecd9b0; cursor: pointer; display: grid; gap: 2px; justify-items: center; font: 700 12px var(--body); color: #3a2f22; }
.promo-grid svg { width: 100%; height: auto; }
#promoCancel { justify-self: end; }

/* HP mendatar: papan di kiri */
@media (max-height: 520px) and (orientation: landscape) {
  .reversi.table {
    grid-template-columns: minmax(0, calc(var(--app-h) - 16px)) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: 'board bar' 'board top' 'board side' 'board bottom';
  }
  .history { flex-wrap: wrap; white-space: normal; overflow-y: auto; max-height: 100%; align-content: flex-start; }
  .cc-side { align-content: start; min-height: 0; overflow: hidden; }
}

/* Layar bandar: papan besar di tengah, pemain di kiri, catatan langkah di kanan */
@media (min-width: 900px) {
  .reversi.table.is-dealer {
    max-width: 1500px; margin: 0 auto; padding: 12px 16px 16px; gap: 14px 24px;
    grid-template-columns: minmax(240px, 1fr) minmax(0, calc(var(--app-h) - 90px)) minmax(240px, 1fr);
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: 'bar bar bar' 'top board side' 'bottom board side';
  }
  .is-dealer .player-bar { flex-wrap: wrap; align-self: center; padding: 14px; gap: 12px; }
  .is-dealer .player-bar.top { align-self: end; }
  .is-dealer .player-bar.bottom { align-self: start; }
  .is-dealer .pb-name { font-size: 20px; }
  .is-dealer .pb-dot { width: 30px; height: 30px; }
  .is-dealer .clock { font-size: 34px; padding: 8px 14px; }
  .is-dealer .pb-taken { flex-basis: 100%; }
  .is-dealer .pb-taken svg { width: 26px; height: 26px; }
  .is-dealer .cc-side { align-content: start; padding-top: 8px; }
  .is-dealer .cc-status { display: none; }
  .is-dealer .history {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; white-space: normal;
    font-size: 17px; max-height: 60vh; overflow-y: auto; padding: 12px; border-radius: 12px; background: rgba(0, 0, 0, .25);
  }
  .is-dealer .history li:nth-child(odd) b { display: inline; }
  .reversi.is-dealer .host.on { left: auto; right: 18px; }
  .reversi.is-dealer .host.on .host-bubble { order: -1; border-radius: 18px 18px 4px 18px; }
  .reversi.is-dealer .host.on .host-bubble::before { left: auto; right: -9px; border-right: 0; border-left: 9px solid var(--ivory); }
}

/* Papan 3D */
.board3d { position: absolute; top: 0; right: 0; bottom: 0; left: 0; border-radius: 14px; overflow: hidden; background: radial-gradient(80% 80% at 50% 40%, #3a2818, #130c07); touch-action: none; }
.board3d[hidden] { display: none; }
