/* =========================================================
   MOBILE UI CURRENT — Atelier des Charmes
   Couche d'override responsive mobile-first : desktop/tablette inchangés.
   ========================================================= */

@media (max-width: 640px) {
  :root {
    --mobile-gap: 10px;
    --mobile-radius: 8px;
  }

  html, body {
    overflow-x: hidden;
  }

  body {
    padding: 10px 8px 32px;
  }

  /* ---------- Header ---------- */
  header {
    padding: 2px 44px 6px;
  }

  .eyebrow {
    font-size: 9px;
    letter-spacing: .14em;
  }

  h1 {
    margin-top: 3px;
    font-size: 18px;
    line-height: 1.25;
  }

  /* ---------- Wallet ---------- */
  .wallet-centered {
    margin-bottom: 10px;
    padding-bottom: 10px;
    gap: 5px;
  }

  .wallet-row {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .wallet-row .chip {
    min-width: 0;
    justify-content: center;
    padding: 6px 4px;
    gap: 4px;
  }

  .wallet-row .chip-value {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .wallet-row .currency-icon {
    width: 16px;
    height: 16px;
  }

  .level-block {
    width: 100%;
    min-width: 0;
    max-width: 330px;
    margin: 2px auto 0;
  }

  .level-row {
    justify-content: center;
    gap: 10px;
    font-size: 10px;
  }

  .level-name {
    font-size: 13px;
  }

  .xp-bar {
    height: 4px;
    max-width: 270px;
    margin: 0 auto;
    width: 100%;
  }

  /* ---------- Navigation principale ---------- */
  nav,
  .view-tabs {
    width: 100%;
  }

  .view-tabs {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 5px !important;
    overflow: visible;
    padding: 5px 2px 8px;
    margin-bottom: 8px;
  }

  .view-tab,
  .nav-dropdown-trigger {
    flex: 1 1 calc(33.333% - 5px);
    min-width: 0;
    min-height: 44px;
    padding: 6px 4px !important;
    font-size: 9.5px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .view-tab svg,
  .nav-dropdown-trigger svg {
    width: 16px !important;
    height: 16px !important;
  }

  .nav-dropdown {
    flex: 1 1 calc(33.333% - 5px);
    display: flex;
  }

  .nav-dropdown .view-tab {
    flex: 1 1 auto;
    width: 100%;
  }

  .nav-dropdown-menu {
    position: fixed;
    left: 8px;
    right: 8px;
    top: auto;
    width: auto;
    max-width: none;
    z-index: 120;
  }

  /* ---------- Bannières de section ---------- */
  .menu-banner {
    aspect-ratio: auto !important;
    height: 132px;
    margin: 6px 0 12px;
    background-position: center 45%;
  }

  .menu-banner-title {
    font-size: 16px;
  }

  /* ---------- Sections / panneaux ---------- */
  .panel,
  .dungeon-section,
  .upgrade-shop-featured {
    padding-left: 8px;
    padding-right: 8px;
  }

  .dungeon-card {
    padding: 12px;
  }

  /* ---------- Aventure : combat ---------- */
  .battle-strip {
    min-height: 0 !important;
    height: 335px;
    display: grid !important;
    grid-template-columns: 1fr 32px 1fr;
    align-items: center;
    justify-items: center;
    gap: 2px !important;
    padding: 54px 8px 14px !important;
    margin-bottom: 10px;
  }

  .battle-prev-btn,
  .battle-next-btn {
    top: 12px !important;
    min-height: 44px;
    padding: 6px 12px !important;
    font-size: 11px !important;
  }

  .battle-prev-btn {
    left: 10px !important;
  }

  .battle-next-btn {
    right: 10px !important;
  }

  .battle-side,
  .battle-hero,
  .battle-monster-group {
    width: 100% !important;
    max-width: 155px;
  }

  .battle-vfx {
    width: 32px !important;
    margin: 0 !important;
    order: initial !important;
    font-size: 20px;
  }

  .party-formation,
  .monster-formation {
    width: 145px !important;
    height: 170px !important;
    max-width: none !important;
  }

  .party-slot-front .battle-icon,
  .monster-slot-front .battle-icon {
    width: 68px !important;
    height: 68px !important;
  }

  .party-slot-left-top .battle-icon,
  .party-slot-left-bottom .battle-icon,
  .party-slot-left-top2 .battle-icon,
  .party-slot-left-bottom2 .battle-icon {
    width: 44px !important;
    height: 44px !important;
  }

  .monster-icon-back {
    width: 68px !important;
    height: 68px !important;
  }

  .party-slot-left-top,
  .party-slot-left-bottom {
    left: 46px !important;
  }

  .party-slot-left-top2,
  .party-slot-left-bottom2 {
    left: 0 !important;
  }

  .party-slot .battle-label-mini {
    display: none !important;
  }

  .battle-label {
    max-width: 145px;
    font-size: 11px;
    line-height: 1.15;
  }

  .battle-hero > .hp-bar {
    width: 135px !important;
  }

  .hp-bar-mini {
    width: 40px !important;
  }

  /* ---------- Stats combat ---------- */
  .battle-stats-row {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px !important;
    margin: 8px 0 !important;
    padding: 0 4px;
  }

  .battle-stat {
    min-width: 0 !important;
    padding: 6px 4px !important;
    font-size: 10px !important;
  }

  .battle-stat strong {
    display: block;
    font-size: 12px;
    margin-top: 2px;
  }

  .battle-stats-row .battle-stat:nth-child(4),
  .battle-stats-row .battle-stat:nth-child(5) {
    grid-column: auto;
  }

  .battle-result {
    margin: 6px auto 4px;
    padding: 0 8px;
    font-size: 12px;
    line-height: 1.35;
    min-height: 0;
  }

  /* ---------- Compétences ---------- */
  .battle-skill-bar {
    width: 100%;
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center;
    gap: 8px !important;
    margin: 6px 0 !important;
  }

  .battle-skill-btn {
    flex: 1 1 calc(33.333% - 8px);
    min-width: 84px;
    min-height: 46px;
    padding: 5px 6px !important;
    font-size: 10px !important;
  }

  .battle-skill-time {
    font-size: 9px !important;
  }

  .stage-progress {
    margin: 7px 0 9px !important;
    font-size: 10px !important;
    text-align: center;
  }

  .auto-battle-row {
    margin-bottom: 12px;
  }

  .auto-battle-row .dungeon-btn {
    width: auto;
    min-width: 220px;
    min-height: 48px;
  }

  /* ---------- Hero / Compagnons ---------- */
  .hero-top {
    display: grid !important;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center !important;
    margin-bottom: 10px;
  }

  .hero-score-box {
    min-width: 125px;
    padding: 10px !important;
  }

  .hero-score-box .hero-score {
    font-size: 30px !important;
  }

  .mode-tabs {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    overflow: visible;
    gap: 6px !important;
    padding: 4px 2px 8px;
  }

  .mode-tab {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
    min-height: 44px;
    padding: 6px 6px !important;
    font-size: 10px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .companion-row {
    display: grid !important;
    grid-template-columns: 56px 1fr auto;
    gap: 8px !important;
    align-items: center;
    padding: 8px 5px !important;
  }

  .companion-portrait {
    width: 54px !important;
    height: 54px !important;
  }

  .companion-info {
    min-width: 0;
  }

  .companion-info .item-name {
    font-size: 13px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .companion-info .item-meta {
    font-size: 10px !important;
    line-height: 1.35;
  }

  .companion-stats-btn {
    min-width: 72px;
    min-height: 44px;
    padding: 6px 8px !important;
  }

  /* ---------- Comptoir ---------- */
  #pullCatTabs.mode-tabs {
    justify-content: center !important;
    overflow: visible;
    gap: 4px !important;
  }

  #pullCatTabs .mode-tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 4px !important;
    font-size: 9px !important;
  }

  .banner-info {
    margin-bottom: 10px;
    padding: 9px 10px;
  }

  .pull-row {
    gap: 7px;
  }

  .pull-btn {
    min-width: 0;
    padding: 10px 6px;
    font-size: 14px;
  }

  .results-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  /* ---------- Side rail ---------- */
  .side-icon-rail {
    right: 4px !important;
  }

  .side-icon-rail .shop-icon-btn {
    width: 40px !important;
    height: 40px !important;
  }

  /* ---------- Popups ---------- */
  .popup-overlay {
    padding: 8px;
  }

  .popup-card {
    width: calc(100vw - 16px);
    max-width: none !important;
    max-height: 90dvh !important;
    padding: 14px !important;
  }
}

/* Très petits écrans */
@media (max-width: 380px) {
  .wallet-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .battle-strip {
    height: 315px;
  }

  .party-formation,
  .monster-formation {
    transform: scale(.92);
  }

  .view-tab,
  .nav-dropdown-trigger,
  .mode-tab {
    min-width: 96px;
  }
}
