/* ============================================================
   Mobile Responsive — Compact Layout
   ============================================================ */

@media (max-width: 768px) {
  /* ── Root ── */
  :root {
    --sidebar-width: 0px;
    --content-padding: 10px;
  }

  #app {
    flex-direction: column;
  }

  /* ── Sidebar header compact ── */
  .sidebar-brand { padding: 10px 12px 6px; }
  .sidebar-brand .brand-logo { width: 26px; height: 26px; }
  .sidebar-brand .brand-text { font-size: 14px; }
  .sidebar-nav .nav-item { padding: 8px 12px; font-size: 12px; }
  .sidebar-nav .nav-item .nav-icon { font-size: 16px; width: 20px; }

  /* ── Sidebar hidden by default, slides over ── */
  #sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 260px;
    min-width: 260px;
    height: 100vh;
    height: 100dvh;
    z-index: 3000;
    transition: left 0.25s ease;
    box-shadow: 2px 0 30px rgba(0,0,0,0.6);
    overflow-y: auto;
  }
  #sidebar.open { left: 0; }

  /* ── Top Bar ── */
  #mobile-bar {
    display: flex;
    flex: 0 0 auto;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-deep);
    border-bottom: 1px solid var(--gold-border-light);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 8px;
  }
  .mobile-menu-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 6px;
    line-height: 1;
    flex-shrink: 0;
  }
  .mobile-logo {
    font-weight: 900;
    color: var(--text-primary);
    font-size: 16px;
    letter-spacing: 1px;
    white-space: nowrap;
  }
  .mobile-logo span { color: var(--gold); }
  .mobile-sub {
    font-size: 9px;
    color: var(--text-muted);
    display: none;
  }

  /* ── Sidebar overlay ── */
  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2999;
  }
  #sidebar-overlay.active { display: block; }

  /* ── Content: full width ── */
  #content {
    flex: 1 1 auto;
    min-height: 0;
    margin-left: 0 !important;
    width: 100%;
    padding-top: 0;
  }
  #content-inner {
    padding: 10px;
  }

  /* ── Stat cards: 2 columns ── */
  .stat-cards {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }
  .stat-card { padding: 12px 10px; }
  .stat-card .stat-value { font-size: 18px; }
  .stat-card .stat-label { font-size: 10px; }

  /* ── Grid layouts ── */
  .game-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }

  /* ── Game Cards (compact) ── */
  .game-card .game-cover { height: 80px; font-size: 32px; }
  .game-card .game-info { padding: 8px; }
  .game-card .game-name { font-size: 12px; }
  .game-card .game-meta { font-size: 10px; }
  .game-card .game-price { font-size: 13px; }
  .game-card .buy-btn { padding: 4px 10px; font-size: 10px; }

  /* ── Store detail ── */
  .game-detail { grid-template-columns: 1fr; gap: 12px; }
  .game-detail .detail-cover { height: 160px; }
  .game-detail .detail-header h2 { font-size: 22px; }

  /* ── Trading / Market ── */
  .trading-layout { grid-template-columns: 1fr; gap: 8px; }
  .kline-container { min-height: 240px; }
  .trading-header { flex-direction: column; gap: 8px; }
  .trading-header .game-selector { max-width: 100%; width: 100%; }
  .trading-header .timeframe-btns { flex-wrap: wrap; }
  .kline-panel-header { padding: 8px 12px; font-size: 12px; }
  .kline-tf-btn { padding: 3px 8px; font-size: 9px; }

  /* ── Market grid ── */
  .market-grid { grid-template-columns: 1fr; gap: 8px; }
  .market-card-header { height: 70px; }
  .market-card-icon { font-size: 28px; }
  .market-card-body { padding: 10px; }
  .market-card-price { font-size: 18px; }

  /* ── Library ── */
  .lib-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .lib-card-cover { height: 80px; }
  .lib-card-icon { font-size: 28px; }
  .lib-hero { height: 140px; }
  .lib-hero-overlay { padding: 14px; }
  .lib-hero-title { font-size: 18px; }
  .lib-hero-icon { font-size: 28px; width: 50px; height: 50px; }
  .lib-toolbar { flex-direction: column; gap: 8px; }
  .lib-toolbar-left { flex-wrap: wrap; justify-content: flex-start; }
  .lib-toolbar-right { flex-wrap: wrap; }
  .lib-nav-btn { padding: 6px 10px; font-size: 11px; }

  /* ── Creator ── */
  .concept-card { grid-template-columns: 1fr; gap: 8px; }
  .concept-votes { flex-direction: row; }
  .studio-grid { grid-template-columns: 1fr; }

  /* ── Friends ── */
  .friends-layout { grid-template-columns: 1fr; }
  .friend-item { padding: 8px; }
  .friend-avatar { width: 34px; height: 34px; font-size: 16px; }
  .friend-actions { flex-wrap: wrap; gap: 2px; }
  .friend-actions button { padding: 4px 8px; font-size: 10px; }

  /* ── Tables ── */
  table { font-size: 10px; }
  thead th, tbody td { padding: 5px 3px; }

  /* ── Modals ── */
  .modal { width: 94vw; padding: 18px; max-height: 88vh; }
  .modal h2 { font-size: 16px; margin-bottom: 16px; }

  /* ── Cart ── */
  .cart-item { flex-wrap: wrap; gap: 8px; }
  .cart-summary { text-align: center; }

  /* ── Section header ── */
  .section-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  .section-header h2 { font-size: 18px; }
  .section-header .subtitle { font-size: 11px; }

  /* ── Store filters ── */
  .store-filters { flex-direction: column; gap: 8px; }
  .store-filters .search-box { max-width: 100%; }
  .store-filters select { width: 100%; }

  /* ── Breadcrumb ── */
  .breadcrumb { font-size: 10px; padding-bottom: 12px; }

  /* ── Launch overlay ── */
  .launch-container { width: 94vw; }
  .launch-game-icon { width: 70px; height: 44px; font-size: 24px; }
  .launch-game-title { font-size: 18px; }

  /* ── Voice panel ── */
  .voice-panel { width: calc(100vw - 16px); right: 8px; bottom: 8px; }

  /* ── Buttons ── */
  .btn-primary.btn-lg, .btn-secondary.btn-lg { padding: 8px 16px; font-size: 12px; }
  .btn-sm { padding: 4px 10px; font-size: 10px; }

  /* ── Price stats bar ── */
  .price-stats { gap: 12px; flex-wrap: wrap; }
  .price-stats .stat-item .value { font-size: 12px; }

  /* ── Portfolio / Order Book ── */
  .order-book .ob-rows { max-height: 200px; }
}

/* ── Tiny phones (< 400px) ── */
@media (max-width: 400px) {
  #content-inner { padding: 6px; }
  .game-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .game-card .game-cover { height: 70px; }
  .game-card .game-name { font-size: 11px; }
  .lib-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-card .stat-value { font-size: 15px; }
  .kline-container { min-height: 200px; }
}

/* ── Desktop: hide mobile bar ── */
@media (min-width: 769px) {
  #mobile-bar { display: none; }
  #sidebar-overlay { display: none; }
}
