/* Undermine Squad – Handy und Tablet (Konzept: docs/mobil.md, Tokens: ui/tokens.css).
 *
 * Drei Stufen über Klassen am <body> (game/touch.js applyInputMode):
 *   .im-phone    Handy: kompaktes HUD, Stick links, Knöpfe rechts, Menüs als Vollbild-Blatt
 *   .im-tablet   Tablet: HUD wie am Desktop mit größeren Zielen, schwebende Aktionsleiste
 *   .im-desktop  Tastatur und Maus (hud.css, style.css wie bisher)
 * .is-touch gilt für Handy und Tablet: alle Touch-Ziele mindestens 48 px.
 * Safe-Areas (Notch, Home-Leiste) über env(safe-area-inset-*).
 *
 *   .tc-*   Touch-Bedienung (game/touch.js)
 */

:root {
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  --tc-hit: 48px;
}

/* ---- Allgemein für Touch ------------------------------------------------------ */
body.is-touch { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; overscroll-behavior: none; }
body.is-touch #view { touch-action: none; cursor: default; }
body.is-touch .hx, body.is-touch .tc { -webkit-user-select: none; user-select: none; }
/* Tooltips sind für Zeiger mit Hover gedacht */
body.is-touch .ux-tip { display: none; }

/* Touch-Ziele ≥ 48 px */
body.is-touch :is(.ux-btn, .ux-tab, .ux-filter, .us-choice__btn, .mm-navbtn, .um-flag, .ux-search) { min-height: var(--tc-hit); }
body.is-touch .us-choice__btn { padding-inline: 16px; }
body.is-touch .ux-win .us-choice__btn { min-height: var(--tc-hit); }
body.is-touch .ux-close { width: var(--tc-hit); height: var(--tc-hit); }
body.is-touch .hx-menubtn { width: var(--tc-hit); min-height: var(--tc-hit); }
body.is-touch .ux-item { min-height: 96px; }
body.is-touch .ux-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
body.is-touch .ux-grid.is-fixed { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
body.is-touch .mm-navbtn { height: var(--tc-hit); }
body.is-touch .um-flag { height: 42px; min-height: 42px; }
body.is-touch .um-flags { padding: 3px; }
body.is-touch .mm-card { min-height: var(--tc-hit); }
.us-setting__stack { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.us-detected { font-size: 12.5px; }

/* Safe-Areas auch am Desktop-Layout (Tablet quer mit Kamera am Rand) */
body.is-touch .hx-topgrid { left: calc(var(--hx-gap) + var(--sa-l)); right: calc(var(--hx-gap) + var(--sa-r)); top: calc(var(--hx-gap) + var(--sa-t)); }
body.is-touch .hx-bottom { left: calc(var(--hx-gap) + var(--sa-l)); right: calc(var(--hx-gap) + var(--sa-r)); bottom: calc(var(--hx-gap) + var(--sa-b)); }
body.is-touch .mm-view { padding-top: calc(14px + var(--sa-t)); padding-left: calc(clamp(14px, 3.5vw, 48px) + var(--sa-l)); padding-right: calc(clamp(14px, 3.5vw, 48px) + var(--sa-r)); padding-bottom: calc(10px + var(--sa-b)); }

/* ---- Touch-Ebene ---------------------------------------------------------------- */
.tc { position: fixed; inset: 0; z-index: 10; pointer-events: none; display: none; font: 650 12px/1 var(--us-font); color: var(--us-text); }
.tc.is-on.in-round { display: block; }
body.in-menu .tc { display: none; }
.tc-zone { position: absolute; left: 0; bottom: 0; width: 44%; top: 34%; pointer-events: auto; touch-action: none; }
.tc-zone[hidden] { display: none; }
.tc-stick { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.tc-stick::before { content: ""; position: absolute; left: -64px; top: -64px; width: 128px; height: 128px; border-radius: 50%;
  background: radial-gradient(circle, rgba(11, 16, 32, .25), rgba(11, 16, 32, .55)); border: 2px solid rgba(143, 182, 255, .45);
  box-shadow: 0 0 0 1px rgba(5, 8, 20, .4), inset 0 0 24px rgba(61, 123, 255, .18); }
.tc-stick__knob { position: absolute; left: -28px; top: -28px; width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(180deg, rgba(143, 182, 255, .95), rgba(61, 123, 255, .9)); box-shadow: 0 4px 14px rgba(3, 6, 16, .5), inset 0 1px 0 rgba(255, 255, 255, .5); }
.tc-stick[data-dir*="u"]::before { border-top-color: var(--us-gold); }
.tc-stick[data-dir*="d"]::before { border-bottom-color: var(--us-gold); }
.tc-stick[data-dir*="l"]::before { border-left-color: var(--us-gold); }
.tc-stick[data-dir*="r"]::before { border-right-color: var(--us-gold); }

/* Knöpfe rechts im Bogen: dunkles Glas mit feinem Rand, darin die Pixel-Symbole des Spiels,
   Beschriftung klein darunter. Farbe nur als Akzent (Goldring am Graben-Knopf). */
.tc-pad { position: absolute; right: calc(12px + var(--sa-r)); bottom: calc(6px + var(--sa-b)); width: 224px; height: 214px; pointer-events: none; }
.tc-btn { position: absolute; pointer-events: auto; touch-action: none; display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 0; border: 0; background: none; color: var(--us-text); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tc-btn__disc { position: relative; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; box-sizing: border-box;
  background: radial-gradient(120% 120% at 50% 0%, rgba(40, 52, 88, .62) 0%, rgba(11, 16, 32, .58) 62%);
  border: 1px solid rgba(255, 255, 255, .16);
  -webkit-backdrop-filter: blur(12px) saturate(1.3); backdrop-filter: blur(12px) saturate(1.3);
  box-shadow: 0 8px 22px rgba(3, 6, 16, .38), inset 0 1px 0 rgba(255, 255, 255, .14), inset 0 -10px 18px rgba(3, 6, 16, .25);
  transition: transform 90ms var(--us-ease), border-color 90ms, background 90ms, box-shadow 90ms; }
.tc-btn__disc canvas { display: block; image-rendering: pixelated; filter: drop-shadow(0 2px 0 rgba(3, 6, 16, .55)); }
.tc-btn__label { font: 650 10.5px/1 var(--us-font); letter-spacing: .03em; color: rgba(238, 242, 255, .88); white-space: nowrap;
  text-shadow: 0 1px 2px rgba(3, 6, 16, .9), 0 0 6px rgba(3, 6, 16, .6); }
.tc-btn.is-down .tc-btn__disc { transform: scale(.93); border-color: rgba(143, 182, 255, .7); background: radial-gradient(120% 120% at 50% 0%, rgba(61, 123, 255, .45) 0%, rgba(11, 16, 32, .6) 70%); }
/* Graben: größer, Goldring statt Goldfläche */
.tc-btn--dig { right: 4px; bottom: 6px; }
.tc-btn--dig .tc-btn__disc { width: 84px; height: 84px; border: 1.5px solid rgba(255, 194, 61, .65);
  box-shadow: 0 10px 26px rgba(3, 6, 16, .42), 0 0 0 4px rgba(255, 194, 61, .08), inset 0 1px 0 rgba(255, 255, 255, .16), inset 0 0 22px rgba(255, 194, 61, .14); }
.tc-btn--dig .tc-btn__label { color: var(--us-gold); }
.tc-btn--dig.is-down .tc-btn__disc { border-color: var(--us-gold); background: radial-gradient(120% 120% at 50% 0%, rgba(255, 194, 61, .32) 0%, rgba(11, 16, 32, .6) 70%); }
.tc-btn--jump { right: 106px; bottom: 6px; }
.tc-btn--throw { right: 16px; bottom: 122px; }
.tc-btn--throw.is-empty .tc-btn__disc canvas { opacity: .35; filter: grayscale(1); }
.tc-btn--throw.is-empty .tc-btn__label { opacity: .5; }

/* Kontextknopf: Glas-Pille, Symbol in einem getönten Kreis, Akzent nur am Rand */
.tc-ctx { position: absolute; right: 92px; bottom: 112px; pointer-events: auto; touch-action: none; display: inline-flex; align-items: center; gap: 8px;
  height: 52px; max-width: 220px; padding: 0 16px 0 6px; box-sizing: border-box; border-radius: var(--us-pill); cursor: pointer;
  color: var(--us-text); font: 650 14px/1 var(--us-font);
  background: linear-gradient(180deg, rgba(40, 52, 88, .7), rgba(11, 16, 32, .66));
  border: 1px solid rgba(143, 182, 255, .45);
  -webkit-backdrop-filter: blur(12px) saturate(1.3); backdrop-filter: blur(12px) saturate(1.3);
  box-shadow: 0 8px 22px rgba(3, 6, 16, .4), inset 0 1px 0 rgba(255, 255, 255, .14);
  transition: transform 90ms var(--us-ease); }
.tc-ctx[hidden] { display: none; }
.tc-ctx__ico { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, rgba(143, 182, 255, .3), rgba(61, 123, 255, .1) 70%); box-shadow: inset 0 0 0 1px rgba(143, 182, 255, .3); }
.tc-ctx__ico canvas { display: block; image-rendering: pixelated; filter: drop-shadow(0 2px 0 rgba(3, 6, 16, .55)); }
.tc-ctx__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-ctx[data-kind="chop"], .tc-ctx[data-kind="activate"] { border-color: rgba(76, 215, 135, .5); }
.tc-ctx[data-kind="chop"] .tc-ctx__ico, .tc-ctx[data-kind="activate"] .tc-ctx__ico { background: radial-gradient(circle at 50% 35%, rgba(76, 215, 135, .3), rgba(76, 215, 135, .08) 70%); box-shadow: inset 0 0 0 1px rgba(76, 215, 135, .35); }
.tc-ctx:active { transform: scale(.96); }
.tc-ctx.is-new { animation: tc-pop .28s var(--us-ease); }
@keyframes tc-pop { 0% { transform: translateY(6px) scale(.9); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* Rückmeldung beim Tippen ins Feld */
.tc-ping { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; border: 2px solid rgba(143, 182, 255, .9); pointer-events: none; animation: tc-ping .45s ease-out forwards; }
.tc-ping.is-strong { border-color: var(--us-gold); }
@keyframes tc-ping { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
.tc-ghost { position: absolute; left: -24px; top: -24px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: rgba(11, 16, 32, .7); border: 1px solid var(--us-gold); pointer-events: none; }
.tc-ghost canvas { width: 36px; height: 36px; image-rendering: pixelated; }

/* Hinweis zum Drehen */
.tc-rotate { display: none; position: absolute; inset: 0; pointer-events: auto; place-items: center; padding: calc(20px + var(--sa-t)) 20px calc(20px + var(--sa-b)); box-sizing: border-box; background: rgba(5, 8, 20, .82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.tc-rotate__card { max-width: 320px; padding: 24px 22px; text-align: center; display: grid; justify-items: center; gap: 10px; }
.tc-rotate__card svg { color: var(--us-sky-2); animation: tc-turn 2.4s var(--us-ease) infinite; }
@keyframes tc-turn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
.tc-rotate__title { margin: 0; font: 700 24px/1.15 var(--us-font-display); }
.tc-rotate__text { margin: 0 0 6px; color: var(--us-text-2); font: 500 15px/1.45 var(--us-font); }
.tc-rotate__btn { min-height: var(--tc-hit); }
@media (orientation: portrait) {
  body.im-phone:not(.tc-portrait-ok) .tc.in-round .tc-rotate { display: grid; }
}

/* =============================================================================
 * Handy
 * ============================================================================= */
body.im-phone .hx { --hx-gap: 8px; }
body.im-phone .hx-topgrid { grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto); grid-template-areas: "who mid side"; gap: 8px; }
/* Buddler-Karte: kleines Wappen mit Energie */
body.im-phone .hx-who { width: 184px; padding: 6px 10px 7px 6px; column-gap: 8px; grid-template-columns: auto minmax(0, 1fr); }
body.im-phone .hx-ava { width: 38px; height: 42px; grid-row: span 2; }
body.im-phone .hx-name { font-size: 13.5px; gap: 4px; }
body.im-phone .hx-name canvas { width: 18px; height: 18px; }
body.im-phone .hx-rank, body.im-phone .hx-bar--exp { display: none; }
body.im-phone .hx-bars { margin-top: 2px; gap: 3px; }
body.im-phone .hx-bar { grid-template-columns: 12px minmax(0, 1fr) auto; gap: 5px; font-size: 10px; }
body.im-phone .hx-bar .ux-ico { width: 12px; height: 12px; }
body.im-phone .hx-track { height: 6px; }
/* Mitte: Uhr und Hinweise schmal */
body.im-phone .hx-mid { width: auto; max-width: 100%; justify-self: center; gap: 6px; }
body.im-phone .hx-pill { padding: 6px 11px; font-size: 12px; gap: 7px; }
body.im-phone .hx-pill .hx-title { max-width: 26vw; }
body.im-phone .hx-tut { padding: 8px 10px; max-width: 46vw; }
body.im-phone .hx-tut__head { margin-bottom: 4px; }
body.im-phone .hx-tut__text { font-size: 12px; line-height: 1.35; }
body.im-phone .hx-tut .ux-btn { min-height: 40px; }
body.im-phone .hx-toast { font-size: 12.5px; padding: 7px 12px 7px 10px; }
body.im-phone .hx-toast.is-goal { font-size: 16px; padding: 10px 16px; }
/* Rechts: Crew, Geld, Menü; Strom und Wind nur als Symbol; Ziel als einklappbarer Chip */
body.im-phone .hx-side { gap: 6px; }
body.im-phone .hx-res { padding: 3px; }
body.im-phone .hx-res .hx-chip { padding: 3px 7px 3px 4px; font-size: 12px; }
body.im-phone .hx-res .hx-chip canvas { width: 22px; height: 22px; margin: -2px -1px; }
body.im-phone .hx-res .hx-chip:not(.hx-chip--crew):not(.hx-chip--money) { display: none; }
body.im-phone .hx-res .hx-chip--crew { display: inline-flex; }
body.im-phone .hx-sys { padding: 2px; }
body.im-phone .hx-sys .hx-sys__label { display: none; }
body.im-phone .hx-goal { display: block; width: auto; max-width: 42vw; padding: 0; cursor: pointer; }
body.im-phone .hx-goal[hidden] { display: none; }
body.im-phone .hx-goal__head { min-height: 40px; box-sizing: border-box; margin: 0; padding: 0 12px; align-items: center; gap: 10px; }
body.im-phone .hx-goal__head::after { content: "▸"; font-size: 13px; color: var(--us-gold); transition: transform var(--us-fast); }
body.im-phone .hx-goal.is-open .hx-goal__head::after { transform: rotate(90deg); }
body.im-phone .hx-goal > div:last-child { display: none; padding: 0 12px 10px; }
body.im-phone .hx-goal.is-open > div:last-child { display: block; }
body.im-phone .hx-goal__line { font-size: 12px; }

/* Unten: Inventar in der Mitte zwischen den Daumen, Crew als wischbare Leiste oben links */
body.im-phone .hx-bottom { grid-template-columns: minmax(0, 1fr); justify-items: center; left: calc(232px + var(--sa-l)); right: calc(232px + var(--sa-r)); bottom: calc(8px + var(--sa-b)); }
body.im-phone .hx-dock { grid-column: 1; padding: 5px; gap: 5px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
body.im-phone .hx-slot { width: 48px; height: 48px; }
body.im-phone .hx-acts .hx-act__label, body.im-phone .hx-acts .ux-keys { display: none; }
body.im-phone .hx-act { min-height: 48px; padding: 4px 6px; }
/* Was Stick und Knöpfe schon können, steht nicht doppelt in der Leiste */
body.im-phone .hx-act:is([data-act="dig"], [data-act="throw"], [data-act="chop"], [data-act="build"], [data-act="grab"], [data-act="ungrab"], [data-act="activate"], [data-act="enter"], [data-act="stop"]) { display: none; }
body.im-phone .hx-acts:empty::after { display: none; }
body.im-phone .hx-acts:not(:has(.hx-act:not([data-act="dig"], [data-act="throw"], [data-act="chop"], [data-act="build"], [data-act="grab"], [data-act="ungrab"], [data-act="activate"], [data-act="enter"], [data-act="stop"]))) { display: none; }
body.im-phone .hx-dock:not(:has(.hx-acts > .hx-act:not([data-act="dig"], [data-act="throw"], [data-act="chop"], [data-act="build"], [data-act="grab"], [data-act="ungrab"], [data-act="activate"], [data-act="enter"], [data-act="stop"]))) .hx-sep { display: none; }
body.im-phone .hx-crew { position: fixed; left: calc(8px + var(--sa-l)); top: calc(70px + var(--sa-t)); max-width: min(42vw, 360px); padding: 4px; gap: 4px; overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; touch-action: pan-x; }
body.im-phone .hx-crewslot { width: 44px; height: 50px; scroll-snap-align: start; }
body.im-phone .hx-crewslot .hx-crewslot__img { width: 30px; height: 34px; }
body.im-phone .hx-crewall { height: 50px; width: 44px; }
/* Das Stickfeld beginnt unter der Crew-Leiste */
body.im-phone .tc-zone { top: 130px; }

/* Handy im Hochformat (wer bleibt): kleinerer Ausschnitt oben, Knöpfe darunter */
@media (orientation: portrait) {
  /* Die Buddler-Karte braucht die volle Breite, sonst bleiben neben der Ressourcen-Leiste nur ~100 px */
  body.im-phone .hx-topgrid { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who who" ". side" "mid mid"; }
  body.im-phone .hx-who { justify-self: stretch; width: auto; max-width: none; }
  body.im-phone .hx-mid { justify-self: stretch; }
  body.im-phone .hx-tut { max-width: none; }
  body.im-phone .hx-pill .hx-title { max-width: 40vw; }
  body.im-phone.tc-portrait-ok:not(.in-menu) #view { height: 60vh; height: 60dvh; }
  body.im-phone.tc-portrait-ok:not(.in-menu) { background: var(--us-bg); }
  body.im-phone.tc-portrait-ok .tc-zone { top: 60vh; top: 60dvh; width: 52%; }
  body.im-phone.tc-portrait-ok .tc-zone::before { content: ""; position: absolute; inset: 10px; border-radius: 20px; border: 1px dashed rgba(143, 182, 255, .25); }
  body.im-phone.tc-portrait-ok .hx-bottom { left: calc(8px + var(--sa-l)); right: calc(8px + var(--sa-r)); bottom: auto; top: calc(60dvh - 64px); justify-items: start; }
  body.im-phone.tc-portrait-ok .hx-crew { top: calc(60dvh + 8px); left: auto; right: calc(8px + var(--sa-r)); max-width: 44vw; }
  body.im-phone .tc-pad { transform-origin: bottom right; }
}

/* Menüs als Vollbild-Blatt mit großen Kacheln */
body.im-phone .ux-modal { padding: 0; align-items: stretch; justify-items: stretch; }
body.im-phone .ux-win { width: 100%; max-height: none; height: 100%; border-radius: 0; border: 0; animation: tc-sheet .26s var(--us-ease); }
@keyframes tc-sheet { from { transform: translateY(24px); opacity: 0; } }
body.im-phone .ux-win__head { padding: calc(8px + var(--sa-t)) calc(10px + var(--sa-r)) 8px calc(16px + var(--sa-l)); }
body.im-phone .ux-win__body { padding: 12px calc(14px + var(--sa-r)) calc(14px + var(--sa-b)) calc(14px + var(--sa-l)); }
body.im-phone .ux-win__foot { padding: 8px calc(14px + var(--sa-r)) calc(8px + var(--sa-b)) calc(14px + var(--sa-l)); }
body.im-phone .ux-win__foot .ux-hints { display: none; }
body.im-phone .ux-shop { grid-template-columns: minmax(0, 1fr) 200px; }
body.im-phone .ux-grid, body.im-phone .ux-grid.is-fixed { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
body.im-phone .ux-pause__buttons .ux-btn { min-height: 52px; }
body.im-phone .ux-win .us-setting { grid-template-columns: 130px 1fr; }
@media (orientation: portrait) {
  body.im-phone .ux-shop { grid-template-columns: minmax(0, 1fr); }
  body.im-phone .ux-win .us-setting { grid-template-columns: 1fr; }
}
@media (max-height: 500px) {
  body.im-phone .ux-end__hero { padding: 0 0 8px; }
  body.im-phone .ux-end__hero h2 { font-size: 26px; }
  body.im-phone .ux-detail { position: static; }
}

/* Hauptmenü am Handy quer: flacher Kopf, Szenarien als Leiste */
@media (max-height: 520px) {
  body.is-touch .mm-view, body .mm-view { gap: 10px; }
  .mm-hero { margin-top: 0; }
  .mm-title { font-size: clamp(28px, 7vh, 44px); }
  .mm-desc { margin-top: 8px; font-size: 14px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .mm-facts { margin-top: 10px; flex-direction: row; }
  .mm-fact { padding: 5px 10px 5px 8px; }
  .mm-actions { margin-top: 12px; }
  .mm-play { height: 50px; }
  .mm-cards { grid-auto-columns: minmax(170px, 200px); }
  .mm-card__pic { aspect-ratio: 16 / 6; }
  .mm-foot { display: none; }
}
@media (max-height: 520px) and (min-width: 700px) {
  .mm-scen { flex-direction: row; align-items: flex-end; gap: 16px; }
  .mm-hero { flex: 1 1 50%; min-width: 0; }
  .mm-cardsrow { flex: 1 1 50%; min-width: 0; overflow-y: hidden; }
  .mm-cards { grid-auto-columns: minmax(150px, 170px); }
  .mm-facts .mm-fact:nth-child(n+3) { display: none; }
}
/* Am Handy: Navigation nur mit Symbolen, keine Tastenkappen */
body.im-phone .mm-top { flex-wrap: nowrap; }
body.im-phone .mm-navbtn { padding: 0 14px; }
body.im-phone .mm-navbtn span, body.im-phone .mm-lang > .ux-ico { display: none; }
body.im-phone .mm-lang { margin-left: auto; }
@media (orientation: portrait) {
  body.im-phone .mm-top { flex-wrap: wrap; }
  body.im-phone .mm-navbtn { flex: 1; justify-content: center; }
}
body.is-touch .mm-play .ux-kbd, body.is-touch .ux-btn .ux-kbd, body.is-touch .ux-tab .ux-kbd { display: none; }

/* =============================================================================
 * Tablet
 * ============================================================================= */
body.im-tablet .hx-slot { width: 56px; height: 56px; }
body.im-tablet .hx-act { min-height: 56px; }
body.im-tablet .hx-crewslot { width: 56px; height: 64px; }
body.im-tablet .hx-crewslot .hx-crewslot__img { width: 42px; height: 47px; }
body.im-tablet .hx-crewall { height: 64px; width: 52px; }
body.im-tablet .hx-chip { min-height: 40px; }
body.im-tablet .hx-goal__head { min-height: 24px; }
body.im-tablet .hx-ava { width: 61px; height: 68px; }
/* Schwebende Aktionsleiste unten rechts, über der Crew- und Inventarzeile */
body.im-tablet .tc-pad { right: calc(16px + var(--sa-r)); bottom: calc(100px + var(--sa-b)); width: auto; height: auto; display: flex; flex-direction: row-reverse; align-items: flex-end; gap: 12px; padding: 10px 14px 8px;
  border-radius: 28px; background: rgba(11, 16, 32, .42); border: 1px solid var(--us-line); -webkit-backdrop-filter: var(--us-blur); backdrop-filter: var(--us-blur); pointer-events: auto; box-shadow: var(--us-shadow); }
body.im-tablet .tc-btn, body.im-tablet .tc-ctx { position: static; }
body.im-tablet .tc-btn__disc { width: 60px; height: 60px; }
body.im-tablet .tc-btn--dig .tc-btn__disc { width: 72px; height: 72px; }
body.im-tablet .tc-ctx { align-self: center; margin-bottom: 14px; }
body.im-tablet .tc-zone { top: 40%; bottom: calc(100px + var(--sa-b)); width: 38%; }
@media (max-width: 900px) {
  body.im-tablet .tc-pad { bottom: calc(150px + var(--sa-b)); }
}
@media (orientation: portrait) {
  body.im-tablet .tc-pad { bottom: calc(170px + var(--sa-b)); }
}
@media (max-height: 420px) {
  .mm-facts { display: none; }
  .mm-desc { -webkit-line-clamp: 2; }
  .mm-eyebrow { margin-bottom: 4px; }
  .mm-actions { margin-top: 10px; }
  .mm-view { padding-top: calc(10px + var(--sa-t)); }
}

/* Pause am Handy quer: Knöpfe in zwei Spalten, damit alles ohne Scrollen passt */
body.is-touch .ux-win .um-flag { width: auto; height: 42px; }
@media (orientation: landscape) {
  body.im-phone .ux-pause__buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.im-phone .ux-pause__buttons > :first-child { grid-column: 1 / -1; }
  body.im-phone .ux-pause { gap: 10px; }
}
body.is-touch .hx-act .ux-keys { display: none; }

/* =============================================================================
 * Echte Geräte: Fallen in iOS Safari und Android Chrome (docs/geraetetest.md)
 * ============================================================================= */
/* Kein Markieren von Text und kein Systemmenü beim langen Drücken, außer in Eingabefeldern */
body.is-touch { -webkit-user-select: none; user-select: none; }
body.is-touch :is(input, textarea, [contenteditable="true"]) { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
/* iOS zoomt beim Antippen eines Eingabefelds unter 16 px Schrift ins Bild */
body.is-touch :is(input, textarea, select) { font-size: max(16px, 1em); }
/* Bilder und Zeichenflächen nicht ziehen oder sichern */
body.is-touch :is(img, canvas) { -webkit-user-drag: none; -webkit-touch-callout: none; }
/* Rollbare Bereiche: Schwung behalten, aber nicht die ganze Seite mitziehen */
body.is-touch :is(.mm-view, .mm-panelwrap, .ux-win__body, .mm-cardsrow) { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* Hover bleibt am Touch-Gerät nach dem Tippen „kleben“: Anheben nur mit echtem Hover */
@media (hover: none) {
  .mm-card:hover:not(.is-selected) { transform: none; border-color: var(--us-line); }
  .mm-play:hover { transform: none; box-shadow: var(--us-glow-gold); }
  .mm-navbtn:hover:not(.is-on), .um-flag:hover:not(.is-active), .us-choice__btn:hover:not(.is-active) { background: none; color: var(--us-text-2); }
}

/* Rundenende und Spielstände am Handy: alles im Blatt erreichbar */
body.im-phone .ux-win__body { min-height: 0; overflow-y: auto; }
@media (max-height: 420px) {
  body.im-phone .ux-win__head { padding-top: calc(4px + var(--sa-t)); padding-bottom: 4px; }
  body.im-phone .ux-win__foot { padding-top: 6px; padding-bottom: calc(6px + var(--sa-b)); }
}
/* Sehr schmale Handys (iPhone SE quer: 667×375, hoch: 375 breit) */
@media (max-width: 380px) {
  body.im-phone .hx-who { width: 150px; }
  /* Hochkant hat die Karte eine eigene Zeile über die ganze Breite */
  body.im-phone .hx-topgrid > .hx-who { width: auto; }
  body.im-phone .hx-goal { max-width: 38vw; }
}
@media (max-width: 700px) and (orientation: landscape), (max-height: 380px) {
  body.im-phone .hx-bottom { left: calc(196px + var(--sa-l)); right: calc(214px + var(--sa-r)); }
  body.im-phone .tc-pad { transform: scale(.9); transform-origin: bottom right; }
}

/* Bewegung reduzieren: keine Wackel- und Einblendeffekte der Touch-Ebene */
@media (prefers-reduced-motion: reduce) {
  .tc-ctx.is-new, .tc-rotate__card svg, body.im-phone .ux-win { animation: none; }
  .tc-ping { animation-duration: .01s; }
  .tc-btn__disc, .tc-ctx { transition: none; }
}

/* ---- Geräte-Info (ui/debug-overlay.js) -------------------------------------------------- */
.dbg { position: fixed; z-index: 9999; left: calc(8px + var(--sa-l)); top: calc(8px + var(--sa-t)); width: min(440px, calc(100% - 16px - var(--sa-l) - var(--sa-r)));
  max-height: calc(100% - 16px - var(--sa-t) - var(--sa-b)); display: flex; flex-direction: column; box-sizing: border-box; padding: 10px 12px; gap: 6px;
  border-radius: 14px; background: rgba(5, 8, 20, .92); border: 1px solid rgba(143, 182, 255, .4); color: #EEF2FF; box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  font: 500 12px/1.35 ui-monospace, Menlo, monospace; pointer-events: auto; touch-action: pan-y; -webkit-user-select: text; user-select: text; }
.dbg__head { display: flex; align-items: center; gap: 10px; font: 700 14px/1 var(--us-font); }
.dbg__hint { flex: 1; font: 500 11px/1 var(--us-font); color: rgba(238, 242, 255, .55); }
.dbg__info { display: grid; gap: 2px; overflow-y: auto; min-height: 0; flex: 0 1 auto; }
.dbg__row { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; }
.dbg__k { color: #8FB6FF; }
.dbg__v { overflow-wrap: anywhere; }
.dbg__eh { margin-top: 4px; font: 700 12px/1 var(--us-font); color: #FFC23D; }
.dbg__count:not(:empty) { margin-left: 4px; padding: 1px 6px; border-radius: 99px; background: #E5484D; color: #fff; }
.dbg__errs { margin: 0; max-height: 30vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; color: #FFB4B4; flex: 0 1 auto; }
.dbg__errs.is-none { color: rgba(238, 242, 255, .5); }
.dbg__raw { width: 100%; height: 90px; font: 11px/1.3 ui-monospace, Menlo, monospace; font-size: 16px; background: #0B1020; color: #EEF2FF; border: 1px solid rgba(255, 255, 255, .2); border-radius: 8px; }
.dbg__foot { display: flex; flex-wrap: wrap; gap: 6px; }
.dbg__btn { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .08); color: inherit; font: 650 13px/1 var(--us-font); cursor: pointer; }
.dbg__btn--main { background: #3D7BFF; border-color: #3D7BFF; color: #fff; flex: 1; }
.dbg__close { min-width: 44px; padding: 0; }

/* Kontextmenü (ui/contextmenu.js) am Finger: große Einträge, keine Tastenziffern */
body.is-touch .cm-menu { min-width: min(260px, calc(100vw - 16px)); max-height: calc(100% - 16px - var(--sa-t) - var(--sa-b)); overflow-y: auto; overscroll-behavior: contain; }
body.is-touch .cm-item { min-height: var(--tc-hit); padding-block: 6px; font-size: 15px; }
body.is-touch .cm-ico { width: 32px; height: 32px; }
body.is-touch .cm-ico canvas { width: 24px !important; height: 24px !important; }
body.is-touch .cm-key, body.is-touch .cm-foot { display: none; }

/* Baumenü und Laden am Handy quer (Höhe ≤ 500 px): Detailspalte bleibt stehen, Bild klein,
   der Bauen-/Kaufen-Knopf ist ohne Scrollen sichtbar */
@media (max-height: 500px) {
  body.im-phone .ux-shop { align-items: start; }
  body.im-phone .ux-shop .ux-detail { position: sticky; top: 0; align-self: start; box-sizing: border-box; gap: 6px; padding: 10px 12px;
    max-height: calc(100dvh - 116px - var(--sa-t) - var(--sa-b)); overflow-y: auto; overscroll-behavior: contain; }
  body.im-phone .ux-detail__pic { height: 52px; min-height: 0; padding: 0; margin: 0; }
  body.im-phone .ux-detail__pic canvas { max-height: 44px; width: auto; }
  body.im-phone .ux-detail h3 { margin: 0; }
  body.im-phone .ux-detail p { margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  body.im-phone .ux-detail > .ux-btn { position: sticky; bottom: 0; flex: none; }
}
