/* 모바일 전용 하단 탭 바 (데스크톱에서는 숨김) */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 1380px) and (min-width: 961px) {
  .top-bar {
    gap: 10px;
    padding: 7px 12px;
  }
  .top-bar-left {
    max-width: 320px;
  }
  .top-bar-gauges {
    gap: 10px;
    padding: 5px 10px;
  }
  .mini-gauge {
    min-width: 64px;
  }
  .top-bar-actions {
    gap: 4px;
  }
  .nav-pill {
    padding: 6px 8px;
    font-size: 12px;
    gap: 4px;
  }
}

@media (max-width: 1220px) and (min-width: 961px) {
  .main-grid {
    grid-template-columns: 248px minmax(0, 1fr) 280px;
  }
  .brand-subtitle {
    display: none;
  }
  .top-bar-left {
    max-width: 230px;
  }
  .mini-gauge {
    min-width: 54px;
  }
}

@media (max-width: 960px) {
  html,
  body {
    height: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .auth-screen {
    height: 100dvh;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .panel-body,
  .events-list,
  .tile-inspector {
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: flex !important;
  }

  .game-shell {
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
    height: 100vh;
    height: 100dvh;
  }

  /* 모바일 상단 바: 단 1줄(46px)로 슬림하게 압축! */
  .top-bar {
    min-height: 46px;
    padding: 6px 10px;
    gap: 8px;
    border-radius: var(--radius-md);
  }

  .brand-emblem {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }

  .brand-title-row h1 {
    font-size: 13.5px;
  }

  .brand-subtitle {
    display: none;
  }

  .mobile-top-controls {
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .mobile-faith-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 9px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    font-size: 11.5px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
  }

  .mobile-faith-chip .ui-icon {
    color: var(--accent-gold);
  }

  .mobile-faith-chip strong {
    color: var(--text-main);
  }

  .chip-sep {
    opacity: 0.4;
  }

  /* 모바일 상단 통합 퀵 드로어 */
  .mobile-quick-drawer {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    background: rgba(18, 21, 31, 0.98);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-popover);
    z-index: 45;
  }

  .drawer-summary {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
  }

  .drawer-gauges {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
  }

  .drawer-gauges .mini-gauge {
    min-width: 0;
  }

  .drawer-status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
    align-items: center;
  }

  .drawer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }

  .drawer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.035);
    color: var(--text-main);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
  }

  .drawer-item:active {
    background: rgba(255, 255, 255, 0.08);
  }

  .drawer-item-danger {
    color: var(--accent-crimson);
    border-color: rgba(251, 113, 133, 0.28);
  }

  .drawer-item-muted {
    color: var(--text-muted);
  }

  /* 데스크톱 3단 그리드를 모바일 단일 활성 뷰로 전환 */
  .main-grid {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  #desktop-center-tabs {
    display: none;
  }

  .main-grid > .panel {
    display: none;
    flex: 1;
    min-height: 0;
    max-height: none;
    border-radius: var(--radius-md);
  }

  /* 활성 모바일 탭에 따른 패널 노출 제어 */
  .main-grid[data-mobile-tab="globe"] #center-stage-panel,
  .main-grid[data-mobile-tab="events"] #center-stage-panel,
  .main-grid[data-mobile-tab="chat"] #center-stage-panel {
    display: flex;
  }

  .main-grid[data-mobile-tab="entities"] #world-entities-panel {
    display: flex;
  }

  .main-grid[data-mobile-tab="me"] #constellation-panel {
    display: flex;
  }

  .world-split {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  .main-grid[data-mobile-tab="globe"] .globe-pane {
    display: flex;
    flex: 1;
    border-right: none;
  }

  .main-grid[data-mobile-tab="globe"] .events-pane {
    display: none;
  }

  .main-grid[data-mobile-tab="events"] .globe-pane {
    display: none;
  }

  .main-grid[data-mobile-tab="events"] .events-pane {
    display: flex;
    flex: 1;
  }

  .tile-inspector {
    height: 116px;
    min-height: 116px;
    max-height: 116px;
    justify-content: flex-start;
  }

  /* 모바일 하단 내비게이션 바 (모던 라인 아이콘) */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    background: var(--bg-panel);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 4px 6px;
    flex-shrink: 0;
  }

  .mobile-nav-btn {
    border: none;
    background: transparent;
    color: var(--text-dim);
    padding: 6px 2px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
  }

  .mobile-nav-btn .nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-nav-btn.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.055);
  }

  .mobile-nav-btn.active .nav-icon {
    color: var(--accent-indigo-light);
  }

  /* 모바일 입력창 자동 줌 방지 (16px) 및 슬림 컴포저 */
  input, select, textarea {
    font-size: 16px;
  }

  .auth-card {
    padding: 20px 18px;
  }

  .oracle-options-strip {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .oracle-options-strip select[name="targetTileId"] {
    grid-column: 1 / -1;
  }

  .pill-select {
    font-size: 12.5px;
    padding: 6px 10px;
  }

  .composer {
    padding: 7px 10px 9px;
    gap: 6px;
  }

  .composer-pill textarea {
    font-size: 16px;
    line-height: 22px;
    height: 32px;
    min-height: 32px;
    padding: 5px 0;
  }

  .msg-row {
    max-width: 94%;
  }

  .msg-bubble {
    padding: 9px 11px;
  }

  .dice-badge-toggle {
    font-size: 10px;
    gap: 4px;
    padding: 3px 7px;
  }

  .dice-badge-main {
    gap: 2px 3px;
    flex-wrap: nowrap;
  }

  .dice-expand-caret {
    padding-left: 4px;
    font-size: 9.5px;
  }

  .chat-floating-popover {
    max-width: none;
  }

  .spec-action-item {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .spec-action-controls {
    width: 100%;
  }

  .spec-target-select {
    flex: 1;
    max-width: none;
  }

  /* 모달 반응형 */
  .modal-backdrop {
    padding: 8px;
    align-items: flex-end;
  }

  .modal-content {
    max-height: 90dvh;
    padding: 16px;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-md) var(--radius-md);
  }

  .modal-header-sticky {
    top: -16px;
    margin: -16px -16px 2px;
    padding: 13px 16px 11px;
  }

  .tabs .btn {
    font-size: 12px;
    padding: 7px 6px;
    gap: 4px;
  }

  .tab-sub {
    font-size: 10px;
    padding: 1px 5px;
  }

  .market-grid,
  .trade-form-grid,
  .invite-form-grid {
    grid-template-columns: 1fr;
  }

  .toast-container {
    bottom: 68px;
    right: 12px;
    left: 12px;
    align-items: center;
  }
}
