/* ════════════════════════════════════════════════════════════════════
   TypeArena — PREMIUM MOBILE DESIGN v7
   Дизайн вдохновлён Duolingo, Telegram, Figma
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* ═══════════════════════════════════════════════════════════════ */
  /* COLOR SCHEME & GRADIENTS */
  /* ═══════════════════════════════════════════════════════════════ */

  :root {
    --primary: #58a6ff;
    --primary-dark: #3d8fd1;
    --success: #3fb950;
    --warning: #ffc832;
    --danger: #ff6464;
    --accent: #58a6ff;
    --bg: #0d1117;
    --bg2: #161b22;
    --bg3: #21262d;
    --border: #30363d;
    --text: #e6edd3;
    --text2: #8b949e;
    --text-muted: #6e7681;
  }

  /* ═══════════════════════════════════════════════════════════════ */
  /* MAIN LAYOUT */
  /* ═══════════════════════════════════════════════════════════════ */

  html, body {
    position: fixed;
    width: 100%;
    height: 100vh;
    overflow: hidden;
  }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Manrope', system-ui, sans-serif;
  }

  #app {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
  }

  /* ═══════════════════════════════════════════════════════════════ */
  /* MAIN CONTENT */
  /* ═══════════════════════════════════════════════════════════════ */

  .topbar, .profile-pill, .topbar-spacer {
    display: none !important;
  }

  .main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
  }

  /* ═══════════════════════════════════════════════════════════════ */
  /* PAGES - АБСОЛЮТНОЕ ПОЗИЦИОНИРОВАНИЕ */
  /* ═══════════════════════════════════════════════════════════════ */

  .page {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    padding: 0 !important;
    display: none !important;
    z-index: 1;
  }

  .page.visible {
    display: block !important;
    animation: pageSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }

  @keyframes pageSlideIn {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* ═══════════════════════════════════════════════════════════════ */
  /* MODES PAGE */
  /* ═══════════════════════════════════════════════════════════════ */

  #page-modes {
    padding: 16px 12px 80px !important;
    background: linear-gradient(
      to bottom,
      var(--bg) 0%,
      rgba(13, 17, 23, 0.95) 50%,
      var(--bg) 100%
    );
  }

  .modes-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .modes-header {
    text-align: center;
    padding: 24px 0 16px;
    background: linear-gradient(
      135deg,
      rgba(88, 166, 255, 0.1),
      rgba(88, 166, 255, 0.05)
    );
    border-radius: 16px;
    margin-bottom: 8px;
  }

  .modes-header h2 {
    font-size: 2rem;
    font-weight: 900;
    margin: 0 0 8px;
    background: linear-gradient(135deg, var(--accent), #7bccff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .modes-header p {
    font-size: 0.95rem;
    color: var(--text2);
    margin: 0;
  }

  /* ─────── FILTER BUTTONS ─────── */
  .modes-filter {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: rgba(22, 27, 34, 0.5);
    border-radius: 12px;
    overflow-x: auto;
    margin-bottom: 8px;
    scrollbar-width: none;
  }

  .modes-filter::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text2);
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
  }

  .filter-btn:active {
    transform: scale(0.95);
  }

  .filter-btn.active {
    background: linear-gradient(135deg, var(--primary), #3d8fd1);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
  }

  /* ─────── MODE CARDS ─────── */
  .modes-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .mode-card-large {
    background: linear-gradient(135deg, var(--bg2), rgba(22, 27, 34, 0.5));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .mode-card-large::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
      90deg,
      transparent,
      rgba(88, 166, 255, 0.3),
      transparent
    );
  }

  .mode-card-large:active {
    transform: scale(0.98);
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(22, 27, 34, 0.8), rgba(22, 27, 34, 0.6));
    box-shadow: 0 8px 24px rgba(88, 166, 255, 0.15);
  }

  /* ─────── CARD HEADER ─────── */
  .mcl-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
  }

  .mcl-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(88, 166, 255, 0.2));
  }

  .mcl-info {
    flex: 1;
  }

  .mcl-name {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--text);
    margin: 0;
  }

  .mcl-tag {
    font-size: 0.8rem;
    color: var(--warning);
    font-weight: 700;
    margin-top: 4px;
  }

  /* ─────── CARD DESCRIPTION ─────── */
  .mcl-description {
    font-size: 0.9rem;
    color: var(--text2);
    line-height: 1.5;
    margin: 0;
  }

  /* ─────── STATS BADGES ─────── */
  .mcl-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .stat-badge {
    padding: 8px 10px;
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.2);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    color: var(--text2);
    line-height: 1.3;
  }

  /* ─────── CARD ACTIONS ─────── */
  .mcl-actions {
    display: flex;
    gap: 8px;
  }

  .mcl-play-btn {
    flex: 1;
    padding: 10px 12px;
    background: linear-gradient(135deg, var(--primary), #3d8fd1);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.2);
  }

  .mcl-play-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 6px rgba(88, 166, 255, 0.15);
  }

  .mcl-info-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.2);
    border-radius: 10px;
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
  }

  .mcl-info-btn:active {
    background: rgba(88, 166, 255, 0.2);
    border-color: var(--primary);
  }

  /* ═══════════════════════════════════════════════════════════════ */
  /* BOTTOM NAVIGATION */
  /* ═══════════════════════════════════════════════════════════════ */

  .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(
      to top,
      rgba(13, 17, 23, 0.98),
      rgba(13, 17, 23, 0.92)
    );
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(8px);
  }

  .bottom-nav-btn {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
  }

  .bottom-nav-btn:active {
    transform: scale(0.9);
  }

  .bottom-nav-btn.active {
    color: var(--primary);
  }

  .bottom-nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 24px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), transparent);
    border-radius: 1.5px;
  }

  .bottom-nav-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  /* ═══════════════════════════════════════════════════════════════ */
  /* HOME PAGE IMPROVEMENTS */
  /* ═══════════════════════════════════════════════════════════════ */

  #page-home {
    background: linear-gradient(
      to bottom,
      var(--bg),
      rgba(88, 166, 255, 0.05) 50%,
      var(--bg)
    );
    padding: 20px 12px 80px !important;
  }

  .home-hero {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.15), rgba(88, 166, 255, 0.05));
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
    border: 1px solid rgba(88, 166, 255, 0.2);
  }

  .home-greeting {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 8px;
  }

  /* ═══════════════════════════════════════════════════════════════ */
  /* SHOP PAGE IMPROVEMENTS */
  /* ═══════════════════════════════════════════════════════════════ */

  #page-shop {
    padding: 16px 12px 80px !important;
    background: linear-gradient(
      to bottom,
      var(--bg),
      rgba(88, 166, 255, 0.03),
      var(--bg)
    );
  }

  .shop-header {
    text-align: center;
    padding: 20px 0;
    background: linear-gradient(135deg, rgba(255, 200, 50, 0.1), rgba(255, 200, 50, 0.05));
    border-radius: 16px;
    margin-bottom: 16px;
  }

  .shop-header h2 {
    font-size: 1.8rem;
    font-weight: 900;
    margin: 0 0 8px;
    color: var(--warning);
  }

  .shop-item {
    background: linear-gradient(135deg, var(--bg2), rgba(22, 27, 34, 0.5));
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .shop-item:active {
    transform: translateY(-2px);
    border-color: var(--warning);
    box-shadow: 0 6px 16px rgba(255, 200, 50, 0.15);
  }

  /* ═══════════════════════════════════════════════════════════════ */
  /* SCROLLBAR */
  /* ═══════════════════════════════════════════════════════════════ */

  .page::-webkit-scrollbar {
    width: 4px;
  }

  .page::-webkit-scrollbar-track {
    background: transparent;
  }

  .page::-webkit-scrollbar-thumb {
    background: rgba(88, 166, 255, 0.3);
    border-radius: 2px;
    transition: background 0.2s;
  }

  .page::-webkit-scrollbar-thumb:hover {
    background: rgba(88, 166, 255, 0.5);
  }

  /* ═══════════════════════════════════════════════════════════════ */
  /* GRAPHICS OPTIMIZATION */
  /* ═══════════════════════════════════════════════════════════════ */

  body[data-graphics="low"] .mode-card-large,
  body[data-graphics="low"] .shop-item {
    box-shadow: none;
  }

  body[data-graphics="low"] .modes-header,
  body[data-graphics="low"] .shop-header,
  body[data-graphics="low"] .home-hero {
    background: transparent;
  }

  body[data-graphics="high"] .mode-card-large:active,
  body[data-graphics="high"] .shop-item:active {
    box-shadow: 0 12px 32px rgba(88, 166, 255, 0.25);
  }

  body[data-graphics="high"] .bottom-nav {
    backdrop-filter: blur(12px);
    box-shadow: 0 -8px 24px rgba(88, 166, 255, 0.1);
  }
}
