/* ==========================================================================
   GAME GHÉP HÌNH 3x3 - GIAO DIỆN MỚI (TƯƠI SÁNG, KHÔNG DÙNG MÀU XANH, KHÔNG SCROLL)
   - Tông màu: Vàng Ánh Kim Amber, Hồng San Hô & Trắng Sữa Ngọc Trai
   - Vừa vặn 1 màn hình (No scroll)
   - Hỗ trợ khóa mảnh số 5 ở lượt đầu
   - Hỗ trợ Crop ảnh trong Admin
   ========================================================================== */

:root {
  --game-bg: linear-gradient(135deg, #fff9f0 0%, #fff1f2 50%, #fef3c7 100%);
  --game-surface: #ffffff;
  --game-border: #fed7aa;
  --game-primary: #f59e0b;
  --game-primary-hover: #d97706;
  --game-coral: #fb7185;
  --game-coral-hover: #f43f5e;
  --game-text: #1e293b;
  --game-text-muted: #64748b;
  --game-radius: 16px;
  --game-font: 'Be Vietnam Pro', 'Montserrat', -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.game-body {
  font-family: var(--game-font);
  background: var(--game-bg);
  color: var(--game-text);
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Tránh scroll toàn trang */
}

/* Header gọn gàng */
.game-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--game-border);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.08);
  flex-shrink: 0;
}

.game-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-badge {
  background: linear-gradient(135deg, #f59e0b, #fb7185);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.game-logo h1 {
  font-size: 1.2rem;
  font-weight: 800;
  color: #78350f;
  line-height: 1.2;
}

.game-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.audio-control-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fffbeb;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid #fde68a;
}

.vol-slider-box {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mini-vol-slider {
  width: 60px;
  height: 4px;
  accent-color: #f59e0b;
  cursor: pointer;
}

.round-pill {
  background: #fef3c7;
  border: 1.5px solid #fde68a;
  color: #b45309;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 800;
}

.btn-icon {
  background: #ffffff;
  border: 1px solid #fed7aa;
  color: #b45309;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: #fef3c7;
  transform: scale(1.06);
}

/* Main Arena - Fit 100vh */
.game-arena {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  overflow: hidden;
}

.round-info-bar {
  text-align: center;
}

.round-info-bar h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: #78350f;
  margin-bottom: 3px;
}

.round-hint {
  font-size: 0.9rem;
  color: #9a3412;
  font-weight: 600;
  background: #ffedd5;
  display: inline-block;
  padding: 3px 14px;
  border-radius: 16px;
  border: 1px solid #fed7aa;
}

/* Jigsaw Board Container - Giữ tỉ lệ hoàn hảo không bị scroll */
.jigsaw-container-outer {
  position: relative;
  height: 48vh;
  max-height: 440px;
  aspect-ratio: 1 / 1;
  border-radius: var(--game-radius);
  box-shadow: 
    0 12px 36px rgba(180, 83, 9, 0.16),
    0 0 0 5px #ffffff,
    0 0 0 8px #fed7aa;
  background: #ffffff;
  overflow: hidden;
}

.jigsaw-board-svg {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
}

/* Mảnh ghép - Tông vàng hổ phách & hồng san hô ấm áp (không dùng xanh) */
.jigsaw-piece {
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
  transform-origin: center;
}

.jigsaw-piece:hover:not(.revealed):not(.locked) {
  filter: brightness(1.08);
  transform: scale(1.02);
}

.jigsaw-piece:hover:not(.revealed):not(.locked) .piece-path {
  stroke: #ffffff;
  stroke-width: 4.5;
}

.jigsaw-piece.revealed {
  opacity: 0;
  transform: scale(0.6) translateY(-25px);
  pointer-events: none;
}

/* Trạng thái mảnh số 5 bị khóa ở lượt 1 */
.jigsaw-piece.locked {
  cursor: not-allowed;
}

.jigsaw-piece.locked .piece-path {
  stroke: #fca5a5;
  stroke-dasharray: 6 3;
}

/* Player Controls Bar Gọn Gàng */
.controls-dock {
  width: 100%;
  max-width: 540px;
  background: #ffffff;
  border: 1px solid var(--game-border);
  border-radius: var(--game-radius);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.1);
  flex-shrink: 0;
}

.dock-row-primary {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.quick-pick-box {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-piece {
  width: 90px;
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  color: #78350f;
  border-radius: 10px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  text-align: center;
  outline: none;
}

.input-piece:focus {
  border-color: var(--game-primary);
  background: #fff;
}

.btn-game {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-game:hover {
  transform: translateY(-2px);
}

.btn-game-amber {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-game-coral {
  background: linear-gradient(135deg, #fb7185, #f43f5e);
  color: white;
  box-shadow: 0 4px 12px rgba(251, 113, 133, 0.25);
}

.btn-game-outline {
  background: #ffffff;
  color: #78350f;
  border: 1.5px solid #fed7aa;
}

.btn-game-outline:hover {
  background: #fffbeb;
}

.dock-row-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px dashed #fed7aa;
}

.stat-badge {
  font-size: 0.85rem;
  color: #9a3412;
  font-weight: 700;
}

.jigsaw-progress {
  width: 100%;
  height: 6px;
  background: #fef3c7;
  border-radius: 8px;
  overflow: hidden;
}

.jigsaw-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fb7185);
  border-radius: 8px;
  transition: width 0.3s ease;
}

/* ==========================================================================
   ADMIN DRAWER & IMAGE CROPPER TOOL
   ========================================================================== */

.admin-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
}

.admin-drawer-overlay.open { display: block; }

.admin-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 92vw;
  height: 100vh;
  background: #ffffff;
  border-left: 1px solid var(--game-border);
  z-index: 1000;
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.12);
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.admin-drawer.open { right: 0; }

.admin-drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid #fed7aa;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-drawer-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #78350f;
}

.admin-drawer-body {
  padding: 16px 20px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #78350f;
  text-transform: uppercase;
}

.admin-input, .admin-select {
  padding: 8px 12px;
  background: #fffbeb;
  border: 1.5px solid #fed7aa;
  color: #1e293b;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.admin-input:focus, .admin-select:focus {
  border-color: #f59e0b;
  background: #ffffff;
}

/* Image Cropper UI inside Admin Drawer */
.crop-container {
  background: #f8fafc;
  border: 1.5px dashed #fed7aa;
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.crop-canvas-box {
  width: 220px;
  height: 220px;
  margin: 8px auto;
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  background: #000;
  cursor: grab;
}

.crop-canvas-box:active {
  cursor: grabbing;
}

.crop-canvas-box img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  user-select: none;
  pointer-events: none;
}

.crop-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.crop-slider {
  flex: 1;
  accent-color: #f59e0b;
}

/* Answer modal */
.game-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.game-modal-backdrop.active { display: flex; }

.game-modal-card {
  background: #ffffff;
  border-radius: 20px;
  max-width: 460px;
  width: 100%;
  padding: 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.answer-img-preview {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 12px;
  margin: 12px 0;
  border: 2px solid #f59e0b;
}

/* Toast */
.toast-notice {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #78350f;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 99999;
  font-size: 0.9rem;
  font-weight: 600;
}

.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-notice.warning {
  background: #dc2626;
}

.toast-notice.success {
  background: #d97706;
}
