/**
 * mobile-layout-v2.css
 * Dedicated mobile-first layout stylesheet for HexSettlers Online.
 * 
 * STRICT ARCHITECTURAL ISOLATION:
 * This stylesheet is completely additive and scoped strictly under:
 *   body.mobile-layout-v2
 * Desktop styles in hud-layout.css remain 100% untouched.
 */

:root {
  --mobile-sat: env(safe-area-inset-top, 0px);
  --mobile-sab: env(safe-area-inset-bottom, 0px);
  --mobile-sal: env(safe-area-inset-left, 0px);
  --mobile-sar: env(safe-area-inset-right, 0px);
  --mobile-gold-primary: #e2b93b;
  --mobile-gold-glow: rgba(226, 185, 59, 0.45);
  --mobile-bg-glass: rgba(15, 23, 42, 0.85);
  --mobile-border-glass: rgba(255, 255, 255, 0.12);
}

@media (max-width: 1023px) {
  /* When in lobby or waiting view, body scrolls naturally */
  body.mobile-layout-v2 {
    touch-action: pan-y manipulation;
  }

  body.mobile-layout-v2:not(.in-game):not(:has(#view-game.active)) {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    height: auto !important;
    min-height: 100vh !important;
  }

  /* Hide in-game Mobile HUD elements while in lobby or waiting room */
  body.mobile-layout-v2:not(.in-game):not(:has(#view-game.active)) .mobile-hud-root {
    display: none !important;
  }

  /* Hide brand title text in mobile header so all auth/stats/profile buttons fit without widening the bar */
  body.mobile-layout-v2 .brand-title {
    display: none !important;
  }

  /* Hide yellow Buy Me a Coffee pill on mobile to free space for user profile & auth actions */
  body.mobile-layout-v2 #btn-header-bmc,
  body.mobile-layout-v2 .bmc-header-pill {
    display: none !important;
  }

  /* Ensure user profile badge has room and displays name cleanly on mobile */
  body.mobile-layout-v2 #header-user-profile:not(.is-hidden),
  body.mobile-layout-v2 .header-profile-badge:not(.is-hidden) {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 3px 8px 3px 4px !important;
    flex-shrink: 0 !important;
  }

  body.mobile-layout-v2 #header-user-profile #header-user-name,
  body.mobile-layout-v2 .header-profile-badge .header-user-name {
    display: inline-block !important;
    max-width: 90px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 11.5px !important;
  }

  /* Profile modal tabs: eliminate horizontal scrollbar on mobile */
  body.mobile-layout-v2 .profile-sidebar-tabs {
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 6px !important;
    gap: 6px !important;
  }
  body.mobile-layout-v2 .profile-sidebar-tabs::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }
  body.mobile-layout-v2 .profile-nav-btn {
    width: auto !important;
    flex: 1 1 auto !important;
    min-width: max-content !important;
    padding: 9px 12px !important;
    font-size: 13.5px !important;
    justify-content: center !important;
    border-radius: 8px !important;
  }

  /* Only lock body viewport when IN-GAME */
  body.mobile-layout-v2.in-game,
  body.mobile-layout-v2:has(#view-game.active) {
    overflow: hidden !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    touch-action: manipulation;
  }

  /* PORTRAIT ORIENTATION SHELL */
  body.mobile-layout-v2.in-game .game-viewport-container,
  body.mobile-layout-v2:has(#view-game.active) .game-viewport-container {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    grid-template-areas: none !important;
  }

  /* Eliminate legacy desktop sidebar, panels, desktop header, and C&K widgets on mobile-v2 */
  body.mobile-layout-v2.in-game .app-header,
  body.mobile-layout-v2:has(#view-game.active) .app-header,
  body.mobile-layout-v2 .hud-overlay-toggle,
  body.mobile-layout-v2 #hud-sidebar-backdrop,
  body.mobile-layout-v2 .hud-left,
  body.mobile-layout-v2 .hud-left *,
  body.mobile-layout-v2 .hud-bottom,
  body.mobile-layout-v2 .hud-bottom *,
  body.mobile-layout-v2 .hud-right,
  body.mobile-layout-v2 .hud-right *,
  body.mobile-layout-v2 .board-controls,
  body.mobile-layout-v2 .ck-hud-widget,
  body.mobile-layout-v2 .ck-improvements-panel,
  body.mobile-layout-v2 .barbarian-track,
  body.mobile-layout-v2 #barbarian-track,
  body.mobile-layout-v2 #city-improvements-panel,
  body.mobile-layout-v2 #realm-bank-strip,
  body.mobile-layout-v2 .res-card,
  body.mobile-layout-v2 .res-card.ck-only {
    display: none !important;
    height: 0 !important;
    max-height: 0 !important;
    min-height: 0 !important;
    width: 0 !important;
    max-width: 0 !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }

  /* Fullscreen Fixed Mobile HUD Shell */
  body.mobile-layout-v2.in-game .mobile-hud-root,
  body.mobile-layout-v2:has(#view-game.active) .mobile-hud-root {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    width: 100vw !important;
    max-width: 100vw !important;
    pointer-events: none !important;
    z-index: 50 !important;
  }

  /* Interactive Mobile HUD components */
  body.mobile-layout-v2 .mobile-top-bar,
  body.mobile-layout-v2 .mobile-recenter-fab,
  body.mobile-layout-v2 .mobile-timer-pill,
  body.mobile-layout-v2 .mobile-mandatory-banner,
  body.mobile-layout-v2 .mobile-bank-strip,
  body.mobile-layout-v2 .mobile-resource-dock,
  body.mobile-layout-v2 .mobile-action-bar,
  body.mobile-layout-v2 .mobile-bottom-sheet {
    pointer-events: auto !important;
  }

  /* Pin bank strip, resource dock and action bar to bottom */
  body.mobile-layout-v2 .mobile-bank-strip {
    margin-top: auto !important;
  }
  body.mobile-layout-v2 .mobile-resource-dock {
    margin-top: 0 !important;
  }

  body.mobile-layout-v2 .board-hint {
    position: absolute !important;
    bottom: calc(154px + var(--mobile-sab)) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 48 !important;
    pointer-events: none !important;
    font-size: 11px !important;
    padding: 4px 12px !important;
    line-height: 1.25 !important;
    border-radius: 999px !important;
    white-space: nowrap !important;
    max-width: calc(100vw - 24px) !important;
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
  }

  /* 1. TOP BAR COMPACT STRIP (52px) */
  body.mobile-layout-v2 .mobile-top-bar {
    height: calc(52px + var(--mobile-sat));
    padding: max(6px, var(--mobile-sat)) 12px 6px;
    background: var(--mobile-bg-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--mobile-border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
    flex-shrink: 0;
  }

  body.mobile-layout-v2 .mobile-player-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    flex: 1;
    min-width: 0;
    padding-right: 14px;
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
    mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
  }
  body.mobile-layout-v2 .mobile-player-pills::-webkit-scrollbar {
    display: none;
  }

  body.mobile-layout-v2 .mobile-player-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
  }

  body.mobile-layout-v2 .mobile-player-pill.is-active-turn {
    border-color: var(--mobile-gold-primary);
    box-shadow: 0 0 8px var(--mobile-gold-glow);
  }

  /* FLOATING TURN TIMER (Positioned below top bar, under 1st player pill) */
  body.mobile-layout-v2 .mobile-timer-pill {
    position: absolute;
    top: calc(58px + var(--mobile-sat));
    left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(15, 23, 42, 0.90);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid var(--mobile-gold-primary);
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    color: #fef08a;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), 0 0 10px var(--mobile-gold-glow);
    z-index: 25;
    pointer-events: auto !important;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  }

  body.mobile-layout-v2 .mobile-timer-pill .ico,
  body.mobile-layout-v2 .mobile-timer-pill svg {
    width: 13px;
    height: 13px;
    display: block;
    flex-shrink: 0;
  }

  body.mobile-layout-v2 .mobile-timer-pill.timer-warning {
    border-color: #f59e0b;
    color: #fde68a;
    background: rgba(245, 158, 11, 0.25);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), 0 0 12px rgba(245, 158, 11, 0.45);
  }

  body.mobile-layout-v2 .mobile-timer-pill.timer-critical {
    border-color: #ef4444;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.3);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), 0 0 14px rgba(239, 68, 68, 0.6);
  }

  body.mobile-layout-v2 .mobile-timer-pill.timer-pulse {
    animation: mobile-timer-urgent-pulse 0.9s infinite alternate ease-in-out;
  }

  @keyframes mobile-timer-urgent-pulse {
    0% {
      transform: scale(1);
      box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
    }
    100% {
      transform: scale(1.08);
      box-shadow: 0 0 18px rgba(239, 68, 68, 0.9);
    }
  }

  body.mobile-layout-v2 .mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.16);
    padding-left: 8px;
    margin-left: 4px;
  }

  body.mobile-layout-v2 .mobile-top-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--mobile-border-glass);
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
  }

  body.mobile-layout-v2 .mobile-top-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.16);
  }

  body.mobile-layout-v2 #mobile-leave-btn:active {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.12);
  }

  body.mobile-layout-v2 .mobile-badge-unread {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 999px;
    border: 1.5px solid #0f172a;
  }

  /* 2. BOARD VIEWPORT (Full Screen, Pan & Zoom, Continuous Ocean) */
  body.mobile-layout-v2 .board-viewport {
    position: absolute !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    touch-action: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: #071e2b !important;
    background-image:
      radial-gradient(60% 45% at 30% 28%, rgba(125, 211, 232, 0.14), rgba(125, 211, 232, 0) 68%),
      radial-gradient(55% 45% at 72% 32%, rgba(125, 211, 232, 0.10), rgba(125, 211, 232, 0) 70%),
      radial-gradient(70% 55% at 55% 80%, rgba(56, 178, 210, 0.10), rgba(56, 178, 210, 0) 72%),
      radial-gradient(125% 105% at 50% 46%, #155066 0%, #0f3a4d 38%, #0a2531 72%, #05141d 100%) !important;
  }

  body.mobile-layout-v2 .catan-board-svg {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    pointer-events: auto !important;
    touch-action: none !important;
  }

  /* 3. RECENTER FAB BUTTON */
  body.mobile-layout-v2 .mobile-recenter-fab {
    position: absolute;
    right: 12px;
    top: calc(64px + var(--mobile-sat));
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--mobile-bg-glass);
    border: 1px solid var(--mobile-border-glass);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 20;
    cursor: pointer;
  }

  /* 4. NON-BLOCKING MANDATORY ACTION BANNER */
  body.mobile-layout-v2 .mobile-mandatory-banner {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.94);
    border: 1.5px solid var(--mobile-gold-primary);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    z-index: 30;
    white-space: nowrap;
  }

  /* 4.5. REALM BANK RESERVE STRIP (Slim 26px Horizontal Scroll) */
  body.mobile-layout-v2 .mobile-bank-strip {
    height: 26px;
    min-height: 26px;
    max-height: 26px;
    width: 100%;
    display: flex;
    align-items: center;
    background: rgba(8, 12, 22, 0.90);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(255, 255, 255, 0.10);
    border-bottom: 1px solid rgba(0, 0, 0, 0.45);
    z-index: 39;
    flex-shrink: 0;
    overflow: hidden;
  }

  body.mobile-layout-v2 .mobile-bank-lead {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 7px 0 9px;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #94a3b8;
    flex-shrink: 0;
    height: 100%;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
  }

  body.mobile-layout-v2 .mobile-bank-lead-icon {
    width: 12px;
    height: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
  }

  body.mobile-layout-v2 .mobile-bank-lead-icon svg {
    width: 12px;
    height: 12px;
    display: block;
  }

  body.mobile-layout-v2 .mobile-bank-scroll {
    display: flex;
    align-items: center;
    gap: 5px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 0 8px 0 6px;
    height: 100%;
    flex: 1;
  }

  body.mobile-layout-v2 .mobile-bank-scroll::-webkit-scrollbar {
    display: none;
  }

  body.mobile-layout-v2 .mobile-bank-pill {
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  }

  body.mobile-layout-v2 .mobile-bank-pill:active {
    transform: scale(0.96);
  }

  body.mobile-layout-v2 .mobile-bank-pill .bank-pill-icon {
    width: 12px;
    height: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  body.mobile-layout-v2 .mobile-bank-pill .bank-pill-icon svg {
    width: 12px;
    height: 12px;
    display: block;
  }

  body.mobile-layout-v2 .mobile-bank-pill-label {
    color: #94a3b8;
    font-size: 9px;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.2px;
  }

  body.mobile-layout-v2 .mobile-bank-pill-count {
    font-variant-numeric: tabular-nums;
    color: #f8fafc;
    font-size: 10px;
    font-weight: 800;
    margin-left: 1px;
  }

  /* Resource & Deck Specific Accents */
  body.mobile-layout-v2 .mobile-bank-pill.bank-res-wood {
    border-color: rgba(45, 106, 79, 0.45);
    background: rgba(45, 106, 79, 0.22);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-res-wood .bank-pill-icon {
    color: #52b788;
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-res-brick {
    border-color: rgba(217, 4, 41, 0.45);
    background: rgba(217, 4, 41, 0.22);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-res-brick .bank-pill-icon {
    color: #ff6b6b;
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-res-wool {
    border-color: rgba(116, 198, 157, 0.45);
    background: rgba(116, 198, 157, 0.22);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-res-wool .bank-pill-icon {
    color: #99d98c;
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-res-wheat {
    border-color: rgba(224, 159, 62, 0.45);
    background: rgba(224, 159, 62, 0.22);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-res-wheat .bank-pill-icon {
    color: #ffe6a7;
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-res-ore {
    border-color: rgba(148, 163, 184, 0.45);
    background: rgba(148, 163, 184, 0.22);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-res-ore .bank-pill-icon {
    color: #e2e8f0;
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-com-cloth {
    border-color: rgba(129, 140, 248, 0.45);
    background: rgba(129, 140, 248, 0.22);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-com-cloth .bank-pill-icon {
    color: #a5b4fc;
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-com-coin {
    border-color: rgba(251, 191, 36, 0.45);
    background: rgba(251, 191, 36, 0.22);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-com-coin .bank-pill-icon {
    color: #fde047;
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-com-paper {
    border-color: rgba(52, 211, 153, 0.45);
    background: rgba(52, 211, 153, 0.22);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-com-paper .bank-pill-icon {
    color: #6ee7b7;
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-deck-dev {
    border-color: rgba(192, 132, 252, 0.4);
    background: rgba(192, 132, 252, 0.16);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-deck-dev .bank-pill-icon {
    color: #c084fc;
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-deck-trade {
    border-color: rgba(234, 179, 8, 0.4);
    background: rgba(234, 179, 8, 0.16);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-deck-trade .bank-pill-icon {
    color: #facc15;
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-deck-politics {
    border-color: rgba(96, 165, 250, 0.4);
    background: rgba(96, 165, 250, 0.16);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-deck-politics .bank-pill-icon {
    color: #60a5fa;
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-deck-science {
    border-color: rgba(74, 222, 128, 0.4);
    background: rgba(74, 222, 128, 0.16);
  }
  body.mobile-layout-v2 .mobile-bank-pill.bank-deck-science .bank-pill-icon {
    color: #4ade80;
  }

  /* Low & Depleted Bank States */
  body.mobile-layout-v2 .mobile-bank-pill.is-low .mobile-bank-pill-count {
    color: #facc15 !important;
  }
  body.mobile-layout-v2 .mobile-bank-pill.is-depleted {
    opacity: 0.45;
    border-color: rgba(239, 68, 68, 0.5) !important;
    background: rgba(239, 68, 68, 0.1) !important;
  }
  body.mobile-layout-v2 .mobile-bank-pill.is-depleted .mobile-bank-pill-count {
    color: #ef4444 !important;
  }
  body.mobile-layout-v2 .mobile-bank-pill.is-hidden {
    display: none !important;
  }

  /* 5. RESOURCE HAND DOCK (54px) */
  body.mobile-layout-v2 .mobile-resource-dock {
    height: 56px;
    padding: 4px 10px;
    background: rgba(10, 14, 26, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--mobile-border-glass);
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 6px;
    z-index: 40;
    flex-shrink: 0;
  }

  body.mobile-layout-v2 .mobile-res-chip {
    flex: 1;
    height: 48px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
  }

  body.mobile-layout-v2 .mobile-res-chip.mobile-res-wood {
    background: linear-gradient(180deg, #245843 0%, #17382b 100%);
    border-color: rgba(74, 222, 128, 0.25);
  }
  body.mobile-layout-v2 .mobile-res-chip.mobile-res-brick {
    background: linear-gradient(180deg, #992323 0%, #681717 100%);
    border-color: rgba(248, 113, 113, 0.25);
  }
  body.mobile-layout-v2 .mobile-res-chip.mobile-res-wool {
    background: linear-gradient(180deg, #189849 0%, #106631 100%);
    border-color: rgba(74, 222, 128, 0.25);
  }
  body.mobile-layout-v2 .mobile-res-chip.mobile-res-wheat {
    background: linear-gradient(180deg, #9d5c11 0%, #6d3e09 100%);
    border-color: rgba(250, 204, 21, 0.25);
  }
  body.mobile-layout-v2 .mobile-res-chip.mobile-res-ore {
    background: linear-gradient(180deg, #3e4f68 0%, #293444 100%);
    border-color: rgba(148, 163, 184, 0.25);
  }
  body.mobile-layout-v2 .mobile-res-chip.mobile-com-cloth {
    background: linear-gradient(180deg, #6d28d9 0%, #4c1d95 100%);
    border-color: rgba(192, 132, 252, 0.35);
  }
  body.mobile-layout-v2 .mobile-res-chip.mobile-com-coin {
    background: linear-gradient(180deg, #b8730b 0%, #805007 100%);
    border-color: rgba(253, 224, 71, 0.35);
  }
  body.mobile-layout-v2 .mobile-res-chip.mobile-com-paper {
    background: linear-gradient(180deg, #13746f 0%, #0d4e4a 100%);
    border-color: rgba(94, 234, 212, 0.35);
  }

  body.mobile-layout-v2 .mobile-res-chip .ico {
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f8fafc;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  }

  body.mobile-layout-v2 .mobile-res-chip.has-stock {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 6px rgba(0, 0, 0, 0.3);
  }

  body.mobile-layout-v2 .mobile-res-badge {
    position: absolute;
    top: -5px;
    right: -4px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
  }

  /* 6. HIERARCHICAL ACTION BAR (Thumb Zone Lower: 68px) */
  body.mobile-layout-v2 .mobile-action-bar {
    height: calc(68px + var(--mobile-sab));
    padding: 6px 10px max(10px, var(--mobile-sab));
    background: rgba(10, 14, 26, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 45;
    flex-shrink: 0;
  }

  body.mobile-layout-v2 .mobile-btn-secondary {
    width: 48px;
    height: 52px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--mobile-border-glass);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
  }

  body.mobile-layout-v2 .mobile-btn-secondary .btn-secondary-ico {
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  body.mobile-layout-v2 .mobile-btn-primary {
    flex: 1;
    height: 52px;
    border-radius: 12px;
    background: linear-gradient(135deg, #e2b93b 0%, #b48612 100%);
    border: 1.5px solid #fde047;
    color: #0f172a;
    box-shadow: 0 4px 16px rgba(226, 185, 59, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.02em;
    cursor: pointer;
  }

  body.mobile-layout-v2 .mobile-btn-primary #mbtn-primary-icon {
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  body.mobile-layout-v2 .mobile-btn-primary.pulse-afk {
    animation: afkGlow 1.8s infinite ease-in-out;
  }

  @keyframes afkGlow {
    0% { box-shadow: 0 0 0 0 rgba(226, 185, 59, 0.7); }
    50% { box-shadow: 0 0 16px 4px rgba(226, 185, 59, 0.5); }
    100% { box-shadow: 0 0 0 0 rgba(226, 185, 59, 0); }
  }

  /* 7. SLIDE-UP SHEETS & DRAWERS */
  body.mobile-layout-v2 .mobile-bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1.5px solid var(--mobile-border-glass);
    border-radius: 16px 16px 0 0;
    padding: 14px 14px max(14px, var(--mobile-sab));
    z-index: 2100;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  body.mobile-layout-v2 .mobile-bottom-sheet.is-open {
    transform: translateY(0);
  }

  body.mobile-layout-v2 #mobile-chat-sheet {
    max-height: calc(100dvh - 54px);
    display: flex;
    flex-direction: column;
  }

  body.mobile-layout-v2 #mobile-chat-stream {
    flex: 1 1 auto;
    min-height: 80px;
    max-height: 28dvh;
  }

  /* Mobile Communications Sheet (Game Log & Chat) */
  body.mobile-layout-v2 .mobile-comm-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.45);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  body.mobile-layout-v2 .mobile-comm-tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #94a3b8;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
  }

  body.mobile-layout-v2 .mobile-comm-tab-btn.active {
    background: rgba(226, 185, 59, 0.2);
    color: #fde047;
    border-color: rgba(226, 185, 59, 0.35);
  }

  body.mobile-layout-v2 .mobile-comm-pane {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }

  body.mobile-layout-v2 .mobile-comm-pane.is-hidden {
    display: none !important;
  }

  body.mobile-layout-v2 .mobile-log-stream {
    flex: 1 1 auto;
    height: 40dvh;
    max-height: 48dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    margin-top: 4px;
    scrollbar-width: thin;
  }

  body.mobile-layout-v2 .mobile-log-stream .log-entry {
    padding: 7px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    line-height: 1.4;
    color: #cbd5e1;
    font-size: 12.5px;
  }

  body.mobile-layout-v2 .mobile-barbarian-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    color: #f8fafc;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  }
  body.mobile-layout-v2 .mobile-barbarian-badge:active {
    transform: scale(0.92);
    background: rgba(51, 65, 85, 0.95);
  }
  body.mobile-layout-v2 .mobile-barbarian-badge.barbarian-warning {
    border-color: #f59e0b;
    color: #fef08a;
  }
  body.mobile-layout-v2 .mobile-barbarian-badge.barbarian-danger {
    border-color: #ef4444;
    color: #fca5a5;
    animation: afkGlow 1.2s infinite;
  }

  body.mobile-layout-v2 #mobile-barbarian-sheet {
    max-height: calc(100dvh - 54px);
    display: flex;
    flex-direction: column;
  }

  body.mobile-layout-v2 .mobile-com-chip {
    border-color: rgba(226, 185, 59, 0.35);
  }

  body.mobile-layout-v2 .mobile-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
  }
  body.mobile-layout-v2 .mobile-sheet-title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: #f8fafc;
  }
  body.mobile-layout-v2 .mobile-sheet-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  body.mobile-layout-v2 .mobile-build-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  body.mobile-layout-v2 .btn-touch-card {
    height: 64px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    cursor: pointer;
    touch-action: manipulation;
  }
  body.mobile-layout-v2 .btn-touch-card:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.98);
  }
  body.mobile-layout-v2 .build-card-icon {
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mobile-gold-primary);
  }
  body.mobile-layout-v2 .build-card-info {
    text-align: left;
  }
  body.mobile-layout-v2 .build-card-name {
    font-size: 12px;
    font-weight: 800;
  }
  body.mobile-layout-v2 .build-card-cost {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
  }
  body.mobile-layout-v2 .cost-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    color: #f1f5f9;
  }
  body.mobile-layout-v2 .cost-item .ico {
    font-size: 13px;
    display: inline-flex;
    align-items: center;
  }
  body.mobile-layout-v2 .btn-touch-improve {
    flex: 1;
    min-height: 54px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    padding: 4px;
  }
  body.mobile-layout-v2 .mobile-quick-reactions {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 8px;
  }
  body.mobile-layout-v2 .btn-quick-react {
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #f8fafc;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  body.mobile-layout-v2 .btn-quick-react .ico {
    font-size: 14px;
    display: inline-flex;
    align-items: center;
  }
  body.mobile-layout-v2 .btn-quick-react:active {
    background: rgba(226, 185, 59, 0.25);
    border-color: #e2b93b;
  }

  /* 8. LANDSCAPE PANORAMIC LAYOUT (844x390) */
  @media (orientation: landscape) {
    body.mobile-layout-v2 .game-viewport-container {
      flex-direction: row !important;
    }

    body.mobile-layout-v2 .mobile-top-bar {
      display: none !important;
    }

    body.mobile-layout-v2 .mobile-landscape-dock-left {
      width: calc(76px + var(--mobile-sal));
      padding: 10px 6px 10px max(10px, var(--mobile-sal));
      background: var(--mobile-bg-glass);
      border-right: 1px solid var(--mobile-border-glass);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
      z-index: 50;
      flex-shrink: 0;
    }

    body.mobile-layout-v2 .mobile-landscape-dock-right {
      width: calc(140px + var(--mobile-sar));
      padding: 10px max(10px, var(--mobile-sar)) 10px 6px;
      background: var(--mobile-bg-glass);
      border-left: 1px solid var(--mobile-border-glass);
      display: flex;
      flex-direction: column;
      gap: 8px;
      z-index: 50;
      flex-shrink: 0;
    }

    body.mobile-layout-v2 .board-viewport {
      position: absolute !important;
      inset: 0 !important;
      width: 100vw !important;
      height: 100dvh !important;
    }

    body.mobile-layout-v2 .board-hint {
      bottom: calc(10px + var(--mobile-sab)) !important;
    }

    /* In landscape, drawers open as side-sheets from the right */
    body.mobile-layout-v2 .mobile-bottom-sheet {
      left: auto;
      right: 0;
      top: 0;
      bottom: 0;
      width: 320px;
      border-radius: 16px 0 0 16px;
      border-top: none;
      border-left: 1.5px solid var(--mobile-border-glass);
      transform: translateX(100%);
    }

    body.mobile-layout-v2 .mobile-bottom-sheet.is-open {
      transform: translateX(0);
    }
  }

  /* MOBILE DISCARD MODAL (ROLLED 7) & TOUCH STEPPERS */
  body.mobile-layout-v2 #discard-modal.modal-overlay {
    padding: 10px 8px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  body.mobile-layout-v2 #discard-modal .modal-box {
    max-width: 100% !important;
    width: 100% !important;
    padding: 16px 8px !important;
    border-radius: 16px !important;
    box-sizing: border-box !important;
    gap: 12px !important;
  }

  body.mobile-layout-v2 #discard-modal .trade-steppers-grid {
    gap: 4px !important;
  }

  body.mobile-layout-v2 #discard-modal .res-stepper-card {
    padding: 8px 3px 6px !important;
    border-radius: 8px !important;
    gap: 5px !important;
  }

  body.mobile-layout-v2 #discard-modal .stepper-controls {
    padding: 2px !important;
    border-radius: 7px !important;
    background: rgba(0, 0, 0, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    gap: 1px !important;
  }

  body.mobile-layout-v2 #discard-modal .btn-stepper {
    width: 25px !important;
    min-width: 25px !important;
    height: 30px !important;
    border-radius: 5px !important;
    background: rgba(255, 255, 255, 0.09) !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
  }

  body.mobile-layout-v2 #discard-modal .btn-stepper .ico {
    font-size: 13px !important;
  }

  body.mobile-layout-v2 #discard-modal .stepper-val-input {
    font-size: 14px !important;
    color: #fde047 !important;
  }

  body.mobile-layout-v2.mode-cities-knights #discard-form .trade-steppers-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 5px !important;
  }

  /* ACCESSIBILITY: PREFERS REDUCED MOTION */
  @media (prefers-reduced-motion: reduce) {
    body.mobile-layout-v2 * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}
