*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 17px; }

/* Zoom global UI — no afecta canvas 3D ni callouts */
#top-bar, #side-panel, #settings-panel,
#camera-controls, #zoom-controls, #history-controls, #hint-bar,
#game-actions,
#annotate-toolbar, #annotate-size, #annotate-palette {
  zoom: var(--ui-zoom, 1.4);
}

/* ── LIGHT (default) ── */
:root {
  --bg: #f5eeec;
  --panel-bg: rgba(255, 255, 255, 0.94);
  --panel-border: rgba(111, 58, 43, 0.12);
  --accent: #FC8172;
  --accent2: #F29E9E;
  --accent-dark: #6F3A2B;
  --text: #2d1a15;
  --text-dim: #9a7068;
  --scene-bg: #e8ddd9;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(111,58,43,0.12);
  --cam-sep: rgba(111,58,43,0.15);
}

/* ── DARK ── */
body.dark {
  --bg: #1a0f0d;
  --panel-bg: rgba(30, 16, 12, 0.94);
  --panel-border: rgba(252, 129, 114, 0.12);
  --accent: #FC8172;
  --accent2: #F29E9E;
  --accent-dark: #F8CCCF;
  --text: #f2e8e6;
  --text-dim: #c4918a;
  --scene-bg: #110a09;
  --shadow: 0 2px 12px rgba(0,0,0,0.50);
  --cam-sep: rgba(252,129,114,0.15);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  transition: background 0.3s, color 0.3s;
}

/* ── CANVAS ── */
#viewer-container {
  position: relative; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden;
  background: radial-gradient(ellipse at var(--bg-cx, 60%) 40%, #ddd5cf 0%, #c8bfba 50%, #b8aeaa 100%);
}
body.dark #viewer-container {
  background: radial-gradient(ellipse at var(--bg-cx, 60%) 40%, #2a1e1a 0%, #160e0b 50%, #080404 100%);
}
/* Viñeta radial (bordes tintados → centro limpio) con wobble suave */
#viewer-container::before {
  content: ''; position: absolute; inset: -15%; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 72% 72% at var(--bg-cx, 50%) 46%, transparent 32%, rgba(252,129,114,0.14) 72%, rgba(111,58,43,0.22) 100%);
  filter: blur(8px); transform-origin: center;
  animation: bgWobble 18s ease-in-out infinite alternate;
}
body.dark #viewer-container::before {
  background: radial-gradient(ellipse 72% 72% at var(--bg-cx, 50%) 46%, transparent 30%, rgba(252,129,114,0.10) 70%, rgba(0,0,0,0.45) 100%);
}
/* Capa de ruido (dither) para romper el banding de los gradientes */
#viewer-container::after {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  opacity: 0.05; mix-blend-mode: overlay;
}
body.dark #viewer-container::after { opacity: 0.07; }
@keyframes bgWobble {
  0%   { transform: translate(-2%, -1.5%) rotate(0deg)  scale(1.02); }
  50%  { transform: translate(2.5%, 2%)   rotate(3deg)  scale(1.12); }
  100% { transform: translate(-1.5%, 2.5%) rotate(-3deg) scale(1.06); }
}
#canvas { display: block; width: 100%; height: 100%; touch-action: none; position: relative; z-index: 1; }

/* ── LOADING (cinemático) ── */
#loading-screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #efe8e5 0%, #d9d0cc 45%, #c3b9b4 100%);
  z-index: 100;
  overflow: hidden;
  transition: opacity 0.6s ease;
}
body.dark #loading-screen {
  background: radial-gradient(ellipse at center, #2a1d18 0%, #160e0b 55%, #060403 100%);
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }

/* Bloqueo invisible durante tareas pesadas (p. ej. iniciar juego): solo captura clics, sin panel. */
#busy-overlay { position: fixed; inset: 0; z-index: 9999; display: none; background: transparent; pointer-events: auto; }
#busy-overlay.on { display: block; }

/* Aurora en movimiento (capa de fondo) */
#loading-screen::before {
  content: ''; position: absolute; inset: -30%;
  background:
    radial-gradient(circle at 30% 30%, rgba(252,129,114,0.30), transparent 45%),
    radial-gradient(circle at 70% 60%, rgba(242,158,158,0.25), transparent 45%),
    radial-gradient(circle at 50% 80%, rgba(248,204,207,0.22), transparent 50%);
  filter: blur(30px);
  animation: aurora 14s ease-in-out infinite alternate;
}
body.dark #loading-screen::before { opacity: 0.55; }
@keyframes aurora {
  0%   { transform: translate(-4%, -3%) rotate(0deg) scale(1); }
  50%  { transform: translate(5%, 4%)  rotate(8deg) scale(1.15); }
  100% { transform: translate(-3%, 5%) rotate(-6deg) scale(1.05); }
}

/* Partículas que flotan hacia arriba */
#loading-screen::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 20% 110%, rgba(255,255,255,0.55), transparent),
    radial-gradient(2px 2px at 40% 130%, rgba(252,129,114,0.6), transparent),
    radial-gradient(1.5px 1.5px at 60% 120%, rgba(255,255,255,0.45), transparent),
    radial-gradient(2px 2px at 80% 140%, rgba(242,158,158,0.6), transparent),
    radial-gradient(1.5px 1.5px at 90% 115%, rgba(255,255,255,0.4), transparent);
  background-repeat: repeat-y; background-size: 100% 100%;
  animation: particles 9s linear infinite;
}
@keyframes particles {
  from { transform: translateY(0); }
  to   { transform: translateY(-60%); }
}

.loader-content { text-align: center; position: relative; z-index: 1; }
#loading-logo {
  width: 260px; height: auto; margin-bottom: 40px;
  animation: logo-breathe 2.8s ease-in-out infinite;
  transform-origin: center;
  filter: drop-shadow(0 0 26px rgba(252,129,114,0.45));
}
@keyframes logo-breathe {
  0%   { transform: scale(0.9); }
  50%  { transform: scale(1.07); }
  100% { transform: scale(0.9); }
}

.loader-ring {
  width: 64px; height: 64px;
  border: 4px solid rgba(252,129,114,0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading-text { color: var(--text-dim); font-size: 14px; margin-bottom: 12px; letter-spacing: 0.5px; }
#loading-bar-wrap {
  width: 220px; height: 4px;
  background: rgba(128,128,128,0.18);
  border-radius: 3px; margin: 0 auto; overflow: hidden;
}
#loading-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent2), var(--accent), var(--accent2));
  background-size: 200% 100%;
  border-radius: 3px; transition: width 0.25s ease;
  animation: bar-shimmer 1.6s linear infinite;
  box-shadow: 0 0 10px rgba(252,129,114,0.6);
}
@keyframes bar-shimmer { to { background-position: -200% 0; } }

/* ── HEADER ── */
#top-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 58px;
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  font-size: 15px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  z-index: 20;
}

#logo { display: flex; align-items: center; }
#logo a { display: flex; align-items: center; cursor: pointer; }
#logo-img { height: 36px; width: auto; object-fit: contain; }
#model-title { flex: 1; font-size: 13px; color: var(--text-dim); }

#btn-gender, #btn-settings, #btn-fullscreen, #btn-hide-ui {
  background: none; border: none;
  color: var(--text-dim); font-size: 18px;
  cursor: pointer; padding: 5px; border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
#btn-gender:hover, #btn-settings:hover, #btn-fullscreen:hover, #btn-hide-ui:hover { color: var(--accent); background: rgba(37,99,235,0.08); }
#btn-gender:disabled { opacity: 0.35; cursor: default; }

/* ── SETTINGS PANEL ── */
#settings-panel {
  position: absolute; top: 58px; right: 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  z-index: 90;   /* SIEMPRE por encima de toda la UI (juegos, top-bar, sidebar…); solo debajo de tutorial/carga (100) */
  display: flex; flex-direction: column; gap: 12px;
  min-width: 210px;
  transition: opacity 0.15s, transform 0.15s;
}
#settings-panel.hidden { opacity: 0; pointer-events: none; transform: translateY(-6px); }

.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13px; color: var(--text-dim);
}

.seg-control { display: flex; flex-wrap: wrap; border-radius: 7px; overflow: hidden; border: 1px solid var(--panel-border); }
.seg-btn {
  padding: 5px 12px; font-size: 12px;
  background: transparent; border: none; color: var(--text-dim);
  cursor: pointer; transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.seg-btn.active { background: var(--accent); color: #fff; }
.level-select {
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  color: var(--text); border-radius: 7px; padding: 4px 8px;
  font-size: 12px; cursor: pointer;
}
.settings-actions {
  display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid var(--panel-border); padding-top: 12px;
}
.settings-btn {
  width: 100%; padding: 8px 12px; border-radius: 8px;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  color: var(--text); font-size: 13px; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.settings-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.settings-btn-danger { color: #e05252; border-color: rgba(224,82,82,0.4); }
.settings-btn-danger:hover { background: #e05252; border-color: #e05252; color: #fff; }

/* ── SIDE PANEL ── */
#side-panel {
  /* top:58px ×zoom(1.4) renderiza a ~81px = base real del top-bar (que también lleva zoom).
     La altura sí se compensa para que el panel llegue justo al fondo del viewport. */
  position: absolute; top: 58px; left: 0;
  width: 300px; /* JS override */
  height: calc(100vh / var(--ui-zoom, 1.4) - 58px);
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  padding: 12px 20px 12px 14px;
  z-index: 10;
  display: flex; flex-direction: column; gap: 10px;
  overflow: visible;
  transition: transform 0.22s ease, box-shadow 0.22s;
  box-shadow: 2px 0 16px rgba(0,0,0,0.08);
}
/* Wrapper interno scrollable (el panel no recorta para no ocultar botón/resizer) */
#side-scroll {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; overflow-x: hidden;
  padding-right: 6px;
  padding-bottom: 56px;  /* espacio para que el último botón no quede bajo undo/redo */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
#side-scroll::-webkit-scrollbar { width: 8px; }
#side-scroll::-webkit-scrollbar-track { background: transparent; }

/* En pantallas no muy altas (p.ej. Full HD) compactar la lista para que los sistemas
   quepan sin scrollbar de primeras. QHD (≥1300px de alto) se queda como está. */
@media (max-height: 1200px) {
  #side-panel { gap: 6px; padding-top: 8px; }
  #side-scroll { gap: 6px; padding-bottom: 44px; }
  .panel-section { margin: 0; }
  .panel-section h3 { margin-bottom: 4px; }
  .toggle-list { gap: 3px; }
  .tree-row { min-height: 22px; padding: 2px 8px; }
  .system-icon { width: 20px; height: 20px; }
  .zone-btn { padding: 4px 6px; }
}
@media (max-height: 900px) {
  #side-scroll { gap: 4px; padding-bottom: 40px; }
  .toggle-list { gap: 2px; }
  .tree-row { min-height: 20px; padding: 1px 8px; }
  .system-icon { width: 18px; height: 18px; }
}
#side-scroll::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 4px;
}
#side-scroll::-webkit-scrollbar-thumb:hover { background: var(--accent); }
#side-panel.collapsed {
  transform: translateX(-100%);
  box-shadow: none;
}

/* Handle de resize */
#sidebar-resizer {
  position: absolute; top: 0; right: -6px;
  width: 6px; height: 100%;
  cursor: ew-resize;
  background: transparent;
  transition: background 0.15s;
  z-index: 12;
}
#sidebar-resizer:hover { background: var(--accent); opacity: 0.4; }
#side-panel.collapsed #sidebar-resizer { display: none; }

/* Botón toggle sidebar */
#btn-sidebar-toggle {
  position: absolute; top: 50%; right: -22px;
  transform: translateY(-50%);
  width: 22px; height: 44px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer; z-index: 11;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-dim);
  transition: background 0.15s;
  box-shadow: 2px 0 8px rgba(0,0,0,0.07);
}
#btn-sidebar-toggle:hover { background: var(--accent); color: #fff; }

/* Selector de zona corporal — todas en una fila a igual ancho (sin botón suelto) */
.zone-selector {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
}
.zone-btn {
  padding: 5px 4px; font-size: 11px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 6px; color: var(--text-dim);
  cursor: pointer; text-align: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.zone-btn:hover { border-color: var(--accent); color: var(--accent); }
.zone-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.panel-section h3 {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--text-dim); margin-bottom: 8px;
}

/* Toggles */
.toggle-list { display: flex; flex-direction: column; gap: 6px; }
.toggle-item { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.toggle-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; flex-shrink: 0; }

.toggle-switch { position: relative; width: 32px; height: 18px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--panel-border);
  border-radius: 10px; cursor: pointer; transition: background 0.2s;
  border: 1px solid var(--panel-border);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 12px; height: 12px; left: 2px; top: 2px;
  background: var(--text-dim); border-radius: 50%; transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(14px); background: #fff; }

/* Info section */
.breadcrumb {
  font-size: 11px; color: var(--text-dim); line-height: 1.5;
  margin-bottom: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
}
.breadcrumb .crumb {
  cursor: pointer; padding: 1px 4px; border-radius: 4px;
  transition: background 0.12s, color 0.12s;
}
.breadcrumb .crumb:hover { background: rgba(37,99,235,0.12); color: var(--accent); }
.breadcrumb .crumb.current { color: var(--text); font-weight: 600; cursor: default; }
.breadcrumb .crumb.current:hover { background: none; }
.breadcrumb .sep { opacity: 0.5; padding: 0 1px; }
/* Panel selección flotante derecha */
#info-section {
  position: absolute; right: 56px; bottom: 80px;
  width: 240px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  z-index: 10;
  zoom: var(--ui-zoom, 1.4);
}

#info-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.info-desc { font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.info-wiki { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--panel-border); }
.info-wiki.hidden { display: none; }
#info-wiki-text { font-size: 11px; color: var(--text-dim); line-height: 1.5; margin-bottom: 4px; }
#info-wiki-link { font-size: 10px; color: var(--accent); text-decoration: none; }
#info-wiki-link:hover { text-decoration: underline; }
.info-code {
  display: inline-block;
  background: rgba(37,99,235,0.10);
  color: var(--accent); border-radius: 4px;
  padding: 1px 5px; font-size: 10px; font-family: monospace; margin-bottom: 2px;
}

/* Botones de acción sobre la selección */
#sel-actions { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.sel-btn {
  width: 100%; text-align: left;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 6px; color: var(--text);
  font-size: 12px; padding: 6px 10px; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
/* Solo en dispositivos con hover real: en móvil el :hover se queda "pegado" tras tocar (p. ej. al
   centrar selección, un botón momentáneo, se quedaba coloreado). */
@media (hover: hover) {
  .sel-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
}
.sel-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── CAMERA CONTROLS ── */
#camera-controls {
  position: absolute; right: 12px; top: 68px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px; z-index: 20;
}
.cam-group-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-dim); margin-top: 4px; margin-bottom: 0;
  align-self: center;   /* la etiqueta centrada; los botones al borde derecho como zoom */
}
.cam-btn {
  width: 36px; height: 36px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px; color: var(--text);
  font-size: 16px; font-weight: 700;
  cursor: pointer; backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  transition: all 0.15s;
}
.cam-btn:hover, .cam-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
/* Táctil (sin hover real): el :hover se queda "pegado" tras pulsar. Rosa solo mientras se pulsa. */
@media (hover: none) {
  .cam-btn:hover:not(.active):not(.on) { background: var(--panel-bg); border-color: var(--panel-border); color: var(--text); }
  .cam-btn:active { background: var(--accent); border-color: var(--accent); color: #fff; }
  .view-opt:hover, .preset-name:hover { background: transparent; color: var(--text); }
  .view-opt:active, .preset-name:active { background: rgba(252,129,114,0.18); color: var(--accent); }
}

/* Grupo de botones (p.ej. Cortes), para poder ocultarlo en bloque */
.cam-group { display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.5,0,0.25,1); }
#cuts-group.hidden-right { opacity: 0; transform: translateX(140%); pointer-events: none; }
.cam-divider { border: none; border-top: 1px solid var(--cam-sep); margin: 4px 0; }

#views-dropdown, #g-views-dd {
  position: absolute; right: calc(100% + 8px); top: 0;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 6px;
  backdrop-filter: blur(12px); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
  min-width: 140px; z-index: 20;
}
#views-dropdown.hidden, #g-views-dd.hidden { display: none; }
.view-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 7px; border: none;
  background: transparent; color: var(--text);
  font-size: 13px; cursor: pointer; text-align: left; white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.view-opt:hover { background: var(--accent); color: #fff; }
.view-opt span { pointer-events: none; }

/* ── PRESETS / ESTADOS ── */
#presets-dropdown {
  position: absolute; right: calc(100% + 8px); top: 0;   /* top lo fija el JS a la altura del botón */
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 6px;
  backdrop-filter: blur(12px); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
  min-width: 220px; max-width: 280px; max-height: 60vh; overflow-y: auto; z-index: 20;
}
#presets-dropdown.hidden { display: none; }
.preset-empty { font-size: 12px; color: var(--text-dim); padding: 6px 8px; text-align: center; }
.preset-item {
  display: flex; align-items: center; gap: 4px;
  border-radius: 7px; transition: background 0.12s;
}
.preset-item:hover { background: rgba(252,129,114,0.12); }
.preset-name {
  flex: 1; padding: 8px 10px; border: none; background: transparent;
  color: var(--text); font-size: 13px; cursor: pointer; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.preset-name:hover { color: var(--accent); }
.preset-menu-btn {
  width: 26px; height: 26px; flex-shrink: 0; margin-right: 4px;
  border: none; background: transparent; color: var(--text-dim);
  border-radius: 6px; cursor: pointer; font-size: 15px; line-height: 1;
}
.preset-menu-btn:hover { background: var(--panel-border); color: var(--text); }
#btn-save-preset {
  margin-top: 2px; padding: 8px 10px; border-radius: 7px;
  border: 1px dashed var(--panel-border); background: transparent;
  color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
#btn-save-preset:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Menú contextual de 3 puntos */
#preset-context {
  position: fixed; z-index: 40;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 4px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px; min-width: 150px;
}
#preset-context.hidden { display: none; }
.preset-ctx-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 6px; border: none;
  background: transparent; color: var(--text); font-size: 13px;
  cursor: pointer; text-align: left; white-space: nowrap;
}
.preset-ctx-opt:hover { background: rgba(252,129,114,0.14); }
.preset-ctx-opt.danger { color: #e05252; }
.preset-ctx-opt.danger:hover { background: rgba(224,82,82,0.14); }

/* ── MODAL CENTRAL (entrada de texto) ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 12px; box-shadow: var(--shadow);
  padding: 18px 18px 14px; width: min(360px, 90vw);
  display: flex; flex-direction: column; gap: 12px;
}
.modal-title { font-size: 14px; font-weight: 600; color: var(--text); }
.modal-input {
  width: 100%; padding: 9px 11px; font-size: 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--panel-border); border-radius: 8px; outline: none;
}
.modal-input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-btn {
  padding: 8px 16px; border-radius: 8px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--panel-border); background: transparent; color: var(--text);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.modal-btn.modal-ok { background: var(--accent); border-color: var(--accent); color: #fff; }
.modal-btn:hover { border-color: var(--accent); }
.modal-btn.modal-ok:hover { filter: brightness(1.05); }

/* ── MODO PINTAR: ocultar toda la UI menos el top-bar (logo + título) ── */
body.painting #side-panel,
body.painting #btn-sidebar-toggle,
body.painting #camera-controls,
body.painting #zoom-controls,
body.painting #history-controls,
body.painting #hint-bar,
body.painting #info-section,
body.painting #settings-panel,
body.painting #search-panel,
body.painting #label-svg,
body.painting #label-container,
body.painting #btn-scroll-top,
body.painting #btn-settings,
body.painting #main-nav,
body.painting #btn-hide-ui,
body.painting #btn-fullscreen { display: none !important; }
/* El top-bar (logo + título) queda por encima del overlay de pintar */
body.painting #top-bar { z-index: 60; }
/* Bajar el toolbar de pintar para que no quede bajo el top-bar */
body.painting #annotate-toolbar { top: 64px; }

/* ── OCULTAR INTERFAZ (solo modelo) — con animación ── */
#top-bar, #side-panel, #camera-controls, #zoom-controls, #history-controls, #info-section, #hint-bar {
  transition: opacity 0.35s ease, transform 0.42s cubic-bezier(0.5,0,0.25,1);
}
body.ui-hidden #top-bar         { opacity: 0; transform: translateY(-110%); pointer-events: none; }
body.ui-hidden #side-panel      { opacity: 0; transform: translateX(-100%);  pointer-events: none; }
body.ui-hidden #camera-controls { opacity: 0; transform: translateX(135%);   pointer-events: none; }
body.ui-hidden #zoom-controls   { opacity: 0; transform: translateX(135%);   pointer-events: none; }
body.ui-hidden #history-controls{ opacity: 0; transform: translateY(135%);   pointer-events: none; }
/* Hide-UI NO oculta el selection panel: en PC se corre a la derecha (ancho fijo) para llenar el
   hueco de los botones; en MÓVIL, con left+right fijos, se ENSANCHA hasta ese borde derecho. */
body.ui-hidden #info-section    { right: 12px !important; }
body.is-mobile.ui-hidden #info-section { left: 12px !important; right: 12px !important; }
/* Si hay un panel de un botón derecho abierto (taparía el selection panel), ocultarlo (instantáneo). */
body.right-panel-open #info-section,
body:has(#presets-dropdown:not(.hidden)) #info-section,
body:has(#cut-panel:not(.hidden)) #info-section,
body:has(#g-views-dd:not(.hidden)) #info-section { display: none !important; }
body.ui-hidden #hint-bar,
body.ui-hidden #label-svg,
body.ui-hidden #label-container,
body.ui-hidden #btn-scroll-top,
body.ui-hidden #settings-panel,
body.ui-hidden #search-panel,
body.ui-hidden #cut-panel,
body.ui-hidden #views-dropdown,
body.ui-hidden #presets-dropdown { opacity: 0 !important; pointer-events: none !important; }

/* ── SECCIÓN JUEGOS: oculta las herramientas del visor pero conserva el top-bar (nav) ── */
/* El sidebar solo se oculta si NO está el modo "solo sistemas" (game-sidebar);
   así su colapso/arrastre siguen funcionando con normalidad. */
body.games-mode:not(.game-sidebar) #side-panel { opacity: 0; transform: translateX(-100%); pointer-events: none; }
body.games-mode #camera-controls { opacity: 0; transform: translateX(135%);  pointer-events: none; }
body.games-mode #history-controls{ opacity: 0; transform: translateY(135%);  pointer-events: none; }
/* El zoom (abajo-derecha) SÍ se mantiene en juegos */
/* El panel de selección (#info-section) SÍ se muestra: el jugador necesita ver la pieza seleccionada */
/* PC: en juegos se MANTIENE "Anatomy". Móvil: el model-title ya está oculto (display:none). */
body.is-mobile.games-mode #model-title { opacity: 0; pointer-events: none; }
/* Ocultar "ocultar UI" en juegos. PC: visibility (mantiene hueco, no recoloca). Móvil: display:none. */
body:not(.is-mobile).games-mode #btn-hide-ui { visibility: hidden; }
body.is-mobile.games-mode #btn-hide-ui       { display: none; }
body.games-mode #hint-bar,
body.games-mode #label-svg,
body.games-mode #label-container,
body.games-mode #btn-scroll-top,
body.games-mode #search-panel,
body.games-mode #cut-panel,
body.games-mode #views-dropdown,
body.games-mode #presets-dropdown { opacity: 0 !important; pointer-events: none !important; }

/* En ciertos juegos el sidebar reaparece, pero SOLO con la sección de sistemas
   (para apagar sistemas enteros, no objetos internos). */
body.game-sidebar #gender-section { display: none !important; }
body.game-sidebar #side-panel .panel-section:has(.zone-selector) { display: none !important; }

/* Pestañas de navegación (Visor 3D / Juegos) en el top-bar */
#main-nav { flex: 0 0 auto; margin-left: 4px; }
#main-nav .nav-btn { font-size: 13px; font-weight: 600; padding: 6px 14px; white-space: nowrap; }
/* PC: orden del top-bar → logo, "Anatomy", nav (Visor 3D/Juegos), luego botones a la derecha. */
body:not(.is-mobile) #model-title { order: 1; flex: 0 0 auto; margin: 0 6px; }
body:not(.is-mobile) #main-nav    { order: 2; margin-left: 0; }
body:not(.is-mobile) #btn-hide-ui   { order: 3; margin-left: auto; }
body:not(.is-mobile) #btn-settings  { order: 4; }
body:not(.is-mobile) #btn-fullscreen{ order: 5; }
/* PC: el tooltip inicial de controles ahora es el primer paso del tutorial → ocultar la barra. */
body:not(.is-mobile) #hint-bar { display: none !important; }

#btn-show-ui {
  position: fixed; top: 12px; right: 12px; z-index: 80;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  color: var(--text); font-size: 17px; cursor: pointer;
  box-shadow: var(--shadow); backdrop-filter: blur(12px);
  opacity: 1; transition: opacity 0.3s ease 0.15s, background 0.15s, transform 0.15s;
}
#btn-show-ui.hidden { opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
#btn-show-ui:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── TUTORIAL (tour guiado) ── */
/* Capa que bloquea TODA interacción durante el tutorial (salvo el tooltip) */
#tour-block {
  position: fixed; inset: 0; z-index: 100;
  background: transparent; pointer-events: auto;
}
#tour-spot {
  position: fixed; z-index: 101; border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
  border: 2px solid var(--accent);
  pointer-events: none; transition: all 0.22s ease;
}
#tour-tip {
  position: fixed; z-index: 102; max-width: 260px;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow);
  font-size: 13px; color: var(--text);
}
#tour-tip p { margin-bottom: 10px; line-height: 1.5; }
.tour-actions { display: flex; justify-content: flex-end; gap: 8px; }
.tour-actions button {
  padding: 6px 12px; border-radius: 7px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--panel-border); background: transparent; color: var(--text);
}
.tour-actions .tour-next { background: var(--accent); border-color: var(--accent); color: #fff; }
.tour-actions button:hover { filter: brightness(1.05); }

/* ── ZOOM ── */
#zoom-controls {
  position: absolute; right: 12px; bottom: 12px;   /* arranca desde abajo, alineado con undo/redo */
  display: flex; flex-direction: column; gap: 4px; z-index: 10;
}
.zoom-btn {
  width: 36px; height: 36px;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 8px; color: var(--text);
  font-size: 20px; line-height: 1;
  cursor: pointer; backdrop-filter: blur(12px);
  box-shadow: var(--shadow); transition: all 0.15s;
}
.zoom-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── HISTORIAL (deshacer/rehacer) ── */
#history-controls {
  position: absolute; left: 12px; bottom: 12px;
  display: flex; gap: 4px; z-index: 10;
}
.hist-btn {
  width: 36px; height: 36px;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 8px; color: var(--text);
  font-size: 18px; line-height: 1; cursor: pointer;
  backdrop-filter: blur(12px); box-shadow: var(--shadow); transition: all 0.15s;
}
.hist-btn:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #fff; }
.hist-btn:disabled { opacity: 0.35; cursor: default; }
/* Botón volver arriba: DENTRO del sidebar, esquina inferior derecha */
#btn-scroll-top {
  position: absolute; right: 40px; bottom: 12px; z-index: 13;
  width: 34px; height: 34px;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 8px; color: var(--text); font-size: 18px; line-height: 1;
  cursor: pointer; box-shadow: var(--shadow);
  transition: opacity 0.18s, background 0.15s, color 0.15s;
}
#btn-scroll-top:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
#btn-scroll-top.hidden { opacity: 0; pointer-events: none; }

/* En modo iconos: undo/redo dentro del sidebar, MISMO ancho que el panel (100px) y centrados,
   para que el centro de la separación undo/redo coincida con el centro de los iconos. */
body.sidebar-icononly #history-controls {
  left: 0; right: auto;
  width: 100px;
  justify-content: center;
  z-index: 12;
}

/* ── HINT ── */
#hint-bar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 20px; padding: 6px 16px;
  font-size: 12px; color: var(--text-dim);
  backdrop-filter: blur(12px); box-shadow: var(--shadow);
  white-space: nowrap; z-index: 10; transition: opacity 0.8s;
}
#hint-bar.hidden { opacity: 0; pointer-events: none; }

/* ── ÁRBOL DE SISTEMAS ── */
.tree-row {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 5px; cursor: default;
  min-height: 26px;
}
.tree-row:hover { background: var(--hover-bg, rgba(128,128,128,0.1)); }
/* Pelo/cejas/uñas enlazados a la piel: cuando la piel está oculta, se ven inactivos (van con ella). */
body.skin-hidden .tree-row.skin-linked { opacity: 0.4; }
body.skin-hidden .tree-row.skin-linked .toggle-switch { pointer-events: none; }
.tree-arrow {
  width: 24px; height: 24px; font-size: 10px; color: var(--text-dim);
  flex-shrink: 0; text-align: center; user-select: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; cursor: pointer;
}
.tree-arrow:not(.tree-arrow-leaf):hover { background: rgba(128,128,128,0.15); color: var(--accent); }
.tree-row.tree-ancestor { background: rgba(252,129,114,0.07); border-radius: 6px; }
.tree-row.tree-selected { background: rgba(252,129,114,0.18); border-radius: 6px; }
.tree-row.tree-selected .tree-label { color: var(--accent); font-weight: 600; }
.tree-arrow-leaf { cursor: default !important; }
.system-icon { width: 22px; height: 22px; object-fit: contain; flex-shrink: 0; }
.tree-label {
  flex: 1; font-size: 12px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.tree-label:hover { color: var(--accent); }
/* Móvil: deslizar horizontalmente el sidebar para leer los nombres largos que se cortan por la
   derecha (el swipe-izquierda ya no cierra el panel). Si el nombre cabe NO hay scroll; cuando un
   nombre se pasa de largo, aparece scroll horizontal y se puede desplazar para leerlo entero.
   Los toggles quedan SIEMPRE pegados a la derecha (sticky), tapando el nombre al desplazar. */
body.is-mobile #side-scroll { overflow-x: auto; }
/* Las filas crecen a su ancho REAL (max-content) → el sticky del toggle ancla de verdad y todos los
   toggles quedan en la MISMA columna a la derecha, sin depender del largo del nombre. */
body.is-mobile #system-toggles,
body.is-mobile .tree-children { min-width: max-content; }
body.is-mobile .tree-label {
  overflow: visible; text-overflow: clip; flex: 0 0 auto;
  padding-right: 40px;                         /* justo el ancho del toggle: el último carácter queda pegado a él, sin quedar tapado */
}
body.is-mobile .tree-row .toggle-switch {
  position: sticky; right: 0; z-index: 2;
  margin-left: auto;                          /* columna fija a la derecha */
  background: var(--panel-bg);                /* tapa el texto que pasa por debajo al desplazar */
  padding-left: 6px;
}
/* Nodo oculto (toggle off) o dentro de un subárbol oculto: label sin hover ni clic */
.tree-row.node-off .tree-label,
.tree-children.greyed .tree-label { pointer-events: none; cursor: default; }
.tree-row.node-off .tree-label:hover,
.tree-children.greyed .tree-label:hover { color: var(--text); }
.tree-children { padding-left: 0; }
.tree-children.greyed .tree-row { opacity: 0.38; }
.tree-children.greyed .tree-row .toggle-switch { pointer-events: none; }
.tree-children.greyed .tree-row .toggle-slider { filter: grayscale(1); }

/* Cuando el género se apila (lo detecta JS), las zonas se apilan a 1 por fila también */
#side-panel.stacked .zone-selector { grid-auto-flow: row; grid-template-columns: 1fr; }

/* ── MODO SOLO-ICONOS (snap al ocultarse los textos) ── */
/* Ancho fijo = aire izq de undo/redo (12) + botones (36+36+gap 4 = 76) + mismo aire dcho (12) = 100px.
   #side-panel y #history-controls comparten el mismo zoom var(--ui-zoom), así que las medidas
   en px pre-zoom coinciden en pantalla. Contenido siempre centrado. */
#side-panel.icon-only:not(.collapsed) { width: 100px !important; max-width: 100px; }
#side-panel.icon-only { padding: 12px 12px; }
#side-panel.icon-only #side-scroll { align-items: center; }
#side-panel.icon-only .panel-section,
#side-panel.icon-only .zone-selector,
#side-panel.icon-only #gender-control { align-items: center; text-align: center; }
#side-panel.icon-only .zone-btn { text-align: center; }
#side-panel.icon-only #side-scroll { padding-right: 0; padding-bottom: 52px; align-items: center; }
#side-panel.icon-only .panel-section { width: 100%; }
#side-panel.icon-only .panel-section h3 { display: none; }
/* Género: solo símbolos ♂♀ apilados, rellenando todo el ancho */
#side-panel.icon-only #gender-control { flex-direction: column; }
#side-panel.icon-only #gender-control .seg-btn { width: 100%; }
#side-panel.icon-only #gender-control .seg-btn span { display: none; }
/* Zona: apilada y compacta, con margen interno para que el texto respire */
#side-panel.icon-only .zone-selector { grid-auto-flow: row; grid-template-columns: 1fr; }
#side-panel.icon-only .zone-btn { padding: 5px 6px; font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
/* Árbol: solo iconos, sin etiquetas/flechas/hijos; clic = toggle global */
#side-panel.icon-only .tree-children { display: none; }
#side-panel.icon-only .tree-label,
#side-panel.icon-only .tree-arrow { display: none; }
#side-panel.icon-only .tree-row { justify-content: center; padding: 7px 0; cursor: pointer; }
#side-panel.icon-only .tree-row .toggle-switch { display: none; }
#side-panel.icon-only .system-icon { width: 25px; height: 25px; cursor: pointer; transition: opacity 0.15s; }
/* Modo iconos: si no caben todos los iconos, que hagan SCROLL (barra oculta) en vez de
   colapsarse o cortarse. Filas compactas para que quepan cuantos más mejor. */
/* Modo simple (iconos): SIN scroll (ni rueda) */
#side-panel.icon-only #side-scroll { overflow-y: hidden; scrollbar-width: none; }
#side-panel.icon-only #system-toggles > .tree-row { padding: 4px 0; }
#side-panel.icon-only #side-scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }
/* Sistema desactivado → icono atenuado */
#side-panel.icon-only .tree-row:has(.toggle-switch input:not(:checked)) .system-icon { opacity: 0.3; }

/* ── ETIQUETAS ANATÓMICAS ── */
.anatomy-label {
  position: absolute;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 11.5px; font-weight: 500;
  color: var(--text);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  transform: translateY(-50%);
  transition: opacity 0.2s;
  max-width: 190px;
  line-height: 1.25;
  pointer-events: auto; cursor: pointer;
}
.anatomy-label:hover { border-color: var(--accent); }
.anatomy-label .cl-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
.anatomy-label .cl-text { white-space: normal; }
.anatomy-label.label-left  { flex-direction: row-reverse; text-align: right; }
.anatomy-label.label-right { text-align: left; }
#label-svg, #label-container { z-index: 2; }   /* por encima del canvas (z-index:1) */
#label-svg polyline { fill: none; stroke-width: 1.6; opacity: 0.9; stroke-linecap: round; stroke-linejoin: round; }
#label-svg circle    { opacity: 0.95; }

/* ── LOGIN auth-switch (cortina curva que se desplaza) ── */
/* Flota sobre el visor (no oscurece a pantalla completa) */
.modal-overlay.auth-modal { background: rgba(10,6,5,0.18); backdrop-filter: blur(2px); }

.auth-card {
  position: relative; width: 760px; max-width: 94vw; height: 470px; max-height: 92vh;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,0.4);
  overflow: hidden; color: var(--text);
}
.auth-close {
  position: absolute; top: 12px; right: 14px; z-index: 200;
  width: 30px; height: 30px; border: none; border-radius: 50%;
  background: rgba(0,0,0,0.14); color: var(--text); font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.auth-close:hover { background: rgba(0,0,0,0.26); color: #fff; }

/* Formularios: cada uno ocupa una mitad; la cortina tapa el inactivo */
.auth-form {
  position: absolute; top: 0; height: 100%; width: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 44px; text-align: center; gap: 13px; background: var(--panel-bg);
}
.auth-form.form-in { right: 0; }
.auth-form.form-up { left: 0; }
.auth-form h2 { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.auth-field {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: rgba(128,128,128,0.12); border: 1px solid transparent;
  border-radius: 24px; padding: 11px 16px; transition: border-color 0.15s, background 0.15s;
}
.auth-field:focus-within { border-color: var(--accent); background: rgba(252,129,114,0.08); }
.auth-field span { font-size: 14px; opacity: 0.7; }
.auth-field input { flex: 1; background: none; border: none; outline: none; font-size: 13px; color: var(--text); }
.auth-field input::placeholder { color: var(--text-dim); }
.auth-submit {
  margin-top: 6px; border: none; border-radius: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  padding: 13px 50px; cursor: pointer; box-shadow: 0 8px 22px rgba(252,129,114,0.4);
  transition: filter 0.15s, transform 0.08s;
}
.auth-submit:hover { filter: brightness(1.06); }
.auth-submit:active { transform: scale(0.97); }
.auth-hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.auth-socials { display: flex; gap: 12px; }
.auth-social {
  width: 40px; height: 40px; border: 1px solid var(--panel-border); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: #fff;
  cursor: pointer; font-size: 15px; font-weight: 800; transition: transform 0.12s, box-shadow 0.12s;
}
.auth-social:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,0.18); }
.auth-social.s-google { color: #DB4437; }
.auth-social.s-fb { color: #1877F2; }
.auth-social.s-tw { color: #111; }
.auth-social.s-in { color: #0A66C2; font-size: 12px; }

/* Cortina de color con borde curvo (círculo) que se desplaza al cambiar de modo */
.auth-curtain {
  position: absolute; inset: 0; z-index: 10; color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 60%, #6F3A2B 135%);
  clip-path: ellipse(58% 150% at -8% 50%);   /* borde curvo suave en ~50% (no invade el form) */
  transition: clip-path 0.7s cubic-bezier(0.6,0,0.4,1);
}
.auth-card.active .auth-curtain { clip-path: ellipse(58% 150% at 108% 50%); }
.auth-promo {
  position: absolute; top: 0; height: 100%; width: 44%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 30px; text-align: center; gap: 16px;
  transition: opacity 0.4s ease;
}
.auth-promo h2 { font-size: 26px; font-weight: 800; }
.auth-promo p { font-size: 13px; line-height: 1.55; opacity: 0.95; }
.auth-promo.promo-up { left: 0; }
.auth-promo.promo-in { right: 0; opacity: 0; pointer-events: none; }
.auth-card.active .auth-promo.promo-up { opacity: 0; pointer-events: none; }
.auth-card.active .auth-promo.promo-in { opacity: 1; pointer-events: auto; }
.auth-ghost {
  margin-top: 6px; background: transparent; border: 1.5px solid rgba(255,255,255,0.9);
  color: #fff; border-radius: 24px; padding: 11px 44px; cursor: pointer;
  font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  transition: background 0.15s;
}
.auth-ghost:hover { background: rgba(255,255,255,0.16); }

@media (max-width: 600px) {
  .auth-card { height: 520px; }
  .auth-form { padding: 0 22px; }
  .auth-promo { padding: 0 18px; }
  .auth-form h2, .auth-promo h2 { font-size: 21px; }
}

/* ── CONFETI ── */
.confetti-wrap { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti-piece {
  position: absolute; top: -16px; border-radius: 2px; opacity: 0.95;
  animation-name: confetti-fall; animation-timing-function: cubic-bezier(0.3,0.6,0.5,1);
  animation-iteration-count: 1; animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotateZ(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotateZ(720deg); opacity: 0.6; }
}

/* ── CORTES (clipping) ── */
#cut-panel {
  position: absolute; right: calc(100% + 10px); top: 0;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px; padding: 12px 14px; min-width: 210px; z-index: 20;
  box-shadow: 0 10px 30px rgba(111,58,43,0.18), var(--shadow);
  backdrop-filter: blur(16px);
  display: flex; flex-direction: column; gap: 10px;
}
#cut-panel::before {   /* franja superior de marca */
  content: ''; position: absolute; left: 14px; right: 14px; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 0 0 3px 3px;
}
#cut-panel.hidden { display: none; }
#cut-panel .cut-title {
  font-size: 13px; font-weight: 800; letter-spacing: 0.2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
#cut-panel .cut-row { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--text-dim); }
#cut-panel .cut-axes { display: flex; gap: 6px; }
#cut-panel .cut-axis {
  flex: 1; padding: 6px 0; border-radius: 9px; border: 1px solid var(--panel-border);
  background: rgba(252,129,114,0.06); color: var(--text); cursor: pointer;
  font-size: 12px; font-weight: 700; transition: all 0.14s;
}
#cut-panel .cut-axis:hover { border-color: var(--accent); }
#cut-panel .cut-axis.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent; color: #fff; box-shadow: 0 3px 10px rgba(252,129,114,0.4);
}
#cut-panel .cut-foot { display: flex; gap: 6px; margin-top: 2px; }
#cut-panel .cut-btn {
  flex: 1; padding: 8px; border-radius: 9px; border: 1px solid var(--panel-border);
  background: transparent; color: var(--text); cursor: pointer; font-size: 12px; font-weight: 600;
  transition: all 0.14s;
}
#cut-panel .cut-btn:hover { background: rgba(252,129,114,0.12); border-color: var(--accent); }
#cut-panel label.cut-chk { display: flex; align-items: center; gap: 5px; cursor: pointer; font-weight: 600; }
#cut-panel label.cut-chk input { accent-color: var(--accent); }

/* Sliders de marca */
#cut-panel input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none; height: 5px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); cursor: pointer; outline: none;
}
#cut-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); box-shadow: 0 2px 6px rgba(0,0,0,0.25); cursor: pointer;
}
#cut-panel input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  border: 2px solid var(--accent); box-shadow: 0 2px 6px rgba(0,0,0,0.25); cursor: pointer;
}

/* ── JUEGOS / QUIZ ── */
#games-screen { position: fixed; inset: 0; z-index: 55; pointer-events: none; }
#games-screen.hidden { display: none; }
/* Capa oscura solo en menús (start/end); durante el juego se ve el 3D */
#games-screen .games-dim {
  position: absolute; inset: 0; background: rgba(10,6,5,0.55);
  backdrop-filter: blur(3px); pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
}
#games-screen .games-dim.hidden { display: none; }
.games-card {
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 16px; box-shadow: var(--shadow);
  padding: 22px 24px; width: min(420px, 92vw); color: var(--text);
  text-align: center;
}
.games-card h2 { font-size: 20px; margin-bottom: 6px; }
.games-card p.games-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 16px; }
.games-btn {
  display: block; width: 100%; margin: 8px 0; padding: 12px 14px;
  border-radius: 10px; border: 1px solid var(--panel-border);
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: filter 0.12s, background 0.12s;
}
.games-btn.secondary { background: transparent; color: var(--text); }
.games-btn:hover { filter: brightness(1.06); }
.games-btn.secondary:hover { background: rgba(252,129,114,0.12); }
/* Móvil: el hub/pickers arrancan DEBAJO del top-bar (no cortados) y hacen scroll si no caben;
   card compacta (sin tanto aire abajo de "Cerrar"). */
/* Móvil: por defecto centrado (panel de fin de juego, récords…). El HUB (muchas tarjetas) va
   arriba, bajo el top-bar, con scroll. */
body.is-mobile #games-screen .games-dim { overflow-y: auto; }
body.is-mobile #games-screen .games-dim.menu-scroll {
  align-items: flex-start;
  padding: calc(78px + env(safe-area-inset-top, 0px)) 0 calc(12px + env(safe-area-inset-bottom, 0px));
}
body.is-mobile .games-card { padding: 14px 16px; }

/* HUD durante el juego (arriba centro) */
#games-hud {
  position: absolute; top: 92px; left: var(--bg-cx, 50%); transform: translateX(-50%);
  pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: min(1080px, 94vw);   /* aprovechar el espacio horizontal (enunciado y cartelas más anchos) */
}
#games-hud.hidden { display: none; }
.games-bar {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 8px 14px; box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
/* PC: la barra del enunciado al ancho del CONTENIDO (no 100% del HUD) → sin aire entre texto y stats. */
body:not(.is-mobile) .games-bar { width: auto; max-width: 100%; }
body:not(.is-mobile) .games-bar .g-prompt { flex: 0 1 auto; }
/* min-width:0 + wrap: enunciado largo encoge/parte en vez de empujar el ⏭ fuera de la cartela */
.games-bar .g-prompt { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; font-size: 15px; font-weight: 600; color: var(--text); }
.games-bar .g-skip, .games-bar .g-close { flex: 0 0 auto; }
.games-bar .g-stat { font-size: 13px; color: var(--text-dim); white-space: nowrap; flex: 0 0 auto; }
.games-bar .g-stat b { color: var(--accent); }
.games-bar .g-close, .games-bar .g-skip, .games-bar .g-act {
  border: none; background: transparent; color: var(--text-dim);
  font-size: 18px; cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.games-bar .g-close:hover, .games-bar .g-skip:hover, .games-bar .g-act:hover { background: var(--panel-border); color: var(--text); }
.games-bar .g-act.on { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.games-options { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.games-opt {
  flex: 1 1 45%; min-width: 160px; padding: 11px 12px;
  border-radius: 10px; border: 1px solid var(--panel-border);
  background: var(--panel-bg); color: var(--text); font-size: 14px;
  cursor: pointer; transition: background 0.12s, border-color 0.12s;
  backdrop-filter: blur(12px);
}
.games-opt:hover { border-color: var(--accent); }
/* PC: opciones (no emparejar) al ancho del texto, sin estirar → menos aire entre medias. */
body:not(.is-mobile) .games-opt:not(.match-name) { flex: 0 0 auto; min-width: 0; white-space: nowrap; }
.games-opt.correct { background: #2e7d4f; border-color: #2e7d4f; color: #fff; }
.games-opt.wrong   { background: #b3413f; border-color: #b3413f; color: #fff; }
.games-hint { font-size: 13px; color: var(--text-dim); text-align: center; }

/* En "Adivina" no se puede ocultar el objetivo: se esconde solo ese botón */
body.guessing #btn-hide-sel { display: none; }

/* Modo "Escribe el nombre" */
.games-spell { display: flex; gap: 8px; width: 100%; justify-content: center; }
.games-input {
  flex: 1 1 auto; max-width: 360px; padding: 11px 14px; font-size: 15px;
  border-radius: 10px; border: 1px solid var(--panel-border);
  background: var(--panel-bg); color: var(--text); backdrop-filter: blur(12px);
}
.games-input:focus { outline: none; border-color: var(--accent); }
.games-input.correct { border-color: #2e7d4f; background: rgba(46,125,79,0.15); }
.games-input.shake { animation: gshake 0.32s; border-color: #b3413f; }
@keyframes gshake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-7px)} 40%,80%{transform:translateX(7px)} }
.spell-suggest {
  width: 100%; max-width: 360px; margin: 6px auto 0;
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: 10px; box-shadow: var(--shadow); backdrop-filter: blur(12px);
  overflow: hidden; max-height: 220px; overflow-y: auto; text-align: left;
}
.spell-sugg-item { padding: 9px 12px; font-size: 14px; color: var(--text); cursor: pointer; }
.spell-sugg-item:hover { background: rgba(252,129,114,0.14); }
.spell-sugg-item + .spell-sugg-item { border-top: 1px solid var(--panel-border); }

/* Columna de acciones del juego (derecha): mismo formato que los del Visor 3D,
   pero un poco más abajo para que la etiqueta no quede pegada al top-bar. */
#game-actions {
  position: absolute; right: 12px; top: 68px; z-index: 56;   /* misma posición que #camera-controls */
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  pointer-events: auto;
}
#game-actions.hidden { display: none; }
#g-act-game { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
#game-actions .cam-btn.on { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: var(--accent); color: #fff; }
/* Hover de marca (gradiente) en los botones derechos de juegos */
#game-actions .cam-btn:hover:not(.on) { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: var(--accent); color: #fff; }
#game-actions .g-hint { position: relative; }
#game-actions .g-hint.off { opacity: 0.4; cursor: not-allowed; }
#game-actions .g-hint-n {
  position: absolute; top: -3px; right: -3px; min-width: 15px; height: 15px;
  padding: 0 3px; border-radius: 8px; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}
#game-actions .g-hint-n:empty { display: none; }

/* Hub de juegos: tarjetas */
.games-hub { width: min(480px, 94vw); }
.game-cards { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 14px; }
.game-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--panel-border); background: var(--panel-bg); color: var(--text);
  transition: border-color 0.12s, transform 0.08s, background 0.12s;
}
.game-card:hover { border-color: var(--accent); background: rgba(252,129,114,0.08); transform: translateY(-1px); }
.game-card .gc-icon { font-size: 26px; line-height: 1; flex: 0 0 auto; }
.game-card .gc-txt { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.game-card .gc-txt b { font-size: 15px; }
.game-card .gc-txt small { font-size: 12px; color: var(--text-dim); line-height: 1.3; }
.game-card .gc-arrow { font-size: 22px; color: var(--text-dim); flex: 0 0 auto; }

/* Pestañas de récords */
.rec-tabs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 4px 0 10px; }
.rec-tab {
  padding: 6px 10px; border-radius: 999px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--panel-border); background: transparent; color: var(--text-dim);
}
.rec-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Modo emparejar: lista de nombres (guía visual, no botones) */
/* Emparejar: cartelas empaquetadas para aprovechar el ancho (tantas por fila como quepan). */
/* Emparejar: 2 por fila (2+2), nunca una sola; texto centrado vertical si la otra salta de línea. */
.games-opt.match-name {
  cursor: default; opacity: 0.65; text-align: center; flex: 1 1 46%; min-width: 0; max-width: 100%;
  display: flex; align-items: center; justify-content: center;
}
.games-opt.match-name.current { opacity: 1; border-color: var(--accent); font-weight: 700; }
.games-opt.match-name.correct { opacity: 1; background: #2e7d4f; border-color: #2e7d4f; color: #fff; }

/* Leaderboard */
.games-board { text-align: left; margin: 10px 0 4px; max-height: 46vh; overflow-y: auto; }
.games-board .row {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  border-radius: 8px; font-size: 14px;
}
.games-board .row:nth-child(odd) { background: rgba(128,128,128,0.08); }
.games-board .row.me { background: rgba(252,129,114,0.18); font-weight: 700; }
.games-board .rk { width: 22px; color: var(--text-dim); text-align: right; }
.games-board .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.games-board .sc { color: var(--accent); font-weight: 700; }

/* ── MODO ANOTACIÓN ── */
#annotate-overlay {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: stretch;
}
#annotate-overlay.hidden { display: none; }
#annotate-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; pointer-events: none;
}
#annotate-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  cursor: none; touch-action: none;
}
#annotate-cursor {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
}

/* Toolbar */
#annotate-toolbar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 3px;
  background: rgba(30,32,40,0.92); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 6px 10px;
  backdrop-filter: blur(12px); box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 2;
}
.ann-btn {
  width: 34px; height: 34px; border-radius: 8px; border: none;
  background: transparent; color: #c0c4d0; font-size: 15px;
  cursor: pointer; transition: background 0.12s, color 0.12s;
  display: flex; align-items: center; justify-content: center;
}
.ann-btn:hover:not(:disabled) { background: rgba(255,255,255,0.1); color: #fff; }
.ann-btn:disabled { opacity: 0.25; cursor: default; }
.ann-btn.active { background: var(--accent); color: #fff; }
.ann-btn.ann-exit:hover { background: #ef4444; color: #fff; }
.ann-sep { width: 1px; height: 24px; background: rgba(255,255,255,0.12); margin: 0 3px; }

/* Slider tamaño */
#annotate-size {
  position: absolute; left: 20px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(30,32,40,0.88); border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px; padding: 10px 8px;
  backdrop-filter: blur(12px); z-index: 2;
}
#annotate-size span { color: #c0c4d0; font-size: 16px; cursor: pointer; user-select: none; line-height:1; }
#annotate-size span:hover { color: #fff; }
#ann-size-slider {
  writing-mode: vertical-lr; direction: rtl;
  -webkit-appearance: slider-vertical;
  width: 4px; height: 120px; cursor: pointer;
  accent-color: var(--accent);
}
#ann-size-preview-wrap {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  margin-top: 4px; overflow: hidden;
}
#ann-size-preview {
  border-radius: 50%; background: #fff;
  max-width: 44px; max-height: 44px;
  flex-shrink: 0;
}

/* Paleta */
#annotate-palette {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  background: rgba(30,32,40,0.92); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 40px; padding: 8px 14px;
  backdrop-filter: blur(12px); box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 2;
}
.ann-color {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: border-color 0.12s, transform 0.12s;
}
.ann-color:hover { transform: scale(1.15); }
.ann-color.active { border-color: #fff; transform: scale(1.2); }
#ann-color-custom {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.3);
  padding: 0; cursor: pointer; background: conic-gradient(red,yellow,lime,cyan,blue,magenta,red);
}

/* Input texto */
/* Texto inline anotación */
#ann-text-wrap {
  position: absolute; z-index: 3;
}
#ann-text-editable {
  min-width: 40px; min-height: 1.2em;
  outline: none; white-space: pre;
  caret-color: #fff;
  border-bottom: 1.5px dashed rgba(255,255,255,0.5);
  padding: 2px 4px;
  font-family: sans-serif;
}
#ann-text-editable:empty::before {
  content: 'Escribe aquí…'; opacity: 0.4; pointer-events: none;
}
#ann-text-toolbar {
  display: flex; align-items: center; gap: 2px;
  margin-top: 6px;
  background: rgba(30,32,40,0.92); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; padding: 4px 6px;
  backdrop-filter: blur(10px);
}
#ann-text-toolbar button {
  width: 28px; height: 28px; border: none; border-radius: 6px;
  background: transparent; color: #ccc; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#ann-text-toolbar button:hover { background: rgba(255,255,255,0.12); color: #fff; }
#ann-text-confirm:hover { background: #22c55e !important; color: #fff !important; }
#ann-text-delete:hover  { background: #ef4444 !important; color: #fff !important; }
.ann-text-align.active  { background: var(--accent) !important; color: #fff !important; }

/* ── BUSCADOR ── */
#search-panel {
  position: absolute; top: 68px; left: 50%; transform: translateX(-50%);
  width: 420px; max-width: calc(100vw - 40px);
  background: var(--panel-bg); border: 1px solid var(--panel-border);
  border-radius: var(--radius); backdrop-filter: blur(14px);
  box-shadow: var(--shadow); z-index: 30; overflow: hidden;
  zoom: var(--ui-zoom, 1.4);
}
#search-panel.hidden { display: none; }
#search-input {
  width: 100%; padding: 12px 16px; border: none; outline: none;
  background: transparent; color: var(--text); font-size: 14px;
  border-bottom: 1px solid var(--panel-border);
}
#search-results { max-height: 320px; overflow-y: auto; }
.search-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 16px; cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--panel-border);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover, .search-item.active { background: rgba(252,129,114,0.12); }
.search-item-name { font-size: 13px; color: var(--text); font-weight: 500; }
.search-item-sub  { font-size: 11px; color: var(--text-dim); }
.search-item-code { font-size: 10px; color: var(--accent); font-family: monospace; }
.search-item-sides { display: flex; gap: 6px; margin-top: 5px; }
.search-side {
  padding: 3px 10px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--panel-border); background: transparent;
  color: var(--text); font-size: 11px; font-weight: 600;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.search-side:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.search-empty { padding: 14px 16px; color: var(--text-dim); font-size: 13px; text-align: center; }

/* ── TOOLTIP ── */
#tooltip {
  position: absolute;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 9px; padding: 6px 12px;
  font-size: 12px; font-weight: 600; color: #fff;
  pointer-events: none; z-index: 20; white-space: nowrap;
  box-shadow: 0 6px 20px rgba(252,129,114,0.45), 0 2px 6px rgba(0,0,0,0.25);
  opacity: 0; transform: translateY(6px) scale(0.94);
  transform-origin: left bottom;
  transition: opacity 0.16s ease, transform 0.22s cubic-bezier(0.22,1.2,0.4,1);
}
#tooltip::after {
  content: ''; position: absolute; left: 14px; bottom: -5px;
  width: 10px; height: 10px; background: var(--accent2);
  border-right: 1px solid rgba(255,255,255,0.35); border-bottom: 1px solid rgba(255,255,255,0.35);
  transform: rotate(45deg);
}
#tooltip.visible { opacity: 1; transform: translateY(0) scale(1); }

/* Tooltip propio de botones (hint con colores de marca) */
#btn-tip {
  position: fixed; z-index: 200; pointer-events: none; white-space: nowrap;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 9px; border: 1px solid rgba(255,255,255,0.35);
  box-shadow: 0 6px 20px rgba(252,129,114,0.45), 0 2px 6px rgba(0,0,0,0.25);
  opacity: 0; transform: scale(0.9); transition: opacity 0.15s ease, transform 0.22s cubic-bezier(0.22,1.2,0.4,1);
}
#btn-tip[data-dir="left"] { transform-origin: right center; transform: scale(0.9) translateX(6px); }
#btn-tip[data-dir="down"] { transform-origin: top left; transform: scale(0.9) translateY(-6px); }
#btn-tip[data-dir="up"] { transform-origin: bottom left; transform: scale(0.9) translateY(6px); }
#btn-tip.visible { opacity: 1; transform: scale(1) translate(0,0); }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  #side-panel { font-size: 12px; }
  #hint-bar { font-size: 10px; }
  .cam-btn, .zoom-btn { width: 30px; height: 30px; }
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 2px; }

/* ─── MÓVIL: UI adaptada (vertical y horizontal). PC sin cambios ─── */
/* Todo gated por body.is-mobile → en escritorio no aplica nada de esto. */
body.is-mobile #model-title { display: none; }                 /* liberar espacio en top-bar */
#row-callouts { display: none; }                               /* rótulos desactivados: sin ajuste (móvil y PC) */
body.is-mobile #top-bar { padding: 0 16px 0 10px; gap: 8px; }
/* Botones del top-bar más pequeños y con margen del borde derecho */
body.is-mobile #top-bar #btn-hide-ui,
body.is-mobile #top-bar #btn-settings,
body.is-mobile #top-bar #btn-fullscreen { font-size: 14px; padding: 4px; }
body.is-mobile #top-bar #btn-fullscreen { margin-right: 4px; }
/* Botones (ocultar UI, ajustes, pantalla completa) empujados a la derecha */
body.is-mobile #btn-hide-ui { margin-left: auto; }
/* En juegos el botón de ocultar UI no sale → ajustes toma el empuje para quedar pegado a la derecha */
body.is-mobile.games-mode #btn-settings { margin-left: auto; }

/* Apilado móvil: canvas(1) < HUD juego(55) < backdrop(58) < sidebar(62) < top-bar(66).
   El modelo (canvas) SIEMPRE queda por detrás de la UI; el HUD del juego por delante del modelo
   pero por detrás del sidebar/backdrop al abrirlo. */
body.is-mobile #side-panel:not(.collapsed) { z-index: 62; }
body.is-mobile #top-bar { z-index: 66; }
/* Botón de cerrar el drawer DENTRO del panel (no se sale por la derecha) */
body.is-mobile #side-panel:not(.collapsed) #btn-sidebar-toggle {
  right: 8px; top: 10px; transform: none;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent); color: #fff; border: none;
  font-size: 22px; font-weight: 700; box-shadow: var(--shadow); z-index: 60;
}
#sidebar-backdrop {
  position: fixed; inset: 0; z-index: 58;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
/* Flecha del sidebar colapsado: destacada (antes casi no se veía) */
body.is-mobile #side-panel.collapsed #btn-sidebar-toggle {
  right: -30px; left: auto; width: 30px; height: 60px;
  background: var(--accent); color: #fff; border: none;
  font-size: 22px; font-weight: 700; border-radius: 0 12px 12px 0;
  box-shadow: 2px 2px 12px rgba(0,0,0,0.4); opacity: 1;
}
/* Chrome (barra de dirección arriba/abajo) tapa controles → separarlos de los bordes */
body.is-mobile #zoom-controls   { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
body.is-mobile #history-controls { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
body.is-mobile #side-panel { box-shadow: 2px 0 24px rgba(0,0,0,0.4); }
/* Móvil: COMPLEJO ocupa toda la pantalla. El panel lleva zoom var(--ui-zoom), así que el ancho
   se divide por el zoom para que renderice exactamente 100vw y NO se salga por la derecha. */
body.is-mobile #side-panel:not(.collapsed):not(.icon-only) {
  width: calc(100vw / var(--ui-zoom, 1)) !important; max-width: none;
}
/* SIMPLE (icon-only): tira estrecha SIEMPRE visible, sin backdrop, sin flecha de colapsar */
body.is-mobile #side-panel.icon-only:not(.collapsed) { width: 120px !important; max-width: 120px; }
body.is-mobile #side-panel.icon-only:not(.collapsed) #btn-sidebar-toggle { display: none; }
/* (El ajuste "todos los iconos sin scroll" del modo simple lo cubren ya las reglas
   generales #side-panel.icon-only …; el modo simple está desactivado en móvil.) */

/* ── Nada de UI se sale de pantalla (guardas de overflow) ── */
/* OJO: NADA de overflow en #camera-controls: sus paneles (presets, corte, caja) salen de la
   columna con right:100%+8px y un overflow aquí los recortaría (se ve el corte pero no el panel). */
body.is-mobile #views-dropdown,
body.is-mobile #g-views-dd,
body.is-mobile #presets-dropdown { max-height: 60dvh; overflow-y: auto; max-width: 82vw; }
/* Estados (presets): ancho fijo calibrado. */
body.is-mobile #presets-dropdown { width: 205px; max-width: none; min-width: 0; }
body.is-mobile #settings-panel { max-width: 92vw; max-height: 82dvh; overflow-y: auto; }
/* Selection panel en móvil: anclado abajo (su base a la altura de undo/redo), crece hacia
   arriba hasta cerca de la flechita del sidebar (sin llegar a ella) y con scroll para ver todo.
   Lleva zoom var(--ui-zoom): anchos/altos se dividen por el zoom para no desbordar. */
body.is-mobile #info-section {
  top: auto;
  left: 12px;                                              /* mismo aire que los botones de la derecha (right:12) */
  right: 56px;                                             /* deja hueco a undo/redo a su derecha */
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));   /* misma base que undo/redo (más bajo, menos aire) */
  width: auto;                                             /* left+right fijan el ancho → SIEMPRE igual */
  max-width: none;
  height: calc((50dvh - 112px) / var(--ui-zoom, 1.4));     /* altura FIJA, borde superior por debajo de la flecha */
  max-height: none;
  overflow-y: auto;
}
/* Corte (plano y caja): más estrecho para que no se salga por la izquierda (sobre todo el de caja) */
body.is-mobile #cut-panel { max-width: calc(100vw - 150px); min-width: 0; max-height: 72dvh; overflow-y: auto; }
/* Altura del panel al alto VISIBLE (dvh) para que no lo corte la barra de Chrome */
body.is-mobile #side-panel { height: calc(100dvh / var(--ui-zoom, 1.4) - 58px); }
/* Móvil: modo con DOS BOTONES (no arrastre) → resizer oculto */
body.is-mobile #sidebar-resizer { display: none; }
/* Barra de modo (Simple / Completo) arriba del panel */
#sidebar-mode { display: none; }
/* Modo simple/complejo desactivado: ocultar los botones de cambio de modo */
#sidebar-mode { display: none !important; }
body.is-mobile #side-panel:not(.collapsed) #side-scroll { padding-top: 10px; }
/* Móvil: sin botones de zoom (se hace con pellizco) → undo/redo abajo-derecha en vertical */
body.is-mobile #zoom-controls { display: none; }
body.is-mobile #history-controls {
  left: auto; right: 12px; flex-direction: column;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}
/* Botones de la derecha SIEMPRE visibles en móvil, por encima del panel abierto */
body.is-mobile #camera-controls,
body.is-mobile #zoom-controls { z-index: 15; }
/* Desplegables y paneles no se salen de pantalla */
body.is-mobile #views-dropdown,
body.is-mobile #g-views-dd,
body.is-mobile #presets-dropdown { max-height: 60vh; overflow-y: auto; }
body.is-mobile #settings-panel { max-width: 92vw; }
/* El buscador lleva zoom var(--ui-zoom); el ancho se divide por el zoom para que
   renderice como máximo el ancho de pantalla (con un pequeño margen) y NO se salga. */
body.is-mobile #search-panel {
  width: calc((100vw - 20px) / var(--ui-zoom, 1.25));
  max-width: none;
}
body.is-mobile #search-results { max-height: 46vh; }
/* HUD de juego en móvil: ocupa de la izquierda hasta dejar hueco a los botones de la derecha
   (así no se solapan) y no lo mueve el sidebar (ignora --bg-cx). */
body.is-mobile #games-hud {
  left: 8px !important; right: 68px; width: auto !important; transform: none !important;
}
/* La ✕ de salir del HUD quedaba tras los botones de Vistas; en móvil se sale por las pestañas */
body.is-mobile .games-bar .g-close { display: none; }
/* Aire a la derecha del botón "saltar pregunta" (último de la barra, quedaba pegado al borde) */
body.is-mobile .games-bar { padding-right: 20px; }
body.is-mobile .games-bar .g-skip { margin-right: 6px; }
/* Móvil: enunciado ARRIBA (ancho completo) y debajo la info de ronda (pts/tiempo/saltar). */
body.is-mobile .games-bar { flex-wrap: wrap; justify-content: space-between; row-gap: 6px; }
body.is-mobile .games-bar .g-prompt { flex: 1 1 100%; }
/* Todas las cartelas del juego (opciones, barra de escribir, sugerencias) con los MISMOS
   límites izq/der que la cartela del enunciado: ocupar el ancho del hud y encoger, no desbordar. */
body.is-mobile .games-options { width: 100%; box-sizing: border-box; }
body.is-mobile .games-spell { width: 100%; }
body.is-mobile .games-input { flex: 1 1 auto; min-width: 0; max-width: none; }
body.is-mobile .spell-suggest { width: 100%; max-width: none; }
body.is-mobile .games-opt { min-width: 0; }
/* Botón comprobar: solo el tick, compacto */
.games-opt.games-check { flex: 0 0 auto; padding: 11px 14px; }

/* Modo pintar en móvil: sin zoom (evita desbordes), ajustado y respetando la barra de Chrome */
body.is-mobile #annotate-toolbar,
body.is-mobile #annotate-size,
body.is-mobile #annotate-palette { zoom: 1; }
body.is-mobile #annotate-toolbar {
  /* Panel centrado con bordes redondeados, sin llegar a los bordes de pantalla; una sola fila
     (scroll horizontal si no cabe). Debajo del top-bar (que en pintar sigue visible ~73px). */
  top: calc(78px + env(safe-area-inset-top, 0px));
  left: 50%; right: auto; transform: translateX(-50%);
  width: auto; max-width: calc(100vw - 20px);
  border-radius: 12px; flex-wrap: nowrap; justify-content: flex-start;
  gap: 3px; padding: 6px 8px; overflow-x: auto;
}
body.is-mobile #annotate-palette {
  bottom: calc(10px + env(safe-area-inset-bottom, 0px)); max-width: 96vw; flex-wrap: wrap; justify-content: center;
}
body.is-mobile #annotate-size { top: 50%; }   /* centrado vertical dentro del área visible */

/* Login: enlace de cambio (login <-> registro). Solo visible en móvil. */
.auth-switch { display: none; background: none; border: none; color: var(--accent);
  font-size: 13px; cursor: pointer; margin-top: 4px; text-decoration: underline; }
/* Login responsive en móvil: una sola columna, sin cortina deslizante */
body.is-mobile .auth-card { width: 92vw; height: auto; max-height: 88vh; overflow-y: auto; }
body.is-mobile .auth-curtain { display: none; }
body.is-mobile .auth-form { position: static; width: 100%; height: auto; padding: 30px 22px 26px; }
body.is-mobile .auth-form.form-up { display: none; }
body.is-mobile .auth-card.active .auth-form.form-in { display: none; }
body.is-mobile .auth-card.active .auth-form.form-up { display: flex; }
body.is-mobile .auth-switch { display: inline-block; }

/* Horizontal (landscape): pantalla baja → subir zoom/undo y acercar controles */
@media (orientation: landscape) {
  body.is-mobile #zoom-controls   { bottom: 10px; }
  body.is-mobile #history-controls { bottom: 8px; }
  body.is-mobile #camera-controls { top: 62px; gap: 2px; }
}

/* Vertical (portrait): la barra de cámara puede chocar con el HUD del juego;
   se mantiene arriba-derecha, compacta. */
@media (orientation: portrait) {
  body.is-mobile #camera-controls { gap: 3px; }
}

/* ── Pop-up de BIENVENIDA (grande) ── */
.welcome-box { width: min(500px, 92vw); text-align: center; padding: 30px 28px; }
.welcome-emoji { font-size: 46px; line-height: 1; margin-bottom: 10px; }
.welcome-title { font-size: 25px; font-weight: 800; margin-bottom: 10px; }
.welcome-text  { font-size: 16px; color: var(--text-dim); line-height: 1.55; margin-bottom: 20px; }
.welcome-box .modal-actions { justify-content: center; gap: 12px; }
.welcome-box .welcome-start { padding: 10px 22px; font-size: 15px; }
/* En móvil, aún más grande */
body.is-mobile .welcome-emoji { font-size: 54px; }
body.is-mobile .welcome-title { font-size: 28px; }
body.is-mobile .welcome-text  { font-size: 18px; }
