/* ========== 洪荒世界 Mobile UI — 修仙暗色主题 ========== */

/* --- Foundation --- */
@media (max-width: 900px) {
  :root {
    --safe-bottom: max(env(safe-area-inset-bottom), 8px);
    --mx-card-bg: linear-gradient(180deg, rgba(22,28,45,0.92) 0%, rgba(14,18,31,0.95) 100%);
    --mx-border: rgba(80,110,170,0.12);
    --mx-glow-gold: rgba(255,215,0,0.08);
    --mx-chip-res: #4ade80;
    --mx-chip-mon: #c084fc;
    --mx-chip-npc: #38bdf8;
  }

  body { overflow: hidden; font-size: 13px; }

  #app, #game-screen { height: 100dvh; }

  /* --- Top bar --- */
  .top-info {
    padding: 5px 10px;
    position: sticky; top: 0; z-index: 70;
    background: linear-gradient(180deg, rgba(18,22,36,0.97) 0%, rgba(12,16,28,0.92) 100%);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--mx-border);
  }
  .top-info .loc-text { font-size: 13px; font-weight: 600; }
  .top-info .loc-coord { font-size: 10px; color: #64748b; }
  .top-info .time-line { font-size: 10px; color: #64748b; }

  /* --- Status row --- */
  .status-row {
    padding: 4px 8px; gap: 5px;
    position: sticky; top: 34px; z-index: 69;
    background: linear-gradient(180deg, rgba(13,20,36,0.94) 0%, rgba(10,15,28,0.9) 100%);
    border-bottom: 1px solid var(--mx-border);
  }

  /* --- Main area grid --- */
  .main-area, body.force-mobile .main-area {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 6px; padding: 6px;
    overflow: hidden; min-height: 0;
  }

  /* --- Hide desktop-only elements --- */
  .left-col, body.force-mobile .left-col { display: none !important; }
  .map-panel, body.force-mobile .map-panel,
  .world-map-container, body.force-mobile .world-map-container,
  .dir-pad, body.force-mobile .dir-pad,
  .func-bar, body.force-mobile .func-bar { display: none !important; }

  /* 隐藏资源/怪物/NPC复选框按钮，保留列表内容 */
  .res-header, body.force-mobile .res-header { display: none !important; }

  /* --- Right column --- */
  .right-col {
    flex: 1; min-height: 0; overflow: hidden;
    display: grid !important;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 5px;
  }

  /* --- Minimap (horizontal terrain lens) --- */
  .mini-map {
    background: var(--mx-card-bg);
    border: 1px solid var(--mx-border);
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    max-height: none !important;
    display: flex !important;
    flex-direction: row !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.02);
    order: 0;
  }
  .mm-grid {
    display: grid; grid-template-columns: repeat(3, 30px);
    gap: 2px; padding: 6px;
    cursor: pointer; flex-shrink: 0;
  }
  .mm-cell {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    font-size: 14px; border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.04);
    transition: transform .1s;
    position: relative;
  }
  .mm-cell.mm-center {
    border: 1.5px solid rgba(251,191,36,0.5);
    background: rgba(251,191,36,0.12) !important;
  }
  .mm-cell.mm-center::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #fbbf24;
    box-shadow: 0 0 6px 2px rgba(251,191,36,0.4);
  }
  .mm-cell.mm-center::after {
    content: ''; position: absolute; inset: -3px;
    border-radius: 7px; border: 1px solid rgba(251,191,36,0.15);
    animation: mm-glow 2.4s ease-in-out infinite;
    pointer-events: none;
  }
  @keyframes mm-glow {
    0%, 100% { opacity: .2; transform: scale(1); }
    50% { opacity: .7; transform: scale(1.06); }
  }
  .mm-grid:active .mm-cell { transform: scale(0.95); }
  .mm-side {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; justify-content: center;
    gap: 3px; padding: 6px 10px;
    border-left: 1px solid var(--mx-border);
    background: linear-gradient(135deg, rgba(251,191,36,0.03), transparent);
  }
  .mm-terrain-label {
    font-size: 13px; font-weight: 700; color: #fbbf24;
    text-shadow: 0 0 8px rgba(251,191,36,0.15);
  }
  .mm-coord {
    font-size: 10px; color: #475569; font-variant-numeric: tabular-nums;
  }
  .mm-expand {
    font-size: 10px; color: rgba(255,255,255,0.25);
    margin-top: 2px;
  }
  /* Layout order: minimap → msg-box → res-box */
  .msg-box { order: 1; }
  .res-box { order: 2; }

  /* --- Message box --- */
  .msg-box {
    min-height: 0; min-height: 150px; display: flex; flex-direction: column;
    background: var(--mx-card-bg);
    border: 1px solid var(--mx-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  }
  .msg-header {
    padding: 4px 8px;
    background: linear-gradient(135deg, rgba(251,191,36,0.04), transparent);
    border-bottom: 1px solid rgba(255,215,0,0.06);
  }
  .msg-content {
    min-height: 40px; max-height: 90px;
    font-size: 11px; line-height: 1.5;
    overflow-y: hidden;
    padding: 6px 8px;
    color: #94a3b8;
  }
  .msg-content .msg-line { padding: 1px 0; }

  /* ===================== */
  /* === RESOURCE PANEL === */
  /* ===================== */
  .res-box {
    background: var(--mx-card-bg);
    border: 1px solid var(--mx-border);
    border-radius: 10px;
    padding: 0;
    max-height: 180px;
    overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    order: 2;
  }

  /* Content lists */
  .res-list {
    min-height: 0;
    padding: 6px 8px;
    gap: 4px;
    max-height: 140px;
    overflow: hidden;
    display: flex; flex-wrap: wrap;
    flex: none;
    font-size: 11px;
  }
  .res-list.hidden { display: none; }

  /* Resource tags — refined pills */
  .res-tag {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 4px 8px;
    font-size: 11px;
    background: rgba(74,222,128,0.06);
    border: 1px solid rgba(74,222,128,0.12);
    border-radius: 6px;
    color: #86efac;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
  }
  .res-tag:hover {
    background: rgba(74,222,128,0.12);
    border-color: rgba(74,222,128,0.25);
    color: #bbf7d0;
  }
  .res-tag:active {
    transform: scale(0.96);
  }

  /* Monster tags — purple variant */
  .monster-tag, .monster-item {
    background: rgba(192,132,252,0.06) !important;
    border: 1px solid rgba(192,132,252,0.12) !important;
    border-radius: 6px !important;
    color: #d8b4fe !important;
    font-size: 11px !important;
    padding: 4px 8px !important;
  }
  .monster-tag:hover, .monster-item:hover {
    background: rgba(192,132,252,0.12) !important;
    border-color: rgba(192,132,252,0.25) !important;
  }
  .monster-item .m-name {
    color: #d8b4fe !important;
    font-weight: 600 !important;
  }

  /* NPC tags — blue variant */
  .npc-tag, #npc-list .res-tag {
    background: rgba(56,189,248,0.06);
    border: 1px solid rgba(56,189,248,0.12);
    border-radius: 6px;
    color: #7dd3fc;
    padding: 4px 8px;
  }
  #npc-list .res-tag:hover, .npc-tag:hover {
    background: rgba(56,189,248,0.12);
    border-color: rgba(56,189,248,0.25);
    color: #bae6fd;
  }

  /* Monster level info line */
  .monster-level-info {
    font-size: 10px;
    color: #64748b;
    padding: 2px 0;
    width: 100%;
  }

  /* --- Bottom navigation --- */
  .bot-nav, .bot-nav.enhanced,
  body.force-mobile .bot-nav, body.force-mobile .bot-nav.enhanced {
    position: sticky; bottom: 0; z-index: 60;
    padding: 6px 8px calc(6px + var(--safe-bottom));
    gap: 5px;
    background: linear-gradient(180deg, rgba(14,19,31,0.96) 0%, rgba(10,14,24,0.98) 100%);
    backdrop-filter: blur(6px);
    border-top: 1px solid var(--mx-border);
  }
  .nav-b {
    min-height: 50px; padding: 6px 4px; border-radius: 10px;
  }
  .nav-b .nav-icon { font-size: 18px; }
  .nav-b .nav-label { font-size: 10px; }

  /* --- Modals --- */
  .modal-box {
    width: 96%; max-height: calc(100dvh - 16px);
    background: linear-gradient(180deg, #181d30 0%, #111525 100%) !important;
    border: 1px solid rgba(255,215,0,0.08) !important;
    border-radius: 14px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,215,0,0.04) !important;
  }
  .modal-overlay {
    background: rgba(5,8,18,0.82) !important;
    backdrop-filter: blur(8px) !important;
  }
  .modal, body.force-mobile .modal {
    align-items: flex-end; justify-content: center; padding: 0;
  }

  /* 奇遇/剧情弹窗 — 居中显示 */
  #event-modal,
  #story-modal,
  body.force-mobile #event-modal,
  body.force-mobile #story-modal {
    align-items: center !important;
    padding: 24px 16px !important;
  }
  #event-modal .modal-content,
  #story-modal .modal-content,
  body.force-mobile #event-modal .modal-content,
  body.force-mobile #story-modal .modal-content {
    width: 88vw !important;
    max-width: 400px !important;
    max-height: 70vh !important;
    margin: auto !important;
    border-radius: 14px !important;
    background: linear-gradient(180deg, #181d30 0%, #111525 100%) !important;
    border: 1px solid rgba(255,215,0,0.08) !important;
    box-shadow: 0 16px 48px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,215,0,0.06) !important;
    animation: popIn .25s ease !important;
  }

  /* 系统菜单 + 二级弹窗 — 居中悬浮卡片 */
  #system-modal,
  #codex-modal,
  #cultivation-modal,
  #realm-modal,
  #dongfu-modal,
  #monster-info-modal,
  #encounter-modal,
  #creature-dispatch-modal,
  #creature-equipment-modal,
  #creature-fusion-modal,
  body.force-mobile #system-modal,
  body.force-mobile #codex-modal,
  body.force-mobile #cultivation-modal,
  body.force-mobile #realm-modal,
  body.force-mobile #dongfu-modal,
  body.force-mobile #monster-info-modal,
  body.force-mobile #encounter-modal,
  body.force-mobile #creature-dispatch-modal,
  body.force-mobile #creature-equipment-modal,
  body.force-mobile #creature-fusion-modal {
    align-items: center !important;
    padding: 24px 16px !important;
  }
  #system-modal .modal-box,
  #codex-modal .modal-box,
  #cultivation-modal .modal-box,
  #realm-modal .modal-box,
  #dongfu-modal .modal-box,
  #monster-info-modal .modal-box,
  #encounter-modal .modal-box,
  #creature-dispatch-modal .modal-box,
  #creature-equipment-modal .modal-box,
  #creature-fusion-modal .modal-box,
  body.force-mobile #system-modal .modal-box,
  body.force-mobile #codex-modal .modal-box,
  body.force-mobile #cultivation-modal .modal-box,
  body.force-mobile #realm-modal .modal-box,
  body.force-mobile #dongfu-modal .modal-box,
  body.force-mobile #monster-info-modal .modal-box,
  body.force-mobile #encounter-modal .modal-box,
  body.force-mobile #creature-dispatch-modal .modal-box,
  body.force-mobile #creature-equipment-modal .modal-box,
  body.force-mobile #creature-fusion-modal .modal-box {
    width: 88vw !important;
    max-width: 360px !important;
    max-height: 70vh !important;
    margin: auto !important;
    border-radius: 18px !important;
    box-shadow: 0 16px 48px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,215,0,0.06) !important;
    animation: popIn .25s ease !important;
  }
  @keyframes popIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
  }
  .m-head {
    background: linear-gradient(135deg, rgba(251,191,36,0.08), rgba(251,191,36,0.02)) !important;
    border-bottom: 1px solid rgba(255,215,0,0.1) !important;
    border-radius: 14px 14px 0 0 !important;
    padding: 10px 14px !important;
    font-size: 15px !important;
    color: #fbbf24 !important;
    letter-spacing: 1px;
  }
  .m-close {
    width: 36px !important; height: 36px !important;
    font-size: 18px !important;
    border-radius: 50% !important;
    background: rgba(248,113,113,0.1) !important;
    border: 1px solid rgba(248,113,113,0.2) !important;
    color: #f87171 !important;
    transition: all .15s !important;
  }
  .m-close:active { transform: scale(0.9); background: rgba(248,113,113,0.2) !important; }
  .m-body, body.force-mobile .m-body {
    padding-bottom: calc(10px + max(env(safe-area-inset-bottom), 8px));
    max-height: calc(85dvh - 52px) !important;
  }
  .m-body { padding: 10px 12px; font-size: 13px; }
  .m-grid, body.force-mobile .m-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .skill-list.active, body.force-mobile .skill-list.active {
    grid-template-columns: 1fr;
  }

  /* System menu — floating module cards */
  .sys-menu, body.force-mobile .sys-menu {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px !important;
    padding: 6px 4px !important;
  }
  .sys-btn {
    padding: 16px 4px 12px !important;
    font-size: 11px !important;
    background: linear-gradient(145deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    border-radius: 14px !important;
    color: #94a3b8 !important;
    transition: all .2s cubic-bezier(.4,0,.2,1) !important;
    display: flex !important; flex-direction: column !important;
    align-items: center !important; justify-content: center !important;
    gap: 6px !important;
    min-height: 72px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.04) !important;
  }
  .sys-btn span:first-child {
    font-size: 26px !important;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)) !important;
    transition: transform .2s ease !important;
  }
  .sys-btn:hover, .sys-btn:active {
    background: linear-gradient(145deg, rgba(251,191,36,0.08) 0%, rgba(251,191,36,0.03) 100%) !important;
    border-color: rgba(251,191,36,0.2) !important;
    color: #fbbf24 !important;
    transform: translateY(-3px) scale(1.02) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35), 0 0 16px rgba(251,191,36,0.08), inset 0 1px 0 rgba(255,255,255,0.06) !important;
  }
  .sys-btn:active {
    transform: translateY(-1px) scale(0.98) !important;
  }
  .sys-btn:active span:first-child,
  .sys-btn:hover span:first-child {
    transform: scale(1.1) !important;
  }
  .sys-btn[style*="ff4444"], .sys-btn[style*="#ff4444"] {
    color: #f87171 !important;
    border-color: rgba(248,113,113,0.12) !important;
  }
  .sys-btn[style*="ff4444"]:hover, .sys-btn[style*="#ff4444"]:hover {
    background: linear-gradient(145deg, rgba(248,113,113,0.08) 0%, rgba(248,113,113,0.03) 100%) !important;
    border-color: rgba(248,113,113,0.25) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35), 0 0 16px rgba(248,113,113,0.08) !important;
  }

  /* Skill / Cultivation tabs — game-style segmented */
  .skill-tabs, .codex-tabs, .cultivation-tabs {
    gap: 4px !important;
    margin-bottom: 10px !important;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    padding: 3px;
  }
  .skill-tab, .codex-tab, .cultivation-tab {
    flex: 1; flex-shrink: 0 !important;
    padding: 8px 10px !important;
    font-size: 12px !important;
    border-radius: 8px !important;
    min-height: 36px !important;
    background: transparent !important;
    border: none !important;
    color: #64748b !important;
    transition: all .15s !important;
  }
  .skill-tab.active, .codex-tab.active, .cultivation-tab.active {
    background: rgba(251,191,36,0.1) !important;
    color: #fbbf24 !important;
    box-shadow: 0 0 8px rgba(251,191,36,0.08);
  }

  /* Crafting recipe cards */
  .recipe-item, .recipe-card {
    background: rgba(255,255,255,0.02) !important;
    border: 1px solid rgba(255,255,255,0.05) !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
    margin-bottom: 6px !important;
    transition: all .15s !important;
  }
  .recipe-item:active, .recipe-card:active {
    background: rgba(251,191,36,0.06) !important;
    border-color: rgba(255,215,0,0.12) !important;
  }

  /* Cultivation action buttons */
  .cult-btn {
    border-radius: 10px !important;
    font-size: 13px !important;
    padding: 10px 16px !important;
  }

  /* Dongfu modal — wider on mobile */
  #dongfu-modal .modal-box {
    max-width: none !important; width: 96vw !important;
  }

  /* Inventory V3 panel — compact mobile layout */
  #inventory-panel { padding: 0 !important; }
  #inventory-panel .inv-v3-container {
    background: linear-gradient(180deg, #181d30 0%, #111525 100%) !important;
    border: none !important;
    border-radius: 0 !important;
    width: 100vw !important; max-width: none !important;
    max-height: 100dvh !important;
    height: 100dvh !important;
  }
  #inventory-panel .inv-v3-header {
    background: linear-gradient(135deg, rgba(251,191,36,0.08), rgba(251,191,36,0.02)) !important;
    border-bottom: 1px solid rgba(255,215,0,0.1) !important;
    border-radius: 0 !important;
    color: #fbbf24 !important;
    padding: 8px 12px !important;
    flex-shrink: 0;
  }
  #inventory-panel .inv-v3-close {
    background: rgba(248,113,113,0.1) !important;
    border: 1px solid rgba(248,113,113,0.2) !important;
    color: #f87171 !important;
    border-radius: 50% !important;
  }
  #inventory-panel .inv-v3-main {
    flex-direction: column !important;
    overflow: hidden !important;
  }
  /* Left panel: compact, no scroll */
  #inventory-panel .inv-v3-left {
    width: 100% !important;
    max-height: 360px !important;
    overflow: hidden !important;
    padding: 6px 10px !important;
    background: rgba(0,0,0,0.15) !important;
    border-right: none !important;
    border-bottom: 1px solid rgba(255,255,255,0.04) !important;
  }
  /* Avatar card: hidden on mobile (shown in main UI) */
  #inventory-panel .inv-v3-avatar-card { display: none !important; }
  /* Sections: compact inline */
  #inventory-panel .inv-v3-section {
    padding: 4px 0 !important;
    margin-bottom: 2px !important;
  }
  #inventory-panel .inv-v3-section-title {
    font-size: 10px !important;
    padding: 2px 0 !important;
    margin-bottom: 2px !important;
  }
  #inventory-panel .inv-v3-attr-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 2px !important;
    font-size: 10px !important;
  }
  #inventory-panel .inv-v3-attr-grid .attr-item,
  #inventory-panel .inv-v3-attr-grid > div {
    padding: 2px 4px !important;
    font-size: 9px !important;
    line-height: 1.2 !important;
  }
  /* Equipment grid: compact */
  #inventory-panel .inv-v3-equip-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 3px !important;
  }
  #inventory-panel .inv-v3-equip-grid > div,
  #inventory-panel .inv-v3-equip-grid .equip-slot {
    padding: 3px 4px !important;
    font-size: 9px !important;
    min-height: 32px !important;
    border-radius: 6px !important;
  }
  /* Life skills section visible */
  /* Artifacts: compact */
  #inventory-panel .inv-v3-section:nth-child(4) .inv-v3-equip-grid,
  #inventory-panel .inv-v3-section:nth-child(4) [class*="grid"] {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 3px !important;
  }
  #inventory-panel .inv-v3-section:nth-child(4) > div:last-child > div {
    padding: 2px 4px !important;
    font-size: 9px !important;
    min-height: 28px !important;
  }
  /* Right panel: items take remaining space */
  #inventory-panel .inv-v3-right {
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 6px 10px !important;
  }
  #inventory-panel .inv-v3-cats {
    gap: 3px !important;
    margin-bottom: 6px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
  }
  #inventory-panel .inv-v3-cat {
    padding: 5px 8px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
  #inventory-panel .inv-v3-items {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)) !important;
    gap: 4px !important;
    overflow: hidden !important;
  }
  /* Footer: compact */
  #inventory-panel .inv-v3-footer {
    padding: 8px 10px !important;
    gap: 6px !important;
    flex-shrink: 0;
  }
  #inventory-panel .inv-v3-footer-btn {
    padding: 10px !important;
    font-size: 12px !important;
    border-radius: 8px !important;
  }

  /* =============================== */
  /* === CRAFTING PANEL (#crafting-panel) === */
  /* =============================== */
  #crafting-panel {
    padding: 0 !important;
  }
  #crafting-panel .crafting-container {
    width: 100vw !important; max-width: none !important;
    height: 100dvh !important; max-height: 100dvh !important;
    border-radius: 0 !important;
  }
  #crafting-panel .crafting-header {
    padding: 8px 12px !important;
    background: linear-gradient(135deg, rgba(251,191,36,0.08), rgba(251,191,36,0.02)) !important;
    border-bottom: 1px solid rgba(255,215,0,0.1) !important;
    flex-shrink: 0;
  }
  #crafting-panel .crafting-title {
    font-size: 16px !important;
  }
  #crafting-panel .crafting-close {
    width: 34px !important; height: 34px !important;
    font-size: 16px !important;
    background: rgba(248,113,113,0.1) !important;
    border: 1px solid rgba(248,113,113,0.2) !important;
    color: #f87171 !important;
  }
  /* Stack sidebar + detail vertically */
  #crafting-panel .crafting-main {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 8px 10px !important;
    overflow: hidden !important;
  }
  /* Sidebar: full width, compact, capped height */
  #crafting-panel .crafting-sidebar {
    width: 100% !important;
    flex-direction: column !important;
    gap: 4px !important;
    flex-shrink: 0;
    max-height: 220px !important;
    overflow: hidden !important;
  }
  /* Hide empty workstation section on mobile */
  #crafting-panel .workstation-select {
    display: none !important;
  }
  #crafting-panel .recipe-select {
    min-width: 0;
    overflow: hidden !important;
  }
  #crafting-panel .workstation-title,
  #crafting-panel .recipe-title {
    font-size: 11px !important;
    margin-bottom: 3px !important;
    color: #fbbf24 !important;
  }
  /* Lists: compact items, clip overflow */
  #crafting-panel .workstation-list,
  #crafting-panel .recipe-list {
    max-height: 180px !important;
    overflow: hidden !important;
    gap: 2px !important;
  }
  #crafting-panel .workstation-item,
  #crafting-panel .recipe-item {
    padding: 4px 7px !important;
    border-radius: 5px !important;
    border-width: 1px !important;
  }
  #crafting-panel .workstation-name,
  #crafting-panel .recipe-name {
    font-size: 11px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  /* Hide difficulty text to save space */
  #crafting-panel .workstation-level,
  #crafting-panel .recipe-difficulty {
    display: none !important;
  }
  #crafting-panel .workstation-item.active,
  #crafting-panel .recipe-item.active {
    background: rgba(251,191,36,0.12) !important;
    border-color: rgba(251,191,36,0.4) !important;
  }
  /* Hide search input on mobile — too few recipes to warrant it */
  #craft-search {
    display: none !important;
  }
  /* Upgrade workstation button */
  #upgrade-workstation {
    margin-top: 4px !important;
    padding: 5px 8px !important;
    font-size: 10px !important;
  }
  /* Detail panel: compact, no scroll */
  #crafting-panel .crafting-detail {
    flex: 1 !important;
    min-height: 0 !important;
    gap: 4px !important;
    overflow: hidden !important;
    max-height: 280px !important;
  }
  #crafting-panel .recipe-detail {
    flex: 1 !important;
    padding: 8px 10px !important;
    overflow: hidden !important;
    border-radius: 8px !important;
  }
  #crafting-panel .detail-placeholder {
    padding: 16px !important;
    font-size: 13px !important;
  }
  #crafting-panel .detail-name {
    font-size: 15px !important;
    margin-bottom: 6px !important;
  }
  #crafting-panel .detail-section {
    margin-bottom: 6px !important;
  }
  #crafting-panel .detail-section-title {
    font-size: 11px !important;
    margin-bottom: 3px !important;
  }
  #crafting-panel .material-item {
    padding: 4px 8px !important;
    margin-bottom: 2px !important;
    border-radius: 5px !important;
  }
  #crafting-panel .material-name {
    font-size: 11px !important;
  }
  #crafting-panel .material-count {
    font-size: 11px !important;
  }
  #crafting-panel .material-status {
    font-size: 10px !important;
  }
  #crafting-panel .stat-row {
    padding: 3px 0 !important;
  }
  #crafting-panel .stat-label {
    font-size: 11px !important;
  }
  #crafting-panel .stat-value {
    font-size: 11px !important;
  }
  /* Controls: inline row */
  #crafting-panel .crafting-controls {
    padding: 8px 10px !important;
    border-radius: 8px !important;
    flex-shrink: 0;
  }
  #crafting-panel .batch-control {
    margin-bottom: 6px !important;
    gap: 6px !important;
  }
  #crafting-panel .batch-control label {
    font-size: 11px !important;
  }
  #crafting-panel .batch-control select {
    padding: 5px 8px !important;
    font-size: 12px !important;
    width: 80px !important;
  }
  #crafting-panel .action-buttons {
    gap: 6px !important;
  }
  #crafting-panel .craft-btn-single,
  #crafting-panel .craft-btn-batch {
    padding: 8px !important;
    font-size: 13px !important;
    border-radius: 8px !important;
  }
  /* Log: hidden on mobile */
  #crafting-panel .crafting-log {
    display: none !important;
  }

  /* --- Fullscreen map --- */
  .fullscreen-map-container {
    width: 100vw; height: 100dvh;
    border-radius: 0; border: none;
  }
  .fullscreen-map-content {
    min-height: 220px; padding: 6px;
  }
}

/* =============================== */
/* === Force-mobile overrides === */
/* =============================== */
body.force-mobile,
body.force-mobile #app,
body.force-mobile #game-screen {
  height: 100dvh; overflow: hidden;
}

body.force-mobile .left-col { display: none !important; }
body.force-mobile .map-panel,
body.force-mobile .world-map-container,
body.force-mobile .dir-pad,
body.force-mobile .func-bar { display: none !important; }

body.force-mobile .top-info {
  position: sticky; top: 0; z-index: 70;
}
body.force-mobile .status-row {
  position: sticky; top: 34px; z-index: 69;
  background: #131822;
}
body.force-mobile .right-col {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 5px; min-height: 0; flex: 1;
}
body.force-mobile .msg-content {
  min-height: 40px; max-height: 90px;
  font-size: 11px; line-height: 1.5;
  overflow-y: hidden;
}
body.force-mobile .res-box {
  max-height: 180px; overflow: hidden;
}
body.force-mobile .modal-box {
  max-height: calc(100dvh - 16px);
}
body.force-mobile .nav-b {
  min-height: 50px; padding: 6px 4px; border-radius: 10px;
}
body.force-mobile .modal-box {
  width: 96%; max-height: 86dvh;
}
body.force-mobile #sys-update-panel {
  margin-top: 8px; padding: 8px;
}
body.force-mobile #sys-update-panel input,
body.force-mobile #sys-update-panel select {
  font-size: 12px;
}
body.force-mobile #sys-update-panel > div:last-child {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
body.force-mobile #update-env-switch {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 480px) {
  body.force-mobile #update-env-switch { grid-template-columns: 1fr; }
  body.force-mobile #sys-update-panel > div:last-child { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .login-box { width: 92%; padding: 18px 14px; }
  .login-title { font-size: 22px; letter-spacing: 3px; }
  .loc-text { font-size: 12px; }
  .loc-coord, .time-line { font-size: 10px; }
  .world-map-cell, .fullscreen-map-cell { width: 20px; height: 20px; font-size: 10px; }
}

/* =============================== */
/* === force-mobile layout refinement === */
/* =============================== */
@media (max-width: 900px) {
  body.force-mobile #game-screen.active {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    min-height: 100dvh;
  }
  body.force-mobile .top-info {
    justify-content: space-between; align-items: center;
    flex-direction: row; gap: 4px; padding: 4px 8px;
  }
  body.force-mobile .status-row {
    display: flex; flex-wrap: wrap; gap: 4px;
    font-size: 11px; padding: 4px 6px;
  }
  body.force-mobile .status-row .stat-item {
    white-space: nowrap; padding: 2px 6px;
    border-radius: 8px; flex-shrink: 0;
  }
  body.force-mobile .main-area {
    overflow: hidden; overflow-x: hidden;
    grid-template-rows: auto minmax(0, 1fr);
    align-content: start; padding-bottom: 8px;
  }
  body.force-mobile .left-col { display: none !important; }
  body.force-mobile .right-col {
    grid-template-rows: auto auto minmax(60px, 1fr);
    gap: 5px;
  }
  body.force-mobile .mini-map { display: flex !important; }
  body.force-mobile .res-box {
    order: 2; max-height: 180px;
    overflow: hidden; padding: 0;
  }
  body.force-mobile .res-header {
    display: none !important;
  }
  body.force-mobile .res-header {
    display: none !important;
  }
  body.force-mobile .res-list {
    gap: 4px; max-height: 140px;
    overflow: hidden; min-height: 0;
  }
  body.force-mobile .res-tag {
    font-size: 11px; padding: 4px 8px; border-radius: 6px;
  }
  body.force-mobile .msg-box {
    order: 1; min-height: 40px; flex: 1;
  }
  body.force-mobile .msg-content {
    min-height: 40px; max-height: 90px;
    font-size: 11px; line-height: 1.4;
  }
  body.force-mobile .bot-nav,
  body.force-mobile .bot-nav.enhanced {
    position: sticky; bottom: 0;
    backdrop-filter: blur(6px);
    background: linear-gradient(180deg, rgba(14,19,31,0.96) 0%, rgba(10,14,24,0.98) 100%);
  }
}
