:root {
    --fondo: #eef1f0; --tinta: #1f2430; --suave: #5f6673; --linea: rgba(31, 36, 48, .12);
    --panel: rgba(255, 255, 255, .86); --activo: #1f2430; --activo-tinta: #fff;
    --borde-px: 0 0 0 1.5px var(--tinta), 4px 4px 0 0 rgba(0, 0, 0, .14);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --fondo: #12141b; --tinta: #e9ebf0; --suave: #9aa1ae; --linea: rgba(233, 235, 240, .14); --panel: rgba(24, 27, 36, .86); --activo: #e9ebf0; --activo-tinta: #12141b; }
}
:root[data-theme="dark"] { --fondo: #12141b; --tinta: #e9ebf0; --suave: #9aa1ae; --linea: rgba(233, 235, 240, .14); --panel: rgba(24, 27, 36, .86); --activo: #e9ebf0; --activo-tinta: #12141b; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--fondo); color: var(--tinta); font: 400 13px/1.4 Poppins, system-ui, sans-serif; }
#lienzo { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: grab; }
#lienzo:active { cursor: grabbing; }

.titulo { position: fixed; top: 20px; left: 20px; max-width: 262px; padding: 10px 12px; background: var(--panel); backdrop-filter: blur(8px); box-shadow: var(--borde-px); border-radius: 12px; pointer-events: none; }
.titulo .pre { margin: 0 0 4px; font: 9px/1 Silkscreen, monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--suave); }
.titulo h1 { margin: 0 0 6px; font: 28px/1 Silkscreen, monospace; letter-spacing: .06em; text-transform: uppercase; }
.titulo .txt { margin: 0; color: var(--suave); font-size: 14px; }

.reloj { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: baseline; padding: 6px 14px; background: #161a26; color: #f2f2f2; border-radius: 6px; font: 12px/1 Silkscreen, monospace; pointer-events: none; }
.reloj b { font-size: 16px; font-weight: 400; }
.reloj span { color: #b9c0d0; }

.panel { position: fixed; top: 20px; right: 20px; width: 224px; padding: 12px; background: var(--panel); backdrop-filter: blur(8px); box-shadow: var(--borde-px); border-radius: 14px; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.panel section + section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--linea); }
.panel h2 { margin: 0 0 7px; font: 10px/1 Silkscreen, monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--suave); font-weight: 400; }
.fila2, .fila3 { display: grid; gap: 4px; margin-bottom: 6px; }
.fila2 { grid-template-columns: 1fr 1fr; }
.fila3 { grid-template-columns: 1fr 1fr 1fr; }
.panel button { font: 500 12.5px/1 Poppins, system-ui, sans-serif; color: var(--tinta); background: transparent; border: 0; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--linea); padding: 7px 4px 6px; cursor: pointer; }
.panel button:hover { box-shadow: inset 0 0 0 1px var(--suave); }
.panel button[aria-pressed="true"] { background: var(--activo); color: var(--activo-tinta); box-shadow: inset 0 0 0 2px var(--activo), inset 0 -3px 0 2px rgba(0, 0, 0, .25); }
.panel button:focus-visible, .panel input:focus-visible { outline: 2px solid #3b82f6; outline-offset: 1px; }
.panel input[type="range"] { width: 100%; accent-color: var(--activo); margin: 4px 0 6px; }
.check { display: flex; align-items: center; gap: 6px; margin: 4px 0; color: var(--suave); cursor: pointer; }
.check input { accent-color: var(--activo); margin: 0; }
.panel button.ancho { width: 100%; margin-top: 4px; }
.panel .nota { margin: 2px 0 0; color: var(--suave); font-size: 13px; }
.pie-panel { display: grid; grid-template-columns: auto 1fr; gap: 6px; margin-top: 12px; }
.panel .inicio { display: grid; place-items: center; padding: 0 10px; color: var(--tinta); text-decoration: none; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--linea); }
.panel .inicio:hover { background: var(--activo); color: var(--activo-tinta); }
.panel.cerrado section { display: none; }
.panel.cerrado { width: auto; }
.panel.cerrado .pie-panel { margin: 0; }
.panel.cerrado .ocultar { padding: 7px 10px 6px; }

.ayuda { position: fixed; left: 20px; bottom: 16px; margin: 0; padding: 5px 9px 4px; background: var(--panel); box-shadow: var(--borde-px); border-radius: 10px; color: var(--suave); font-size: 13px; pointer-events: none; }
kbd { font: 9px/1 Silkscreen, monospace; padding: 2px 4px; border: 1px solid var(--linea); border-radius: 3px; background: var(--panel); color: var(--tinta); }

body.limpio .titulo, body.limpio .reloj, body.limpio .panel, body.limpio .ayuda { display: none; }
.etiqueta-web { position: fixed; z-index: 20; padding: 6px 10px; border-radius: 8px; background: #0a0f1d; color: #e6ebf5; font: 600 13px/1 Poppins, system-ui, sans-serif; pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; box-shadow: 0 0 0 1px rgba(255,193,7,.5); }
.etiqueta-web.visible { opacity: 1; transform: none; }
.aviso-sonido { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 30; border: 0; cursor: pointer; padding: 10px 16px; border-radius: 10px; background: #0a0f1d; color: #e6ebf5; font: 600 14px/1 Poppins, system-ui, sans-serif; box-shadow: 0 0 0 1.5px rgba(255,193,7,.6), 0 6px 18px rgba(0,0,0,.25); animation: aviso-sonido 1.6s ease-in-out infinite; }
.aviso-sonido[hidden] { display: none; }
@keyframes aviso-sonido { 50% { transform: translateX(-50%) translateY(-3px); } }
body.limpio .aviso-sonido { display: none; }

/* Cronómetro, estilo pixel art: pantalla de cristal líquido con borde escalonado */
.crono-pantalla { margin: 2px 4px 10px; padding: 10px 8px 7px; text-align: center; background: #161a26; color: #ffd166;
    font: 26px/1 Silkscreen, monospace; letter-spacing: .06em; text-shadow: 2px 2px 0 #7a4b12;
    box-shadow: 0 -3px 0 0 #0b0d14, 0 3px 0 0 #0b0d14, -3px 0 0 0 #0b0d14, 3px 0 0 0 #0b0d14, inset 0 0 0 2px #2a3047; }
#reloj-ciudad i { font-style: normal; animation: crono-latido 1s steps(1) infinite; }
.reloj-ciudad .nota { text-align: center; margin: -4px 0 0 !important; }
.crono.parado .crono-pantalla { color: #8a8fa3; text-shadow: 2px 2px 0 #2a2e3e; }
.panel .crono-btn { font: 11px/1 Silkscreen, monospace; letter-spacing: .04em; border-radius: 0; border: 0; padding: 9px 4px 7px;
    background: #f4ecd8; color: #1c1a2e; box-shadow: inset 0 0 0 2px #1c1a2e, inset 0 -4px 0 2px #d9cdb0; }
.panel .crono-btn:hover { background: #fff; box-shadow: inset 0 0 0 2px #1c1a2e, inset 0 -4px 0 2px #d9cdb0; }
.panel .crono-btn:active { box-shadow: inset 0 0 0 2px #1c1a2e; transform: translateY(1px); }
#crono-marcha { background: #d64541; color: #fff; box-shadow: inset 0 0 0 2px #1c1a2e, inset 0 -4px 0 2px #a8322f; }
.crono.andando #crono-marcha { background: #ffd166; color: #1c1a2e; box-shadow: inset 0 0 0 2px #1c1a2e, inset 0 -4px 0 2px #d9a93c; }
/* versión pequeña en una esquina, visible con la interfaz oculta mientras corre */
.crono-mini { position: fixed; left: 16px; bottom: 16px; z-index: 5; display: none; align-items: center; gap: 8px; padding: 7px 10px 5px; background: #161a26; color: #ffd166;
    font: 16px/1 Silkscreen, monospace; box-shadow: 0 -3px 0 0 #0b0d14, 0 3px 0 0 #0b0d14, -3px 0 0 0 #0b0d14, 3px 0 0 0 #0b0d14, 5px 5px 0 2px rgba(0,0,0,.3); pointer-events: none; }
.crono-mini i { width: 8px; height: 8px; background: #d64541; animation: crono-latido 1s steps(1) infinite; }
@keyframes crono-latido { 50% { opacity: 0; } }
body.limpio .crono-mini.andando { display: flex; }

/* ── Barra táctil (tablet y móvil) ── */
.tactil { display: none; }
.tactil button { font: 500 14px/1 Poppins, system-ui, sans-serif; color: var(--tinta); background: transparent; border: 0; border-radius: 9px; box-shadow: inset 0 0 0 1px var(--linea); min-width: 44px; height: 44px; padding: 0 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; white-space: nowrap; }
.tactil button[aria-pressed="true"], .tactil .tactil-abre[aria-expanded="true"] { background: var(--activo); color: var(--activo-tinta); box-shadow: inset 0 0 0 2px var(--activo); }
.tactil-barra, .tactil-desplegar { background: var(--panel); backdrop-filter: blur(8px); box-shadow: var(--borde-px); border-radius: 14px; }
.tactil-barra { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; max-width: calc(100vw - 24px); }
.tactil-grupo { position: relative; }
.tactil-menu { position: absolute; left: 0; bottom: calc(100% + 10px); display: flex; flex-direction: column; gap: 5px; padding: 6px; min-width: 150px; background: var(--panel); backdrop-filter: blur(8px); box-shadow: var(--borde-px); border-radius: 12px; animation: tactil-sube .16s ease-out; }
.tactil-menu[hidden] { display: none; }
.tactil-menu button { text-align: left; width: 100%; }
@keyframes tactil-sube { from { opacity: 0; transform: translateY(6px); } }
.tactil.plegada .tactil-barra { display: none; }
.tactil-desplegar { font-size: 20px !important; }
/* modo táctil (móvil y tableta hasta ~12"): la clase la pone un script en el <head> de index.html */
.es-tactil .tactil { display: block; position: fixed; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 25; }
.es-tactil .ayuda { display: none; }
.es-tactil .panel.cerrado { display: none; }                      /* se abre y se cierra con ◷ en la barra */
.es-tactil .panel { max-height: calc(100vh - 110px); max-height: calc(100dvh - 110px); }
.es-tactil .panel section:not(.reloj-ciudad):not(.crono) { display: none; }   /* lo demás está en la barra */
.es-tactil .panel .pie-panel { display: none; }                    /* portada (⌂) y ocultar (◷) están en la barra */
.es-tactil .tactil a.tactil-portada { display: inline-grid; place-items: center; min-width: 44px; height: 44px; border-radius: 9px; box-shadow: inset 0 0 0 1px var(--linea); color: var(--tinta); text-decoration: none; font-size: 18px; }
.es-tactil .tactil-fila { display: flex; gap: 5px; margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--linea); }
.es-tactil .tactil-fila button { flex: 1; min-width: 0; text-align: center; padding: 0 6px; }
.es-tactil .tactil button:disabled { opacity: .4; }
.es-tactil .aviso-sonido { bottom: auto; top: 16px; }
.es-tactil body.limpio .tactil { display: none; }
@media (max-width: 640px) {
    .titulo { display: none; }
    .reloj { top: 12px; }
    .panel { top: auto; bottom: 12px; right: 12px; left: 12px; width: auto; max-height: 45vh; }
    /* móvil: reloj y cronómetro arriba, centrados y lado a lado; la barra abajo; la ciudad libre en medio */
    .es-tactil .reloj { display: none; }
    .es-tactil .panel { top: calc(10px + env(safe-area-inset-top)); bottom: auto; left: 50%; right: auto; transform: translateX(-50%);
        width: min(400px, calc(100vw - 20px)); max-height: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 9px; }
    .es-tactil .panel.cerrado { display: none; }
    .es-tactil .panel section + section { margin-top: 0; padding-top: 0; border-top: 0; }
    .es-tactil .panel .pie-panel { display: none; }
    .es-tactil .panel h2 { margin-bottom: 5px; font-size: 9px; }
    .es-tactil .panel .crono-pantalla { margin: 0 0 6px; padding: 7px 4px 5px; }
    .es-tactil .panel .crono-pantalla span { font-size: 20px; }
    .es-tactil .panel .reloj-ciudad .nota { font-size: 11px; }
    .es-tactil .panel .crono .fila2 { gap: 4px; }
    .es-tactil .panel .crono-btn { font-size: 9px; padding: 7px 2px 6px; }
    .tactil-abre span { display: none; }                                    /* en el móvil, solo iconos */
    .tactil button { min-width: 42px; height: 42px; padding: 0 10px; }
    .ayuda { display: none; }
}
