/* ═══════════════════════════════════════════════════════
   SHELL / RESPONSIVE — قواعد التجاوب العامة
   ═══════════════════════════════════════════════════════ */

/* ── DESKTOP ── */
@media(min-width:1024px) {
  .bottom-nav {
    display: none !important;
  }
  .sidebar {
    display: flex !important;
  }
  .scr {
    padding-bottom: 0 !important;
  }
  .tbody {
    padding-bottom: 40px !important;
  }
  .wrap {
    max-width: 820px;
    margin: 0 auto;
    padding: 16px 20px 40px;
  }
  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
  .game-grid-enhanced {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .modal-sheet {
    max-width: 520px;
    border-radius: var(--radius) !important;
    margin: auto;
  }
  .modal-overlay {
    align-items: center !important;
  }
  .bottom-nav {
    max-width: 500px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
  }
}

/* ── TABLET ── */
@media(min-width:768px) and (max-width:1023px) {
  .bottom-nav {
    display: none !important;
  }
  .sidebar {
    display: flex !important;
    width: 56px;
  }
  .nb .ni {
    font-size: 1.1rem;
  }
  .nb .nl {
    font-size: .34rem;
  }
  .scr {
    padding-bottom: 0 !important;
  }
  .tbody {
    padding-bottom: 40px !important;
  }
  .wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 12px 16px 30px;
  }
  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
  .game-grid-enhanced {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── MOBILE ── */
@media(max-width:767px) {
  .sidebar {
    display: none !important;
  }
  .bottom-nav {
    display: block !important;
  }
  .app {
    flex-direction: column;
  }
  .main {
    flex: 1;
    overflow: hidden;
  }
  .scr {
    padding-bottom: 72px !important;
  }
  .tbody {
    padding-bottom: 80px !important;
  }
  .wrap {
    padding: 8px 10px 20px;
  }
  
  /* Dashboard */
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px;
  }
  .dashboard-card {
    padding: 10px 8px;
  }
  .dashboard-card .dc-value {
    font-size: 1rem;
  }
  
  /* Games */
  .game-grid-enhanced {
    grid-template-columns: 1fr !important;
  }
  
  /* Stats */
  .stat4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  
  /* Quiz */
  .qword {
    font-size: 1.4rem;
  }
  .srsrow {
    grid-template-columns: repeat(2, 1fr);
  }
  .srsb {
    padding: 6px 2px;
    font-size: .5rem;
  }
  
  /* Modal */
  .modal {
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
  }
  .mw {
    font-size: 1.3rem;
  }
  .modal-header {
    padding: 10px 12px;
    flex-wrap: wrap;
  }
  .modal-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }
  .modal-ar {
    font-size: .75rem;
  }
  .modal-body {
    padding: 10px 12px;
    gap: 8px;
  }
  
  /* Navigation */
  .bn-btn {
    min-width: 40px;
    padding: 2px 4px;
  }
  .bn-btn .ni {
    font-size: 1rem;
  }
  .bn-btn .nl {
    font-size: .35rem;
  }
  .bn-btn .badge {
    font-size: .32rem;
    padding: 1px 4px;
    min-width: 12px;
  }
  
  /* Achievements */
  .achieve-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  /* Compact elements */
  .compact-progress {
    flex-wrap: wrap;
    gap: 4px;
  }
  .compact-progress .cp-label {
    min-width: 40px;
    font-size: 0.4rem;
  }
  .compact-progress .cp-value {
    font-size: 0.35rem;
  }
  
  /* Toast */
  .xp-toast {
    font-size: .6rem;
    padding: 4px 12px;
    top: 48px;
    white-space: normal;
    max-width: 90%;
  }
  
  /* Tree */
  .tr-node {
    width: 100px;
    padding: 6px 7px 14px;
  }
  .tr-gnode {
    width: 80px;
    padding: 5px 6px 11px;
  }
  .tr-word {
    font-size: .65rem;
  }
  .tr-gnode .tr-word {
    font-size: .55rem;
  }
}

/* ── SMALL MOBILE ── */
@media(max-width:480px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 4px;
  }
  .dashboard-card .dc-value {
    font-size: 0.85rem;
  }
  .dashboard-card .dc-icon {
    font-size: 1.1rem;
  }
  .dashboard-card .dc-label {
    font-size: 0.38rem;
  }
  
  .main-tab {
    padding: 4px 8px;
    font-size: 0.45rem;
  }
  .main-tab .tab-icon {
    font-size: 0.6rem;
  }
  
  .section-header {
    padding: 8px 10px;
  }
  .section-header .sh-title {
    font-size: 0.5rem;
  }
  .section-body {
    padding: 0 10px 10px;
  }
  
  .game-card-enhanced {
    padding: 12px 10px !important;
  }
  .game-card-enhanced .cc-icon {
    font-size: 1.4rem !important;
  }
  .game-card-enhanced .cc-title {
    font-size: 0.6rem !important;
  }
  
  .bottom-nav {
    height: 52px;
    padding: 2px 0 6px;
  }
  .bn-btn {
    min-width: 32px;
  }
  .bn-btn .ni {
    font-size: 0.85rem;
  }
  .bn-btn .nl {
    font-size: 0.3rem;
  }
  
  .modal-word {
    font-size: 1.1rem;
  }
  .modal-ph {
    font-size: 0.6rem;
  }
  .srs-btn {
    font-size: 0.45rem;
    padding: 6px 2px;
  }
  .srs-btn .se {
    font-size: 0.7rem;
  }
}

/* ── REDUCED MOTION ── */
@media(prefers-reduced-motion:reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ── SAFE AREA (NOTCH) ── */
@supports (padding: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 4px);
  }
  .scr {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }
}