* {
    box-sizing: border-box;
}

html, body, form {
    margin: 0;
    width: 100%;
    min-height: 100%;
}

body {
    font-family: "Leelawadee UI", "Tahoma", "Arial", sans-serif;
}

.qr-reference-page {
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 58% 20%, rgba(255,255,255,.98) 0 22%, rgba(247,253,255,.96) 43%, rgba(226,247,251,.95) 100%);
    color: #064f48;
}

.qr-reference-layout {
    position: relative;
    min-height: 100vh;
    padding: clamp(24px, 2vw, 30px);
    overflow: hidden;
}

/* Poster is the original pixel crop from the user's reference image. */
.reference-poster {
    position: relative;
    z-index: 5;
    width: min(43vw, 669px);
}

.reference-poster-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(100vh - 48px);
    object-fit: contain;
    object-position: left top;
}

/* Right-side controls based on the supplied reference. */
.reference-actions {
    position: absolute;
    z-index: 10;
    top: clamp(64px, 6.4vh, 86px);
    left: 46.5vw;
    right: clamp(28px, 2.8vw, 52px);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: clamp(18px, 2vw, 30px);
}

.reference-print-button {
    width: min(34vw, 520px);
    min-width: 390px;
    height: clamp(138px, 16vh, 172px);
    border: 3px solid rgba(255,255,255,.88);
    border-radius: 28px;
    background: linear-gradient(135deg, #09c99e 0%, #02ad7c 45%, #008b53 100%);
    color: #fff;
    box-shadow:
        0 7px 0 rgba(7,94,64,.24),
        0 18px 35px rgba(0,127,92,.22);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(28px, 2.5vw, 50px);
    padding: 0 38px;
    cursor: pointer;
    font-size: clamp(48px, 4.3vw, 72px);
    font-weight: 900;
    line-height: 1;
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

.reference-print-button:hover {
    transform: translateY(-2px);
    filter: brightness(1.02);
    box-shadow:
        0 8px 0 rgba(7,94,64,.24),
        0 22px 40px rgba(0,127,92,.25);
}

.reference-print-button:active {
    transform: translateY(2px);
}

.reference-print-button svg {
    width: clamp(66px, 5.4vw, 92px);
    height: clamp(66px, 5.4vw, 92px);
    fill: currentColor;
    flex: 0 0 auto;
}

.button-divider {
    width: 2px;
    height: 62%;
    background: rgba(255,255,255,.75);
    flex: 0 0 auto;
}

.reference-back-button {
    height: clamp(88px, 9.2vh, 108px);
    min-width: 255px;
    padding: 0 clamp(24px, 2vw, 38px);
    border: 2px solid #16a865;
    border-radius: 24px;
    background: rgba(255,255,255,.94);
    color: #075f4d;
    box-shadow: 0 6px 13px rgba(1,90,67,.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    text-decoration: none;
    font-size: clamp(23px, 1.65vw, 31px);
    font-weight: 800;
    white-space: nowrap;
    transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

.reference-back-button:hover {
    transform: translateY(-2px);
    background: #fff;
    box-shadow: 0 10px 18px rgba(1,90,67,.18);
}

.back-arrow {
    font-size: 1.5em;
    line-height: 1;
    font-weight: 900;
}

.medical-cross {
    position: absolute;
    z-index: 1;
    color: rgba(39, 201, 222, .13);
    font-weight: 900;
    line-height: .75;
    user-select: none;
}

.cross-large {
    right: 5.2vw;
    top: 25vh;
    font-size: clamp(150px, 13vw, 230px);
}

.cross-small {
    right: 17vw;
    top: 46vh;
    font-size: clamp(75px, 7vw, 120px);
}

.medical-hexagons {
    position: absolute;
    z-index: 1;
    right: -2vw;
    top: 38vh;
    width: 280px;
    height: 310px;
    opacity: .28;
}

.medical-hexagons span {
    position: absolute;
    width: 112px;
    height: 98px;
    border: 3px solid rgba(255,255,255,.95);
    clip-path: polygon(25% 0,75% 0,100% 50%,75% 100%,25% 100%,0 50%);
}

.medical-hexagons span:nth-child(1) { left: 74px; top: 0; }
.medical-hexagons span:nth-child(2) { left: 22px; top: 87px; }
.medical-hexagons span:nth-child(3) { left: 126px; top: 87px; }
.medical-hexagons span:nth-child(4) { left: 74px; top: 174px; }

.medical-wave {
    position: absolute;
    z-index: 0;
    left: 32%;
    right: -14%;
    border-radius: 50%;
    transform: rotate(8deg);
    pointer-events: none;
}

.wave-one {
    bottom: -185px;
    height: 430px;
    background: linear-gradient(180deg, rgba(115,225,228,.54), rgba(24,199,193,.72));
}

.wave-two {
    bottom: -265px;
    height: 470px;
    border: 18px solid rgba(255,255,255,.72);
    background: rgba(73,207,214,.18);
}

@media (max-width: 1366px) {
    .qr-reference-layout {
        padding: 18px 20px;
    }

    .reference-poster {
        width: min(44.5vw, 600px);
    }

    .reference-actions {
        left: 47vw;
        top: 52px;
        right: 24px;
        gap: 16px;
    }

    .reference-print-button {
        min-width: 330px;
        height: 116px;
        border-radius: 23px;
        font-size: 48px;
        gap: 28px;
        padding: 0 26px;
    }

    .reference-print-button svg {
        width: 64px;
        height: 64px;
    }

    .reference-back-button {
        min-width: 220px;
        height: 78px;
        font-size: 22px;
        border-radius: 20px;
    }
}

@media (max-width: 1050px) {
    .qr-reference-layout {
        padding: 18px;
        overflow: visible;
    }

    .reference-actions {
        position: relative;
        inset: auto;
        width: 100%;
        margin-bottom: 18px;
        justify-content: center;
        flex-wrap: wrap;
    }

    .reference-poster {
        width: min(100%, 669px);
        margin: 0 auto;
    }

    .reference-poster-image {
        max-height: none;
    }

    .reference-print-button {
        width: min(620px, 100%);
        min-width: 0;
        height: 100px;
        font-size: 42px;
    }

    .reference-back-button {
        width: min(360px, 100%);
    }
}

@media print {
    @page {
        size: A4 portrait;
        margin: 7mm;
    }

    html, body, form, .qr-reference-page {
        background: #fff !important;
    }

    .no-print,
    .reference-actions,
    .medical-cross,
    .medical-hexagons,
    .medical-wave {
        display: none !important;
    }

    .qr-reference-layout {
        min-height: 0;
        padding: 0;
        overflow: visible;
    }

    .reference-poster {
        width: 100%;
        max-width: 190mm;
        margin: 0 auto;
    }

    .reference-poster-image {
        width: 100%;
        max-height: 277mm;
        object-fit: contain;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}
