@font-face { font-family: B612; src: url(fuentes/B612-Regular.ttf) format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: B612; src: url(fuentes/B612-Bold.ttf) format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --tinta: #F3EBDD;
  --tinta-2: #CDBFA9;
  --panel: rgba(22, 17, 13, 0.78);
  --panel-2: rgba(36, 28, 22, 0.9);
  --borde: rgba(243, 235, 221, 0.14);
  --amarillo: #F4C430;
  --ig: #C13584;
  --yt: #E62117;
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #16110d; color: var(--tinta);
  font-family: B612, system-ui, sans-serif; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
a { color: var(--amarillo); }
#lienzo { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; outline: none; }

/* ---------------------------------------------------------------- etiquetas sobre el 3D */
#etiquetas { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.eti { position: fixed; left: 0; top: 0; white-space: nowrap; pointer-events: none; will-change: transform; }
.eti > * { display: block; }
.eti.colono { pointer-events: auto; cursor: pointer; margin-top: -4px; }
.eti.colono { translate: -50% -100%; background: rgba(18, 14, 11, 0.8); border-left: 3px solid var(--c, var(--amarillo));
  padding: 3px 7px 3px 6px; border-radius: 3px; line-height: 1.15; }
.eti.colono b { font-size: 12px; font-weight: 700; }
.eti.colono span { font-size: 10px; color: var(--tinta-2); text-transform: uppercase; letter-spacing: 0.04em; }
.eti.colono.sel { background: var(--amarillo); color: #16110d; border-left-color: #16110d; z-index: 2; }
.eti.colono.sel span { color: #3a2d10; }
.eti.colono.sel b { font-size: 14px; }
.eti.colonia { translate: -50% calc(-100% - 16px); pointer-events: auto; cursor: pointer; background: var(--panel-2); border: 1px solid var(--borde);
  padding: 6px 10px; border-radius: 4px; text-align: center; }
.eti.colonia b { font-size: 15px; letter-spacing: 0.02em; }
.eti.colonia span { font-size: 11px; color: var(--tinta-2); }
.eti.colonia i, .eti.parcela i, #resultados i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.eti.colonia i { display: block; width: 100%; height: 3px; border-radius: 0; margin: -6px 0 5px; }
.eti.obra { translate: -50% -100%; background: rgba(18, 14, 11, 0.72); padding: 2px 6px; border-radius: 3px; font-size: 11px; }
.eti.obra small { display: block; font-size: 9.5px; color: var(--tinta-2); }
.eti.parcela { translate: -50% -100%; background: rgba(220, 235, 242, 0.88); color: #12202a; padding: 2px 6px; border-radius: 3px;
  font-size: 11px; }
.eti.parcela > * { display: inline; }
.eti.zona { translate: -50% -100%; background: rgba(220, 235, 242, 0.9); color: #12202a; padding: 5px 9px; border-radius: 4px;
  text-align: center; max-width: 230px; white-space: normal; }
.eti.zona b { font-size: 13px; }
.eti.zona span { font-size: 10.5px; }
.eti.estacion { translate: 12px -50%; font-size: 10.5px; color: #e6eeff; text-shadow: 0 0 6px #000; }
.eti.estacion span { font-size: 9.5px; opacity: 0.8; }
.eti.apagada, .eti.colono.apagada, .eti.colonia.apagada { pointer-events: none; }   /* tapada por otra o bajo un panel: se apaga */

/* ---------------------------------------------------------------- arriba: marcador y buscador */
#arriba { position: fixed; top: 0; left: 0; right: 0; padding: calc(8px + var(--sa-t)) 10px 0; display: flex; flex-direction: column;
  gap: 8px; pointer-events: none; }
#arriba > * { pointer-events: auto; }
#marcador { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; background: var(--panel);
  border: 1px solid var(--borde); border-radius: 6px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); overflow: hidden; }
.lado { background: none; border: 0; padding: 6px 10px 7px; text-align: left; display: grid; grid-template-columns: 1fr auto;
  grid-template-rows: auto auto; column-gap: 6px; cursor: pointer; min-width: 0; border-top: 3px solid var(--c); }
.lado.der { text-align: right; grid-template-columns: auto 1fr; }
.lado .p { grid-column: 1 / -1; font-size: 10px; color: var(--tinta-2); text-transform: uppercase; letter-spacing: 0.08em; }
.lado .n { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; align-self: end; }
.lado .v { font-size: 20px; line-height: 1; align-self: end; }
.lado.der .n { order: 2; }
.lado.der .v { order: 1; }
.lado.der em { order: 3; }
.lado em { grid-column: 1 / -1; font-style: normal; font-size: 10px; color: var(--tinta-2); }
.lado.lider .v { color: var(--amarillo); }
#m-centro { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 8px;
  border-left: 1px solid var(--borde); border-right: 1px solid var(--borde); }
#m-centro small { font-size: 9px; color: var(--tinta-2); letter-spacing: 0.12em; }
#m-centro b { font-size: 20px; line-height: 1; }
#m-barra { height: 4px; margin-top: -6px; border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, var(--cig, var(--ig)) 0 var(--ig, 50%), var(--cyt, var(--yt)) var(--ig, 50%) 100%); }

#busca { position: relative; display: flex; align-items: center; background: var(--panel); border: 1px solid var(--borde);
  border-radius: 6px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#busca svg { width: 18px; height: 18px; margin-left: 11px; fill: none; stroke: var(--tinta-2); stroke-width: 2; flex: none; }
#q { flex: 1; min-width: 0; background: none; border: 0; padding: 11px 10px; font-size: 16px; outline: none; }
#q::placeholder { color: var(--tinta-2); }
#q::-webkit-search-cancel-button { filter: invert(0.8); }
#busca:focus-within { border-color: var(--amarillo); }
#resultados { position: absolute; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
  background: var(--panel-2); border: 1px solid var(--borde); border-radius: 6px; max-height: 50vh; overflow-y: auto; }
#resultados li { padding: 9px 8px; border-radius: 4px; cursor: pointer; display: flex; align-items: baseline; gap: 2px; flex-wrap: wrap; }
#resultados li:hover, #resultados li:focus { background: rgba(244, 196, 48, 0.14); }
#resultados li b { font-size: 14px; margin-right: 8px; }
#resultados li span { font-size: 11px; color: var(--tinta-2); }
#resultados li.nada { font-size: 12.5px; color: var(--tinta-2); cursor: default; line-height: 1.4; }

/* ---------------------------------------------------------------- ficha del colono */
#ficha { position: fixed; left: 10px; right: 10px; bottom: calc(118px + var(--sa-b)); background: var(--panel-2);
  border: 1px solid var(--borde); border-left: 4px solid var(--c, var(--amarillo)); border-radius: 6px; padding: 10px 40px 10px 12px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#ficha b { display: block; font-size: 17px; overflow-wrap: anywhere; }
#ficha span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--amarillo); margin-top: 2px; }
#ficha p { margin: 6px 0 8px; font-size: 13px; color: var(--tinta-2); line-height: 1.4; }
#ficha .acciones { display: flex; gap: 8px; }
#ficha .acciones button { flex: 1; padding: 9px 8px; border-radius: 4px; border: 1px solid var(--borde); background: rgba(243, 235, 221, 0.08);
  font-size: 13px; cursor: pointer; }
#ficha .acciones button:first-child { background: var(--amarillo); color: #16110d; border-color: var(--amarillo); font-weight: 700; }
#f-cerrar { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border: 0; background: none; font-size: 22px;
  color: var(--tinta-2); cursor: pointer; }

/* ---------------------------------------------------------------- abajo: llamada, botones y credito */
#abajo { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 10px calc(6px + var(--sa-b)); display: flex; flex-direction: column;
  gap: 6px; pointer-events: none; }
#abajo > * { pointer-events: auto; }
#llamada { margin: 0; align-self: center; background: var(--amarillo); color: #16110d; font-size: 12px; font-weight: 700;
  padding: 6px 10px; border-radius: 4px; text-align: center; line-height: 1.35; max-width: 100%; }
#llamada a { color: #16110d; }
#botones { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; background: var(--panel); border: 1px solid var(--borde);
  border-radius: 6px; padding: 4px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#botones button { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 48px; padding: 5px 2px;
  border: 0; border-radius: 4px; background: none; cursor: pointer; font-size: 10px; line-height: 1.15; text-align: center; min-width: 0; }
#botones button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#botones svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round;
  stroke-linejoin: round; flex: none; }
#botones button:hover:not(:disabled) { background: rgba(243, 235, 221, 0.08); }
#botones button:disabled { opacity: 0.38; cursor: default; }
#botones button.activo { background: var(--amarillo); color: #16110d; }
#credito { margin: 0; font-size: 10px; color: rgba(243, 235, 221, 0.78); text-shadow: 0 0 4px #000, 0 0 2px #000; text-align: center; }
#credito b { font-weight: 400; color: var(--tinta); }

#aviso { position: fixed; left: 50%; top: 50%; translate: -50% -50%; background: var(--panel-2); border: 1px solid var(--borde);
  padding: 10px 14px; border-radius: 6px; font-size: 13px; text-align: center; max-width: calc(100vw - 40px); pointer-events: none; }

/* ---------------------------------------------------------------- info */
#info { position: fixed; inset: 0; background: rgba(10, 8, 6, 0.62); display: flex; align-items: flex-end; justify-content: center; }
#info[hidden] { display: none; }
#info article { position: relative; background: var(--panel-2); border: 1px solid var(--borde); border-radius: 8px 8px 0 0;
  padding: 18px 18px calc(18px + var(--sa-b)); max-width: 560px; width: 100%; max-height: 82vh; overflow-y: auto; }
#info h1 { font-size: 17px; margin: 0 30px 10px 0; }
#info p { font-size: 14px; line-height: 1.5; margin: 0 0 10px; color: var(--tinta); }
#info p.peq { font-size: 12px; color: var(--tinta-2); }
#i-cerrar { position: absolute; top: 8px; right: 8px; width: 38px; height: 38px; border: 0; background: none; font-size: 24px;
  color: var(--tinta-2); cursor: pointer; }

/* ---------------------------------------------------------------- carga */
#carga { position: fixed; inset: 0; background: radial-gradient(circle at 50% 40%, #3a2a1e, #120d0a 70%); display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 12px; transition: opacity 0.6s; z-index: 10; padding: 20px;
  text-align: center; }
#carga.fuera { opacity: 0; pointer-events: none; }
#carga b { font-size: 22px; letter-spacing: 0.12em; }
#carga span { font-size: 13px; color: var(--tinta-2); }
#carga .pista { width: min(260px, 70vw); height: 3px; background: rgba(243, 235, 221, 0.15); border-radius: 2px; overflow: hidden; }
#carga-barra { height: 100%; width: 0; background: var(--amarillo); transition: width 0.25s; }

body.noche #llamada { background: #f4c430; }

/* ---------------------------------------------------------------- pantallas anchas */
@media (min-width: 760px) {
  #arriba { flex-direction: row; align-items: flex-start; padding: 12px 14px 0; }
  #marcador { width: 430px; }
  #m-barra { display: none; }
  #busca { width: 330px; margin-left: auto; }
  #abajo { padding: 0 14px 10px; align-items: center; }
  #botones { width: 560px; }
  #botones button { font-size: 11px; }
  #ficha { left: auto; right: 14px; bottom: auto; top: 76px; width: 330px; }
  #info { align-items: center; }
  #info article { border-radius: 8px; }
}
@media (max-width: 360px) {
  .lado .n { font-size: 11px; }
  .lado .v { font-size: 17px; }
  #botones button { font-size: 9px; }
}
