/* ============================================================
   Paramax Pools 4D - Responsive Overrides
   Mobile-first responsive fixes. Loaded LAST after all other CSS
   so declarations here win specificity ties.
   Breakpoints:
     max-width: 480px  -> small phones
     max-width: 767px  -> phones / tablets portrait
     max-width: 1024px -> tablets landscape / small laptops
     min-width: 1025px -> desktops
   ============================================================ */

/* ---------- Global safety ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

.container,
.main-wrap,
.hero-swiper {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: clamp(12px, 3vw, 24px);
    padding-right: clamp(12px, 3vw, 24px);
}

.hero-swiper { max-width: 1100px; }

/* Prevent any element from breaking the viewport */
.result-panel,
.live-draw-panel,
.history-card,
.static-page,
.footer-pro,
.marquee-band,
.marble-top,
.hero-swiper .swiper,
.navbot-pro {
    max-width: 100%;
}

/* Grid children must not blow out their column when content is wide.
   Without min-width:0, an auto-min-content child (e.g. horizontally-scrolling
   day pills) will force the grid track to grow past the viewport. */
.main-grid > * {
    min-width: 0;
    max-width: 100%;
}

/* ---------- Wrap tables to prevent overflow ---------- */
.funds-table,
.res-table {
    display: table;
    width: 100%;
}

/* When there's not enough space, allow horizontal scroll on tables
   without breaking the parent layout */
.result-panel,
.main-wrap {
    overflow-x: hidden;
}

.result-panel {
    /* keep rounded corners while allowing tables to scroll inside */
    isolation: isolate;
}

/* ============================================================
   TABLETS & SMALL LAPTOPS (<= 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .navbar-pro { padding: 12px 0 !important; }
    .navbar-pro .logo { height: 56px !important; }

    .hero-swiper { margin: 6px auto 18px; }
    .hero-swiper .swiper-button-prev,
    .hero-swiper .swiper-button-next {
        width: 38px; height: 38px;
    }
    .hero-swiper .swiper-button-prev:after,
    .hero-swiper .swiper-button-next:after { font-size: 15px; }

    .result-panel { padding: 22px 18px; }
    .draw-title h2 { font-size: 1.75rem; }

    .funds-table thead th,
    .funds-table tbody td { padding: 9px 8px; font-size: 0.85rem; }
    .funds-table td.fund-highlight { font-size: 0.98rem; }
}

/* ============================================================
   PHONES / TABLETS PORTRAIT (<= 767px)
   ============================================================ */
@media (max-width: 767px) {

    /* ---- Header ---- */
    .responsible-badge {
        position: static;
        display: inline-flex;
        margin: 8px auto 0;
        padding: 5px 12px;
        font-size: 0.66rem;
        border-radius: 4px;
        justify-content: center;
        max-width: fit-content;
    }
    .marble-top {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .marble-top > header { width: 100%; }
    .navbar-pro { padding: 10px 0 !important; }
    .navbar-pro .container { padding: 0 12px; }
    .navbar-pro .logo { height: 46px !important; }
    .navbar-pro .navbar-collapse {
        margin-top: 10px;
        background: rgba(20,16,10,0.96);
        border: 1px solid var(--border-gold);
        border-radius: 10px;
        padding: 8px 10px;
    }
    .navbar-pro .nav-link {
        font-size: 0.92rem;
        padding: 10px 12px !important;
    }

    /* ---- Marquee ---- */
    .marquee-band { padding: 6px 0; }
    .text-runn { font-size: 0.72rem !important; }

    /* ---- Hero swiper ---- */
    .hero-swiper {
        margin: 6px auto 14px;
        padding: 0 10px;
    }
    .hero-swiper .swiper { border-radius: 10px; }
    .hero-swiper .swiper-button-prev,
    .hero-swiper .swiper-button-next {
        width: 32px; height: 32px;
    }
    .hero-swiper .swiper-button-prev:after,
    .hero-swiper .swiper-button-next:after { font-size: 13px; }

    /* ---- Main grid stacks (already at 991px, reinforce) ---- */
    .main-wrap { padding: 0 12px 30px; }
    .main-grid {
        grid-template-columns: 1fr !important;
        gap: 14px;
        margin-top: 14px;
    }

    /* Days sidebar as horizontal scroll pills on mobile */
    .days-sidebar {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 8px;
        padding: 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .days-sidebar::-webkit-scrollbar { height: 6px; }
    .days-sidebar::-webkit-scrollbar-thumb {
        background: rgba(212,175,55,0.35);
        border-radius: 3px;
    }
    .day-item {
        flex: 0 0 auto;
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    .day-item .fa-chevron-right { display: none; }

    .side-promo { margin-top: 10px; padding: 12px; font-size: 0.8rem; }

    /* ---- Result panel ---- */
    .result-panel {
        padding: 16px 12px;
        border-radius: 10px;
    }
    .draw-header {
        gap: 10px;
        margin-bottom: 14px;
    }
    .draw-arrow {
        width: 34px; height: 34px;
        font-size: 0.8rem;
        flex: 0 0 34px;
    }
    .draw-title h2 { font-size: 1.35rem; }
    .draw-title .draw-date { font-size: 0.82rem; }
    .draw-title .draw-sub { font-size: 0.72rem; }

    /* ---- Prize row: stack for readability ---- */
    .prize-row {
        grid-template-columns: 1fr;
        gap: 12px;
        margin: 16px 0 6px;
    }
    .prize-block .prize-label {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }

    /* ---- Balls: scale using clamp so digits always fit ---- */
    .balls-row { gap: 4px !important; }
    .ball {
        width: clamp(26px, 8vw, 32px) !important;
        height: clamp(26px, 8vw, 32px) !important;
        font-size: clamp(0.72rem, 2.4vw, 0.92rem) !important;
    }
    .ball.small {
        width: clamp(22px, 7vw, 28px) !important;
        height: clamp(22px, 7vw, 28px) !important;
        font-size: clamp(0.65rem, 2.1vw, 0.8rem) !important;
    }
    .live-content .ball {
        width: clamp(20px, 6.4vw, 24px) !important;
        height: clamp(20px, 6.4vw, 24px) !important;
        font-size: clamp(0.6rem, 1.9vw, 0.72rem) !important;
    }

    /* ---- Funds table: allow horizontal scroll without breaking layout ---- */
    .funds-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        max-width: 100%;
    }
    .funds-table thead,
    .funds-table tbody,
    .funds-table tr { display: table; width: 100%; table-layout: fixed; }
    .funds-table thead th,
    .funds-table tbody td {
        padding: 8px 6px;
        font-size: 0.72rem;
        word-break: break-word;
    }
    .funds-table td.fund-highlight { font-size: 0.85rem; }
    /* subtle hint that table can scroll if too narrow */
    .funds-table::-webkit-scrollbar { height: 6px; }
    .funds-table::-webkit-scrollbar-thumb {
        background: rgba(212,175,55,0.35); border-radius: 3px;
    }

    /* ---- History section ---- */
    .history-title {
        font-size: 1.2rem;
        margin: 22px 0 14px;
    }
    .history-title::before,
    .history-title::after { width: 30px; margin: 0 8px; }
    .history-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .history-card { padding: 12px 10px; }
    .history-card h5 { font-size: 0.85rem; }
    .history-card h6 { font-size: 0.72rem; margin-bottom: 8px; }
    .history-card .prize-mini { font-size: 0.72rem; }
    .history-card .p-num {
        font-size: 1rem;
        letter-spacing: 1.5px;
    }

    .all-results-btn {
        padding: 9px 20px;
        font-size: 0.85rem;
    }

    /* ---- Result page (list) table: convert to card-like rows ---- */
    .result-title { font-size: 1.25rem; margin: 18px 0 12px; }
    .result-search { max-width: 100%; }

    .res-table {
        display: table;
        width: 100%;
        table-layout: fixed;
        white-space: normal;
    }
    .res-table thead th,
    .res-table tbody td {
        padding: 10px 6px;
        font-size: 0.78rem;
        word-break: break-word;
    }
    /* Hide the static "Prize Funds" column on mobile - value is identical for every row */
    .res-table thead th:nth-child(4),
    .res-table tbody td:nth-child(4) { display: none; }

    /* Column widths tuned so date + balls always fit */
    .res-table thead th:nth-child(1),
    .res-table tbody td:nth-child(1) { width: 46px; padding-left: 6px; padding-right: 4px; }
    .res-table thead th:nth-child(2),
    .res-table tbody td:nth-child(2) {
        width: auto;
        font-size: 0.72rem;
        letter-spacing: 0;
        line-height: 1.25;
    }
    .res-table thead th:nth-child(3),
    .res-table tbody td:nth-child(3) { width: 46%; padding-left: 4px; padding-right: 4px; }
    .res-table tbody td .balls-row { justify-content: center; flex-wrap: wrap; gap: 3px; }

    .pagination .page-link {
        padding: 6px 9px;
        font-size: 0.8rem;
        margin: 2px;
    }

    /* ---- Live draw panel ---- */
    .live-draw-panel {
        padding: 18px 14px;
        margin: 14px 8px;
        border-radius: 12px;
    }
    .live-draw-panel .logo { height: 46px; }

    /* ---- Static (about/contact) ---- */
    .static-page {
        padding: 20px 16px;
        margin: 18px 6px;
        border-radius: 10px;
    }
    .static-page h1 { font-size: 1.4rem; }
    .static-page h2 { font-size: 1.05rem; margin: 14px 0 8px; }
    .static-page p { font-size: 0.9rem; line-height: 1.65; }

    .contact-form input,
    .contact-form textarea {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    .contact-form button {
        width: 100%;
        padding: 12px 20px;
    }

    /* ---- Footer ---- */
    .footer-pro {
        padding: 26px 0 22px;
        text-align: center;
    }
    .footer-pro h5 { font-size: 1rem; margin-bottom: 10px; }
    .footer-pro p { font-size: 0.82rem; }
    .footer-pro p i { margin-right: 4px !important; }
    .footer-social { justify-content: center; }
    .footer-social a { width: 34px; height: 34px; font-size: 0.85rem; }

    .copyright-bar {
        font-size: 0.72rem;
        padding: 10px 8px;
        line-height: 1.4;
        margin-bottom: 64px;
    }

    /* ---- Bottom fixed nav ---- */
    .navbot-pro { padding: 6px 0 !important; }
    .navbot-pro .bottom-nav {
        gap: 10px;
        padding: 0 8px;
    }
    .navbot-pro .bottom-nav li { font-size: 0.68rem; gap: 4px; }
    .navbot-pro .bottom-nav li img { width: 18px !important; }

    /* ---- Modal (responsible) ---- */
    .modal-dialog { margin: 0.5rem; }
    .modal-body p { font-size: 0.88rem; }
    .modal-body h3 { font-size: 1rem; }

    /* ---- Marquee: allow underlying <marquee> to keep working, just resize ---- */
    .marquee-band .container { padding: 0 8px; }
}

/* ============================================================
   SMALL PHONES (<= 480px)
   ============================================================ */
@media (max-width: 480px) {

    .navbar-pro .logo { height: 40px !important; }
    .responsible-badge { font-size: 0.6rem; padding: 4px 10px; }

    .hero-swiper { padding: 0 8px; }
    .hero-swiper .swiper-button-prev,
    .hero-swiper .swiper-button-next {
        width: 28px; height: 28px;
    }
    .hero-swiper .swiper-button-prev:after,
    .hero-swiper .swiper-button-next:after { font-size: 11px; }

    .main-wrap { padding: 0 8px 24px; }

    .draw-title h2 { font-size: 1.15rem; }
    .draw-title .draw-date { font-size: 0.75rem; }
    .draw-title .draw-sub { font-size: 0.65rem; }
    .draw-arrow { width: 30px; height: 30px; flex: 0 0 30px; font-size: 0.72rem; }

    .prize-block .prize-label { font-size: 0.78rem; }

    .funds-table thead th,
    .funds-table tbody td {
        padding: 6px 4px;
        font-size: 0.62rem;
    }
    .funds-table td.fund-highlight { font-size: 0.72rem; }

    .history-grid { grid-template-columns: 1fr; }
    .history-card { padding: 14px 12px; }
    .history-card h5 { font-size: 0.9rem; }
    .history-card .p-num { font-size: 1.1rem; letter-spacing: 2px; }

    .day-item { padding: 8px 12px; font-size: 0.78rem; }

    .live-draw-panel { padding: 14px 10px; }

    .static-page { padding: 16px 12px; margin: 14px 4px; }
    .static-page h1 { font-size: 1.2rem; }

    .copyright-bar { font-size: 0.65rem; }
    .navbot-pro .bottom-nav li { font-size: 0.62rem; }
    .navbot-pro .bottom-nav li img { width: 16px !important; }

    .pagination .page-link { padding: 5px 8px; font-size: 0.72rem; }
}

/* ============================================================
   EXTRA SMALL (<= 360px)  -- narrow devices safety net
   ============================================================ */
@media (max-width: 360px) {
    .navbar-pro .logo { height: 36px !important; }
    .draw-title h2 { font-size: 1rem; }
    .prize-block .prize-label { font-size: 0.72rem; }
    .funds-table thead th,
    .funds-table tbody td { font-size: 0.58rem; padding: 5px 3px; }
    .history-card .p-num { font-size: 1rem; }
}

/* ============================================================
   TABLET PORTRAIT (481px – 768px) refinements
   ============================================================ */
@media (min-width: 481px) and (max-width: 767px) {
    .prize-row { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .history-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   LANDSCAPE MOBILES (short height)
   ============================================================ */
@media (max-height: 480px) and (orientation: landscape) {
    .navbar-pro { padding: 6px 0 !important; }
    .navbar-pro .logo { height: 38px !important; }
    .hero-swiper { margin: 4px auto 10px; }
    .copyright-bar { margin-bottom: 48px; }
}

/* ============================================================
   DESKTOP (>= 1025px) - keep existing layout intact
   ============================================================ */
@media (min-width: 1025px) {
    .main-grid { grid-template-columns: 260px 1fr; }
    .history-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   Print
   ============================================================ */
@media print {
    .navbar-pro, .navbot-pro, .footer-pro, .copyright-bar,
    .hero-swiper, .marquee-band, .responsible-badge { display: none !important; }
    body { background: #fff !important; color: #000 !important; }
    .result-panel, .history-card, .static-page {
        background: #fff !important; color: #000 !important; border-color: #ccc !important;
    }
}
