:root {
    color-scheme: light;
    --brand: #b91c1c;
    --brand-strong: #7f1d1d;
    --brand-soft: #fee2e2;
    --ink: #171717;
    --muted: #667085;
    --line: #f3caca;
    --surface: #ffffff;
    --surface-soft: #fff7f7;
    --success: #027a48;
    --shadow: 0 24px 70px rgba(127, 29, 29, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Tahoma, Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 0%, rgba(220, 38, 38, 0.12), transparent 32rem),
        linear-gradient(180deg, #fff8f3 0%, #ffffff 48%, #fff5f5 100%);
}

body.camera-open {
    overflow: hidden;
}

body.register-open {
    overflow: hidden;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    width: min(1100px, calc(100% - 28px));
    margin: 0 auto;
    padding: max(18px, env(safe-area-inset-top)) 0 48px;
}

.app-shell[hidden],
.device-blocker[hidden] {
    display: none !important;
}

.device-blocker {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.device-blocker-card {
    width: min(560px, 100%);
    border: 1px solid rgba(185, 28, 28, 0.18);
    border-radius: 8px;
    padding: 28px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
    text-align: center;
}

.device-blocker-card img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin-bottom: 14px;
}

.device-blocker-card h1 {
    margin-inline: auto;
    font-size: clamp(1.9rem, 8vw, 3.2rem);
}

.device-blocker-card p:last-child {
    margin: 0 auto;
    max-width: 420px;
    color: var(--muted);
    line-height: 1.75;
}

.hero-panel,
.result-panel {
    border: 1px solid rgba(185, 28, 28, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
}

.hero-panel {
    position: relative;
    overflow: hidden;
    padding: 22px;
}

.hero-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 7px;
    background: linear-gradient(90deg, var(--brand-strong), #ef4444);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 34px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand img {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid var(--brand-soft);
}

.brand strong,
.brand span {
    display: block;
}

.brand strong {
    font-size: 1.08rem;
    color: var(--brand-strong);
}

.brand span,
.secure-badge,
.eyebrow,
.lead,
.message,
.next-reward,
.coupon-card small {
    color: var(--muted);
}

.secure-badge {
    flex: 0 0 auto;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    padding: 7px 11px;
    background: #f0fdf4;
    color: var(--success);
    font-weight: 700;
    font-size: 0.88rem;
}

.hero-copy {
    max-width: 760px;
}

.eyebrow {
    margin: 0 0 10px;
    font-weight: 700;
    color: var(--brand);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 760px;
    margin-bottom: 12px;
    color: var(--brand-strong);
    font-size: clamp(2rem, 7vw, 4.4rem);
    line-height: 1.04;
    letter-spacing: 0;
}

.hero-copy p:last-child {
    margin-bottom: 0;
    max-width: 680px;
    line-height: 1.75;
}

.lookup-form {
    margin-top: 26px;
    max-width: 760px;
}

.lookup-form label {
    display: block;
    margin-bottom: 8px;
    color: var(--brand-strong);
    font-weight: 700;
}

.input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

input,
.input-row button,
.tool-button,
.ghost-button {
    min-height: 48px;
    border-radius: 8px;
}

input {
    width: 100%;
    border: 1px solid #f4b4b4;
    padding: 0 15px;
    background: #ffffff;
    color: var(--ink);
}

input:focus {
    outline: 4px solid rgba(220, 38, 38, 0.14);
    border-color: var(--brand);
}

.input-row button,
.tool-button {
    border: 0;
    padding: 0 18px;
    background: var(--brand);
    color: #ffffff;
    font-weight: 700;
}

.input-row button:disabled,
.tool-button:disabled {
    opacity: 0.62;
    cursor: wait;
}

.scan-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.tool-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--brand);
}

.tool-button span {
    font-size: 1.15rem;
    line-height: 1;
}

.file-button {
    background: #ffffff;
    color: var(--brand);
}

.camera-panel {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
    background: rgba(23, 23, 23, 0.72);
    backdrop-filter: blur(8px);
}

.camera-panel[hidden] {
    display: none !important;
}

.camera-sheet {
    width: min(520px, 100%);
    max-height: calc(100vh - 28px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 8px;
    padding: 12px;
    background: #111827;
    color: #ffffff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

.camera-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.camera-topbar strong {
    min-width: 0;
}

.camera-stage {
    position: relative;
    overflow: hidden;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
    background: #020617;
}

.camera-stage video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-frame {
    position: absolute;
    inset: 18%;
    border: 3px solid #ffffff;
    border-radius: 8px;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.25);
}

.camera-hint {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    text-align: center;
    line-height: 1.5;
}

.ghost-button {
    min-height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--brand-strong);
    font-weight: 700;
}

.message {
    min-height: 26px;
    margin-top: 16px;
    line-height: 1.55;
}

.message.error {
    color: var(--brand);
}

.message.success {
    color: var(--success);
}

.register-modal {
    position: fixed;
    inset: 0;
    z-index: 1010;
    display: none;
    place-items: center;
    padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
    background: rgba(23, 23, 23, 0.72);
    backdrop-filter: blur(8px);
}

.register-modal.is-open {
    display: grid;
}

.register-modal[hidden] {
    display: none !important;
}

.register-sheet {
    width: min(720px, 100%);
    max-height: calc(100vh - 28px);
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

.register-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.register-topbar h2,
.register-copy h2 {
    margin-bottom: 0;
    color: var(--brand-strong);
    font-size: clamp(1.4rem, 4vw, 2rem);
}

.register-copy p {
    margin-bottom: 0;
    line-height: 1.75;
}

.register-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin-top: 18px;
}

.register-form label {
    display: block;
    margin-bottom: 8px;
    color: var(--brand-strong);
    font-weight: 700;
}

.register-row {
    max-width: none;
}

.line-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--brand-soft);
    border-radius: 8px;
    background: var(--surface-soft);
}

.line-card strong {
    display: block;
    margin-bottom: 6px;
    color: var(--brand-strong);
}

.line-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.register-success-notice {
    margin-top: 18px;
    padding: 18px;
    border: 1px solid #86efac;
    border-radius: 8px;
    background: #f0fdf4;
}

.register-success-notice h3 {
    margin: 0 0 10px;
    color: var(--brand-strong);
    font-size: clamp(1.15rem, 3.5vw, 1.5rem);
    line-height: 1.35;
}

.register-success-notice p {
    margin: 0 0 10px;
    line-height: 1.7;
}

.register-success-notice p:last-child {
    margin-bottom: 0;
}

.register-line-id {
    color: var(--brand-strong);
    font-weight: 700;
}

.register-success-hint {
    color: var(--muted);
    font-size: 0.95rem;
}

.register-modal.is-submitted .line-card {
    border-color: #86efac;
    background: #ffffff;
}

.app-shell.has-result .hero-panel {
    padding-bottom: 18px;
}

.result-panel {
    margin-top: 18px;
    padding: 22px;
    overflow: hidden;
    position: relative;
}

.result-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 6px;
    background: linear-gradient(90deg, var(--brand-strong), #ef4444);
}

.result-panel.is-entering {
    animation: result-enter 360ms ease;
}

@keyframes result-enter {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--brand-soft);
}

.result-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--success);
    font-weight: 700;
}

.result-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(2, 122, 72, 0.14);
}

.result-ghost {
    border-color: #f4b4b4 !important;
    color: var(--brand-strong) !important;
    background: #ffffff !important;
}

.member-profile-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--brand-soft);
    border-radius: 12px;
    background: linear-gradient(180deg, #fff7f7 0%, #ffffff 100%);
}

.member-profile-main {
    display: flex;
    align-items: center;
    gap: 14px;
}

.member-avatar {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    min-width: 64px;
    min-height: 64px;
    max-width: 64px;
    max-height: 64px;
    overflow: hidden;
    border-radius: 16px;
    background: linear-gradient(180deg, #fff1f2 0%, #fee2e2 100%);
    border: 1px solid #fecaca;
    box-shadow: 0 8px 20px rgba(127, 29, 29, 0.1);
    color: var(--brand-strong);
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
}

.result-panel img {
    max-width: 72px;
    max-height: 72px;
    object-fit: contain;
}

.member-badge {
    display: inline-block;
    margin-bottom: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #fee2e2;
    color: var(--brand-strong);
    font-size: 0.82rem;
    font-weight: 700;
}

.member-profile-copy h2 {
    margin: 0 0 8px;
    color: var(--brand-strong);
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    line-height: 1.1;
}

.member-code-pill {
    display: inline-block;
    margin: 0;
    padding: 6px 12px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid var(--brand-soft);
    color: var(--muted);
    font-size: 0.95rem;
}

.member-highlights {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.highlight-card {
    padding: 14px;
    border-radius: 10px;
    border: 1px solid var(--brand-soft);
    background: rgba(255, 255, 255, 0.92);
}

.highlight-card span,
.highlight-card small {
    display: block;
}

.highlight-card span {
    color: var(--muted);
    font-size: 0.9rem;
}

.highlight-card strong {
    display: block;
    margin: 8px 0 4px;
    color: var(--brand-strong);
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    line-height: 1;
}

.highlight-card strong em {
    font-size: 1rem;
    font-style: normal;
    color: var(--muted);
    font-weight: 700;
}

.highlight-card small {
    color: var(--muted);
    font-size: 0.85rem;
}

.highlight-card--coupon {
    background: linear-gradient(180deg, #ffffff, #f0fdf4);
    border-color: #bbf7d0;
}

.highlight-card--loyalty {
    background: linear-gradient(180deg, #ffffff, #fff7f7);
}

.loyalty-card,
.stats-section,
.coupon-section {
    margin-top: 18px;
}

.loyalty-card {
    padding: 18px;
    border-radius: 12px;
    background: var(--surface-soft);
    border: 1px solid var(--brand-soft);
}

.loyalty-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.loyalty-card-head h3 {
    margin: 0 0 6px;
    color: var(--brand-strong);
    font-size: 1.1rem;
}

.loyalty-remaining {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #fecaca;
    color: var(--brand-strong);
    font-size: 0.95rem;
}

.progress-track--large {
    height: 16px;
}

.loyalty-steps {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 6px;
    margin-top: 12px;
}

.loyalty-step {
    height: 10px;
    border-radius: 999px;
    background: #fee2e2;
}

.loyalty-step.is-filled {
    background: linear-gradient(90deg, var(--brand-strong), #ef4444);
}

.section-title {
    margin: 0;
    color: var(--brand-strong);
    font-size: 1.05rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.stat-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--brand-soft);
    border-radius: 10px;
    background: #ffffff;
}

.stat-card--wide {
    grid-column: span 1;
}

.stat-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #fff7f7;
    color: var(--brand-strong);
    font-size: 1rem;
}

.stat-card span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.88rem;
}

.stat-card strong {
    color: var(--brand-strong);
    font-size: 1.35rem;
    line-height: 1.2;
}

.coupon-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.coupon-count-label {
    padding: 6px 10px;
    border-radius: 999px;
    background: #fee2e2;
    color: var(--brand-strong);
    font-size: 0.85rem;
    font-weight: 700;
}

.coupon-list {
    display: grid;
    gap: 10px;
}

.coupon-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--brand-soft);
    border-radius: 10px;
    background: #ffffff;
}

.coupon-card-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #fff7f7;
    font-size: 1.2rem;
}

.coupon-card strong {
    color: var(--brand-strong);
}

.coupon-card p {
    margin: 4px 0;
    font-weight: 700;
}

.coupon-card small {
    color: var(--muted);
}

.coupon-card-badge {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 6px 10px;
    background: #ecfdf3;
    color: var(--success);
    font-weight: 700;
    font-size: 0.88rem;
}

.progress-track {
    height: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: #fee2e2;
}

.progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-strong), #ef4444);
    transition: width 320ms ease;
}

.next-reward {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.empty {
    margin: 0;
    padding: 14px;
    border: 1px dashed #fca5a5;
    border-radius: 8px;
    color: var(--muted);
}

@media (max-width: 760px) {
    .app-shell {
        width: min(100% - 18px, 1100px);
        padding-top: 10px;
    }

    .hero-panel,
    .result-panel {
        padding: 18px;
    }

    .topbar,
    .result-toolbar,
    .coupon-card {
        align-items: stretch;
        flex-direction: column;
    }

    .member-profile-main {
        flex-direction: row;
        align-items: center;
    }

    .result-toolbar .result-ghost {
        width: 100%;
    }

    .member-highlights,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .loyalty-card-head {
        flex-direction: column;
    }

    .loyalty-remaining {
        width: fit-content;
    }

    .secure-badge {
        width: max-content;
    }

    .input-row,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .input-row button,
    .tool-button {
        width: 100%;
    }

    .scan-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .register-sheet {
        width: 100%;
        max-height: none;
        height: 100vh;
        border: 0;
        border-radius: 0;
        padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
    }

    .register-topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .camera-panel {
        padding: 0;
    }

    .camera-sheet {
        width: 100%;
        height: 100vh;
        max-height: none;
        border: 0;
        border-radius: 0;
        padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
    }

    .camera-stage {
        min-height: 0;
        aspect-ratio: auto;
    }

    .coupon-card {
        grid-template-columns: 1fr;
    }

    .coupon-card-badge {
        width: fit-content;
    }
}
