/* ══════════════════════════════════════════════════════════════════════
   MOBIL / TOUCH — Steuerung, Safe-Area, lesbare Schrift, große Ziele
   ══════════════════════════════════════════════════════════════════════ */
html, body { height: 100dvh; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
canvas#gl { touch-action: none; }
#hud { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

.only-touch { display: none; }
body.touch .only-touch { display: block; }
body.touch .only-desktop { display: none; }

/* Hilfe-Knopf (immer erreichbar) */
.hud-help-btn {
  position: absolute; left: 16px; bottom: 136px; width: 40px; height: 40px; border-radius: 50%;
  pointer-events: auto; cursor: pointer; z-index: 12;
  font: 800 17px/1 var(--font); color: #cfe6ff;
  background: rgba(10, 14, 22, 0.78); border: 1px solid rgba(51, 225, 255, 0.45);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.hud-help-btn:hover, .hud-help-btn.act { background: rgba(51, 225, 255, 0.18); border-color: #33e1ff; color: #fff; }

/* Hilfe-Modal */
.help {
  position: fixed; inset: 0; left: 0; bottom: 0; max-width: none; width: 100%;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px; z-index: 45; gap: 0; overflow-y: auto;
  background: rgba(3, 5, 10, 0.72); backdrop-filter: blur(6px); pointer-events: auto;
}
.help.on { display: flex; }
.help-head { display: flex; align-items: center; gap: 20px; width: min(760px, 94vw); padding: 14px 18px 10px;
  background: rgba(10, 13, 21, 0.96); border: 1px solid #2b3348; border-bottom: 0; border-radius: 14px 14px 0 0; }
.help-head b { font-size: 12px; letter-spacing: 3px; color: var(--neon-cyan); }
.help-x { margin-left: auto; width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  background: rgba(255, 255, 255, 0.07); border: 1px solid #39415a; color: #dbe5f4; font-size: 19px; line-height: 1; }
.help-body {
  width: min(760px, 94vw); max-height: min(66vh, 520px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 18px 10px; background: rgba(10, 13, 21, 0.96); border-left: 1px solid #2b3348; border-right: 1px solid #2b3348;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 26px; font-size: 12.5px; line-height: 1.85; color: #b9c7da;
}
.help-body section:last-child { grid-column: 1 / -1; }
.help-body h3 { margin: 10px 0 4px; font-size: 10px; letter-spacing: 2.4px; color: #8fa4c0; text-transform: uppercase; }
.help-body div { break-inside: avoid; }
.help-body b { color: #eaf2ff; }
.help-foot { width: min(760px, 94vw); padding: 10px 18px 14px; font-size: 11px; color: #7b8da8; text-align: center;
  background: rgba(10, 13, 21, 0.96); border: 1px solid #2b3348; border-top: 0; border-radius: 0 0 14px 14px; }

/* ── Touch-Overlay ─────────────────────────────────────────────────── */
#touch { position: fixed; inset: 0; z-index: 9; pointer-events: auto; touch-action: none; font-family: var(--font); }
#touch .tbtn { pointer-events: auto; touch-action: none; -webkit-user-select: none; user-select: none; }

/* Joystick */
.t-stick { position: absolute; left: 92px; bottom: 22px; width: 132px; height: 132px; pointer-events: none; opacity: 0.6; transition: opacity 0.15s; }
.t-stick.on { opacity: 1; }
.t-stick-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(120, 200, 255, 0.35);
  background: radial-gradient(circle, rgba(10, 20, 34, 0.5), rgba(10, 20, 34, 0.16) 70%, transparent 72%);
  box-shadow: inset 0 0 22px rgba(51, 225, 255, 0.12);
}
.t-stick-knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 40% 35%, #d8f4ff, #56c9ea 55%, #1c6b86);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 18px rgba(51, 225, 255, 0.35);
}

/* Aktions-Buttons unten rechts */
.t-actions { position: absolute; right: 12px; bottom: 10px; width: 216px; height: 196px; pointer-events: none; }
.tbtn {
  display: flex; align-items: center; justify-content: center; text-align: center;
  font: 800 10px/1.15 var(--font); letter-spacing: 1.1px; color: #dff1ff;
  background: rgba(10, 14, 22, 0.6); border: 1.5px solid rgba(120, 200, 255, 0.4);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45); backdrop-filter: blur(4px);
  transition: transform 0.06s, background 0.1s, border-color 0.1s;
}
.tbtn.down { transform: scale(0.94); background: rgba(51, 225, 255, 0.3); border-color: #8ef0ff; }
.t-round { position: absolute; border-radius: 50%; }
.t-fire { right: 0; bottom: 0; width: 92px; height: 92px; font-size: 11px; color: #ffd7ec;
  border-color: rgba(255, 62, 165, 0.55); background: rgba(46, 8, 26, 0.6); }
.t-fire.down { background: rgba(255, 62, 165, 0.35); border-color: #ff8fc8; }
.t-use { right: 92px; bottom: 16px; width: 76px; height: 76px; font-size: 8.5px; }
.t-jump { right: 30px; bottom: 102px; width: 60px; height: 60px; font-size: 8.5px; }
.t-hb { right: 110px; bottom: 100px; width: 58px; height: 58px; font-size: 8.5px; }

/* Seitenleiste */
.t-side { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); display: flex; gap: 6px; pointer-events: none; }
.t-small { width: 40px; height: 34px; border-radius: 9px; font-size: 9.5px; letter-spacing: 0.3px; }
.t-small.act { background: rgba(51, 225, 255, 0.25); border-color: #8ef0ff; }

/* Touch-Prompt (Interaktions-Hinweis, antippbar) */
.t-prompt {
  position: absolute; left: 50%; bottom: 118px; transform: translateX(-50%) translateY(6px);
  padding: 8px 16px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #eaf6ff;
  background: rgba(10, 14, 22, 0.85); border: 1px solid rgba(51, 225, 255, 0.45);
  opacity: 0; transition: opacity 0.15s, transform 0.15s; pointer-events: none;
  max-width: 62vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.t-prompt.on { opacity: 1; transform: translateX(-50%); }

.t-rotate { display: none; }

/* Im Fahrzeug: FEUER aus, GAS / BREMSE / HANDBREMSE rein */
#touch .t-hb, #touch .t-gas, #touch .t-brake { display: none; }
#touch.in-veh .t-fire { display: none; }
#touch.in-veh .t-jump { display: none; }
#touch.in-veh .t-hb { display: flex; }
#touch.in-veh .t-gas { display: flex; right: 0; bottom: 0; width: 86px; height: 86px; font-size: 11px; background: rgba(20, 60, 40, 0.7); border-color: rgba(50, 220, 120, 0.6); }
#touch.in-veh .t-brake { display: flex; right: 94px; bottom: 8px; width: 72px; height: 72px; font-size: 9.5px; background: rgba(60, 20, 20, 0.7); border-color: rgba(255, 70, 70, 0.6); }
#touch.in-veh .t-hb { right: 94px; bottom: 92px; width: 62px; height: 62px; font-size: 8px; }
#touch.in-veh .t-use { right: 12px; bottom: 98px; width: 68px; height: 68px; font-size: 8px; }

/* Hochformat-Hinweis */
@keyframes t-spin { to { transform: rotate(360deg); } }
@media (orientation: portrait) {
  body.touch .t-rotate {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    position: fixed; inset: 0; z-index: 60; background: #05070c;
    color: #cfe6ff; text-align: center; padding: 24px;
  }
  #touch { z-index: 50; }
  body.touch .t-rotate::before {
    content: ''; width: 46px; height: 46px; border-radius: 50%;
    border: 3px solid rgba(51, 225, 255, 0.22); border-top-color: #33e1ff; border-right-color: #33e1ff;
    animation: t-spin 2.2s linear infinite;
  }
  body.touch .t-rotate b { font: 800 14px/1.5 var(--font); letter-spacing: 3px; }
  body.touch .t-rotate span { font: 500 11.5px/1.6 var(--font); color: #8fa4c0; max-width: 250px; }
  body.touch .t-rotate, body.touch .t-rotate * { display: revert; }
  body.touch .t-rotate { display: flex; }
  body.touch .t-rotate b, body.touch .t-rotate span { display: block; }
}

/* ── Schmale / kurze Displays: HUD kompakter ────────────────────────── */
@media (max-width: 900px), (max-height: 560px) {
  .tl { top: 8px; left: 8px; min-width: 0; padding: 6px 10px; }
  .clock { font-size: 18px; }
  .clock small { font-size: 10px; }
  .wx { font-size: 9.5px; }
  .tr { top: 8px; right: 8px; min-width: 0; padding: 6px 10px; }
  .money { font-size: 17px; }
  .stars { font-size: 16px; letter-spacing: 2px; }
  .starlabel { font-size: 9px; }
  .shards { font-size: 9.5px; }
  .bl { bottom: 8px; left: 8px; min-width: 0; padding: 6px 10px; }
  .who { font-size: 11px; margin-bottom: 4px; }
  .bar { height: 7px; margin-bottom: 4px; }
  .ammo { font-size: 11px; margin-top: 5px; }
  .br { bottom: 8px !important; right: 8px; min-width: 0; padding: 6px 10px; }
  .spd { font-size: 22px; }
  .mission { top: 54px; width: 58vw; max-width: 400px; padding: 8px 12px 10px; }
  .mission .mtitle { font-size: 13px; }
  .mission .mtext { font-size: 11px; }
  .objective { top: 96px; max-width: 54vw; padding: 8px 10px; font-size: 11.5px; }
  .radio { top: 96px; right: 8px; padding: 5px 9px; }
  .radio b { font-size: 11px; }
  .toasts { bottom: 108px; }
  .toast { font-size: 11.5px; padding: 6px 12px; white-space: normal; max-width: 76vw; text-align: center; }
  .newsticker { font-size: 11px; max-width: 80%; top: 8px; }
  .help-body { grid-template-columns: 1fr; font-size: 12px; }
  .hud-help-btn { left: 8px; bottom: 112px; width: 36px; height: 36px; }
  .pause-panel { padding: 18px 16px 14px; }
  .pause h2 { font-size: 19px; letter-spacing: 5px; }
  .pause-stats { grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 10px; }
  .pause-row { font-size: 11px; padding: 6px 0; }
  .pause-actions button { padding: 10px 6px; font-size: 10px; }
  .shop, .jobs, .pause { max-height: 94dvh; }
  .shop-list { max-height: 56dvh; }
}

/* Kleine Geräte: Seitenleiste kompakter, damit sie neben Uhr und Geld passt */
@media (max-width: 780px) {
  .t-small { width: 34px; height: 30px; font-size: 8.5px; }
  .t-side { gap: 4px; }
  .t-actions { transform: scale(0.9); transform-origin: bottom right; }
  .t-stick { left: 78px; bottom: 18px; width: 112px; height: 112px; }
  .t-stick-knob { width: 46px; height: 46px; }
}

/* Touch: Layout umbauen (Minimap oben rechts, Tacho mittig unten) */
body.touch .minimap { right: 8px; top: 72px; bottom: auto; width: 104px; height: 104px; border-radius: 10px; }
body.touch .minimap canvas { width: 104px; height: 104px; }
body.touch .bl { left: 8px; bottom: 170px; width: 150px; padding: 6px 9px; }
body.touch .br { left: 50%; right: auto; transform: translateX(-50%); bottom: 6px !important; }
body.touch .hud-help-btn { display: none; }
body.touch .mission { top: 46px; width: 46vw; max-width: 340px; }
body.touch .mission .mtext { display: none; }
body.touch .mission .mtitle { font-size: 13px; }
body.touch .objective { top: 118px; max-width: 46vw; }
body.touch .toasts { top: 112px; bottom: auto; }
body.touch .crosshair { opacity: 0.55; }
body.touch .help { padding: 8px; }

/* Startbildschirm mobil */
@media (max-height: 560px) {
  #start .panel { padding: 16px 18px; max-height: 94dvh; overflow-y: auto; }
  #start h1 { font-size: 26px; letter-spacing: 3px; }
  #start h1 span { font-size: 10px; letter-spacing: 5px; }
  #start .tag { font-size: 11.5px; margin: 8px 0; }
  #start ul { font-size: 11px; line-height: 1.7; margin-bottom: 10px; }
  #start button { padding: 11px; font-size: 13px; }
  #start .note { font-size: 9.5px; }
  #loading .brand { font-size: 34px; letter-spacing: 8px; }
}
