/* El mapa es el escenario; la interfaz conserva espacio para explorar. */
:root {
  --tinta: #253e33;
  --tinta-suave: #687565;
  --bosque: #244b3b;
  --hoja: #6c9670;
  --menta: #d9e7cb;
  --papel: #fcf9ed;
  --borde: #d6dac4;
  --sombra: 0 4px 0 rgba(40, 65, 39, .1), 0 10px 32px rgba(40, 65, 39, .12);
  --fuente-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body { color: var(--tinta); background: #bdcda6; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button, a, input { touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid #33856d; outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: .45; }
button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.solo-lectores { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
#mundo, #map { width: 100%; height: 100%; height: 100dvh; }
#map { position: absolute; inset: 0; background: #bdcda6; }
.marco-mundo { position: fixed; inset: 0; border: 8px solid rgba(252, 249, 237, .64); pointer-events: none; z-index: 2; }
.cabecera-mundo { position: fixed; z-index: 10; top: max(22px, env(safe-area-inset-top)); left: 26px; right: 26px; display: flex; align-items: center; justify-content: flex-end; pointer-events: none; }
.cabecera-mundo > * { pointer-events: auto; }
.cabecera-acciones { display: flex; align-items: center; gap: 10px; }
.estado-conexion { display: flex; align-items: center; gap: 7px; padding: 11px 13px; background: var(--papel); border: 1px solid var(--borde); border-radius: 6px; box-shadow: var(--sombra); font-size: 11px; }
.estado-conexion i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #729c6a; box-shadow: 0 0 0 3px rgba(114, 156, 106, .12); flex: none; }
.estado-conexion:has([data-estado="offline"]) i { background: #b38c4e; box-shadow: 0 0 0 3px rgba(179, 140, 78, .12); }
.boton-icono { display: grid; place-items: center; width: 40px; height: 40px; background: var(--papel); border: 1px solid var(--borde); border-radius: 6px; box-shadow: var(--sombra); font: 700 18px var(--fuente-mono); }
.boton-icono:hover { background: #e9eedb; }
.jugadores-toggle { display: none; }
.panel { background: var(--papel); border: 1px solid var(--borde); border-radius: 8px; box-shadow: var(--sombra); }
.etiqueta { display: block; color: var(--tinta-suave); font: 700 9px/1.5 var(--fuente-mono); letter-spacing: 1.15px; }
.ficha-explorador { position: fixed; z-index: 6; top: max(22px, env(safe-area-inset-top)); left: 26px; width: max-content; min-width: 0; padding: 6px 10px; border-radius: 6px; text-align: center; }
.ficha-explorador strong { display: block; font: 700 16px/1 var(--fuente-mono); font-variant-numeric: tabular-nums; }
.panel-jugadores { position: fixed; z-index: 7; top: 110px; right: 26px; width: 254px; overflow: hidden; }
.panel-encabezado { padding: 17px 17px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e0e3d0; }
.panel-encabezado h2 { margin-top: 5px; font-size: 16px; }
.contador { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; margin-left: 5px; padding: 0 5px; background: #e7ecd9; border-radius: 4px; color: #537151; font: 700 10px var(--fuente-mono); vertical-align: 2px; }
.boton-cerrar { display: grid; place-items: center; height: 32px; width: 32px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: #78836d; font-size: 23px; flex: none; }
.boton-cerrar:hover { background: #e9eddb; color: var(--tinta); }
#cerrarJugadoresBtn { display: none; }
#jugadores-lista { max-height: min(38vh, 320px); overflow-y: auto; padding: 4px 10px; scrollbar-width: thin; scrollbar-color: #bdc9aa transparent; }
.lista-vacia, .jugadores-vacio { text-align: center; font-size: 12px; line-height: 1.8; padding: 24px 3px; color: #5d6d57; }
.lista-vacia span, .jugadores-vacio span { color: #8b927f; font-size: 11px; }
.jugador-fila, .jugador-item { display: flex; align-items: center; gap: 10px; padding: 11px 7px; width: 100%; border: 0; border-bottom: 1px solid #e6e7d9; text-align: left; background: transparent; border-radius: 5px; }
.jugador-fila:last-child, .jugador-item:last-child { border-bottom: 0; }
.jugador-fila:hover, .jugador-item:hover { background: #eaf0de; }
.jugador-fila svg, .jugador-item svg { width: 29px; height: 36px; flex: none; image-rendering: pixelated; stroke: none; }
.jugador-avatar { width: 31px; height: 37px; display: grid; place-items: center; flex: none; background: #e7edd9; border-radius: 4px; }
.jugador-info { flex: 1; min-width: 0; }
.jugador-info strong { display: block; font-size: 12px; }
.jugador-info small { display: block; color: var(--tinta-suave); font-size: 10px; margin-top: 4px; }
.jugador-chat { color: #64825d; font-size: 12px; }
.jugador-no-leidos { background: #315b43; color: #fffdf1; border-radius: 4px; padding: 2px 5px; font: 10px var(--fuente-mono); }
.panel-pie { padding: 11px 9px; border-top: 1px solid #e0e3d0; text-align: center; font-size: 10px; color: var(--tinta-suave); background: #f3f3e5; }
.panel-pie > span { color: #709168; margin-right: 3px; }
.panel-ayuda { position: fixed; z-index: 35; top: 83px; right: 26px; padding: 24px; width: 335px; }
.panel-ayuda h2 { font-size: 21px; margin: 8px 0 9px; letter-spacing: -.5px; }
.panel-ayuda > p { font-size: 12px; line-height: 1.7; color: var(--tinta-suave); }
.panel-ayuda ul { list-style: none; margin: 20px 0; padding: 0; }
.panel-ayuda li { display: flex; gap: 12px; margin: 15px 0; color: var(--tinta-suave); font-size: 11px; line-height: 1.6; }
.panel-ayuda li strong { display: block; margin-bottom: 3px; font-size: 12px; color: var(--tinta); }
.ayuda-simbolo { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #d7dfc4; background: #edf1df; font-size: 20px; flex: none; color: #5d7a57; }
.panel-ayuda .ayuda-nota { font-size: 10px; border-top: 1px solid #dee2ce; padding-top: 13px; }
.inicio-aventura { position: fixed; z-index: 15; width: min(390px, calc(100vw - 36px)); left: 50%; top: 49%; transform: translate(-50%, -50%); padding: 23px 31px 26px; text-align: center; box-shadow: 0 7px 0 rgba(40, 65, 39, .13), 0 20px 100px rgba(40, 65, 39, .23); }
.inicio-emblema { width: 72px; height: 72px; margin: 0 auto 6px; }
.inicio-emblema svg { width: 100%; height: 100%; }
.inicio-aventura > .etiqueta { font-size: 8px; letter-spacing: 1.5px; }
.inicio-aventura h2 { font-size: 29px; letter-spacing: -1px; line-height: 1.2; margin: 10px -8px 12px; }
.inicio-aventura > p:not(.gps-detalle) { font-size: 12px; line-height: 1.7; color: var(--tinta-suave); }
.inicio-gps { display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 24px; font-size: 12px; }
.pulso-gps { width: 7px; height: 7px; background: #7e9d6b; border-radius: 50%; box-shadow: 0 0 0 4px #e5ecd6; }
.gps-detalle { margin: 10px 0 16px; font-size: 11px; line-height: 1.6; color: #7b826f; }
#geoRetryBtn { width: 100%; justify-content: space-between; }
.inicio-nota { display: block; margin-top: 14px; font: 8px var(--fuente-mono); color: #8a927d; }
.error-mapa { position: fixed; left: 50%; top: 88px; transform: translateX(-50%); z-index: 40; max-width: 440px; width: calc(100vw - 32px); padding: 16px 18px; line-height: 1.6; border-color: #d4b487; color: #775529; }
.aviso { position: fixed; z-index: 50; left: 50%; bottom: 143px; transform: translateX(-50%); max-width: min(520px, calc(100vw - 32px)); width: max-content; padding: 13px 20px; border: 1px solid #466c4b; border-radius: 6px; color: #f3f5df; background: #2d4c38; box-shadow: var(--sombra); font-size: 12px; text-align: center; line-height: 1.5; }
.aviso:empty { display: none; }
.herramientas-mapa { position: fixed; right: 27px; bottom: 49px; z-index: 5; display: flex; flex-direction: column; gap: 15px; align-items: center; }
.brujula { width: 40px; text-align: center; opacity: .9; }
.brujula > span { font: 700 10px var(--fuente-mono); display: block; margin-bottom: 3px; }
.brujula svg { display: block; margin: auto; width: 23px; height: 29px; }
.zoom-mapa { display: flex; flex-direction: column; border: 1px solid var(--borde); border-radius: 5px; background: var(--papel); box-shadow: var(--sombra); }
.zoom-mapa button { width: 38px; height: 38px; font: 23px var(--fuente-mono); border: 0; background: transparent; }
.zoom-mapa button + button { border-top: 1px solid var(--borde); }
.zoom-mapa button:hover { background: #eaf0de; }
.controles-movimiento { position: fixed; bottom: 48px; left: 29px; z-index: 8; }
.control-etiqueta { text-align: center; margin-bottom: 10px; color: #4f684c; font-size: 8px; letter-spacing: 2px; }
.cruceta { width: 122px; height: 122px; display: grid; grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 40px); gap: 1px; filter: drop-shadow(0 3px 0 rgba(40, 65, 39, .17)); }
.direccion { display: grid; place-items: center; padding: 0; border: 1px solid #bcc9ab; background: #f7f7e7; font-size: 12px; color: #6b825e; touch-action: none; user-select: none; -webkit-user-select: none; }
.direccion:hover, .direccion:active, .direccion.activa { background: #dce9c9; color: var(--bosque); }
.norte { grid-column: 2; grid-row: 1; border-radius: 5px 5px 0 0; }
.oeste { grid-column: 1; grid-row: 2; border-radius: 5px 0 0 5px; }
.este { grid-column: 3; grid-row: 2; border-radius: 0 5px 5px 0; }
.sur { grid-column: 2; grid-row: 3; border-radius: 0 0 5px 5px; }
.cruceta-centro { grid-column: 2; grid-row: 2; background: #e8edda; border: 1px solid #d5dfc4; display: grid; place-items: center; color: #b4c5a2; font-size: 13px; }
.barra-aventura { position: fixed; z-index: 9; bottom: 43px; left: 50%; transform: translateX(-50%); }
.pista-movimiento { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 10px; color: #456440; margin-bottom: 13px; white-space: nowrap; text-shadow: 0 1px #e4ebd6; }
.pista-movimiento kbd { font: 9px var(--fuente-mono); border: 1px solid #91ac7b; background: rgba(242, 246, 228, .6); border-radius: 2px; min-width: 16px; padding: 2px 3px; text-align: center; }
.pista-movimiento span { margin-left: 4px; }
.pista-movimiento i { margin: 0 3px 0 9px; }
.acciones-aventura { display: flex; align-items: center; gap: 7px; background: var(--papel); border: 1px solid var(--borde); border-radius: 9px; padding: 8px; box-shadow: var(--sombra); }
.boton { border: 1px solid #d5ddc4; border-radius: 5px; padding: 11px 14px; background: #f4f5e7; display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-size: 11px; font-weight: 600; white-space: nowrap; min-height: 42px; }
.boton:hover { background: #e7eed8; border-color: #b9cba8; }
.boton:active { transform: translateY(1px); }
.boton-primario { border-color: var(--bosque); background: var(--bosque); color: #f5f7e8; }
.boton-primario:hover { border-color: #366049; background: #366049; }
#chatBtn { min-width: 82px; }
#chatBtn::before { content: ""; display: inline-block; width: 14px; height: 12px; border: 1.4px solid currentColor; clip-path: polygon(0 0, 100% 0, 100% 80%, 35% 80%, 0 100%); background: linear-gradient(currentColor, currentColor) 3px 3px / 6px 1px no-repeat, linear-gradient(currentColor, currentColor) 3px 6px / 4px 1px no-repeat; }
.separador-barra { width: 1px; height: 23px; background: #dce1cb; margin: 0 1px; }
#consola { display: none; position: fixed; z-index: 25; right: 26px; bottom: 116px; width: 365px; max-width: calc(100vw - 32px); height: min(440px, calc(100dvh - 225px)); }
#consola-panel { display: flex; flex-direction: column; height: 100%; overflow: hidden; border-color: #b2c09f; }
.consola-cabecera { display: flex; align-items: center; gap: 10px; padding: 15px 12px 15px 16px; border-bottom: 1px solid #dce2cc; background: #f2f4e5; }
.chat-emblema { width: 32px; height: 34px; background: #e2eace; display: grid; place-items: center; border: 1px solid #c9d8b6; flex: none; }
.chat-emblema svg { width: 19px; height: 19px; stroke: #5d7b51; fill: none; stroke-width: 1.5; stroke-linejoin: round; }
.consola-identidad { flex: 1; min-width: 0; }
.consola-identidad .etiqueta { font-size: 8px; }
#consola-titulo { margin-top: 5px; font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#consola-mensajes { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px 8px; scrollbar-width: thin; scrollbar-color: #bdc9aa transparent; }
.msg { font-size: 12px; line-height: 1.6; margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; padding: 9px 11px; border: 1px solid #e0e4cf; border-radius: 5px; }
.msg .hora { display: block; font: 8px var(--fuente-mono); color: #839173; margin-bottom: 5px; }
.msg-yo { background: #e9efdc; margin-left: 22px; border-color: #d9e2c8; }
.msg-otro { background: #f6f1e2; margin-right: 22px; }
.msg-sistema { text-align: center; font-size: 10px; color: #8a907c; border: 0; padding: 5px 0; }
.msg-sistema .hora { display: inline; margin-right: 5px; color: #9b9f8e; }
.msg-pendiente { opacity: .55; }
.msg-fallido { color: #a24e35; background: #f8eade; cursor: pointer; border-color: #e6c6b4; }
#consola-form { display: flex; align-items: stretch; gap: 7px; padding: 12px 12px 0; border-top: 1px solid #e1e5d3; }
#consola-input { min-width: 0; width: 100%; border: 1px solid #d4ddc3; border-radius: 5px; padding: 11px 12px; background: #fffef8; color: var(--tinta); font-size: 12px; }
#consola-input::placeholder { color: #939b86; }
#consola-form button { width: 42px; padding: 10px; flex: none; }
.consola-nota { font-size: 8px; color: #939b86; display: flex; gap: 5px; padding: 8px 13px 12px; }
.consola-nota > span:last-child { margin-left: auto; }
/* Cada OverlayView coloca este origen en las coordenadas geográficas del personaje. */
.personaje-rpg { position: absolute; width: 0; height: 0; pointer-events: none; z-index: 1; }
.personaje-boton { position: absolute; bottom: 0; left: -26px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 52px; height: 61px; padding: 0; background: transparent; border: 0; pointer-events: auto; overflow: visible; }
.personaje-boton::before { content: ""; position: absolute; bottom: 0; width: 33px; height: 10px; background: rgba(37, 62, 51, .22); border-radius: 50%; z-index: -1; }
.personaje-sprite { width: 40px; height: 52px; image-rendering: pixelated; filter: drop-shadow(1px 2px 0 rgba(35, 55, 35, .2)); transform-origin: center bottom; }
.personaje-boton svg { width: 40px; height: 52px; stroke: none; }
.personaje-nombre { position: absolute; left: 50%; top: 7px; transform: translateX(-50%); padding: 4px 7px; border: 1px solid rgba(83, 102, 67, .5); border-radius: 3px; background: #fcf9ed; color: #3b5438; font: 700 9px/1.2 var(--fuente-mono); white-space: nowrap; box-shadow: 0 2px 0 rgba(40, 65, 39, .12); pointer-events: none; }
.es-propio .personaje-nombre { background: #2a523e; border-color: #163d2b; color: #f5f8e9; }
.es-propio .personaje-boton::after { content: ""; position: absolute; top: -10px; left: 22px; width: 8px; height: 6px; background: #f7f7e3; border-top: 1px solid #2b553b; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.personaje-boton:hover .personaje-sprite { filter: drop-shadow(0 0 3px #fff9c6) drop-shadow(1px 2px 0 rgba(35, 55, 35, .2)); }
.personaje-burbuja { position: absolute; bottom: 77px; left: 50%; transform: translateX(-50%); max-width: 210px; width: max-content; padding: 8px 11px; border: 1px solid #91a67b; border-radius: 6px; background: #fffef5; color: #304b34; box-shadow: 0 3px 0 rgba(40, 65, 39, .13); font: 11px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; pointer-events: none; }
.personaje-burbuja::after { content: ""; position: absolute; bottom: -5px; left: calc(50% - 4px); width: 8px; height: 8px; border-bottom: 1px solid #91a67b; border-right: 1px solid #91a67b; transform: rotate(45deg); background: #fffef5; }
.personaje-rpg.mirando-oeste .personaje-sprite { transform: scaleX(-1); }
.personaje-rpg.caminando .personaje-sprite { animation: caminar .28s steps(2, end) infinite; }
.personaje-rpg.caminando.mirando-oeste .personaje-sprite { animation-name: caminar-oeste; }
.personaje-rpg.tiene-mensajes .personaje-nombre { border-color: #be9342; background: #fff1bd; color: #775620; }
.personaje-rpg.tiene-mensajes .personaje-nombre::before { content: "● "; color: #bd8741; }
@keyframes caminar { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-3px) rotate(3deg); } }
@keyframes caminar-oeste { 0%, 100% { transform: scaleX(-1) translateY(0) rotate(-3deg); } 50% { transform: scaleX(-1) translateY(-3px) rotate(3deg); } }
.sin-javascript { position: fixed; z-index: 100; left: 16px; right: 16px; top: 30%; background: var(--papel); padding: 30px; border: 1px solid var(--borde); text-align: center; }
@media (min-width: 1350px) { .cabecera-mundo { left: 32px; right: 32px; top: 28px; } .ficha-explorador { left: 32px; top: 28px; } .panel-jugadores { right: 32px; top: 120px; } }
@media (max-width: 1000px) {
  .panel-jugadores { width: 230px; }
  .barra-aventura { left: 54%; }
  .boton { padding: 11px 10px; gap: 7px; }
  .pista-movimiento { font-size: 9px; gap: 2px; }
  .cruceta { width: 107px; height: 107px; grid-template-columns: repeat(3, 35px); grid-template-rows: repeat(3, 35px); }
  .direccion { font-size: 10px; }
}
@media (max-width: 700px) {
  .marco-mundo { border-width: 5px; }
  .cabecera-mundo { top: max(13px, env(safe-area-inset-top)); left: 14px; right: 14px; }
  .cabecera-acciones { gap: 6px; }
  .estado-conexion { display: none; }
  .boton-icono { width: 36px; height: 36px; }
  .jugadores-toggle { display: grid; }
  .ficha-explorador { top: max(13px, env(safe-area-inset-top)); left: 14px; }
  .panel-jugadores { display: none; right: 14px; top: 82px; z-index: 30; width: min(300px, calc(100vw - 28px)); }
  .panel-jugadores.abierto { display: block; }
  #cerrarJugadoresBtn { display: grid; }
  #jugadores-lista { max-height: 42vh; }
  .panel-ayuda { top: 77px; right: 14px; width: min(335px, calc(100vw - 28px)); max-height: calc(100dvh - 100px); overflow-y: auto; padding: 20px; }
  .inicio-aventura { top: 48%; padding: 20px 25px; }
  .inicio-aventura h2 { font-size: 27px; }
  .inicio-emblema { width: 58px; height: 58px; }
  .inicio-gps { margin-top: 17px; }
  .controles-movimiento { bottom: max(114px, calc(env(safe-area-inset-bottom) + 100px)); left: 18px; }
  .control-etiqueta { display: none; }
  .cruceta { width: 122px; height: 122px; grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 40px); }
  .direccion { background: rgba(252, 249, 237, .95); }
  .herramientas-mapa { right: 18px; bottom: max(116px, calc(env(safe-area-inset-bottom) + 102px)); gap: 12px; }
  .brujula { width: 34px; }
  .brujula svg { width: 18px; height: 24px; }
  .zoom-mapa button { width: 34px; height: 34px; }
  .barra-aventura { bottom: max(34px, calc(env(safe-area-inset-bottom) + 21px)); left: 50%; width: max-content; max-width: calc(100vw - 26px); }
  .pista-movimiento { display: none; }
  .acciones-aventura { gap: 5px; padding: 6px; border-radius: 7px; }
  .boton { font-size: 10px; padding: 10px; gap: 6px; }
  .boton svg { width: 17px; height: 17px; }
  #chatBtn { min-width: 62px; }
  .separador-barra { margin: 0; }
  .aviso { bottom: 103px; padding: 10px 15px; font-size: 11px; }
  #consola { right: 13px; bottom: max(100px, calc(env(safe-area-inset-bottom) + 87px)); width: calc(100vw - 26px); max-width: none; height: min(405px, calc(100dvh - 185px)); }
  #consola-input { font-size: 16px; }
  .consola-cabecera { padding: 12px; }
  .error-mapa { top: 78px; font-size: 12px; }
}
@media (max-width: 360px) {
  .boton { padding: 10px 7px; gap: 4px; font-size: 9px; }
  #chatBtn { min-width: 54px; }
  .inicio-aventura { padding: 18px 23px; }
}
@media (max-height: 650px) and (min-width: 701px) {
  .panel-jugadores { top: 100px; }
  .inicio-aventura { padding: 16px 26px; }
  .inicio-emblema { width: 45px; height: 45px; }
  .inicio-gps { margin-top: 14px; }
  #consola { bottom: 108px; height: calc(100dvh - 205px); }
}
@media (max-height: 600px) and (max-width: 700px) {
  .inicio-aventura { top: 47%; padding: 14px 23px; }
  .inicio-emblema { display: none; }
  .inicio-aventura h2 { margin: 7px 0; font-size: 23px; }
  .inicio-aventura > p:not(.gps-detalle) { font-size: 11px; }
  .inicio-gps { margin-top: 13px; }
  .gps-detalle { margin: 7px 0 10px; font-size: 10px; }
  .inicio-nota { margin-top: 10px; }
  .brujula { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
