#tren-fantasma {
  --tf-paper:#f4e2b6; --tf-amber:#f4b95f; --tf-ink:#161f22;
  box-sizing:border-box; position:fixed; inset:0; padding:0;
  width:min(860px,calc(100vw - 22px)); max-width:none; height:max-content;
  max-height:calc(100dvh - 18px); margin:auto; overflow:auto;
  color:var(--tf-paper); background:#172526;
  border:1px solid #957653; border-radius:9px;
  box-shadow:0 15px 80px #050a0bd9; font:500 15px/1.4 system-ui,sans-serif;
}
#tren-fantasma::backdrop {background:rgb(8 13 19 / 85%)}
#tren-fantasma *,#tren-fantasma *::before,#tren-fantasma *::after {box-sizing:border-box}
#tren-fantasma [hidden] {display:none!important}
#tren-fantasma button {
  position:static; min-width:0; min-height:42px; margin:0; padding:8px 13px;
  font:650 14px/1.2 system-ui,sans-serif; color:var(--tf-paper); background:#223638;
  border:1px solid #76817b; border-radius:4px; box-shadow:none; cursor:pointer;
  text-align:center; touch-action:manipulation;
}
#tren-fantasma button:hover {border-color:var(--tf-amber);color:white}
#tren-fantasma button:focus-visible, #tren-fantasma canvas:focus-visible {outline:3px solid #f4bd64;outline-offset:-3px}
#tren-fantasma button:disabled {opacity:.6;cursor:default}
#tren-fantasma .tf-cabecera {display:flex;align-items:center;gap:10px;justify-content:space-between;padding:10px 16px}
#tren-fantasma .tf-cabecera small {display:block;color:#d3c5a8;font-size:12px;line-height:1.4}
#tren-fantasma .tf-cabecera h2 {margin:0;color:#fae7ba;font:700 clamp(22px,4vw,36px)/1.03 Georgia,serif;letter-spacing:-.04em}
#tren-fantasma .tf-cuadro {position:relative;isolation:isolate;border-block:1px solid #7b6754;background:#0b1720}
#tren-fantasma canvas {display:block;width:100%;height:clamp(240px,49dvh,427px);touch-action:manipulation;border-radius:0;margin:0}
#tren-fantasma .tf-cuenta {position:absolute;right:9px;top:8px;padding:3px 7px;border-radius:3px;background:#142323ed;color:#f6deae;font:650 13px/1.35 ui-monospace,monospace;pointer-events:none}
#tren-fantasma .tf-via {height:4px;background:#283336}
#tren-fantasma .tf-distancia {display:block;height:100%;background:#f4b95f;transform:scaleX(0);transform-origin:left}
#tren-fantasma .tf-pie {padding:12px 16px 14px}
#tren-fantasma .tf-pie h3 {color:#fae7ba;margin:0;font:700 clamp(19px,3vw,26px)/1.08 Georgia,serif}
#tren-fantasma .tf-texto {margin:4px 0 9px;color:#eee4ce;min-height:1.45em;font:500 15px/1.38 system-ui,sans-serif}
#tren-fantasma .tf-mandos {display:flex;align-items:center;gap:6px;flex-wrap:wrap}
#tren-fantasma [data-tf=iniciar],#tren-fantasma [data-tf=volver] {background:#f1bd71;color:#241c17;border-color:#e1a248}
#tren-fantasma .tf-pulsos {display:flex;align-items:stretch;gap:4px}
#tren-fantasma .tf-pulsos button {background:#273f40;border-bottom:3px solid #738e85}
#tren-fantasma .tf-pulsos button[aria-pressed=true] {color:#211b18;border-color:#dba459;background:#f1cd8c}
#tren-fantasma .tf-teclas {font:550 12px/1.3 ui-monospace,monospace;color:#dad2bb;margin:7px 0 0}
@media(pointer:coarse){#tren-fantasma .tf-teclas {display:none}}
@media(max-width:530px){
  #tren-fantasma {width:calc(100vw - 10px);max-height:calc(100dvh - 8px)}
  #tren-fantasma .tf-pie,#tren-fantasma .tf-cabecera {padding:10px}
  #tren-fantasma .tf-pulsos {width:100%}
  #tren-fantasma .tf-pulsos button {flex:1}
  #tren-fantasma canvas {height:clamp(225px,39dvh,390px)}
}
@media(max-height:510px) and (orientation:landscape){
  #tren-fantasma {width:min(820px,100vw - 8px);max-height:calc(100dvh - 6px)}
  #tren-fantasma canvas {height:39dvh;min-height:108px}
  #tren-fantasma .tf-cabecera,#tren-fantasma .tf-pie {padding:4px 10px}
  #tren-fantasma .tf-cabecera h2,#tren-fantasma .tf-pie h3 {font-size:19px}
  #tren-fantasma .tf-cabecera small {font-size:10px}
  #tren-fantasma .tf-pie .tf-texto {margin:2px 0 4px;font-size:13px}
  #tren-fantasma .tf-teclas {display:none}
}
