/* =========================================================
   Styles/mobile.css - F1.com "Compact List" Mobile Overrides
   Design Language: Sharp edges, solid darks, tight lists
   ========================================================= */

:root {
  --f1-red: #e10600;
  --f1-dark: #15151e;
  --f1-grey: #333333;
  --f1-light: #f4f4f4;
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 20px);
}

@media (max-width: 768px) {
  /* =========================================================
     1. GLOBAL F1 TYPOGRAPHY & LAYOUT
     ========================================================= */
  html, body {
    overflow-x: hidden;
    width: 100%;
    background-color: #000 !important; 
  }

  .dashboard-main, .about-main, .schedule-main, .circuits-main, 
  .drivers-main, .teams-main, .results-main, .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  h1, .hero-content h1, .bento-hero h1, .hero h1, .schedule-hero h1, .circuits-hero h1 {
    font-size: 1.8rem !important;
    font-weight: 900 !important;
    text-transform: uppercase !important;
    line-height: 1.05;
    letter-spacing: 0.5px;
    border-right: 4px solid var(--f1-red);
    padding-right: 10px;
    display: inline-block;
  }

  h2, .section-title, .box-header h3, .section-header h2, .cta-content h2 {
    font-size: 1.2rem !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
  }

  .hero-actions, .filter-controls, .controls, .schedule-filters, .filter-buttons, .sort-options {
    display: flex !important;
    flex-direction: column !important;
    width: 100%;
    gap: 10px !important;
  }

  .btn, .filter-btn, .controls select, .controls button, #sort-select {
    width: 100% !important;
    padding: 14px !important;
    font-size: 0.9rem !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    border-radius: 0 12px 0 0 !important; 
    background-color: var(--f1-red) !important;
    color: #fff !important;
    border: none !important;
  }

  .btn-outline, .filter-btn {
    background-color: transparent !important;
    border: 2px solid var(--f1-grey) !important;
    color: #fff !important;
  }

  /* =========================================================
     2. TEAMS & DRIVERS (COMPACT HORIZONTAL ROWS)
     ========================================================= */
  .teams-main .teams-grid, 
  .drivers-main .drivers-grid {
    display: flex !important;
    flex-direction: column !important; 
    gap: 10px !important;
  }

  .team-card, .driver-card {
    min-height: 90px !important; 
    max-height: 110px !important;
    flex-direction: row !important; 
    background: var(--f1-dark) !important;
    border: 1px solid var(--f1-grey) !important;
    border-right: 3px solid var(--f1-red) !important;
    border-radius: 0 16px 0 0 !important;
    padding: 0 !important;
    position: relative;
    box-shadow: none !important;
  }

  .driver-header, .team-header {
    flex: 1 !important;
    padding: 16px !important;
    background: transparent !important;
    border: none !important;
    z-index: 2 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: flex-start !important;
  }

  .driver-header h2, .team-header h2 {
    font-size: 1.2rem !important;
    color: #fff !important;
    margin: 0 !important;
    z-index: 3 !important;
  }

  /* Force hide the Location Text and Logo for a clean layout */
  .team-card .team-base,
  .team-card .team-logo {
    display: none !important;
  }

  /* Fade image out on the left side so text is readable */
  .driver-image, .team-image {
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    width: 50% !important; 
    height: 100% !important;
    opacity: 1 !important;
    z-index: 1 !important;
    mask-image: linear-gradient(to right, transparent 0%, black 40%) !important;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 40%) !important;
  }
  
  .driver-image img, .team-image img {
    width: 100% !important;
    height: 100% !important;
  }

  /* Keep driver faces at top, keep cars fully contained and centered right */
  .driver-image img {
    object-fit: cover !important; 
    object-position: top center !important; 
  }
  
  .team-image img {
    object-fit: contain !important; 
    object-position: right center !important; 
  }

  /* Hide the extra details and stats on the main list */
  .driver-details, .team-details {
    display: none !important; 
  }
  
  .driver-header .d-num {
    position: static !important;
    font-size: 1.4rem !important;
    color: var(--f1-red) !important;
    line-height: 1 !important;
    margin-bottom: 4px !important;
  }

  /* =========================================================
     3. CADILLAC & DARK CAR MASTER FIX
     ========================================================= */
  
  /* Force ALL text in the Cadillac header to be White */
  .team-card[data-team="cadillac"] .team-header,
  .team-card[data-team="cadillac"] .team-header h2 {
    color: #ffffff !important;
  }

  /* Force the Cadillac Championship Position (#11) to be F1 Red */
  .team-card[data-team="cadillac"] .championship-position {
    color: var(--f1-red) !important;
  }

  /* Ultimate Cadillac Car visibility fix */
  .team-card[data-team="cadillac"] .team-image {
    mask-image: none !important; 
    -webkit-mask-image: none !important;
    background: radial-gradient(circle at right, rgba(255, 255, 255, 0.15) 0%, transparent 70%) !important;
  }
  
  .team-card[data-team="cadillac"] .team-image img {
    filter: drop-shadow(0px 0px 12px rgba(255, 255, 255, 0.4)) brightness(1.4) contrast(1.2) !important;
  }

  /* =========================================================
     4. SCHEDULE & CIRCUITS (COMPACT HORIZONTAL LISTS)
     ========================================================= */
  #schedule-container, .circuits-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding: 12px !important;
  }

  .race-card, .circuit-card { 
    min-height: 70px !important; 
    padding: 12px 16px !important; 
    border-radius: 0 12px 0 0 !important; 
    background: var(--f1-dark) !important;
    border: 1px solid var(--f1-grey) !important;
    border-left: 4px solid var(--f1-red) !important; 
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    cursor: pointer;
    box-shadow: none !important;
  }

  .race-card .race-info { margin: 0 !important; flex: 1; }
  .race-card h2 { font-size: 1.1rem !important; margin: 0 !important; color: #fff !important; }
  .race-card .race-header { margin: 0 !important; border: none !important; padding: 0 !important; width: auto !important; }
  .race-card .race-round { font-size: 0.75rem !important; padding: 4px 8px !important; margin-right: 12px; }
  .race-card .circuit-details, .race-card .sessions-grid, .race-card .race-badges { display: none !important; }
  .race-card::after { content: '›'; color: var(--f1-red); font-size: 1.8rem; margin-left: 12px; line-height: 0.5; }

  .circuit-card .circuit-image { display: none !important; }
  .circuit-card .circuit-content { padding: 0 !important; flex: 1; display: flex; align-items: center; }
  .circuit-card .circuit-header { margin: 0 !important; flex: 1; }
  .circuit-card .circuit-name { font-size: 1.1rem !important; margin: 0 !important; color: #fff !important; }
  .circuit-card .gp-badge { display: none !important; }
  .circuit-card .circuit-location, .circuit-card .circuit-info, .circuit-card .circuit-description, .circuit-card .circuit-actions { display: none !important; }
  .circuit-card::after { content: '›'; color: var(--f1-red); font-size: 1.8rem; margin-left: 12px; line-height: 0.5; }

  /* =========================================================
     5. BENTO DASHBOARD (Tighter Spacing)
     ========================================================= */
  .bento-grid {
    gap: 12px !important;
  }
  .bento-card {
    background: var(--f1-dark) !important; 
    border: 1px solid var(--f1-grey) !important;
    border-right: 3px solid var(--f1-red) !important; 
    border-radius: 0 16px 0 0 !important; 
  }
  .bento-content {
    padding: 16px !important;
  }

  /* =========================================================
     6. RESULTS PAGE CONTROLS (GRID FIX)
     ========================================================= */
  
  .controls {
    display: grid !important;
    /* Season gets fixed 85px, Race takes the rest of the space */
    grid-template-columns: 85px 1fr !important; 
    width: 100% !important;
    gap: 10px !important;
    margin-top: 16px !important;
    /* Remove any previous horizontal scrolling */
    overflow: visible !important; 
    flex-direction: unset !important; 
  }

  .controls select, .controls button {
    width: 100% !important;
    min-width: 0 !important; /* Crucial to prevent text from blowing out the grid */
    border-radius: 12px !important; 
    padding: 12px 14px !important;
    font-size: 0.9rem !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
  }

  /* Position elements on the grid */
  #seasonSelect {
    grid-column: 1 !important;
  }

  #raceSelect {
    grid-column: 2 !important;
  }

  #loadBtn {
    grid-column: 1 / -1 !important; /* Spans the full width across both columns */
    background: var(--f1-red) !important;
    border-color: var(--f1-red) !important;
    margin-top: 4px !important;
  }

  /* Custom Dropdown Arrow to prevent text overlap */
  .controls select {
    appearance: none !important;
    -webkit-appearance: none !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 16px !important;
    padding-right: 36px !important; /* Strict padding so text never touches the arrow */
    overflow: hidden !important;
    text-overflow: ellipsis !important; /* Adds the "..." when race names are too long */
  }

  /* Rip out the table structure and convert to an App List */
  .results-table, .results-table tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important; 
    background: transparent !important;
    border: none !important;
    width: 100% !important;
    box-shadow: none !important;
  }

  .results-table thead { 
    display: none !important; 
  }

  /* Main Leaderboard Card */
  .results-table tr {
    display: grid !important;
    grid-template-columns: 45px 1fr auto !important;
    grid-template-rows: auto auto !important;
    background: #111115 !important;
    border: 1px solid #222 !important;
    border-radius: 16px !important;
    padding: 16px !important;
    align-items: center !important;
    position: relative !important;
    overflow: hidden !important;
  }

  .results-table td {
    border: none !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    background: transparent !important;
  }

  /* 1. Position Number (Massive & Italicized) */
  .results-table td:nth-child(1) {
    grid-column: 1;
    grid-row: 1 / span 2;
    font-size: 1.8rem !important;
    font-weight: 900 !important;
    color: #fff !important;
    justify-content: center !important;
    font-style: italic !important;
  }

  /* 2. Driver Number - Hide to save space */
  .results-table td:nth-child(2) { display: none !important; }

  /* 3. Driver Name */
  .results-table td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
    font-size: 1.15rem !important;
    font-weight: 900 !important;
    text-transform: uppercase !important;
    color: #fff !important;
    letter-spacing: 0.5px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* 4. Constructor / Team Name */
  .results-table td:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.8rem !important;
    color: #888 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
  }

  /* 9. Points (Big Red Number on the right) */
  .results-table td:nth-child(9) {
    grid-column: 3;
    grid-row: 1 / span 2;
    font-size: 1.5rem !important;
    font-weight: 900 !important;
    color: var(--f1-red) !important;
    justify-content: flex-end !important;
    text-align: right !important;
    min-width: 60px !important;
  }

  .results-table td:nth-child(9)::after {
    content: "PTS";
    font-size: 0.65rem !important;
    font-weight: 700 !important;
    color: #666 !important;
    margin-left: 4px !important;
    margin-top: 6px !important; 
  }

  /* -- TECHNICAL STATS ACCORDION -- */
  /* Hide Clutter (Grid Pos, Laps, Fastest Lap) and isolate the GAP/Time */
  .results-table td:nth-child(5), 
  .results-table td:nth-child(6), 
  .results-table td:nth-child(8) {
    display: none !important; 
  }

  .results-table td:nth-child(7) {
    grid-column: 1 / -1; 
    font-size: 0.9rem !important;
    color: #aaa !important;
    font-family: monospace !important;
    justify-content: space-between !important;
    border-top: 1px solid rgba(255,255,255,0.06) !important;
    padding-top: 10px !important;
    margin-top: 10px !important;
  }

  .results-table td:nth-child(7)::before {
    content: "GAP / STATUS";
    font-family: var(--font-main, sans-serif) !important;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    color: #555 !important;
    letter-spacing: 1px !important;
  }

  /* =========================================================
     PODIUM SPECIAL METALLIC STYLING (P1, P2, P3)
     ========================================================= */
  
  /* P1 - Pure Gold */
  .results-table tr:nth-child(1) {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), #111115) !important;
    border: 1px solid rgba(212, 175, 55, 0.4) !important;
    border-left: 6px solid #d4af37 !important;
    transform: scale(1.02) !important;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4) !important;
    margin-bottom: 8px !important;
    z-index: 3 !important;
  }
  .results-table tr:nth-child(1) td:nth-child(1) { color: #d4af37 !important; }

  /* P2 - Silver */
  .results-table tr:nth-child(2) {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.1), #111115) !important;
    border: 1px solid rgba(192, 192, 192, 0.3) !important;
    border-left: 6px solid #c0c0c0 !important;
    transform: scale(1.01) !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
    margin-bottom: 4px !important;
    z-index: 2 !important;
  }
  .results-table tr:nth-child(2) td:nth-child(1) { color: #c0c0c0 !important; }

  /* P3 - Bronze */
  .results-table tr:nth-child(3) {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.1), #111115) !important;
    border: 1px solid rgba(205, 127, 50, 0.3) !important;
    border-left: 6px solid #cd7f32 !important;
    margin-bottom: 16px !important; /* Deep split separating the podium from the rest */
    z-index: 1 !important;
  }
  .results-table tr:nth-child(3) td:nth-child(1) { color: #cd7f32 !important; }

  /* Standard Border for the rest (P4 - P20) */
  .results-table tr:nth-child(n+4) {
    border-left: 4px solid var(--f1-grey) !important;
  }
  
  /* =========================================================
     7. F1 OFFICIAL FOOTER STYLE
     ========================================================= */
  .site-footer {
    background: #000 !important;
    border-top: 4px solid var(--f1-red) !important;
    padding: 40px 12px 20px !important;
  }
  .footer-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem !important;
    text-align: left !important; 
  }
  .footer-links, .footer-cta {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    border-bottom: 1px solid var(--f1-grey) !important;
    padding-bottom: 1rem !important;
    width: 100%;
  }

  

  /* =========================================================
     8. MOBILE-ONLY BOTTOM SHEET MODALS
     ========================================================= */
  .mobile-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); z-index: 9999;
    display: flex; flex-direction: column; justify-content: flex-end;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
  }
  .mobile-modal-overlay.active {
    opacity: 1; pointer-events: auto;
  }
  .mobile-modal-content {
    background: var(--f1-dark); width: 100%;
    border-top: 4px solid var(--f1-red);
    border-radius: 24px 24px 0 0; padding: 30px 20px;
    transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    max-height: 85vh; overflow-y: auto; position: relative;
  }
  .mobile-modal-overlay.active .mobile-modal-content {
    transform: translateY(0);
  }
  .mobile-modal-close {
    position: absolute; top: 15px; right: 20px;
    background: #000; color: #fff; border: 1px solid var(--f1-grey);
    width: 32px; height: 32px; border-radius: 50%;
    font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
    cursor: pointer;
  }
  
  .mobile-modal-content h2 { font-size: 1.6rem !important; margin-bottom: 12px !important; color: #fff; }
  .mobile-modal-content .sessions-grid, .mobile-modal-content .circuit-info { display: flex !important; flex-direction: column; gap: 10px; margin-top: 20px; }
  .mobile-modal-content .session-card, .mobile-modal-content .info-item { 
    background: #000; padding: 12px; border: 1px solid var(--f1-grey); border-radius: 0 12px 0 0;
    display: flex; justify-content: space-between; align-items: center;
  }
  .mobile-modal-content .circuit-image { display: block !important; width: 100%; height: 150px; border-radius: 0 16px 0 0; margin-bottom: 20px; }
  .mobile-modal-content .circuit-description { margin-top: 20px; color: #ccc; line-height: 1.5; font-size: 0.95rem; }

  /* =========================================================
     9. TEAMS CHAMPIONSHIP STANDINGS (Mobile Leaderboard)
     ========================================================= */
  .championship-section {
    padding: 0 0 40px 0 !important;
  }

  .championship-section .section-title {
    font-size: 1.4rem !important;
    margin-bottom: 20px !important;
    text-align: left !important;
    border-right: 4px solid var(--f1-red);
    padding-right: 10px;
    display: inline-block;
  }

  .championship-table {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  .championship-table .table-header { display: none !important; }

  .championship-table .table-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: var(--f1-dark) !important;
    border: 1px solid var(--f1-grey) !important;
    border-left: 4px solid var(--f1-red) !important;
    border-radius: 0 16px 0 0 !important; 
    padding: 14px 16px !important;
    margin: 0 !important;
  }

  .championship-table .table-row > div:nth-child(1) {
    font-size: 1.4rem !important;
    font-weight: 900 !important;
    color: #fff !important;
    width: 35px !important;
  }

  .championship-table .table-row > div:nth-child(2) {
    flex: 1 !important;
    font-size: 1.1rem !important;
    font-weight: 800 !important;
    color: #fff !important;
    text-transform: uppercase !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
  }

  .championship-table .table-row > div:nth-child(3) {
    font-size: 1.3rem !important;
    font-weight: 900 !important;
    color: var(--f1-red) !important;
  }

  .championship-table .table-row > div:nth-child(3)::after {
    content: " PTS";
    font-size: 0.7rem;
    color: #888;
    margin-left: 4px;
  }

  .team-color {
    width: 12px !important;
    height: 12px !important;
    border-radius: 50% !important;
    display: inline-block !important;
    box-shadow: 0 0 8px currentColor; 
  }

  /* =========================================================
     10. INDIVIDUAL CAR PAGES (Alpine, Ferrari, etc.)
     ========================================================= */
  .car-main { 
    padding: 12px !important; 
  }
  
  .car-hero {
    min-height: 250px !important; 
    padding: 30px 16px !important; 
    border-radius: 0 16px 0 0 !important; 
    border-right: 4px solid var(--f1-red) !important;
    margin-bottom: 20px !important;
  }
  
  .car-hero h1 { font-size: 2.5rem !important; margin-bottom: 8px !important; }
  .car-hero .subtitle { font-size: 1rem !important; }

  .content-grid { 
    display: flex !important; 
    flex-direction: column !important; 
    gap: 16px !important; 
    margin-bottom: 20px !important;
  }
  
  .main-content, .specs-card, .technical-section {
    padding: 20px 16px !important; 
    border-radius: 0 16px 0 0 !important; 
    background: var(--f1-dark) !important;
    border: 1px solid var(--f1-grey) !important;
    border-left: 3px solid var(--f1-red) !important;
  }

  .stat-highlight {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin: 20px 0 !important;
  }

  .stat-box { 
    padding: 16px 12px !important; 
    border-radius: 0 12px 0 0 !important; 
    background: #000 !important;
    border: 1px solid var(--f1-grey) !important;
  }
  
  .stat-number { font-size: 1.6rem !important; }
  .stat-text { font-size: 0.75rem !important; }

  .drivers-showcase { 
    display: flex !important; 
    flex-direction: column !important; 
    gap: 16px !important; 
  }

  .driver-card-large {
    border-radius: 0 16px 0 0 !important;
    background: var(--f1-dark) !important;
    border: 1px solid var(--f1-grey) !important;
  }

  .driver-image-wrap { height: 200px !important; }

  /* =========================================================
     11. ABOUT PAGE (Mobile Adjustments)
     ========================================================= */
  .dev-socials {
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .social-btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 16px !important;
    border-radius: 12px !important; 
  }

  /* =========================================================
     12. HERO SECTIONS (DRIVERS & TEAMS)
     ========================================================= */
  .drivers-hero, .teams-hero {
    flex-direction: column !important;
    align-items: flex-start !important;
    padding: 24px 20px !important;
    gap: 24px !important;
    border-radius: 0 20px 0 0 !important;
    background: var(--f1-dark) !important;
    border: 1px solid var(--f1-grey) !important;
    border-left: 4px solid var(--f1-red) !important;
    margin-bottom: 24px !important;
  }

  .hero-subtitle {
    font-size: 0.95rem !important;
    margin-top: 12px !important;
    line-height: 1.5 !important;
    color: #bbb !important;
  }

  .drivers-stats, .teams-stats {
    display: flex !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .stat-item {
    flex: 1 1 calc(33.333% - 8px) !important;
    padding: 12px 8px !important;
    background: #000 !important;
    border: 1px solid var(--f1-grey) !important;
    border-radius: 0 12px 0 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .stat-item .stat-number {
    font-size: 1.4rem !important;
    color: var(--f1-red) !important;
  }

  .stat-item .stat-label {
    font-size: 0.65rem !important;
    letter-spacing: 0.5px !important;
  }

  /* Specific fix for the 'View Results' button container inside the Teams hero */
  .teams-stats div[style*="display:flex"] {
    width: 100% !important;
    margin-left: 0 !important;
    margin-top: 8px !important;
  }

  /* =========================================================
     13. THE "BEST" UX UPGRADE: Scrollable Pill Filters
     ========================================================= */
  /* Overriding the vertical stack from Section 1 for a sleek horizontal scroll */
  .filter-controls, .schedule-filters, .filter-buttons {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 12px !important; /* Breathing room */
    gap: 12px !important;
    
    /* Hiding the ugly scrollbar */
    scrollbar-width: none !important; 
    -ms-overflow-style: none !important; 
  }
  
  .filter-controls::-webkit-scrollbar, 
  .schedule-filters::-webkit-scrollbar, 
  .filter-buttons::-webkit-scrollbar {
    display: none !important;
  }

  /* Converting block buttons into modern swipeable pills */
  .filter-btn, .btn-outline {
    flex: 0 0 auto !important; /* Stops them from shrinking */
    width: auto !important; /* Removes the old 100% stretch */
    scroll-snap-align: start !important;
    padding: 12px 24px !important;
    border-radius: 50px !important; /* Perfect pill shape */
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    font-size: 0.85rem !important;
    white-space: nowrap !important;
    letter-spacing: 0.5px !important;
  }

  .filter-btn.active, .btn-outline.active {
    background: var(--f1-red) !important;
    color: #fff !important;
    border-color: var(--f1-red) !important;
    box-shadow: 0 4px 15px rgba(225, 6, 0, 0.4) !important;
  }

 /* =========================================================
     14. THE "BENTO BOX" APP FOOTER (ULTIMATE REDESIGN)
     ========================================================= */
  .site-footer {
    border-top: none !important;
    background: #000 !important; /* Pure black background to make cards pop */
    padding: 16px 12px calc(24px + env(safe-area-inset-bottom)) !important;
    color: #fff !important;
  }

  .footer-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important; /* Tight, app-style spacing */
  }

  /* Bento Card 1: Brand Details (Full Width) */
  .footer-brand {
    grid-column: 1 / -1 !important;
    background: #111115 !important;
    padding: 20px !important;
    border-radius: 20px !important;
    border: 1px solid #222 !important;
    border-left: 4px solid var(--f1-red) !important;
    margin-bottom: 0 !important;
  }

  .footer-brand h2 { 
    font-size: 1.6rem !important; 
    margin-bottom: 4px !important; 
    color: #fff !important; 
  }
  
  .footer-brand p { 
    font-size: 0.85rem !important; 
    color: #888 !important; 
    margin: 0 !important; 
    line-height: 1.4 !important; 
  }

  /* Bento Cards 2 & 3: Navigation Links (Side by Side) */
  .footer-links {
    background: #0a0a0f !important;
    padding: 16px 16px 20px !important;
    border-radius: 16px !important;
    border: 1px solid #1a1a1a !important;
    border-bottom: none !important; /* Override old desktop styles */
    display: flex !important;
    flex-direction: column !important;
  }

  .footer-links h3 {
    font-size: 0.7rem !important;
    color: #555 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    margin-bottom: 12px !important;
  }

  .footer-links ul { 
    display: flex !important; 
    flex-direction: column !important; 
    gap: 12px !important; 
    padding: 0 !important;
  }
  
  .footer-links a { 
    font-size: 0.95rem !important; 
    color: #ddd !important; 
    padding: 0 !important; 
    border: none !important; 
  }
  
  .footer-links a:active { 
    color: var(--f1-red) !important; 
  }

  /* Bento Card 4: Action Banner (Full Width, F1 Red Gradient) */
  .footer-cta {
    grid-column: 1 / -1 !important;
    background: linear-gradient(135deg, #e10600 0%, #990400 100%) !important; 
    padding: 16px 20px !important;
    border-radius: 16px !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    border: none !important;
    margin-top: 4px !important;
  }

  .footer-cta h3 { 
    color: #fff !important; 
    font-size: 1rem !important; 
    margin: 0 !important; 
    font-weight: 800 !important; 
  }
  
  .footer-cta p { 
    display: none !important; /* Hide the extra paragraph text to keep it ultra-clean */ 
  }
  
  .footer-cta .btn {
    background: #000 !important;
    color: #fff !important;
    padding: 10px 18px !important;
    border-radius: 50px !important;
    font-size: 0.8rem !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3) !important;
  }

  /* Bento Row 5: Social Icons Row */
  .social-icons {
    grid-column: 1 / -1 !important;
    display: flex !important;
    justify-content: space-between !important;
    gap: 10px !important;
    margin-top: 4px !important;
  }

  .social-icons a {
    flex: 1 !important;
    height: 50px !important;
    background: #111115 !important;
    border: 1px solid #222 !important;
    border-radius: 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #fff !important;
    transition: transform 0.1s ease !important;
  }

  .social-icons a:active { 
    background: #222 !important; 
    transform: scale(0.92) !important; 
  }
  
  .social-icons a svg, .social-icons a i { 
    width: 20px !important; 
    height: 20px !important; 
    fill: currentColor !important; 
  }

  /* Bottom Area: Copyright & Floating Back to Top Pill */
  .footer-bottom {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-top: 24px !important;
    padding: 0 4px !important;
    border: none !important;
  }

  .footer-bottom p { 
    font-size: 0.75rem !important; 
    color: #555 !important; 
    max-width: 55% !important; 
    margin: 0 !important; 
    line-height: 1.3 !important;
  }
  
  .back-to-top {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    border: none !important;
    padding: 12px 20px !important;
    border-radius: 50px !important;
    font-size: 0.75rem !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
  }

  /* =========================================================
     15. DRIVER & TEAM MODALS AS BOTTOM SHEETS
     ========================================================= */
  
  /* 1. Pin the overlay contents to the bottom of the screen */
  .driver-modal-overlay, .team-modal-overlay {
    flex-direction: column !important;
    justify-content: flex-end !important;
    padding: 0 !important;
  }

  /* 2. Reshape the modal container into a bottom sheet */
  .driver-modal, .team-modal {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 24px 24px 0 0 !important;
    border-top: 4px solid var(--f1-red) !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    background: var(--f1-dark) !important;
    
    /* Start hidden below the screen */
    transform: translateY(100%) scale(1) !important; 
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
    
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* 3. Slide up smoothly when visible */
  .driver-modal-overlay.visible .driver-modal,
  .team-modal-overlay.visible .team-modal {
    transform: translateY(0) scale(1) !important;
  }

  /* 4. Tidy up the images to fit the new rounded top */
  .driver-modal-image, .team-modal-image {
    border-radius: 20px 20px 0 0 !important;
    flex-shrink: 0 !important;
    height: 220px !important;
    min-height: 220px !important;
  }

  /* 5. App-style floating Close buttons */
  .driver-modal-close, .team-modal-close {
    top: 12px !important;
    right: 16px !important;
    background: rgba(0, 0, 0, 0.65) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    width: 36px !important;
    height: 36px !important;
    font-size: 1.6rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 100 !important;
  }
  
  /* 6. Ensure smooth internal scrolling */
  .driver-modal-body, .team-modal-grid {
    overflow-y: auto !important;
    display: block !important; /* Overrides the desktop grid */
  }
  
  .driver-modal-content, .team-modal-content {
    padding: 24px 20px 40px !important; /* Extra bottom padding for safe area */
    background: transparent !important;
  }

  

  /* =========================================================
     18. RACE ANALYTICS DASHBOARD (NATIVE APP MOBILE FIXES)
     ========================================================= */
  
  /* Hero & Controls */
  .analytics-hero {
    flex-direction: column !important;
    align-items: flex-start !important;
    padding: 16px !important;
    border-radius: 12px !important;
    gap: 16px !important;
  }

  .analytics-hero .hero-text h1 { font-size: 1.6rem !important; }
  
  /* Make the pill controls fit small screens perfectly */
  .unified-controls {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .unified-controls select, .unified-controls button {
    padding: 12px 10px !important;
    font-size: 0.8rem !important;
  }

  .unified-controls #seasonSelect { flex: 0 0 75px !important; } /* Just enough for '2024' */
  .unified-controls #raceSelect { padding-left: 4px !important; }
  .unified-controls #loadBtn { padding: 12px 16px !important; }

  /* Stack the Bento Dashboard vertically */
  .bento-dashboard {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    margin-bottom: 24px !important;
  }

  .bento-card {
    padding: 16px !important; /* Tighter padding for mobile */
    border-radius: 12px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
  }

  .stat-hero-text { font-size: 1.6rem !important; }
  .card-header h3 { font-size: 1rem !important; }

  /* Bar Charts (Team Points) */
  .bar-row { gap: 10px !important; }
  .bar-label { 
    width: 80px !important; /* Shrink label width so the bar has more room to animate */
    font-size: 0.75rem !important; 
  }
  .bar-value { font-size: 0.9rem !important; width: 30px !important; }

  /* Overtakes List */
  .list-item { padding: 10px !important; }
  .delta-box { font-size: 1rem !important; padding: 4px 8px !important; min-width: 45px !important; }

  /* Attrition Diagnostics (The 2x2 Grid Fix) */
  .attrition-summary {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important; /* Turns 1 row into a perfect 2x2 square */
    gap: 16px !important;
    padding-bottom: 16px !important;
  }

  .attrition-stat .count { font-size: 1.8rem !important; }
  
  /* Retirements Log adjustments */
  .retirements-list {
    max-height: 220px !important; /* Allow slightly more scrolling height on phones */
  }
  
  .ret-item {
    padding: 8px 10px !important;
  }
  
  .ret-driver {
    width: 40% !important; /* Give driver names slightly more room */
    font-size: 0.85rem !important;
  }
  
  .ret-reason { font-size: 0.7rem !important; }
  .ret-lap { font-size: 0.75rem !important; }

  /* =========================================================
   HERO FEATURE NOTICE (ANALYTICS PILL)
   ========================================================= */
.hero-feature-notice {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(216, 150, 255, 0.08);
  border: 1px solid rgba(216, 150, 255, 0.2);
  padding: 6px 18px 6px 6px;
  border-radius: 50px;
  text-decoration: none;
  margin: 12px 0 20px 0;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  width: fit-content;
}

.hero-feature-notice:hover {
  background: rgba(216, 150, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(216, 150, 255, 0.15);
  border-color: rgba(216, 150, 255, 0.4);
}

.hero-feature-notice:active {
  transform: translateY(1px);
}

.feature-badge {
  background: #d896ff;
  color: #000;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 6px 12px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.feature-text {
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
}

.feature-arrow {
  color: #d896ff;
  margin-left: 6px;
  transition: transform 0.3s ease;
}

/* Make the arrow slide right on hover */
.hero-feature-notice:hover .feature-arrow {
  transform: translateX(4px);
}

/* =========================================================
     19. NATIVE APP TOUCH, REVEALS, & DRAG HANDLES
     ========================================================= */
  
  /* Remove blue tap highlights on Android/iOS */
  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* Smooth transition for the physical press effect */
  .bento-card, .driver-portrait, .btn, .c-logo-box, .circuit-card, .team-card, .driver-card {
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s ease !important;
  }
  
  /* Physical "Press" Feedback on Tap */
  .bento-card:active, .driver-portrait:active, .btn:active, .c-logo-box:active, .circuit-card:active, .team-card:active, .driver-card:active {
    transform: scale(0.96) !important;
  }

  /* Scroll Reveal Animation Classes */
  .mobile-fade-up {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.7s ease-out, transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  
  .mobile-fade-up.is-visible {
    opacity: 1;
    transform: translateY(0);
  }

  /* The grey "Pull handle" at the top of the modals */
  .modal-pull-indicator {
    width: 45px;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    margin: 12px auto 20px auto;
    cursor: grab;
    flex-shrink: 0;
  }
  
  .modal-pull-indicator:active {
    cursor: grabbing;
  }
  
} /* <-- THIS IS THE ONLY CLOSING BRACKET FOR THE @MEDIA QUERY */