:root {
  --bg: #0b0f17;
  --surface: rgba(16, 22, 34, 0.9);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f2f5fa;
  --muted: #9aa7bd;
  --accent: #ff6505;
  --warning: #ffd23f;
  --tabs: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

main {
  position: fixed;
  inset: 0 0 calc(var(--tabs) + var(--safe-bottom)) 0;
}

.tab {
  position: absolute;
  inset: 0;
  visibility: hidden;
}

.tab.active {
  visibility: visible;
}

.tab.scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.muted {
  color: var(--muted);
}

.warning {
  color: var(--warning);
}

/* Pestañas */

#tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabs) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: #0d121c;
  border-top: 1px solid var(--line);
  z-index: 1000;
}

#tabs button {
  flex: 1;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#tabs button.active {
  color: var(--accent);
}

/* Botones */

.button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button.on {
  border-color: var(--accent);
  color: var(--accent);
}

.button.small {
  padding: 6px 10px;
  font-size: 13px;
}

.button.wide {
  display: block;
  width: 100%;
  margin-top: 10px;
}

/* Mapa */

#map {
  position: absolute;
  inset: 0;
  background: #1a2029;
}

.panel {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 500;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.panel-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 220px;
}

.panel-text strong {
  font-size: 16px;
}

.panel-buttons {
  display: flex;
  gap: 8px;
}

.leaflet-container {
  font: inherit;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #111826;
  color: var(--text);
}

.leaflet-popup-content {
  margin: 12px 14px;
}

.popup {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 190px;
}

.popup span {
  color: var(--muted);
  font-size: 13px;
}

.popup-buttons {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* Rayos X */

#xray {
  position: absolute;
  inset: 0;
  overflow: hidden;
  /* Sin cámara: cielo oscuro arriba y suelo abajo. */
  background: linear-gradient(#0a1424 0%, #101c30 42%, #07090d 100%);
}

#camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

#xray.camera-on #camera {
  display: block;
}

#gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.label {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 9px;
  border-radius: 9px;
  background: rgba(9, 13, 21, 0.78);
  border: 1px solid var(--line);
  white-space: nowrap;
  will-change: transform;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.label strong {
  font-size: 14px;
}

.label span {
  font-size: 11px;
  color: var(--muted);
}

.label-boca {
  border-color: rgba(61, 220, 132, 0.6);
}

.label-boca strong {
  font-size: 12px;
  color: #7df0ae;
}

.label-depth {
  border-color: var(--warning);
}

.label-depth strong {
  font-size: 18px;
  color: var(--warning);
}

.hud {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 10px;
  max-width: min(74%, 420px);
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  pointer-events: none;
  font-size: 13px;
}

.hud strong {
  font-size: 15px;
}

.tools {
  position: absolute;
  right: 10px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tools .button {
  background: var(--surface);
}

/* Hojas */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(4, 6, 10, 0.72);
}

body > .overlay {
  position: fixed;
}

.sheet {
  width: min(100%, 420px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #111826;
}

.sheet h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.sheet p {
  margin: 8px 0;
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted);
}

/* Acerca de */

article {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(22px + var(--safe-top)) 20px 40px;
}

article h1 {
  margin: 0;
  font-size: 26px;
}

article h2 {
  margin: 26px 0 6px;
  font-size: 17px;
  color: var(--accent);
}

article .lead {
  margin-top: 4px;
  font-size: 17px;
  color: var(--muted);
}

article ul {
  padding-left: 20px;
}

article li {
  margin: 6px 0;
}
