.biliard.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;
}
.biliard .topbar { grid-area: bar; }
.biliard .timer { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.biliard .timer-fill { height: 100%; width: 0; background: var(--amber); }
.biliard .timer-fill.low { background: var(--danger); }

.biliard-seats {
  grid-area: seats;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.biliard-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;
}
.biliard-seats .seat.is-active {
  background: rgba(255, 179, 71, .15);
  border-color: var(--amber);
}
.biliard-seats .seat-name {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.biliard-seats .seat-group { font-size: 12px; color: var(--ink-2); }
.biliard-seats .seat-score {
  font-size: 12px;
  color: var(--amber);
  font-weight: 700;
}

.felt {
  grid-area: felt;
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: 18px;
  background: #100b08;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.biliard .status {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(20, 14, 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;
}
.biliard .status.mine {
  background: var(--amber);
  color: #1a1612;
  font-weight: 700;
}

.canvas-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#boardCanvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .7);
}

.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;
}

.controls-panel {
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 12px;
  align-items: center;
}
@media (max-width: 600px) {
  .controls-panel {
    grid-template-columns: 1fr 1fr;
  }
}
.control-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, .7);
}
.control-row input[type="range"] {
  width: 100%;
  accent-color: var(--amber);
}
.strike-btn {
  font-weight: 800;
  padding: 8px 16px;
}

.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: #1c140d;
  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;
}

/* Papan 3D */
.canvas-wrap { position: relative; }
.board3d { position: absolute; top: 0; right: 0; bottom: 0; left: 0; border-radius: 12px; overflow: hidden; background: radial-gradient(80% 80% at 50% 40%, #3a2818, #130c07); touch-action: none; }
.board3d[hidden] { display: none; }

.canvas-wrap { width: 100%; height: 100%; }
#boardCanvas { width: 100%; max-height: 100%; object-fit: contain; background: transparent; touch-action: manipulation; }
.aim-hint { margin: 0; font-size: 12px; color: var(--ink-2); text-align: center; min-height: 1.2em; }
@media (max-width: 600px) { .controls-panel { grid-template-columns: 1fr 1fr; } .controls-panel .btn { grid-column: span 2; } }

/* Kontrol gaya 8 Ball Pool: bar tenaga di kiri, bola putarannya di kiri bawah */
.canvas-wrap .pwr { position: absolute; left: 8px; top: 50%; transform: translateY(-58%); width: 40px; height: min(64%, 280px); border-radius: 20px; background: rgba(10, 8, 5, .72); border: 1px solid rgba(255, 255, 255, .22); touch-action: none; z-index: 7; cursor: ns-resize; overflow: visible; }
.pwr-fill { position: absolute; top: 3px; left: 3px; right: 3px; height: 40%; border-radius: 17px; background: linear-gradient(180deg, #ffe39a, #f2a93b 55%, #d9442b); pointer-events: none; }
.pwr-knob { position: absolute; left: -4px; right: -4px; height: 14px; margin-top: -7px; border-radius: 8px; background: #fff7e6; box-shadow: 0 2px 8px rgba(0, 0, 0, .6); pointer-events: none; }
.pwr-val { position: absolute; left: 50%; bottom: -24px; transform: translateX(-50%); font: 800 12px var(--body); color: var(--amber); white-space: nowrap; pointer-events: none; }
.pwr-tip { position: absolute; left: 48px; top: 50%; transform: translateY(-50%); width: 7em; font: 600 11px/1.3 var(--body); color: rgba(255, 255, 255, .6); pointer-events: none; transition: opacity .4s; }
.pwr.used .pwr-tip { opacity: 0; }
.canvas-wrap .spin { position: absolute; left: 12px; bottom: 46px; width: 60px; height: 60px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fffdf4, #d9d2bd); border: 3px solid rgba(0, 0, 0, .5); box-shadow: 0 4px 10px rgba(0, 0, 0, .5); touch-action: none; z-index: 7; cursor: crosshair; }
.spin i { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #d33; box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); pointer-events: none; }
.pocket-hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); max-width: calc(100% - 140px); padding: 6px 14px; border-radius: 999px; background: rgba(20, 14, 10, .88); color: var(--amber); font: 700 12px var(--body); text-align: center; z-index: 7; pointer-events: none; }
.biliard-seats .group-balls { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 3px; }
.gb { width: 15px; height: 15px; border-radius: 50%; font: 800 8px/15px var(--body); text-align: center; color: #111; background: #f6f2e6; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35); }
.gb.stripe { background: linear-gradient(180deg, #f6f2e6 28%, var(--c) 28%, var(--c) 72%, #f6f2e6 72%); }
.gb.solid { background: var(--c); color: #fff; }
.gb.done { opacity: .22; }
.control-row.fine { grid-column: 1 / 3; }
@media (max-width: 600px) { .canvas-wrap .pwr { width: 34px; left: 5px; } .pwr-tip { display: none; } .canvas-wrap .spin { width: 52px; height: 52px; left: 8px; bottom: 44px; } }
.canvas-wrap .pwr { height: min(56%, 250px); transform: translateY(-66%); }
.pwr-tip { left: 4px; top: -34px; transform: none; width: auto; max-width: 11em; white-space: normal; text-shadow: 0 1px 3px #000; }
.canvas-wrap .spin { bottom: 8px; }

/* ===== Arena: tampilan datar dari atas ===== */
.biliard.table { background: radial-gradient(1200px 700px at 50% 30%, #243445, #121a24 70%); }
.biliard-seats { background: linear-gradient(180deg, #4a4f57, #2d3138); border-bottom: 3px solid #14171c; border-radius: 0 0 12px 12px; padding: 6px 10px; display: block; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }
.hud { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; }
.hud-player { flex: 1 1 0; min-width: 0; display: grid; gap: 2px; }
.hud-player.right { text-align: right; justify-items: end; }
.hud-player b { font: 800 14px var(--body); color: #f3f1ea; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-shadow: 0 1px 2px #000; }
.hud-player small { font: 600 11px var(--body); color: #aab3bd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.hud-slots { display: flex; gap: 3px; }
.slot { width: 20px; height: 20px; border-radius: 50%; background: rgba(0, 0, 0, .55); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .8), 0 1px 0 rgba(255, 255, 255, .12); font: 800 9px/20px var(--body); text-align: center; font-style: normal; color: #111; }
.slot.on.solid { background: radial-gradient(circle at 35% 30%, #fff8, transparent 40%), var(--c); color: #fff; box-shadow: 0 1px 3px #000; }
.slot.on.stripe { background: linear-gradient(180deg, #f7f3e8 26%, var(--c) 26%, var(--c) 74%, #f7f3e8 74%); box-shadow: 0 1px 3px #000; }
.hud-av { flex: none; width: 54px; height: 54px; border-radius: 12px; background: linear-gradient(180deg, #1f6fa0, #0f3f60); border: 3px solid #39424d; display: grid; place-items: center; box-shadow: 0 2px 6px #000; }
.hud-av.is-active { border-color: #2ee66b; box-shadow: 0 0 10px rgba(46, 230, 107, .7), 0 2px 6px #000; }
.hud-av .avatar { width: 42px; height: 42px; background: transparent; font-size: 26px; }
.hud-av.is-active .avatar::before { display: none; }
.hud-av.is-offline { opacity: .5; }
.hud-mid { flex: none; width: 64px; height: 54px; border-radius: 10px; background: #101317; border: 2px solid #3a3f47; display: flex; align-items: center; justify-content: center; }
.hud-mid i { width: 20px; height: 20px; border-radius: 50%; margin-left: -6px; box-shadow: 0 1px 3px #000; }
.hud-mid i.solid { background: radial-gradient(circle at 35% 30%, #fff8, transparent 40%), var(--c); }
.hud-mid i.stripe { background: linear-gradient(180deg, #f7f3e8 26%, var(--c) 26%, var(--c) 74%, #f7f3e8 74%); }
.felt { background: transparent; box-shadow: none; }
.canvas-wrap { width: 100%; height: 100%; }
#boardCanvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; max-height: none; object-fit: fill; background: transparent; border-radius: 0; box-shadow: none; }
.canvas-wrap .spin { left: auto; right: 8px; top: 6px; bottom: auto; width: 52px; height: 52px; }
.canvas-wrap .status, .biliard .status { top: auto; bottom: 6px; }
@media (max-width: 700px) { .hud-av { width: 44px; height: 44px; } .hud-av .avatar { width: 34px; height: 34px; font-size: 20px; } .hud-mid { width: 46px; height: 44px; } .slot { width: 15px; height: 15px; font-size: 7px; line-height: 15px; } .hud-player b { font-size: 12px; } .hud-player small { display: none; } .canvas-wrap .spin { width: 44px; height: 44px; } }
.biliard .felt { background: transparent !important; box-shadow: none !important; padding: 4px 4px 34px; }
.biliard .felt .status { position: absolute; top: auto; bottom: 4px; left: 50%; transform: translateX(-50%); }
.biliard .felt::before { display: none; }
@media (max-width: 560px) { .hud-mid { display: none; } .slot { width: 12px; height: 12px; line-height: 12px; font-size: 6px; } .hud-slots { gap: 2px; } .hud-player b { font-size: 11px; } .hud-av { width: 40px; height: 40px; } .hud-av .avatar { width: 30px; height: 30px; font-size: 18px; } .hud { gap: 5px; } }
