        /* GOV.UK */
        :root {
            --govuk-text-colour: #0B0C0C;
            --govuk-secondary-text-colour: #505a5f;
            --govuk-link-colour: #1D70B8;
            --govuk-link-hover-colour: #003078;
            --govuk-border-colour: #b1b4b6;
            --govuk-focus-colour: #ffdd00;
            --govuk-focus-text-colour: #0b0c0c;
            --govuk-button-colour: #1D70B8;
            --govuk-button-hover-colour: #003078;
            --govuk-page-background-colour: #FFFFFF;
            --govuk-panel-background-colour: #F3F2F1;
            --govuk-font-family: "GDS Transport", "Arial", "Helvetica", sans-serif;
        }

        html {
            font-size: 16px;
        }

        body {
            font-family: var(--govuk-font-family);
            background-color: var(--govuk-page-background-colour);
            color: var(--govuk-text-colour);
            margin: 0;
            font-size: 19px;
            line-height: 1.5;
        }

        /* Introduction section styles */
        .intro-section {
            background-color: var(--govuk-panel-background-colour);
            border-left: 4px solid var(--govuk-link-colour);
            padding: 24px;
            margin: 32px 0;
            border-radius: 0 4px 4px 0;
        }

        .intro-text {
            font-size: 22px;
            line-height: 1.5;
            margin: 0;
            color: var(--govuk-text-colour);
            font-weight: 400;
        }

        /* RTL Support */
        [dir="rtl"] .intro-section {
            border-left: none;
            border-right: 4px solid var(--govuk-link-colour);
            border-radius: 4px 0 0 4px;
        }

        /* Mobile styles */
        @media (max-width: 600px) {
            .intro-section {
                padding: 20px;
                margin: 24px 0;
            }
            
            .intro-text {
                font-size: 19px;
            }
        }

        .adsbygoogle {
            min-height: 100px;
            display: none;
        }
            .adsbygoogle.loaded {
            display: block !important;
        }

        .govuk-width-container {
            max-width: 960px;
            margin: 0 auto;
            padding: 0 16px;
        }

        .govuk-header__brand {
            display: flex;
            align-items: center;
        }

        [dir="rtl"] .govuk-header__brand {
            direction: ltr !important;
            flex-direction: row !important;
            text-align: left !important;
        }

        .govuk-header__link {
            display: flex;
            align-items: center;
            text-decoration: none;
            color: inherit;
            padding: 0;
        }

        .govuk-logo {
            height: 100px;
            width: auto;
            padding: 20px 0 20px 0;
        }

        .govuk-header__title {
            font-size: 28px;
            font-weight: bold;
            margin: 0;
        }

        /* === Affiliate product box === */
        .affiliate-box {
            display: flex;
            align-items: center;
            background: #f9f9f9;
            border: 1px solid #ddd;
            border-radius: 8px;
            padding: 16px;
            margin: 24px 0;
            font-family: Arial, sans-serif;
            gap: 20px;
        }

        .affiliate-box img {
            width: 120px;
            height: auto;
            flex-shrink: 0;
            border-radius: 6px;
        }

        .affiliate-content {
            display: flex;
            flex-direction: row;        /* ✅ KEY FIX: Make text and button sit side by side */
            justify-content: space-between;
            align-items: center;        /* ✅ Centers button vertically with the text */
            width: 100%;
        }

        .affiliate-text {
            flex: 1;                    /* ✅ Lets text fill available space */
            padding-right: 20px;
        }

        .affiliate-content h3 {
            font-size: 20px;
            margin: 0 0 8px;
            color: #0B0C0C;
        }

        .affiliate-content p {
            font-size: 16px;
            line-height: 1.5;
            color: #333;
            margin: 0;
        }

        .affiliate-button input[type="submit"] {
            background: linear-gradient(135deg, #ff5722, #ff784e);
            color: white;
            border: none;
            padding: 12px 32px;
            font-size: 18px;
            font-weight: 600;
            border-radius: 50px;
            cursor: pointer;
            transition: transform 0.15s ease, box-shadow 0.15s ease;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }

        .affiliate-button input[type="submit"]:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
        }

        /* --- Language Selection Popup --- */
        .language-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(5px);
            -webkit-backdrop-filter: blur(5px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            padding: 16px;
            box-sizing: border-box;
        }
        .language-popup {
            background-color: var(--govuk-page-background-colour);
            padding: 32px 48px;
            border-radius: 8px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
            text-align: center;
            max-width: 1000px;
            width: 100%;
            max-height: 90vh;
            overflow-y: auto;
        }
        .language-popup-title {
            font-size: 32px;
            font-weight: bold;
            margin-bottom: 32px;
            color: var(--govuk-text-colour);
            min-height: 80px; /* Accommodate 2 lines to prevent layout jump */
        }
        .language-popup-title::after {
            content: '|';
            display: inline-block;
            margin-left: 5px;
            animation: blink 0.7s infinite;
            font-weight: normal;
            color: var(--govuk-secondary-text-colour);
        }
        
        .language-popup-title[dir="rtl"]::after {
            margin-left: 0;
            margin-right: 5px;
        }

        @keyframes blink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0; }
        }

        .flags-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 24px;
            direction: ltr !important;
        }

        .flag-button {
            background-color: transparent;
            border: 2px solid var(--govuk-border-colour);
            border-radius: 4px;
            padding: 16px;
            cursor: pointer;
            transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 12px;
            font-size: 19px;
            font-family: var(--govuk-font-family);
        }
        .flag-button:hover {
            transform: translateY(-3px);
            border-color: var(--govuk-link-hover-colour);
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
        .flag-button:focus {
            outline: 3px solid var(--govuk-focus-colour);
            outline-offset: 2px;
        }
        .flag-button svg, .flag-button img {
            width: 100px;
            height: 60px;
            border: 1px solid #ccc;
            object-fit: cover;
        }

        .hidden {
            display: none !important;
        }

        /* --- Header --- */
        .govuk-header {
            background-color: var(--govuk-panel-background-colour);
            border-bottom: 8px solid var(--govuk-link-colour);
            padding: 0;
            margin-bottom: 32px;
        }
        .govuk-header__container {
             display: flex;
             justify-content: space-between;
             align-items: center;
             flex-wrap: wrap; /* Allow items to wrap for ads */
        }
        .govuk-header__title {
            font-size: 36px;
            font-weight: bold;
            margin: 0;
            line-height: 1.2;
            margin-right: 20px; /* Space between title and toggle */
        }
        
        .header-ad-container {
            width: 100%;
            margin-top: 16px;
        }

        /* --- Main Content & Form --- */
        .govuk-main-wrapper {
            padding-bottom: 48px;
        }

        h2.govuk-heading-l {
            font-size: 36px;
            font-weight: bold;
            margin-top: 48px;
            margin-bottom: 24px;
        }

        .govuk-form-group {
            margin-bottom: 24px;
        }

        .govuk-fieldset {
            border: none;
            padding: 0;
            margin: 0;
        }

        .govuk-fieldset__legend {
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 16px;
            padding: 0;
        }

        .govuk-label {
            display: block;
            font-weight: bold;
            margin-bottom: 8px;
        }

        .govuk-input {
            height: 40px;
            width: 80px;
            padding: 0 8px;
            border: 2px solid var(--govuk-text-colour);
            font-size: 19px;
        }

        .govuk-input:focus {
            outline: 3px solid var(--govuk-focus-colour);
            outline-offset: 0;
            border-color: var(--govuk-text-colour);
        }

        /* --- Radios --- */
        .govuk-radios__item {
            display: flex;
            align-items: center;
            margin-bottom: 16px;
            position: relative;
            padding-left: 40px;
        }
        .govuk-radios__input {
            position: absolute;
            opacity: 0;
            cursor: pointer;
        }
        .govuk-radios__label {
            font-weight: normal;
            margin-bottom: 0;
            cursor: pointer;
        }
        .govuk-radios__label::before {
            content: "";
            position: absolute;
            left: 0;
            top: 0;
            width: 34px;
            height: 34px;
            border: 2px solid var(--govuk-text-colour);
            border-radius: 50%;
            background: var(--govuk-page-background-colour);
        }
        .govuk-radios__input:checked + .govuk-radios__label::after {
            content: "";
            position: absolute;
            top: 9px;
            left: 9px;
            width: 18px;
            height: 18px;
            background: var(--govuk-text-colour);
            border-radius: 50%;
        }
        .govuk-radios__input:focus + .govuk-radios__label::before {
            outline: 3px solid transparent;
            box-shadow: 0 0 0 3px var(--govuk-focus-colour);
        }

        /* --- Household Grid --- */
        .govuk-household-grid {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 20px;
            align-items: stretch; /* ensures items fill row height */
        }

        .govuk-household-grid .govuk-form-group {
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            height: 100%; /* forces equal height */
        }
        .govuk-household-grid .govuk-form-group {
            margin-bottom: 0;
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
        }

        .govuk-household-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
            gap: 24px;
            align-items: start;
        }

        .govuk-household-grid .govuk-form-group {
            display: flex;
            flex-direction: column;
            height: 100%;
        }

        .govuk-input {
            margin-top: auto;
        }

        .govuk-household-grid .govuk-label {
            min-height: 80x; 
        }

        .speak-btn {
            background: none;
            border: none;
            color: #1D70B8; /* GOV.UK link blue */
            font-size: 22px;
            margin-left: 8px;
            cursor: pointer;
            padding: 0;
        }
        .speak-btn:hover {
            color: #003078;
        }

        .speak-btn i {
            background: #f3f2f1;
            border-radius: 50%;
            padding: 4px;
        }

        /* FontAwesome icons for form labels */
        .govuk-form-group i.fa-solid {
            color: #1D70B8;          /* GOV.UK blue */
            font-size: 26px;         /* consistent size */
            margin-right: 6px;       /* space before label text */
            vertical-align: middle;  /* keeps icon level with text */
        }

        /* Speaker buttons */
        .speak-btn {
            background: none;
            border: none;
            color: #1D70B8;
            font-size: 20px;
            margin-left: 6px;
            cursor: pointer;
            padding: 0;
        }
        .speak-btn:hover {
            color: #003078;
        }

        /* PRIVACY MODAL STYLING */
        .privacy-modal {
        display: none;
        position: fixed;
        z-index: 9999;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0,0,0,0.5);
        }

        .privacy-modal-content {
            background: #fff;
            margin: 5% auto;
            padding: 20px;
            border-radius: 8px;
            max-width: 700px;
            max-height: 80vh;       /* ✅ stops content going off-screen */
            overflow-y: auto;       /* ✅ scrolls inside the modal if too tall */
            box-shadow: 0 4px 8px rgba(0,0,0,0.3);
            animation: fadeIn 0.3s ease;
        }

        .privacy-modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        }

        .privacy-modal-close {
        font-size: 28px;
        font-weight: bold;
        background: none;
        border: none;
        cursor: pointer;
        }

        .privacy-modal-close:hover {
        color: #c00;
        }

        /* RTL Support */
        [dir="rtl"] .privacy-modal-header {
            flex-direction: row-reverse;
        }

        /* Mobile Styles */
        @media (max-width: 600px) {
            .privacy-modal {
                padding: 10px;
            }
            
            .privacy-modal-header {
                padding: 16px 20px;
            }
            
            .privacy-modal-header h2 {
                font-size: 24px;
            }
            
            .privacy-modal-body {
                padding: 20px;
            }
            
            .privacy-modal-body h3 {
                font-size: 22px;
            }
            
            .privacy-modal-body p {
                font-size: 16px;
            }
        }

        @media (min-width: 960px) {
            .govuk-household-grid {
                grid-template-columns: repeat(5, 1fr);
                gap: 20px;
            }
        }

        /* --- Results Panel --- */
        .result-panel {
            background-color: var(--govuk-panel-background-colour);
            padding: 32px;
            margin-top: 48px;
            border: 4px solid var(--govuk-link-colour);
        }
        .result-panel__title {
            font-size: 36px;
            font-weight: bold;
            margin-top: 0;
            margin-bottom: 24px;
            word-break: break-word;
        }
        .result-panel__total {
            color: var(--govuk-link-colour);
        }

        /* --- Table --- */
        .govuk-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 24px;
        }
        .govuk-table__head {
            border-bottom: 2px solid var(--govuk-border-colour);
        }
        .govuk-table__header, .govuk-table__cell {
            text-align: left;
            padding: 16px 16px 16px 0;
            border-bottom: 1px solid var(--govuk-border-colour);
        }
        .govuk-table__header { font-weight: bold; }
        .govuk-table__cell--numeric { text-align: right; padding-right: 0; }
        .govuk-table__row:last-child .govuk-table__cell { border-bottom: none; }
        
        /* --- Action Links --- */
        .govuk-link-button {
            font-size: 19px;
            font-weight: bold;
            text-decoration: underline;
            color: var(--govuk-link-colour);
            cursor: pointer;
            display: inline-block;
            margin-top: 16px;
        }
        .govuk-link-button:hover {
            color: var(--govuk-link-hover-colour);
        }

        /* --- Footer --- */
        .govuk-footer {
            border-top: 8px solid var(--govuk-link-colour);
            background-color: var(--govuk-panel-background-colour);
            padding: 32px 0;
            margin-top: 48px;
        }
        .govuk-footer__meta-item {
            color: var(--govuk-secondary-text-colour);
            font-size: 16px;
        }

        /* === NEW FOOTER === */
        .site-footer {
        background-color: #f3f2f1;
        border-top: 8px solid #1D70B8;
        margin-top: 48px;
        padding: 40px 0;
        font-family: var(--govuk-font-family);
        }

        .footer-container {
        max-width: 960px;
        margin: 0 auto;
        padding: 0 16px;
        }

        .footer-top h3 {
        font-size: 22px;
        margin-top: 0;
        margin-bottom: 8px;
        color: #0b0c0c;
        }

        .footer-top p {
        font-size: 17px;
        margin: 0 0 24px;
        color: #505a5f;
        }

        .footer-ad-box {
        background: white;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 12px;
        margin-bottom: 24px;
        text-align: center;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
        }

        .footer-ad-box img {
        max-width: 100%;
        height: auto;
        border-radius: 6px;
        }

        .footer-bottom {
        border-top: 1px solid #ddd;
        padding-top: 16px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        font-size: 15px;
        color: #505a5f;
        }

        .footer-links a {
        color: #1D70B8;
        text-decoration: none;
        font-weight: 600;
        }

        .footer-links a:hover {
        color: #003078;
        text-decoration: underline;
        }

        .footer-links span {
        margin: 0 8px;
        color: #b1b4b6;
        }

        /* --- RTL Support --- */
        [dir="rtl"] .govuk-header__container { flex-direction: row; justify-content: space-between; }
        [dir="rtl"] .govuk-radios__item { padding-left: 0; padding-right: 40px; }
        [dir="rtl"] .govuk-radios__label::before { left: auto; right: 0; }
        [dir="rtl"] .govuk-radios__input:checked + .govuk-radios__label::after { left: auto; right: 9px; }
        [dir="rtl"] .govuk-table__header, [dir="rtl"] .govuk-table__cell { text-align: right; padding: 16px 0 16px 16px; }
        [dir="rtl"] .govuk-table__cell--numeric { text-align: left; padding-left: 0; }
        [dir="rtl"] .govuk-household-grid { direction: rtl; }
        
        /* --- Mobile & Tablet Styles --- */
        @media (max-width: 959px) {
            .flags-grid {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        @media (max-width: 600px) {
             .language-popup {
                padding: 24px;
            }
             .language-popup-title {
                min-height: 70px;
             }
            .flags-grid {
                 grid-template-columns: repeat(2, 1fr);
                 gap: 16px;
            }
            .govuk-header__title, h2.govuk-heading-l, .result-panel__title, .language-popup-title {
                font-size: 28px;
            }
            .govuk-fieldset__legend {
                font-size: 22px;
            }
            .result-panel {
                padding: 24px;
            }
            .govuk-header__container {
                flex-direction: column;
                align-items: flex-start;
            }
        }

        /* === Two-column layout & wider page === */
        .govuk-width-container {            /* expand overall page */
            max-width: 1380px;              /* was 960px */
        }

        .page-layout{                       /* flex wrapper */
            display:flex;
            align-items:flex-start;
            gap:48px;
        }

        .content-area{
            flex:1 1 auto;
            min-width:0;                    /* prevents overflow on narrow screens */
        }

        .language-sidebar{
            flex:0 0 220px;                 /* fixed sidebar width */
        }

        #language-ticker {
            height: 3em;
            overflow: hidden;
            display: block;
        }

        .flags-list{                        /* single vertical column */
            display:flex;
            flex-direction:column;
            gap:16px;
        }

        /* collapse to single column on small screens */
        @media(max-width:900px){
            .page-layout{flex-direction:column;}
            .language-sidebar{flex:none;margin-top:32px;}
        }
        
        /* --- Print Styles --- */
        @media print {
            body { background-color: #fff; color: #000; }
            .language-overlay, .govuk-header, .govuk-main-wrapper form, .govuk-footer, .govuk-link-button, .adsbygoogle {
                display: none !important;
            }
            #app-container.hidden { display: block !important; } /* Ensure calculator shows for print */
            .govuk-main-wrapper { padding-bottom: 0; }
            .govuk-width-container { max-width: 100%; margin: 0; padding: 0; }
            .result-panel { border: none; margin-top: 0; padding: 0; background-color: #fff; }
            .result-panel__title, .result-panel__total { color: #000; }
        }

        /* === Intro Section Speaker Alignment === */
    .intro-flex {
        display: flex;
        align-items: center;      /* ✅ Vertically center speaker */
        justify-content: space-between;  /* ✅ Push speaker to far right */
        gap: 12px;                /* Small gap between text and icon */
    }

    .intro-flex .intro-text {
        flex: 1;                  /* ✅ Text takes all remaining space */
        margin: 0;
    }

    .intro-speaker {
        align-self: center;       /* ✅ Ensures icon is centered next to text */
        font-size: 24px;
    }

    .limit-warning {
        background-color: #ffdddd;
        transition: background-color 0.5s ease;
    }

    .email-capture-section {
                        margin: 32px 0;
                        padding: 24px;
                        background-color: #f8f9fa;
                        border: 1px solid #e1e5e9;
                        border-radius: 8px;
                    }

                    .email-capture-box h3 {
                        margin: 0 0 8px 0;
                        font-size: 22px;
                        color: var(--govuk-text-colour);
                    }

                    .email-capture-box p {
                        margin: 0 0 16px 0;
                        color: var(--govuk-secondary-text-colour);
                    }

                    .email-input-group {
                        display: flex;
                        gap: 8px;
                        margin-bottom: 12px;
                    }

                    .email-input {
                        flex: 1;
                        padding: 12px 16px;
                        border: 2px solid var(--govuk-border-colour);
                        border-radius: 4px;
                        font-size: 16px;
                        font-family: var(--govuk-font-family);
                    }

                    .email-input:focus {
                        outline: 3px solid var(--govuk-focus-colour);
                        outline-offset: 0;
                        border-color: var(--govuk-text-colour);
                    }

                    .email-submit-btn {
                        padding: 12px 24px;
                        background-color: var(--govuk-button-colour);
                        color: white;
                        border: none;
                        border-radius: 4px;
                        font-size: 16px;
                        font-weight: bold;
                        cursor: pointer;
                        white-space: nowrap;
                    }

                    .email-submit-btn:hover {
                        background-color: var(--govuk-button-hover-colour);
                    }

                    .email-privacy-note {
                        font-size: 14px;
                        color: var(--govuk-secondary-text-colour);
                        margin: 0;
                    }

                    .email-status {
                        padding: 8px 12px;
                        border-radius: 4px;
                        font-size: 14px;
                        font-weight: bold;
                    }

                    .email-status.success {
                        background-color: #d4edda;
                        color: #155724;
                        border: 1px solid #c3e6cb;
                    }

                    .email-status.error {
                        background-color: #f8d7da;
                        color: #721c24;
                        border: 1px solid #f5c6cb;
                    }

                    /* Mobile responsive */
                    @media (max-width: 600px) {
                        .email-input-group {
                            flex-direction: column;
                        }
                        
                        .email-submit-btn {
                            width: 100%;
                        }
                    }

                    /* RTL support */
                    [dir="rtl"] .email-input-group {
                        direction: ltr; /* Keep email input LTR */
                    }

                    .optin-label {
  display: block;
  margin: 8px 0;
  font-size: 14px;
  color: #333;
}

.optin-label input[type="checkbox"] {
  margin-right: 6px;
}

/* === MAILING LIST SECTION === */
.mailing-list {
  margin: 40px 0;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #ddd;
  max-width: 600px;
}

.mailing-list h3 {
  margin-top: 0;
  font-size: 22px;
}

.mailing-list p {
  margin-bottom: 12px;
  font-size: 15px;
  color: #444;
}

.email-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.email-input-row input[type="email"] {
  flex: 1;
  padding: 10px;
  font-size: 16px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.notify-btn {
  background: #1D70B8;
  color: white;
  border: none;
  padding: 10px 16px;
  font-size: 16px;
  border-radius: 4px;
  cursor: pointer;
}

.notify-btn:hover {
  background: #003078;
}

.optin-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  margin-top: 5px;
}

.privacy-note {
  font-size: 12px;
  color: #666;
  margin-top: 6px;
}

/* Hide honeypot from humans */
.honeypot {
  position: absolute;
  left: -9999px;
}

/* Add these CSS rules to fix the responsive issues */

/* Fix the affiliate box to be mobile-friendly */
.affiliate-box {
    display: flex;
    flex-direction: column; /* Stack vertically on all screens */
    align-items: center;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    margin: 24px 0;
    font-family: Arial, sans-serif;
    gap: 16px;
    max-width: 100%; /* Prevent overflow */
    box-sizing: border-box;
}

.affiliate-box img {
    width: 120px;
    height: auto;
    flex-shrink: 0;
    border-radius: 6px;
}

.affiliate-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    gap: 16px;
}

.affiliate-text {
    width: 100%;
}

.affiliate-content h3 {
    font-size: 18px; /* Smaller on mobile */
    margin: 0 0 8px;
    color: #0B0C0C;
}

.affiliate-content p {
    font-size: 14px; /* Smaller on mobile */
    line-height: 1.4;
    color: #333;
    margin: 0;
}

.affiliate-button input[type="submit"] {
    background: linear-gradient(135deg, #ff5722, #ff784e);
    color: white;
    border: none;
    padding: 12px 24px; /* Smaller padding */
    font-size: 16px;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    width: auto; /* Don't force full width */
}

/* Desktop: side-by-side layout for affiliate box */
@media (min-width: 768px) {
    .affiliate-box {
        flex-direction: row;
        text-align: left;
        gap: 20px;
    }
    
    .affiliate-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        text-align: left;
    }
    
    .affiliate-text {
        flex: 1;
        padding-right: 20px;
    }
    
    .affiliate-content h3 {
        font-size: 20px;
    }
    
    .affiliate-content p {
        font-size: 16px;
    }
    
    .affiliate-button input[type="submit"] {
        padding: 12px 32px;
        font-size: 18px;
    }
}

/* Fix overall page layout issues */
.govuk-width-container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 0 16px;
    box-sizing: border-box; /* Important for preventing overflow */
}

.page-layout {
    display: flex;
    align-items: flex-start;
    gap: 24px; /* Smaller gap on mobile */
    max-width: 100%;
    box-sizing: border-box;
}

.content-area {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%; /* Prevent content from overflowing */
    box-sizing: border-box;
}

.language-sidebar {
    flex: 0 0 200px; /* Smaller sidebar */
    max-width: 200px;
}

/* Mobile: single column layout */
@media (max-width: 900px) {
    .page-layout {
        flex-direction: column;
        gap: 16px;
    }
    
    .language-sidebar {
        flex: none;
        max-width: 100%;
    }
    
    .govuk-width-container {
        padding: 0 12px; /* Less padding on mobile */
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .govuk-width-container {
        padding: 0 8px;
    }
    
    .affiliate-box {
        padding: 12px;
        margin: 16px 0;
    }
    
    .affiliate-content h3 {
        font-size: 16px;
    }
    
    .affiliate-content p {
        font-size: 13px;
    }
}

/* Fix any other elements that might cause horizontal scroll */
.govuk-header__container,
.result-panel,
.govuk-main-wrapper,
.site-footer {
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
}

/* Fix table overflow on mobile */
@media (max-width: 600px) {
    .govuk-table {
        font-size: 16px;
    }
    
    .govuk-table__header,
    .govuk-table__cell {
        padding: 12px 8px 12px 0;
    }
}

/* Add these CSS rules to fix RTL mobile layout issues */

/* Enhanced RTL mobile support */
@media (max-width: 900px) {
    /* Force language sidebar to top on mobile (RTL and LTR) */
    .page-layout {
        flex-direction: column;
        gap: 16px;
    }
    
    .language-sidebar {
        flex: none;
        max-width: 100%;
        order: -1; /* Move to top */
        margin-bottom: 24px;
    }
    
    /* RTL-specific mobile adjustments */
    [dir="rtl"] .language-sidebar {
        order: -1; /* Ensure it stays at top in RTL */
        text-align: right;
    }
    
    /* Make language flags grid work better in RTL on mobile */
    [dir="rtl"] .flags-list {
        direction: ltr; /* Keep flags themselves LTR for consistency */
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    /* RTL mobile content area adjustments */
    [dir="rtl"] .content-area {
        direction: rtl;
    }
    
    /* RTL text alignment on mobile */
    [dir="rtl"] .intro-text,
    [dir="rtl"] .govuk-fieldset__legend,
    [dir="rtl"] .govuk-label,
    [dir="rtl"] p {
        text-align: right;
    }
    
    /* RTL form elements on mobile */
    [dir="rtl"] .govuk-radios__item {
        padding-left: 0;
        padding-right: 40px;
    }
    
    [dir="rtl"] .govuk-radios__label::before {
        left: auto;
        right: 0;
    }
    
    [dir="rtl"] .govuk-radios__input:checked + .govuk-radios__label::after {
        left: auto;
        right: 9px;
    }
    
    /* RTL affiliate box on mobile */
    [dir="rtl"] .affiliate-box {
        direction: ltr; /* Keep affiliate content LTR for readability */
        text-align: center;
    }
    
    /* RTL results panel on mobile */
    [dir="rtl"] .result-panel {
        text-align: right;
    }
    
    [dir="rtl"] .result-panel__total {
        direction: ltr; /* Keep currency amounts LTR */
        display: inline-block;
    }
    
    /* RTL table on mobile */
    [dir="rtl"] .govuk-table__header,
    [dir="rtl"] .govuk-table__cell {
        text-align: right;
        padding: 12px 0 12px 8px;
    }
    
    [dir="rtl"] .govuk-table__cell--numeric {
        text-align: left;
        padding-left: 0;
        padding-right: 8px;
    }
    
    /* RTL speaker buttons on mobile */
    [dir="rtl"] .speak-btn {
        margin-left: 0;
        margin-right: 6px;
    }
    
    /* RTL intro section on mobile */
    [dir="rtl"] .intro-flex {
        flex-direction: row-reverse;
    }
    
    [dir="rtl"] .intro-speaker {
        margin-right: 0;
        margin-left: 12px;
    }
    
    /* RTL household grid on mobile */
    [dir="rtl"] .govuk-household-grid {
        direction: rtl;
    }
    
    [dir="rtl"] .govuk-form-group i.fa-solid {
        margin-right: 0;
        margin-left: 6px;
    }
}

/* Extra small screens RTL fixes */
@media (max-width: 480px) {
    [dir="rtl"] .govuk-width-container {
        padding: 0 8px;
    }
    
    [dir="rtl"] .language-sidebar {
        margin-bottom: 16px;
    }
    
    [dir="rtl"] .flag-button {
        text-align: center;
    }
    
    [dir="rtl"] .affiliate-box {
        margin: 16px 0;
    }
}

/* Fix any remaining RTL mobile issues */
[dir="rtl"] .page-layout {
    direction: rtl;
}

[dir="rtl"] .content-area {
    direction: rtl;
}

/* Keep specific elements LTR even in RTL mode */
[dir="rtl"] .language-sidebar,
[dir="rtl"] .affiliate-box,
[dir="rtl"] .result-panel__total,
[dir="rtl"] .govuk-table__cell--numeric {
    direction: ltr;
}

/* Ensure proper mobile responsive behavior */
@media (max-width: 900px) {
    .govuk-width-container {
        padding: 0 12px;
    }
    
    .page-layout {
        flex-direction: column;
        gap: 16px;
    }
    
    .language-sidebar {
        flex: none;
        max-width: 100%;
        order: -1;
        margin-bottom: 20px;
    }
    
    .flags-list {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .flag-button {
        padding: 8px;
        font-size: 14px;
    }
    
    .flag-button img {
        width: 60px;
        height: 36px;
    }
}

/* Minimal RTL fixes - add these to your style.css */

/* Prevent layout breaking during RTL switch */
html, body {
    transition: none !important;
}

/* Basic RTL text alignment */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .intro-text,
[dir="rtl"] .govuk-fieldset__legend,
[dir="rtl"] .govuk-label,
[dir="rtl"] p {
    text-align: right;
}

/* Keep specific elements LTR for consistency */
[dir="rtl"] .language-sidebar,
[dir="rtl"] .affiliate-box,
[dir="rtl"] .result-panel__total {
    direction: ltr;
    text-align: left;
}

/* RTL form elements */
[dir="rtl"] .govuk-radios__item {
    padding-left: 0;
    padding-right: 40px;
}

[dir="rtl"] .govuk-radios__label::before {
    left: auto;
    right: 0;
}

[dir="rtl"] .govuk-radios__input:checked + .govuk-radios__label::after {
    left: auto;
    right: 9px;
}

/* RTL table alignment */
[dir="rtl"] .govuk-table__header,
[dir="rtl"] .govuk-table__cell {
    text-align: right;
}

[dir="rtl"] .govuk-table__cell--numeric {
    text-align: left;
}

/* Mobile language sidebar positioning */
@media (max-width: 900px) {
    .language-sidebar {
        order: -1;
        margin-bottom: 20px;
    }
    
    .flags-list {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
}

/* Prevent white screen issues */
.content-area {
    min-height: 100px;
    background: white;
}

/* Emergency fallback for broken layouts */
.page-layout {
    min-height: 50vh;
}

/* Hide honeypot properly */
.honeypot {
    position: absolute !important;
    left: -9999px !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
}

/* Minimal RTL fixes - add these to your style.css */

/* Prevent layout breaking during RTL switch */
html, body {
    transition: none !important;
}

/* Basic RTL text alignment */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .intro-text,
[dir="rtl"] .govuk-fieldset__legend,
[dir="rtl"] .govuk-label,
[dir="rtl"] p {
    text-align: right;
}

/* Keep specific elements LTR for consistency */
[dir="rtl"] .language-sidebar,
[dir="rtl"] .affiliate-box,
[dir="rtl"] .result-panel__total {
    direction: ltr;
    text-align: left;
}

/* RTL form elements */
[dir="rtl"] .govuk-radios__item {
    padding-left: 0;
    padding-right: 40px;
}

[dir="rtl"] .govuk-radios__label::before {
    left: auto;
    right: 0;
}

[dir="rtl"] .govuk-radios__input:checked + .govuk-radios__label::after {
    left: auto;
    right: 9px;
}

/* RTL table alignment */
[dir="rtl"] .govuk-table__header,
[dir="rtl"] .govuk-table__cell {
    text-align: right;
}

[dir="rtl"] .govuk-table__cell--numeric {
    text-align: left;
}

/* Mobile language sidebar positioning */
@media (max-width: 900px) {
    .language-sidebar {
        order: -1;
        margin-bottom: 20px;
    }
    
    .flags-list {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
}

/* Prevent white screen issues */
.content-area {
    min-height: 100px;
    background: white;
}

/* Emergency fallback for broken layouts */
.page-layout {
    min-height: 50vh;
}

/* Hide honeypot properly */
.honeypot {
    position: absolute !important;
    left: -9999px !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
}