:root {
  --bg: #0c0c0f;
  --panel: rgba(0, 0, 0, 0.55);
  --border: rgba(255, 255, 255, 0.15);
  --accent: #00ffaa;
  --accent2: #ff6b35;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.6);
  --danger: #ff4466;
  --sheet-bg: rgba(14, 14, 18, 0.97);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: "JetBrains Mono", monospace;
  color: var(--text);
  touch-action: none;
}

/* â”€â”€ LOADING â”€â”€ */
#loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  gap: 18px;
}
#loading-title {
  font-family: "Montserrat", sans-serif;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
}
#loading-text {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.12em;
}
#progress-wrap {
  width: 220px;
  height: 2px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 2px;
  overflow: hidden;
}
#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #00ccff);
  transition: width 0.15s;
  box-shadow: 0 0 10px var(--accent);
}

/* â”€â”€ CANVAS â”€â”€ */
canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

/* â”€â”€ HEADER â”€â”€ */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: linear-gradient(to bottom, rgba(12, 12, 15, 0.92) 0%, transparent 100%);
  pointer-events: none;
}
#header-title {
  font-family: "Montserrat", sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
}
#model-info {
  font-size: 0.6rem;
  color: var(--muted);
  text-align: right;
  line-height: 1.7;
}

/* â”€â”€ TOOLBAR (top right) â”€â”€ */
#toolbar {
  position: fixed;
  top: 0;
  right: 12px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: calc(56px + env(safe-area-inset-top, 0px));
}
.tb-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  backdrop-filter: blur(12px);
}
.tb-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.12);
}
.tb-btn.active {
  background: rgba(0, 255, 170, 0.15);
  border-color: var(--accent);
}

/* â”€â”€ BOTTOM SHEET â”€â”€ */
#sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
#sheet-overlay.open {
  opacity: 1;
  pointer-events: all;
}

#bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--sheet-bg);
  border-top: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  padding: 0 16px calc(16px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 80vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  margin: 12px auto 16px;
}
.sheet-title {
  font-family: "Montserrat", sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 14px;
}

/* â”€â”€ SECTION â”€â”€ */
.section {
  margin-bottom: 18px;
}
.section-label {
  font-size: 0.55rem;
  letter-spacing: 0.15em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* â”€â”€ PILL GRID â”€â”€ */
.pill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pill-grid.cols3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 8px;
  font-size: 0.68rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  text-align: center;
  line-height: 1.3;
}
.pill:active {
  transform: scale(0.96);
}
.pill.active {
  background: rgba(0, 255, 170, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.pill.danger {
  border-color: rgba(255, 68, 102, 0.4);
  color: var(--danger);
}
.pill .icon {
  font-size: 1rem;
}

/* â”€â”€ SLIDER GROUP â”€â”€ */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  color: var(--muted);
}
.slider-label span:last-child {
  color: var(--accent);
}
input[type="range"] {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* â”€â”€ COLOR SWATCHES â”€â”€ */
.swatch-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.swatch {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  flex-shrink: 0;
}
.swatch:active {
  transform: scale(1.2);
}
.swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

/* â”€â”€ FAB (main button) â”€â”€ */
#fab {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  right: 16px;
  z-index: 30;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #00ccff);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 20px rgba(0, 255, 170, 0.4);
  transition: all 0.2s;
}
#fab:active {
  transform: scale(0.92);
}

/* â”€â”€ QUICK BAR (bottom left) â”€â”€ */
#quick-bar {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 16px;
  z-index: 30;
  display: flex;
  gap: 8px;
}
.q-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  backdrop-filter: blur(12px);
}
.q-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.12);
}
.q-btn.active {
  background: rgba(0, 255, 170, 0.15);
  border-color: var(--accent);
}

/* â”€â”€ OVERLAY PANELS (STATS & INFO) â”€â”€ */
#overlay-container {
  position: fixed;
  top: 60px;
  left: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center; /* Horizontally centers children like QR code */
  justify-content: center;
  gap: 10px;
  pointer-events: none; /* Let clicks pass through empty space */
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}

#stats-overlay {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.6rem;
  line-height: 2;
  color: var(--muted);
  backdrop-filter: blur(10px);
  display: none;
  pointer-events: auto; /* Catch clicks on the panels */
  max-height: 50vh;
  overflow-y: auto;
  width: 150px;
}

/* áº¨n thanh cuá»™n máº·c Ä‘á»‹nh cho Ä‘áº¹p */
#stats-overlay::-webkit-scrollbar {
  display: none;
}

#stats-overlay span {
  color: var(--accent);
}

/* â”€â”€ CENTER MODAL (INFO & MODELS) â”€â”€ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.modal-backdrop.open {
  display: block;
  opacity: 1;
}

.center-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 60;
  background: var(--sheet-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.center-modal.open {
  display: flex;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.title-chi-tiet {
  color: var(--accent);
}

.info-line {
  margin: 16px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.modal-title {
  font-family: "Montserrat", sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--muted);
}
.modal-close:active {
  transform: scale(0.9);
}
.modal-close:hover {
  color: var(--danger);
  background: rgba(255, 68, 102, 0.1);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 0.75rem;
  color: var(--text);
}
.modal-body::-webkit-scrollbar {
  display: none;
}

.info-grid {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px 8px;
}
.info-label {
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.info-value {
  color: #fff;
  font-weight: 600;
}

.info-details {
  line-height: 1.6;
  text-align: justify;
  color: rgba(255, 255, 255, 0.8);
}

/* â”€â”€ MODELS GRID â”€â”€ */
.models-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 10px 5px;
}
.mobile-grid {
  grid-template-columns: repeat(2, 1fr);
}
.model-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 15px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.2));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.model-item:hover {
  background: linear-gradient(145deg, rgba(0, 255, 170, 0.1), rgba(0, 0, 0, 0.3));
  border-color: rgba(0, 255, 170, 0.3);
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 10px 25px rgba(0, 255, 170, 0.15);
}
.model-item:active {
  transform: scale(0.95);
}
.model-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: transparent; /* Loáº¡i bá» viá»n vuÃ´ng tá»‘i cÅ© */
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--muted);
  overflow: visible; /* Cho phÃ©p bÃ³ng Ä‘á»• lá»t ra ngoÃ i */
}
.model-name {
  font-family: "Montserrat", sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.8);
}

/* â”€â”€ TOAST â”€â”€ */
#toast {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: rgba(0, 255, 170, 0.15);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  padding: 8px 18px;
  border-radius: 20px;
  z-index: 300;
  transition: transform 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
}

/* â”€â”€ VR badge â”€â”€ */
#vr-badge {
  display: none;
  align-items: center;
  gap: 6px;
  background: rgba(255, 107, 53, 0.15);
  border: 1px solid var(--accent2);
  color: var(--accent2);
  font-size: 0.68rem;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 8px;
  width: 100%;
  justify-content: center;
}
#vr-badge.visible {
  display: flex;
}

/* â”€â”€ Scrollbar â”€â”€ */
#bottom-sheet::-webkit-scrollbar {
  display: none;
}

.hitbox {
  position: absolute;
  inset: 0;
  z-index: 100;
}

.relative {
  position: relative;
}

/* â”€â”€ Mute Three.js VR Button â”€â”€ */
#VRButton {
  display: none !important;
}

/* â”€â”€ Responsive UI (Mobile) â”€â”€ */
@media (max-width: 959px) {
  #toolbar {
    gap: 4px;
    right: 6px;
    padding-top: calc(50px + env(safe-area-inset-top, 0px));
  }
  .tb-btn {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
    border-radius: 8px;
  }

  #quick-bar {
    left: 6px;
    gap: 4px;
  }
  .q-btn {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
    border-radius: 8px;
  }

  #header-title {
    font-size: 0.75rem;
  }
}

/* -- PREMIUM MODALS -- */
.premium-modal {
  background: rgba(20, 20, 25, 0.85) !important;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px !important;
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: var(--text);
  overflow: hidden;
}

.premium-modal .uk-modal-close-default {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  padding: 8px;
  top: 15px;
  right: 15px;
  transition: all 0.3s ease;
}

.premium-modal .uk-modal-close-default:hover {
  background: var(--danger);
  color: #fff;
  transform: rotate(90deg);
}

/* QR Modal Specific */
.qr-modal-custom {
  width: 340px !important;
  padding: 40px 20px !important;
  text-align: center;
  background: linear-gradient(145deg, rgba(30, 30, 40, 0.95), rgba(15, 15, 20, 0.98)) !important;
}

.qr-wrapper {
  background: #fff;
  padding: 15px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 25px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s ease;
}

.qr-wrapper:hover {
  transform: scale(1.05) translateY(-5px);
}

#qr-modal-img {
  width: 240px;
  height: 240px;
  object-fit: contain;
}

.qr-title {
  font-family: "Montserrat", sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 8px;
  text-shadow: 0 2px 10px rgba(0, 255, 170, 0.2);
}

.qr-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Gallery Modal Specific */
.gallery-modal-custom {
  max-width: 900px !important;
}

.premium-modal-header {
  background: transparent !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  padding: 25px 35px !important;
}

.premium-modal-header .uk-modal-title {
  font-family: "Montserrat", sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0;
  text-shadow: 0 2px 15px rgba(0, 255, 170, 0.25);
}

.premium-modal-header .modal-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 8px 0 0 0;
  letter-spacing: 0.5px;
}

.gallery-modal-custom .uk-modal-body {
  padding: 30px 35px !important;
  max-height: 70vh;
}

.gallery-modal-custom .uk-modal-body::-webkit-scrollbar {
  width: 8px;
}
.gallery-modal-custom .uk-modal-body::-webkit-scrollbar-track {
  background: transparent;
}
.gallery-modal-custom .uk-modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}
.gallery-modal-custom .uk-modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* â”€â”€ PREMIUM UIKIT TOOLTIP CUSTOMIZATION â”€â”€ */
.uk-tooltip {
  background: rgba(10, 10, 14, 0.98) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border: 1px solid var(--accent) !important;
  color: #ffffff !important;
  font-family: "Montserrat", sans-serif !important;
  font-size: 0.65rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.1em !important;
  padding: 6px 12px !important;
  border-radius: 6px !important;
  box-shadow:
    0 10px 25px rgba(0, 0, 0, 0.9),
    0 0 12px rgba(0, 255, 170, 0.25) !important;
  text-transform: uppercase !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5) !important;
}

/* MÅ©i tÃªn cho Tooltip Toolbar (hiá»ƒn thá»‹ bÃªn trÃ¡i nÃºt) */
.uk-tooltip[class*="uk-tooltip-left"]::after {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  top: 50% !important;
  right: -6px !important;
  transform: translateY(-50%) !important;
  border-top: 6px solid transparent !important;
  border-bottom: 6px solid transparent !important;
  border-left: 6px solid var(--accent) !important;
  border-right: none !important;
}

/* MÅ©i tÃªn cho Tooltip Quick Bar (hiá»ƒn thá»‹ bÃªn trÃªn nÃºt) */
.uk-tooltip[class*="uk-tooltip-top"]::after {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  bottom: -6px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  border-left: 6px solid transparent !important;
  border-right: 6px solid transparent !important;
  border-top: 6px solid var(--accent) !important;
  border-bottom: none !important;
}

/* Custom width for models modal to keep it compact */
#models-overlay {
  max-width: 650px !important;
}

#model-info {
  display: none;
}

#qr-display {
  display: none; /* Toggle via JS */
  border-radius: 8px;
  object-fit: contain;
  background: white;
  padding: 5px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  margin-top: 10px;
  pointer-events: auto;
}


/* ── BUTTON LABELS (For Touch Interfaces) ── */
.btn-label {
  display: none;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 4px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  line-height: 1.2;
  text-align: center;
}

@media (min-width: 960px) {
  body.show-labels .btn-label {
    display: block;
  }

  body.show-labels .tb-btn,
  body.show-labels .q-btn,
  body.show-labels #fab {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    min-width: 64px !important;
    height: auto !important;
    min-height: 52px !important;
    border-radius: 12px !important;
    padding: 8px 6px !important;
    gap: 2px !important;
  }

  body.show-labels #quick-bar {
    flex-wrap: wrap;
  }
}