/* Giao diện gọn cho điện thoại / máy tính bảng (body.touch). Nạp sau cùng; máy tính không bị ảnh hưởng.
   - Khung nhân vật nhỏ (chạm chân dung để thu gọn thêm), đồng hồ + bản đồ nhỏ thu nhỏ ở góc phải.
   - Thanh menu chỉ giữ Túi đồ, Gọi xe, Bản đồ và nút ☰ mở bảng đầy đủ (nút nhỏ, không chữ; máy tính xem illustrated.css).
   - Cần điều khiển, nút E nhỏ lại; gợi ý tương tác nằm gọn phía trên cụm nút bên phải. */

/* ---- Khung nhân vật ---- */
body.touch #hud-stats { top: calc(6px + env(safe-area-inset-top)); left: calc(6px + env(safe-area-inset-left)); width: 152px; padding: 6px 7px; border-radius: 10px; transform: none; }
body.touch .hud-top { min-height: 30px; padding-left: 35px; gap: 0 4px; grid-template-columns: 1fr auto; cursor: pointer; }
body.touch .citizen-portrait { width: 50px; height: 50px; transform: scale(.6); transform-origin: top left; }
body.touch .citizen-label { display: none; }
body.touch #hud-name { font-size: 12.5px; }
body.touch #hud-level { position: static; font-size: 8px; padding: 1px 4px; }
body.touch .bar.xp { height: 5px; margin: 4px 0 3px; }
body.touch .bar.xp > span { display: none; }
body.touch .hud-money { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 6px; margin: 3px 0; padding: 3px 0; font-size: 9px; }
body.touch .hud-money b { font-size: 10.5px; }
body.touch .energy-row { margin: 2px 0; gap: 4px; }
body.touch .energy-row > span { width: 12px; font-size: 9px; }
body.touch .energy-row .bar { height: 8px; }
body.touch .bar.energy > span, body.touch .bar.need > span { font-size: 6.5px; line-height: 7px; }
body.touch #hud-stats .hud-wc, body.touch #hud-stats .hud-tax, body.touch #hud-housing, body.touch #room-exit { margin-top: 3px; padding: 3px 6px; font-size: 9px; line-height: 1.3; border-radius: 7px; }
body.touch #hud-stats.mini .bar.xp, body.touch #hud-stats.mini .hud-money, body.touch #hud-stats.mini #hud-housing { display: none; }
body.touch #hud-stats.mini { width: 132px; }

/* ---- Đồng hồ & bản đồ nhỏ ---- */
body.touch #hud-clock { top: calc(6px + env(safe-area-inset-top)); right: calc(6px + env(safe-area-inset-right)); left: auto; transform: none; padding: 3px 4px 3px 9px; gap: 4px; border-radius: 999px; }
body.touch #clock-time { font-size: 13px; }
body.touch #clock-day { display: none; }
body.touch #hud-clock .weather-pill { padding: 2px 4px; gap: 2px; }
body.touch #hud-clock .weather-pill b { display: none; }
body.touch #weather-icon { width: 16px; font-size: 13px; }
body.touch #map-wrap { top: calc(36px + env(safe-area-inset-top)); right: calc(6px + env(safe-area-inset-right)); padding: 3px; border-radius: 9px; }
body.touch #minimap { width: 92px !important; border-radius: 6px; }
body.touch .hud-toggle { top: 5px; left: 5px; width: 18px; height: 18px; font-size: 9px; border-radius: 5px; }
body.touch #map-wrap.collapsed .hud-toggle { width: 28px; height: 28px; font-size: 13px; }
body.touch #quest { top: calc(140px + env(safe-area-inset-top)); right: 6px; width: 132px; padding: 7px; }
@media (max-width: 900px), (max-height: 520px) { body.touch #quest { display: none; } }

/* ---- Thanh menu gọn + bảng ☰ ---- */
body.touch #menu { left: 50%; transform: translateX(-50%); bottom: calc(6px + env(safe-area-inset-bottom)); width: auto; max-width: none; overflow: visible; gap: 5px; padding: 0; justify-content: center; }
body.touch #menu button, body.touch #menu button:nth-child(n) { display: none; flex: none; width: 42px; min-width: 0; height: 42px; padding: 0; font-size: 19px; border-radius: 10px; }
body.touch #menu button.m-main, body.touch #menu #menu-more { display: grid; place-items: center; }
body.touch #menu button span, body.touch #menu kbd { display: none; }
body.touch #menu-more { font-size: 20px; color: #f1dfb6; }
body.touch.menu-open #menu { display: grid; grid-template-columns: repeat(4, 62px); gap: 6px; padding: 8px; bottom: calc(6px + env(safe-area-inset-bottom)); z-index: 30;
  background: linear-gradient(145deg, #514533f8, #302b22f8); border: 2px solid #3a3024; outline: 1px solid #a78d5d90; border-radius: 14px; box-shadow: 0 8px 24px #1a150f66; }
body.touch.menu-open #menu button, body.touch.menu-open #menu button:nth-child(n) { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px; width: 62px; height: 54px; font-size: 20px; }
body.touch.menu-open #menu button span { display: block; font-size: 8.5px; line-height: 1.1; }
body.touch.menu-open #menu #menu-more { background: linear-gradient(#d9aa60, #b5803f); color: #3a2a17; }

/* ---- Cần điều khiển & nút ---- */
body.touch .tc-stick { left: calc(10px + env(safe-area-inset-left)); bottom: calc(58px + env(safe-area-inset-bottom)); width: 112px; height: 112px; }
body.touch .tc-knob { width: 46px; height: 46px; margin: -23px 0 0 -23px; }
body.touch .tc-buttons { right: calc(8px + env(safe-area-inset-right)); bottom: calc(56px + env(safe-area-inset-bottom)); gap: 7px; grid-template-columns: auto auto auto; grid-template-areas: "chat run act" "full brake act"; }
body.touch .tc-small { width: 38px; height: 38px; font-size: 15px; }
body.touch .tc-btn:not(.tc-small):not(.tc-act) { width: 48px; height: 48px; font-size: 18px; }
body.touch .tc-btn span { margin-top: -8px; font-size: 8px; }
body.touch .tc-act { width: 66px; height: 66px; font-size: 26px; }
body.touch .tc-act span { display: none; }

/* Gợi ý tương tác: một dòng gọn phía trên cụm nút bên phải (nút E chỉ còn chữ E). */
body.touch #prompt { left: auto; right: calc(8px + env(safe-area-inset-right)); transform: none; bottom: calc(166px + env(safe-area-inset-bottom)); max-width: min(250px, 64vw); padding: 4px 10px 4px 4px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch #toasts { top: auto; bottom: calc(196px + env(safe-area-inset-bottom)); }
body.touch .fishing-hud { bottom: calc(196px + env(safe-area-inset-bottom)); }
body.touch #drive-hud { top: calc(118px + env(safe-area-inset-top)); left: calc(6px + env(safe-area-inset-left)); width: 168px; padding: 7px 9px; font-size: 11px; transform: none; }
body.touch #dialog { bottom: calc(56px + env(safe-area-inset-bottom)); }

/* Màn ngang: mọi thứ sát mép dưới, thông báo lên giữa phía trên. */
@media (orientation: landscape) {
  body.touch .tc-stick { bottom: calc(14px + env(safe-area-inset-bottom)); }
  body.touch .tc-buttons { bottom: calc(12px + env(safe-area-inset-bottom)); }
  body.touch #prompt { bottom: calc(124px + env(safe-area-inset-bottom)); }
  body.touch #toasts { top: calc(8px + env(safe-area-inset-top)); bottom: auto; }
  body.touch .fishing-hud { bottom: calc(70px + env(safe-area-inset-bottom)); }
  body.touch #dialog { bottom: calc(10px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 20px); }
}

/* Dòng cảnh báo trong khung nhân vật: mỗi dòng một hàng, dài thì cắt "…" (chạm để xem chi tiết). */
body.touch #hud-stats .hud-wc, body.touch #hud-stats .hud-tax, body.touch #hud-housing, body.touch #room-exit { display: block; width: 100%; box-sizing: border-box; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
body.touch #hud-stats .hidden { display: none !important; }
/* Thông báo & tiêu đề chào mừng nhỏ lại */
body.touch .toast { max-width: min(340px, 86vw); padding: 6px 11px; font-size: 11.5px; border-radius: 9px; }
body.touch .banner { top: 30%; width: max-content; max-width: 78vw; padding: 10px 18px; border-radius: 16px; }
body.touch .banner-title { font-size: 22px; }
body.touch .banner-sub { font-size: 11.5px; margin-top: 3px; }
