:root {
    --primary: #5a7bec;
    /* blue theme */
    --bg-dark: #0d0e14;
    --radius: 12px;

    /* --------- Background source variables (default PNG fallback) --------- */
    --welcome-1x: url('../img/bg_welcome.png');
    --welcome-2x: url('../img/bg_welcome.png');
    --terms-1x: url('../img/bg_terms.png');
    --terms-2x: url('../img/bg_terms.png');
    --quiz-1x: url('../img/bg_quiz.png');
    --quiz-2x: url('../img/bg_quiz.png');

    /* the "current" hero picked per-page by body class (see below) */
    --hero-img-1x: var(--welcome-1x);
    --hero-img-2x: var(--welcome-2x);
}

/* Upgrade to WebP when supported */
@supports (background-image: url("../img/bg_welcome.webp")) {
    :root {
        --welcome-1x: url('../img/bg_welcome.webp');
        --welcome-2x: url('../img/bg_welcome@2x.webp');
        --terms-1x: url('../img/bg_terms.webp');
        --terms-2x: url('../img/bg_terms@2x.webp');
        --quiz-1x: url('../img/bg_quiz.webp');
        --quiz-2x: url('../img/bg_quiz@2x.webp');
    }
}

/* Upgrade to AVIF when supported */
@supports (background-image: url("../img/bg_welcome.avif")) {
    :root {
        --welcome-1x: url('../img/bg_welcome.avif');
        --welcome-2x: url('../img/bg_welcome@2x.avif');
        --terms-1x: url('../img/bg_terms.avif');
        --terms-2x: url('../img/bg_terms@2x.avif');
        --quiz-1x: url('../img/bg_quiz.avif');
        --quiz-2x: url('../img/bg_quiz@2x.avif');
    }
}

/* Pick which background to show (welcome / terms+instructions / quiz) */
body.bg-welcome {
    --hero-img-1x: var(--welcome-1x);
    --hero-img-2x: var(--welcome-2x);
}

body.bg-terms {
    --hero-img-1x: var(--terms-1x);
    --hero-img-2x: var(--terms-2x);
}

body.bg-quiz {
    --hero-img-1x: var(--quiz-1x);
    --hero-img-2x: var(--quiz-2x);
}

/* ---------- Base layout ---------- */
html,
body {
    height: 100%;
    margin: 0;
    font-family: 'Heebo', sans-serif;
    background: var(--bg-dark);
    color: #fff;
}

/* ---------- Mobile background (fixed hero) ---------- */
body.mobile-ready {
    background: transparent;

    display: flex;
    align-items: flex-start;
    justify-content: center;
    text-align: center;
    padding: 50px 24px calc(24px + env(safe-area-inset-bottom));

    position: relative;
    z-index: 1;
    overflow-x: hidden;
    transform: translateZ(0);
}

/* ---------- Mobile hero curtain ---------- */
body.mobile-ready::before {
    content: '';
    position: fixed;
    inset: 0;

    background: var(--hero-img-1x) bottom center / cover no-repeat;
    background-color: var(--bg-dark);
    background-attachment: fixed;

    z-index: 0;
    pointer-events: none;
}

/* retina / 2× */
@media (min-resolution:192dpi),
(min-resolution:2dppx) {
    body.mobile-ready::before {
        background-image: var(--hero-img-2x);
        background-size: cover;
        background-position: bottom center;
    }
}

/* performance hint for very old / low-end devices */
@media (prefers-reduced-motion: reduce) {
    body.mobile-ready::before {
        will-change: auto;
    }
}

a,
button,
input {
    font-family: inherit;
}

/* blue links used in consent screen & modal */
a.rules-link,
a.consent-link {
    color: var(--primary);
    text-decoration: underline;
    font-weight: 700;
}

a.rules-link:hover,
a.consent-link:hover {
    filter: brightness(1.06);
}

#consent-next[aria-disabled="true"] {
    opacity: .45;
    filter: saturate(.4);
    cursor: pointer;
    pointer-events: auto;
}

/* ===== Rules-modal polish ===== */
.rules-scroll {
    padding-inline: .5rem .75rem;
}

.rules-scroll p {
    position: relative;
    margin: .8em 0 0;
    padding-inline-start: 3.2em;
    /* number column width (RTL-aware) */
    text-align: right;
    line-height: 1.6;
}

.rules-scroll p:first-child {
    margin-top: 0;
}

.rules-scroll p>strong:first-child {
    position: absolute;
    inset-inline-start: 0;
    display: inline-block;
    min-width: 3.2em;
    margin-inline-end: .4em;
    text-align: center;
    font-weight: 700;
    letter-spacing: .02em;
}

#rules-modal .modal-content h3 {
    text-align: center;
}

/* ---------- Shared wrapper ---------- */
.wrapper {
    width: 100%;
    max-width: 360px;
    min-width: 320px;
    min-height: 100dvh;
    position: relative;
    z-index: 2;
}

/* Logo (rounded corners) */
.logo {
    display: block;
    width: 160px;
    height: auto;
    margin: 0 auto 28px;
    border-radius: 16px;
}

/* Headings */
h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0 0 18px;
    line-height: 1.45;
}

.title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 18px;
}

/* ---------- Form ---------- */
form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

input[type=text] {
    padding: 16px 20px;
    font-size: 1.25rem;
    border: 2px solid var(--primary);
    background: #ffffff08;
    color: #fff;
    border-radius: var(--radius);
    outline: none;
    text-align: center;
    direction: rtl;
}

input[type=text]::placeholder,
input[type=text]::-webkit-input-placeholder {
    font-size: 1.25rem;
    color: #fff;
    text-align: center;
    direction: rtl;
}

button {
    padding: 14px 16px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: filter .2s;
}

button:hover {
    filter: brightness(1.06);
}

/* Make action buttons full-width and consistent */
button[type="submit"],
#begin-btn {
    width: 100%;
}

/* ---------- Desktop warning ---------- */
#desktop-warning {
    display: none;
    height: 100%;
    width: 100%;
    background: var(--bg-dark);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 400;
    padding: 24px;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: 20px;
}

#desktop-warning .dw-logo {
    width: 140px;
    height: auto;
    margin: 0 0 12px;
}

#desktop-warning p {
    max-width: 440px;
    margin: 0;
    line-height: 1.6;
}

/* ---------- Instructions screen ---------- */
.instructions-intro {
    margin: 0 0 12px;
    font-size: 1rem;
    line-height: 1.6;
    text-align: right;
    opacity: .95;
}

/* Make each list item create a fixed number column on the RIGHT (RTL),
   and let the text wrap only within the text column (hanging indent). */
.instructions-list {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
}

.instructions-list li {
    position: relative;
    margin: 12px 0;
    font-size: 1rem;
    line-height: 1.6;
    text-align: right;
    padding-inline-start: 2.4em;
    /* reserve a 2.4em number column on the RTL "start" side */
}

.instructions-list .number {
    position: absolute;
    inset-inline-start: 0;
    /* RTL-aware right edge */
    display: inline-block;
    min-width: 2.4em;
    /* must match the padding above */
    text-align: center;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: .02em;
}

/* ---------- Modal ---------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-dark);
    color: #fff;
    border-radius: var(--radius);
    padding: 24px 20px 32px;
    max-width: 320px;
    width: 90%;
    text-align: right;
    position: relative;
}

.modal-content h3 {
    margin: 0 0 12px;
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-content p {
    margin: 0;
    font-size: .95rem;
    line-height: 1.6;
}

.modal-close {
    position: absolute;
    top: 8px;
    left: 8px;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
}

#feedback-text {
    margin-left: 32px;
}

/* ---------- Quiz question ---------- */
.question-text {
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 12px;
    text-align: right;
}

.pw-item {
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 12px 14px 10px;
    margin: 0 0 14px;
}

.pw-label {
    margin: 0 0 10px;
    font-weight: 700;
    font-size: 1rem;
}

/* === Align radio/checkbox bullets + right-align multi-line text ===
   Grid with two columns: [icon] [text]. For consent label we wrap the text+link
   in <span class="label-text"> so it becomes ONE grid item in column 2. */
.pw-item label {
    direction: rtl;
    /* Hebrew flow */
    display: grid;
    grid-template-columns: auto 1fr;
    /* [radio/checkbox] [text] */
    column-gap: 8px;
    align-items: start;
    /* top-align by default (great for multi-line options) */
    text-align: right;
    /* right-align the text block */
    margin: 6px 0;
    line-height: 1.6;
    font-size: .95rem;
}

/* Put the combined text block in column 2 when present */
.pw-item label .label-text {
    grid-column: 2;
}

/* Tweak the control’s vertical alignment a touch */
.pw-item input[type="radio"],
.pw-item input[type="checkbox"] {
    margin-top: 3px;
    align-self: start;
}

.attempts {
    font-size: .9rem;
    margin: -4px 0 12px;
    color: #c9d3ff;
    /* tuned to the blue theme */
    text-align: center;
}

/* ---------- Final window tweaks ---------- */
.fail-box {
    padding: 28px 18px 26px;
    text-align: center;
}

.fail-label {
    font-size: 1.4rem;
}

.fail-text {
    font-size: 1.1rem;
    line-height: 1.7;
    margin: 0;
}

/* === NEW: consent-only centering ================================
   Center the single-line checkbox and text vertically for a cleaner look,
   without changing the multi-line alignment used in the quiz questions. */
#consent-form .pw-item label {
    align-items: center;
    /* center both cells in the grid row */
}

#consent-form .pw-item input[type="checkbox"] {
    align-self: center;
    /* override the generic start align */
    margin-top: 0;
    /* remove the nudge used elsewhere */
}