/* CubeX – ✨ Đồ hoạ 3D thật (gfx.js, gfx-cube.js, gfx-chess.js) */
.gfx-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin: 8px 0 0; }
.gfx-bar[hidden] { display: none; }
.gfx-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; border-radius: 99px; font-weight: 700; }
.gfx-toggle b { font-size: .72rem; padding: 2px 7px; border-radius: 99px; background: rgba(120, 120, 140, .22); }
.gfx-toggle.on { border-color: var(--accent, #5b3df5) !important; box-shadow: 0 0 0 2px var(--accent-soft, rgba(91, 61, 245, .25)); }
.gfx-toggle.on b { background: #1f9d55; color: #fff; }
.gfx-seg, .gfx-q { display: inline-flex; border-radius: 99px; overflow: hidden; border: 1px solid var(--border, rgba(120, 120, 140, .35)); }
.gfx-seg button, .gfx-q button { border: 0 !important; border-radius: 0 !important; min-height: 36px; padding: 0 12px; font-weight: 700; font-size: .88rem; background: transparent; box-shadow: none !important; }
.gfx-seg button.active, .gfx-q button.active { background: var(--accent, #5b3df5) !important; color: var(--on-accent, #fff) !important; }
.gfx-note { flex-basis: 100%; text-align: center; color: var(--muted, #777); font-size: .82rem; }
.page-head .gfx-bar { margin: 0 0 0 auto; justify-content: flex-end; }

/* Khối Rubik: lớp WebGL vẽ đè, khối CSS cũ trong suốt nhưng vẫn nhận chạm / vuốt */
.scene.gfx-on { position: relative; }
.gfx-canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.cube.gl .face { background: transparent !important; box-shadow: none !important; }
.cube.gl .sticker { background: transparent !important; box-shadow: none !important; }
.cube.gl .sticker::after, .cube.gl .sticker::before, .cube.gl .face::after, .cube.gl .face::before { display: none !important; }

/* Bàn cờ 3D: bàn 2D cũ ẩn đi (vẫn giữ để chạy luật + kéo thả), lớp WebGL nằm trên */
.chess-board.b3d { background: none !important; box-shadow: none !important; overflow: visible; }
.chess-board.b3d .cb-squares, .chess-board.b3d .cb-pieces { opacity: 0; }
.gfx-board { position: absolute; left: 0; top: 0; width: 100%; height: 100%; touch-action: pan-y; z-index: 3; border-radius: 10px;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: transparent; }
.chess-board.g3pov-full, .g3pov-hud { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.gfx-toggle, .gfx-seg button, .gfx-q button { white-space: nowrap; }
/* 🔥 Aura bật / tắt */
.gfx-aura { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 13px 0 10px; border-radius: 99px; font-weight: 800; font-size: .88rem; white-space: nowrap; cursor: pointer; user-select: none;
  border: 1px solid var(--border, rgba(120, 120, 140, .35)); background: var(--card, transparent); }
.gfx-aura input { width: 18px; height: 18px; margin: 0; cursor: pointer; accent-color: #ff5a1f; }
.gfx-aura.on { background: linear-gradient(135deg, #ff5a1f, #b44dff 60%, #36d6ff); color: #fff; border-color: transparent; box-shadow: 0 0 14px rgba(255, 90, 31, .45), 0 0 22px rgba(120, 80, 255, .35); }
.gfx-aura.on input { accent-color: #fff; }
.gfx-aura:focus-within { outline: 2px solid var(--accent, #5b3df5); outline-offset: 2px; }

/* 👁 Góc nhìn quân cờ (gfx-chess.js) – phủ kín cả màn hình cho tới khi bấm Thoát */
.chess-board.b3d.g3pov-full, .chess-board.b3d.g3pov-full:fullscreen { position: fixed !important; inset: 0 !important; width: 100vw !important; height: 100vh !important; height: 100dvh !important;
  max-width: none !important; aspect-ratio: auto !important; margin: 0 !important; border-radius: 0 !important; z-index: 2147482000; background: #0d0a22 !important; overflow: hidden !important; }
.chess-board.g3pov-full .gfx-board { border-radius: 0; }
.chess-board.g3pov-full .g3pov-hud { bottom: max(14px, env(safe-area-inset-bottom)); }
body.g3pov-lock { overflow: hidden !important; }
body.g3pov-lock .ai-fab, body.g3pov-lock .ai-panel { display: none !important; }
.gfx-pov { min-height: 36px; padding: 0 12px; border-radius: 99px; font-weight: 700; font-size: .88rem; white-space: nowrap; }
.g3pov-hud { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 6; width: max-content; max-width: calc(100% - 12px);
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 14px; background: rgba(12, 10, 28, .72); color: #fff;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); pointer-events: auto; }
.g3pov-hud[hidden] { display: none; }
.g3pov-row { display: flex; align-items: center; gap: 6px; }
.g3pov-row button { min-height: 32px; min-width: 32px; padding: 0 9px; border-radius: 99px; border: 1px solid rgba(255, 255, 255, .25) !important; background: rgba(255, 255, 255, .12) !important; color: #fff !important; font-weight: 800; box-shadow: none !important; }
.g3pov-row .g3pov-exit { background: rgba(255, 70, 70, .35) !important; }
.g3pov-row .g3pov-high { background: rgba(70, 140, 255, .38) !important; white-space: nowrap; }
.g3pov-row { flex-wrap: wrap; justify-content: center; }
.g3pov-name { font-size: .9rem; white-space: nowrap; }
.g3pov-info { font-size: .76rem; opacity: .92; text-align: center; line-height: 1.3; }
/* ⏭ Câu tiếp theo – hiện khi giải xong, bấm là sang câu mới mà vẫn ở góc nhìn quân cờ */
.g3pov-go { margin-top: 2px; min-height: 36px; padding: 0 16px; border: 0; border-radius: 999px; background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; font-weight: 800; font-size: .9rem; cursor: pointer; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); animation: g3goIn .35s ease-out; }
.g3pov-go[hidden] { display: none !important; }
@keyframes g3goIn { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (max-width: 480px) { .g3pov-name { font-size: .8rem; } .g3pov-info { font-size: .7rem; } .g3pov-row button { min-height: 30px; min-width: 30px; padding: 0 7px; } }
/* Điện thoại: thanh chọn bàn 2D/3D xuống hàng riêng, không chèn tiêu đề "Cờ vua" */
@media (max-width: 700px) {
  .chess-page .page-head { flex-wrap: wrap; }
  .page-head .gfx-bar { flex: 1 0 100%; margin: 6px 0 0; justify-content: flex-start; }
}
