/* ================= MOBILE / RESPONSIVE CSS ================= */

/* ================= UP TO 768PX ================= */
@media (max-width: 768px) {

  :root {
    --f1-bg: #020617;
    --f1-panel: #0f172a;
    --f1-border: rgba(255,255,255,.08);
    --f1-text: #e5e7eb;
    --f1-muted: #9ca3af;
    --f1-blue: #93C5FD;
  }

  * { box-sizing: border-box; }

  body {
    margin: 0;
    background: radial-gradient(circle at top, #0f172a 0%, #020617 70%);
    color: var(--f1-text);
    font-family: 'Titillium Web', sans-serif;
    min-height: 100vh;
    padding-top: 80px;
  }

  a {
    color: var(--f1-blue);
    text-decoration: none;
  }

  a:hover {
    color: #93c5fd;
  }

  h1 {
    font-size: 2rem;
    text-align: center;
  }

  h2 {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
  }

  h4 .text-muted {
    font-size: 0.85rem;
  }

  .f1-navbar {
    padding: 0 12px;
    min-height: 56px;
  }

  .f1-navbar .nav-link {
    padding: 0 10px;
    height: 56px;
    font-size: 0.85rem;
  }

  .navbar-toggler {
    border-color: var(--f1-blue);
    margin-left: auto;
  }

  .navbar-toggler-icon {
    filter: invert(1);
  }

  .container {
    padding: 0 12px;
    max-width: 100%;
  }

  .season-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px 0;
  }

  .season-back {
    font-size: 0.8rem;
  }

  .race-card {
    padding: 4px 6px 5px;
    border-radius: 6px;
    width: 100%;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }

  .race-card.race-locked {
    background-color: #f8f9fa;
    color: #6c757d;
    opacity: 0.7;
  }

  .race-card:not(.race-locked) {
    background-color: #fff3cd;
    color: #856404;
  }

  .race-card:not(.race-locked):hover,
  .race-card:not(.race-locked):active {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  }

  .race-link {
    display: block;
    width: 100%;
    padding: 10px 12px;
    font-size: 1rem;
    font-weight: 600;
  }

  .race-date {
    font-size: 0.8rem;
    margin-top: 2px;
    display: block;
  }

  .race-status .badge {
    font-size: 0.75rem;
    padding: 2px 6px;
    margin-top: 4px;
    display: inline-block;
  }

  table,
  th,
  td {
    font-size: 0.8rem;
    padding: 6px 4px;
  }

  .leaderboard-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .leaderboard {
    border-collapse: collapse;
    font-size: 0.65rem;
  }

  .leaderboard th.sticky,
  .leaderboard td.sticky {
    position: sticky;
    left: 0;
    background: #0b0b0b;
    z-index: 2;
    text-align: left;
    padding: 6px 12px;
  }

  .leaderboard th.race-header,
  .leaderboard td.race-cell {
    min-width: 50px;
    padding: 6px 4px;
    text-align: center;
  }

  .leaderboard tr:nth-child(odd) td {
    background-color: #0d0d0d;
  }

  .leaderboard tr:nth-child(even) td {
    background-color: #141414;
  }

  .leaderboard td.race-cell:hover {
    background-color: rgba(96,165,250,0.15);
    cursor: pointer;
  }

  .podium-gold {
    background: gold;
    color: #000;
    font-weight: bold;
  }

  .podium-silver {
    background: silver;
    color: #000;
    font-weight: bold;
  }

  .podium-bronze {
    background: #cd7f32;
    color: #000;
    font-weight: bold;
  }

  #race-tooltip {
    position: fixed;
    background: #111;
    color: gold;
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: all 0.15s ease;
    z-index: 999;
  }

  .f1-grid .f1-row {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .f1-grid .f1-pos-label {
    text-align: center;
    width: 100%;
    font-size: 0.85rem;
  }

  .f1-select {
    width: 90%;
    font-size: 0.9rem;
    padding: 0.3rem 0.5rem;
  }

  .f1-submit-wrapper {
    justify-content: left;
    width: 100%;
  }

  .f1-race-header > div {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  .page-picks .f1-countdown.glow-box {
    display: flex;
    justify-content: center;
  }

  .page-picks .f1-countdown .f1-row {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .page-picks .f1-submit-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #f1-inline-message {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
  }

  #f1-inline-message .f1-msg {
    text-align: center;
    max-width: 92%;
  }

  .page-picks .f1-btn-row {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .page-picks .f1-submit-btn {
    width: auto;
    min-width: 220px;
  }

  .hero-buttons {
    flex-direction: column;
  }

  .hero-buttons .btn {
    width: 100%;
    text-align: center;
  }

  .how-card {
    flex: 1 1 100%;
  }
}

/* ================= MOBILE STACKED TABLES: 0–600PX ================= */
@media (max-width: 600px) {

  /* PICKS TABLE */
  .leaderboard-picks,
  .leaderboard-picks tbody,
  .leaderboard-picks tr,
  .leaderboard-picks td {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box;
    min-width: 0 !important;
  }

  .leaderboard-picks thead {
    display: none !important;
  }

  .leaderboard-picks tr {
    background: #111;
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 8px;
  }

  .leaderboard-picks td {
    position: relative !important;
    padding: 8px 12px 8px 78px !important;
    text-align: left !important;
    border-bottom: 1px solid rgba(255,255,255,.06);
    min-height: 42px;
  }

  .leaderboard-picks td:last-child {
    border-bottom: none;
  }

  .leaderboard-picks td::before {
    content: attr(data-label) !important;
    position: absolute !important;
    left: 12px !important;
    top: 8px !important;
    width: 54px !important;
    font-weight: 700 !important;
    color: #93C5FD !important;
    white-space: nowrap !important;
    text-align: left !important;
    display: block !important;
  }

  .leaderboard-picks .cell-content {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-width: 0;
    text-align: left;
    white-space: normal;
    word-break: break-word;
  }

  .leaderboard-picks .score {
    position: static !important;
    transform: none !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 34px;
    white-space: nowrap;
    font-size: 0.72rem !important;
    line-height: 1 !important;
    padding: 2px 8px !important;
    margin-left: 8px;
  }

  .leaderboard-picks .bonus-score .cell-content,
  .leaderboard-picks .total-score .cell-content {
    justify-content: flex-end;
    text-align: right;
    font-weight: 700;
  }

  .leaderboard-picks td[data-label="Submitted"] .cell-content {
    justify-content: flex-end;
    text-align: right;
    color: #9ca3af;
    white-space: nowrap;
  }

  /* OFFICIAL RESULTS - KEEP AS NORMAL TABLE, NO STACKING */
  .leaderboard-results-wrap {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 20px 0 !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
  }

  .leaderboard-results-wrap table {
    display: table !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
  }

  .leaderboard-results-wrap thead {
    display: table-header-group !important;
  }

  .leaderboard-results-wrap tbody {
    display: table-row-group !important;
  }

  .leaderboard-results-wrap tr {
    display: table-row !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border-radius: 0 !important;
  }

  .leaderboard-results-wrap th,
  .leaderboard-results-wrap td {
    display: table-cell !important;
    position: static !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 8px 10px !important;
    white-space: normal !important;
    text-align: center !important;
    box-sizing: border-box !important;
    border-bottom: 1px solid rgba(255,255,255,.06);
  }

  .leaderboard-results-wrap td::before,
  .leaderboard-results-wrap th::before {
    content: none !important;
    display: none !important;
  }

  .leaderboard th.sticky,
  .leaderboard td.sticky,
  .leaderboard th.race-header,
  .leaderboard td.race-cell {
    position: static !important;
    left: auto !important;
  }

  .navbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 12px;
  }

  .nav-links a {
    margin-left: 0;
    margin-top: 6px;
    font-size: .85rem;
  }

  .f1-top-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .f1-top-controls form,
  .f1-top-controls button {
    width: 100%;
    min-height: auto;
  }

  .f1-countdown {
    min-height: 60px;
    padding: 12px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .tile.big {
    grid-column: span 1;
  }

  .tile {
    padding: 16px;
    border-radius: 14px;
    min-height: 120px;
  }

  .tile h3 {
    font-size: 1.1rem;
  }

  .tile .tile-value {
    font-size: 1.8rem;
  }

  .swipe-row {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 8px;
  }

  .swipe-row .tile {
    min-width: 160px;
    flex-shrink: 0;
  }

  .dashboard-grid.stats {
    grid-template-columns: 1fr;
  }

  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 999;
    background: linear-gradient(90deg,#1a1a2e,#0f3460);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0,0,0,.5);
  }

  .mobile-header small {
    font-size: .6rem;
    opacity: .7;
    display: block;
  }

  .f1-container {
    padding-bottom: 80px;
  }

  .landing-hero {
    padding-bottom: 80px;
  }
}

/* ================= TABLET FIX: 601–767PX ================= */
@media (min-width: 601px) and (max-width: 767px) {

  .leaderboard-wrap,
  .leaderboard-results-wrap {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }

  table.leaderboard {
    min-width: 1240px;
  }

  .leaderboard-results-wrap table {
    min-width: 560px;
  }

  table.leaderboard thead,
  .leaderboard-results-wrap thead {
    display: table-header-group !important;
  }

  table.leaderboard tbody,
  .leaderboard-results-wrap tbody {
    display: table-row-group !important;
  }

  table.leaderboard tr,
  .leaderboard-results-wrap tr {
    display: table-row !important;
    margin: 0 !important;
    border-bottom: none !important;
  }

  table.leaderboard th,
  .leaderboard-results-wrap th,
  .leaderboard-results-wrap td {
    display: table-cell !important;
    position: static !important;
    width: auto !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    padding: 10px 8px !important;
    text-align: center;
    vertical-align: middle;
  }

  .leaderboard-picks th {
    display: table-cell !important;
    position: relative !important;
    width: auto !important;
    min-width: 118px !important;
    white-space: nowrap !important;
    padding: 8px 6px !important;
    text-align: center;
    font-size: 0.88rem;
    vertical-align: middle;
  }

  .leaderboard-picks td {
    display: table-cell !important;
    position: relative !important;
    width: auto !important;
    min-width: 118px !important;
    white-space: nowrap !important;
    padding: 6px 6px 22px !important;
    text-align: center;
    vertical-align: middle;
    height: auto !important;
  }

  .leaderboard-picks td.player,
  .leaderboard-picks th:first-child {
    min-width: 190px !important;
  }

  table.leaderboard td::before,
  .leaderboard-results-wrap td::before,
  .leaderboard-picks td::before {
    content: none !important;
    display: none !important;
  }

  .leaderboard th.sticky,
  .leaderboard td.sticky {
    position: sticky !important;
    left: 0;
    background: #0b0b0b;
    z-index: 2;
    text-align: left;
  }

  .leaderboard-picks .cell-content {
    position: static !important;
    display: block;
    min-height: 0 !important;
    padding: 0 !important;
    font-size: 0.81rem;
    line-height: 1.08;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .leaderboard-picks .score {
    position: absolute !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: 4px !important;
    transform: translateX(-50%) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    white-space: nowrap;
    z-index: 2;
    font-size: 0.64rem !important;
    line-height: 1 !important;
    padding: 2px 6px !important;
  }

  td.user-cell {
    font-size: 0.92rem !important;
  }
}

/* EXTRA SMALL HELPERS */
@media (max-width: 767px) {
  .f1-grid .f1-row {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .f1-grid .f1-pos-label {
    text-align: center;
    width: 100%;
    font-size: 0.85rem;
  }

  .f1-select {
    width: 90%;
    font-size: 0.9rem;
    padding: 0.3rem 0.5rem;
  }

  .f1-submit-wrapper {
    justify-content: left;
    width: 100%;
  }

  .f1-race-header > div {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }
}

/* Messages */
.f1-msg-mobile { display: none; }
.f1-msg-desktop { display: none; }

@media (max-width: 767px) {
  .f1-msg-mobile {
    display: block;
    text-align: left;
    font-size: 0.9rem;
    margin-bottom: 5px;
  }
}

@media (min-width: 768px) {
  .f1-msg-desktop {
    display: block;
    text-align: left;
    font-size: 1rem;
    margin-bottom: 10px;
  }
}

.f1-btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
  width: 100%;
}

@media (min-width: 768px) {
  .f1-btn-row {
    flex-wrap: nowrap;
  }
}

@media (max-width: 767px) {
  .f1-btn-row button {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .page-picks .f1-countdown.glow-box {
    display: flex;
    justify-content: center;
  }

  .page-picks .f1-countdown .f1-row {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .page-picks .f1-submit-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #f1-inline-message {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
  }

  #f1-inline-message .f1-msg {
    text-align: center;
    max-width: 92%;
  }

  .page-picks .f1-btn-row {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .page-picks .f1-submit-btn {
    width: auto;
    min-width: 220px;
  }

  .hero-buttons {
    flex-direction: column;
  }

  .hero-buttons .btn {
    width: 100%;
    text-align: center;
  }

  .how-card {
    flex: 1 1 100%;
  }
}

@media (max-width: 480px) {
  .f1-container {
    padding-bottom: 80px;
  }

  .landing-hero {
    padding-bottom: 80px;
  }
}

@keyframes focusFlash {
  0% { box-shadow: 0 0 0 0 rgba(255,215,0,0.8); }
  100% { box-shadow: 0 0 0 14px rgba(255,215,0,0); }
}

/* Fix filter bar selects on mobile */
@media (max-width: 600px) {
  .admin-filters {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    align-items: stretch !important;
    overflow: hidden;
  }

  .admin-filters .d-flex {
    width: 100%;
    min-width: 0;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 8px;
  }

  .admin-filters label {
    flex: 0 0 auto;
    margin-bottom: 0;
    white-space: nowrap;
  }

  .admin-filters .form-select,
  .admin-filters select {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;

    padding-right: 2.2rem !important; /* room for native arrow */
    background-position: right .7rem center !important;
    background-size: 12px 12px !important;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    -webkit-appearance: none;
    appearance: none;
  }
}

/* ================= MOBILE NAV ================= */

@media (max-width: 991.98px){
    .user-group-nav{
        margin-top:10px;
        width:100%;
        align-items:stretch !important;
    }

    .user-group-nav .nav-item{
        width:100%;
    }

    .nav-pill,
    .nav-pill-static{
        width:100%;
        max-width:none;
        justify-content:flex-start;
    }

    .modern-dropdown{
        width:100%;
        min-width:0;
    }
}

