:root {
  --bg: rgba(12, 12, 12, 0.86);
  --fg: #fff;
  --muted: #b9b9b9;
  --green: #2ecc71;
  --yellow: #f4d03f;
  --red: #ff5a4f;
  --accent: #e8342a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* iOS agranda el texto al girar a horizontal: se desactiva para que todo mantenga su tamaño */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; background: #111; color: var(--fg); overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#map { position: fixed; inset: 0; background: #222; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }

.card { position: fixed; z-index: 500; background: var(--bg); border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.35); }

/* ---- Panel compacto (vertical): una franja arriba ---- */
#hud { top: calc(var(--safe-t) + 6px); left: 6px; right: 6px; padding: 6px 8px 4px; }
.hud-main { display: flex; align-items: center; gap: 6px; }
.h-speed { flex: 0 0 auto; min-width: 74px; font-size: 32px; font-weight: 800; line-height: 1; }
.h-speed small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px; }
#callebox { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; }
.nudge { flex: 0 0 34px; height: 44px; border-radius: 10px; background: #2a2a2a; font-size: 16px; }
.nudge:active { background: #555; }
.calle-main { min-width: 64px; text-align: center; cursor: pointer; }
.calle-label { font-size: 10px; letter-spacing: 1.5px; color: var(--muted); font-weight: 700; }
.calle-num { font-size: 34px; font-weight: 900; line-height: 1; }
.calle-num.guess { color: var(--muted); }
.h-tank { flex: 0 0 auto; width: 78px; text-align: right; }
.h-tank-l { font-size: 17px; font-weight: 800; line-height: 1.1; }
.h-tank-ha { font-size: 11px; color: var(--muted); font-weight: 600; }
.tank-bar { height: 7px; border-radius: 4px; background: #333; overflow: hidden; margin: 3px 0 2px; }
#s-tankfill { height: 100%; width: 100%; background: var(--green); transition: width .4s; }
#s-tankfill.low { background: var(--yellow); }
#s-tankfill.empty { background: var(--red); }
.hud-line { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px;
  background: none; padding: 4px 2px 0; margin-top: 4px; border-top: 1px solid rgba(255,255,255,.1);
  font-size: 13px; font-weight: 600; text-align: left; }
.calle-sub { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hud-right { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.chev { color: var(--muted); font-size: 14px; transition: transform .2s; }
body.details-open .chev { transform: rotate(180deg); }
.gpsdot { width: 9px; height: 9px; border-radius: 50%; background: #666; display: inline-block; }
.gpsdot.ok { background: var(--green); } .gpsdot.mid { background: var(--yellow); }
.gpsdot.bad, .gpsdot.off { background: var(--red); }
#details { padding: 4px 2px 2px; font-size: 13px; }
#details[hidden] { display: none; }
.d-row { margin-top: 2px; color: #ddd; }
.d-row b { color: #fff; }
.warn { color: #ff8a80; }
.gps { color: var(--muted); }
.gps.bad { color: var(--red); font-weight: 700; }

#banner { position: fixed; z-index: 600; left: 6px; right: 6px; bottom: calc(var(--safe-b) + 70px);
  background: var(--accent); border-radius: 12px; padding: 8px 10px; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 8px; }
#banner[hidden] { display: none; }
#banner .msg { flex: 1; }
#banner button { background: #fff; color: #111; border-radius: 9px; padding: 8px 10px; font-weight: 800; font-size: 14px; }
#banner.info { background: #1f6feb; }

/* ---- Barra inferior baja ---- */
#bar { position: fixed; z-index: 500; left: 6px; right: 6px; bottom: calc(var(--safe-b) + 6px);
  display: flex; gap: 6px; }
.spray { flex: 1; height: 56px; border-radius: 14px; font-size: 20px; font-weight: 900;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.spray small { font-size: 11px; font-weight: 600; opacity: .85; }
.spray.off { background: var(--accent); }
.spray.on { background: var(--green); color: #062; }
.round { width: 56px; height: 56px; border-radius: 14px; background: var(--bg); font-size: 24px; }
.round.on { color: var(--green); }

/* ---- Horizontal: datos en columna a la izquierda, botones a la derecha, mapa al centro ---- */
@media (orientation: landscape) and (max-height: 600px) {
  #hud { top: calc(var(--safe-t) + 6px); max-height: calc(100vh - var(--safe-t) - var(--safe-b) - 12px); left: calc(var(--safe-l) + 6px); right: auto;
    width: 190px; display: flex; flex-direction: column; overflow-y: auto; }
  .hud-main { flex-direction: column; align-items: stretch; gap: 8px; }
  .h-speed { text-align: center; font-size: 34px; }
  .h-speed small { display: inline; margin-left: 4px; }
  #callebox { justify-content: space-between; }
  .nudge { height: 54px; flex-basis: 38px; }
  .calle-num { font-size: 40px; }
  .h-tank { width: auto; text-align: left; }
  .hud-line { flex-direction: column; align-items: flex-start; gap: 2px; }
  .calle-sub { white-space: normal; }
  #bar { left: auto; right: calc(env(safe-area-inset-right, 0px) + 6px); top: calc(var(--safe-t) + 6px);
    bottom: calc(var(--safe-b) + 6px); width: 96px; flex-direction: column; }
  #bar .round { width: 96px; height: 56px; }
  #bar .spray { flex: 1; font-size: 20px; padding: 0; writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: 1px; }
  #bar .spray small { font-size: 11px; }
  #banner { left: calc(var(--safe-l) + 202px); right: 108px; bottom: calc(var(--safe-b) + 6px); }
  .sheet-card { max-height: 96vh; max-width: 560px; margin: 0 auto; border-radius: 18px 18px 0 0; }
  #sheet { justify-content: center; }
  #editor { left: calc(var(--safe-l) + 6px); right: auto; width: 360px; }
}

#sheet { position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; }
#sheet[hidden] { display: none; }
.sheet-card { position: relative; width: 100%; max-height: 88vh; overflow-y: auto; background: #1b1b1b;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(var(--safe-b) + 18px); }
.close { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 20px;
  background: #333; font-size: 18px; }
.sheet-card h2 { margin: 0 0 12px; font-size: 22px; }
.sheet-card h3 { margin: 18px 0 8px; font-size: 16px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px; }
.sheet-card p { color: var(--muted); margin: 6px 0; line-height: 1.4; }
.menu-btn, .sheet-card .btn { display: block; width: 100%; text-align: left; background: #2a2a2a;
  border-radius: 12px; padding: 14px; margin: 6px 0; font-size: 17px; font-weight: 600; }
.sheet-card .btn.primary { background: var(--green); color: #062; text-align: center; }
.sheet-card .btn.danger { background: #4a1d1a; color: #ffb4ab; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
label { display: block; margin: 10px 0 4px; font-weight: 600; }
input[type=text], input[type=number] { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid #444;
  background: #111; color: #fff; font-size: 18px; }
input[type=checkbox] { width: 22px; height: 22px; vertical-align: middle; }
.field-item { display: flex; gap: 6px; align-items: center; }
.field-item .btn { flex: 1; }
.field-item .small { flex: 0 0 auto; width: auto; padding: 14px 12px; }
.sel { outline: 2px solid var(--green); }
progress { width: 100%; height: 16px; }

#editor { position: fixed; z-index: 700; left: 8px; right: 8px; bottom: calc(var(--safe-b) + 8px);
  background: #1b1b1b; border-radius: 16px; padding: 12px; box-shadow: 0 4px 18px rgba(0,0,0,.5); }
#editor[hidden] { display: none; }
#ed-text { font-size: 16px; line-height: 1.35; margin-bottom: 10px; }
#ed-text b { color: var(--yellow); }
.ed-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-buttons button { flex: 1 1 40%; padding: 14px 8px; border-radius: 12px; background: #2f2f2f; font-weight: 700; }
.ed-buttons .primary { background: var(--green); color: #062; }
body.editing #bar, body.editing #hud { display: none; }

.tractor { width: 36px; height: 58px; }
.tractor svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 0 2px #000) drop-shadow(0 1px 3px rgba(0,0,0,.6)); }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 9px; }

.orilla-tip { background: #ff9f1a; color: #111; border: 0; font-weight: 800; font-size: 13px; padding: 1px 6px; box-shadow: none; }
.orilla-tip::before { display: none; }
body.picking #hud, body.picking #bar { display: none; }
body.picking #banner { bottom: calc(var(--safe-b) + 8px); }

/* ---- Menú y ajustes ---- */
.menu-btn { display: flex; align-items: center; gap: 12px; }
.menu-btn .mi { font-size: 22px; width: 28px; text-align: center; flex: 0 0 auto; }
.menu-btn .mt { flex: 1; }
.menu-btn small, .tg small { display: block; font-size: 13px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.menu-head { display: flex; align-items: center; gap: 10px; background: #233a24; border-radius: 14px; padding: 12px 14px; margin: 4px 48px 6px 0; }
.menu-head > div { flex: 1; min-width: 0; }
.mh-name { font-size: 20px; font-weight: 800; }
.mh-sub { font-size: 13px; color: #c9e7c4; margin-top: 2px; }
.menu-head .btn.small { width: auto; margin: 0; padding: 10px 12px; background: #2f5130; font-size: 15px; }
.tg { display: flex; align-items: center; gap: 12px; background: #2a2a2a; border-radius: 12px; padding: 12px 14px; margin: 6px 0; font-size: 16px; font-weight: 600; }
.tg > span { flex: 1; }
.tg input { position: absolute; opacity: 0; width: 0; height: 0; }
.tg i { flex: 0 0 52px; height: 30px; border-radius: 15px; background: #555; position: relative; transition: background .2s; }
.tg i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: left .2s; }
.tg input:checked + i { background: var(--green); }
.tg input:checked + i::after { left: 25px; }
.stp { display: flex; align-items: center; gap: 10px; background: #2a2a2a; border-radius: 12px; padding: 8px 10px 8px 14px; margin: 6px 0; font-size: 16px; font-weight: 600; }
.stp > span { flex: 1; }
.stp-c { display: flex; align-items: center; gap: 6px; }
.stp-c button, .seg button { min-width: 44px; height: 44px; border-radius: 10px; background: #3a3a3a; font-size: 22px; font-weight: 700; }
.stp-c b { min-width: 58px; text-align: center; font-size: 20px; }
.stp-c small { color: var(--muted); font-size: 13px; margin-left: -4px; margin-right: 2px; }
.seg { display: flex; gap: 6px; }
.seg button { font-size: 17px; }
.seg button.sel { background: var(--green); color: #062; outline: none; }
.hist { display: flex; gap: 8px; align-items: flex-start; border-bottom: 1px solid #2c2c2c; }
.hist p { flex: 1; }
.hist .del { flex: 0 0 44px; height: 44px; border-radius: 10px; background: #3a1f1d; font-size: 18px; margin-top: 6px; }
