:root {
    color-scheme: light;
    --navy: #0f205f;
    --blue: #17388f;
    --blue-bright: #2451d3;
    --red: #e8293e;
    --red-dark: #c91d31;
    --pink: #f4b7c2;
    --cream: #fff8eb;
    --paper: #fffdf8;
    --surface: #ffffff;
    --ink: #11142d;
    --muted: #5c6075;
    --line: rgba(15, 32, 95, .2);
    --soft-blue: #eef2ff;
    --danger: #a51e30;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 280px;
    background: var(--paper);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 4%, rgba(244, 183, 194, .48), transparent 18rem),
        radial-gradient(circle at 96% 34%, rgba(36, 81, 211, .1), transparent 22rem),
        linear-gradient(rgba(15, 32, 95, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 32, 95, .035) 1px, transparent 1px),
        var(--paper);
    background-size: auto, auto, 26px 26px, 26px 26px, auto;
    font-family: "Avenir Next", Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overscroll-behavior-y: none;
}

button,
textarea {
    font: inherit;
}

button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--pink);
    outline-offset: 3px;
}

::selection {
    color: #fff;
    background: var(--blue);
}

[hidden] {
    display: none !important;
}

.payment-page {
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
    padding:
        max(22px, env(safe-area-inset-top))
        max(14px, env(safe-area-inset-right))
        max(32px, env(safe-area-inset-bottom))
        max(14px, env(safe-area-inset-left));
}

.payment-header {
    position: relative;
    margin-bottom: 20px;
    padding-top: 42px;
    text-align: center;
}

.payment-header::before {
    content: "MERCHFANS";
    position: absolute;
    top: 0;
    left: 0;
    color: var(--navy);
    font-family: "Arial Rounded MT Bold", "Avenir Next", sans-serif;
    font-size: 19px;
    font-weight: 950;
    letter-spacing: -.07em;
}

.payment-header::after {
    content: "CHECKOUT";
    position: absolute;
    top: 3px;
    right: 0;
    padding: 5px 8px 4px;
    border: 1px solid var(--navy);
    border-radius: 999px;
    color: var(--navy);
    background: var(--cream);
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .14em;
}

.payment-header h1 {
    margin: 12px 0 5px;
    color: var(--navy);
    font-family: "Arial Rounded MT Bold", "Arial Black", "Avenir Next", sans-serif;
    font-size: 22px;
    font-weight: 950;
    line-height: 1.08;
    letter-spacing: -.035em;
}

.payment-header p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.45;
}

.lock {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 32px;
    border: 2px solid var(--navy);
    border-radius: 9px;
    background: var(--red);
    box-shadow: 4px 4px 0 var(--navy);
    transform: rotate(-3deg);
}

.lock::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 15px;
    left: 7px;
    top: -13px;
    border: 3px solid var(--navy);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: transparent;
}

.lock::after {
    content: "";
    position: absolute;
    width: 4px;
    height: 9px;
    left: 15px;
    top: 10px;
    border-radius: 4px;
    background: #fff;
}

.payment-card,
.instructions {
    border: 2px solid var(--navy);
    background: var(--surface);
}

.payment-card {
    min-height: 250px;
    padding: 19px;
    border-radius: 20px;
    box-shadow: 7px 7px 0 var(--navy);
}

.loading-state,
.error-state {
    min-height: 330px;
    padding: 70px 8px 38px;
    text-align: center;
}

.loading-state h2,
.error-state h2 {
    margin: 21px 0 8px;
    color: var(--navy);
    font-family: "Arial Rounded MT Bold", "Avenir Next", sans-serif;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: -.035em;
}

.loading-state p,
.error-state p {
    max-width: 330px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.loading-state strong,
.error-state strong {
    color: var(--navy);
}

.spinner {
    display: inline-block;
    width: 52px;
    height: 52px;
    border: 5px solid var(--pink);
    border-top-color: var(--red);
    border-right-color: var(--navy);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-state > span {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin: 0 auto;
    border: 2px solid var(--navy);
    border-radius: 50%;
    color: #fff;
    background: var(--red);
    box-shadow: 4px 4px 0 var(--navy);
    font-weight: 950;
}

.error-state button,
.copy-area button {
    border: 2px solid var(--navy);
    border-radius: 12px;
    color: #fff;
    background: var(--red);
    box-shadow: 4px 4px 0 var(--navy);
    cursor: pointer;
    font-weight: 900;
    letter-spacing: .015em;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.error-state button {
    min-height: 50px;
    margin-top: 22px;
    padding: 11px 22px;
}

.error-state button:hover,
.copy-area button:hover {
    background: var(--red-dark);
    transform: translate(-1px, -1px);
    box-shadow: 6px 6px 0 var(--navy);
}

.error-state button:active,
.copy-area button:active {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0 var(--navy);
}

.value-block {
    margin: -19px -19px 20px;
    padding: 22px 18px 19px;
    border-bottom: 2px solid var(--navy);
    border-radius: 17px 17px 0 0;
    background: var(--cream);
    text-align: center;
}

.value-block span {
    display: block;
    color: var(--red);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.value-block strong {
    display: block;
    margin: 5px 0 4px;
    color: var(--navy);
    font-family: "Arial Rounded MT Bold", "Arial Black", "Avenir Next", sans-serif;
    font-size: 36px;
    font-weight: 950;
    line-height: 1.05;
    letter-spacing: -.065em;
}

.value-block small {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--blue);
    font-size: 11px;
    font-weight: 800;
}

.value-block small::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #20a267;
    box-shadow: 0 0 0 4px rgba(32, 162, 103, .12);
}

.qr-wrapper {
    position: relative;
    width: min(70vw, 260px);
    margin: 14px auto 13px;
    padding: 10px;
    border: 2px solid var(--navy);
    border-radius: 16px;
    background: #fff;
    box-shadow: 5px 5px 0 var(--pink);
}

.qr-wrapper::before,
.qr-wrapper::after {
    content: "";
    position: absolute;
    width: 15px;
    height: 15px;
    pointer-events: none;
}

.qr-wrapper::before {
    top: 5px;
    left: 5px;
    border-top: 3px solid var(--red);
    border-left: 3px solid var(--red);
}

.qr-wrapper::after {
    right: 5px;
    bottom: 5px;
    border-right: 3px solid var(--red);
    border-bottom: 3px solid var(--red);
}

.qr-wrapper img {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: pixelated;
}

.scan-label {
    max-width: 300px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.45;
    text-align: center;
}

.separator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 21px 0 16px;
    color: var(--blue);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .07em;
    text-align: center;
    text-transform: uppercase;
}

.separator::before,
.separator::after {
    content: "";
    height: 2px;
    flex: 1;
    background: var(--pink);
}

.pix-state label {
    display: block;
    margin-bottom: 8px;
    color: var(--navy);
    font-size: 12px;
    font-weight: 900;
}

.copy-area {
    display: grid;
    gap: 10px;
}

.copy-area textarea {
    width: 100%;
    min-height: 72px;
    max-height: 72px;
    padding: 11px;
    resize: none;
    border: 2px solid var(--line);
    border-radius: 12px;
    outline: 0;
    color: var(--navy);
    background: var(--soft-blue);
    font: 9.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
    scrollbar-width: thin;
    transition: border-color .16s ease, box-shadow .16s ease;
}

.copy-area textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(244, 183, 194, .5);
}

.copy-area button {
    min-height: 54px;
    font-size: 15px;
    text-transform: uppercase;
}

.copy-feedback {
    min-height: 17px;
    margin: 9px 0 0;
    color: var(--blue);
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}

.instructions {
    position: relative;
    margin-top: 18px;
    padding: 22px 18px;
    overflow: hidden;
    border-radius: 18px;
    background: var(--cream);
}

.instructions::after {
    content: "✦";
    position: absolute;
    top: -23px;
    right: -10px;
    color: var(--pink);
    font-size: 82px;
    line-height: 1;
    opacity: .65;
    pointer-events: none;
    transform: rotate(12deg);
}

.instructions h2 {
    position: relative;
    z-index: 1;
    margin: 0 0 17px;
    color: var(--navy);
    font-family: "Arial Rounded MT Bold", "Avenir Next", sans-serif;
    font-size: 20px;
    font-weight: 950;
    letter-spacing: -.035em;
}

.instructions ol {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 15px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.instructions li {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 12px;
    align-items: start;
}

.instructions li > span {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 2px solid var(--navy);
    border-radius: 10px;
    color: #fff;
    background: var(--blue);
    box-shadow: 3px 3px 0 var(--pink);
    font-size: 12px;
    font-weight: 950;
    transform: rotate(-3deg);
}

.instructions li:nth-child(2) > span {
    background: var(--red);
    transform: rotate(3deg);
}

.instructions p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.instructions strong {
    color: var(--navy);
}

footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 22px;
    color: var(--navy);
    font-size: 11px;
    font-weight: 800;
}

.shield {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border: 1px solid var(--navy);
    border-radius: 50%;
    color: #fff;
    background: var(--blue);
    font-size: 10px;
}

@media (min-width: 521px) {
    .payment-page {
        padding-top: 40px;
        padding-bottom: 46px;
    }

    .payment-header {
        margin-bottom: 26px;
        padding-top: 48px;
    }

    .payment-header::before {
        font-size: 22px;
    }

    .payment-header::after {
        top: 4px;
        font-size: 9px;
    }

    .payment-header h1 {
        margin-top: 15px;
        font-size: 25px;
    }

    .payment-header p {
        font-size: 13px;
    }

    .lock {
        width: 42px;
        height: 36px;
    }

    .lock::before {
        width: 20px;
        height: 18px;
        left: 8px;
        top: -15px;
    }

    .lock::after {
        width: 5px;
        height: 10px;
        left: 16px;
        top: 12px;
    }

    .payment-card {
        padding: 29px;
        border-radius: 22px;
        box-shadow: 9px 9px 0 var(--navy);
    }

    .value-block {
        margin: -29px -29px 25px;
        padding: 26px 22px 22px;
        border-radius: 19px 19px 0 0;
    }

    .value-block strong {
        font-size: 42px;
    }

    .qr-wrapper {
        width: 280px;
        margin-top: 18px;
        padding: 11px;
    }

    .scan-label {
        font-size: 13px;
    }

    .separator {
        margin: 27px 0 20px;
        font-size: 10px;
    }

    .copy-area textarea {
        min-height: 80px;
        max-height: 80px;
        padding: 13px;
        font-size: 10px;
    }

    .copy-area button {
        min-height: 52px;
        font-size: 14px;
    }

    .instructions {
        margin-top: 22px;
        padding: 26px 27px;
        border-radius: 20px;
    }
}

@media (max-width: 340px) {
    .payment-page {
        padding-left: 9px;
        padding-right: 9px;
    }

    .payment-header::before {
        font-size: 17px;
    }

    .payment-card {
        padding: 15px;
        box-shadow: 5px 5px 0 var(--navy);
    }

    .value-block {
        margin: -15px -15px 17px;
    }

    .payment-header h1 {
        font-size: 20px;
    }

    .qr-wrapper {
        width: min(68vw, 224px);
    }

    .instructions {
        padding: 20px 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
