:root {
    --bg: #f7f2e9;
    --bg-soft: #efe5d6;
    --surface: #fffdf9;
    --surface-2: #f8f0e4;
    --ink: #2d1c13;
    --muted: #746357;
    --gold: #d9a126;
    --gold-deep: #9d6817;
    --gold-light: #f8d77e;
    --red: #a62125;
    --green: #258c50;
    --line: rgba(93, 61, 35, .14);
    --shadow: 0 24px 70px rgba(83, 52, 29, .12);
    --radius: 28px;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background:
        linear-gradient(rgba(30, 15, 8, .56), rgba(30, 15, 8, .76)),
        url('../images/festival-cover.jpg') center/cover fixed;
}
.login-shell { width: min(100%, 520px); }
.login-card {
    padding: clamp(24px, 5vw, 42px);
    text-align: center;
    background: rgba(255, 253, 249, .96);
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 30px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, .3);
    backdrop-filter: blur(18px);
}
.login-logo {
    width: min(280px, 75vw);
    max-height: 180px;
    object-fit: contain;
    margin-bottom: 20px;
    border-radius: 18px;
    background: #0a0705;
}
.login-card h1 { margin: 8px 0 10px; font: 700 clamp(1.8rem, 5vw, 2.5rem)/1.1 var(--serif); }
.login-card p { color: var(--muted); line-height: 1.65; }
.login-form { display: grid; gap: 18px; margin-top: 24px; text-align: left; }
.login-form label { display: grid; gap: 8px; font-weight: 750; color: #4b2d1d; }
.login-form input, .cpf-form input {
    width: 100%;
    padding: 15px 16px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #d8c9b7;
    border-radius: 15px;
    outline: none;
    transition: border .2s, box-shadow .2s, background .2s;
}
.login-form input:focus, .cpf-form input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(217, 161, 38, .16);
}
.cpf-form input[aria-invalid="true"] {
    border-color: #c94348;
    background: #fff8f8;
    box-shadow: 0 0 0 4px rgba(201, 67, 72, .1);
}
.login-note { margin-top: 18px; font-size: .9rem; }
.setup-card { width: min(100%, 620px); }
.alert { padding: 13px 15px; margin: 16px 0; border-radius: 13px; font-size: .94rem; }
.alert-error { color: #8a1c20; background: #ffebeb; border: 1px solid #edb4b4; }
.text-link { display: inline-block; margin-top: 22px; color: #6f431f; font-weight: 700; }
.success-panel { display: grid; justify-items: center; gap: 12px; }
.success-panel .primary-button, .success-panel .secondary-button { width: 100%; text-decoration: none; }

.eyebrow, .step-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--gold-deep);
    font-size: .75rem;
    font-weight: 900;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.primary-button, .secondary-button {
    min-height: 52px;
    padding: 13px 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 0;
    border-radius: 16px;
    font-weight: 900;
    transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}
.primary-button {
    color: #2e180b;
    background: linear-gradient(135deg, #f9dc85, #dca326);
    box-shadow: 0 12px 28px rgba(198, 137, 25, .22);
}
.primary-button:hover, .secondary-button:hover { transform: translateY(-2px); }
.primary-button:disabled { cursor: not-allowed; opacity: .5; transform: none; box-shadow: none; }
.secondary-button { color: #59351f; background: #f8f1e6; border: 1px solid #decdb7; }

.app-body {
    min-height: 100vh;
    padding-bottom: 72px;
    background:
        radial-gradient(circle at 5% 0%, rgba(245, 211, 127, .24), transparent 27rem),
        radial-gradient(circle at 96% 18%, rgba(156, 93, 38, .08), transparent 31rem),
        var(--bg);
}
.offline-banner {
    position: sticky;
    top: 0;
    z-index: 80;
    padding: 10px 16px;
    color: #664410;
    background: #fff1bf;
    border-bottom: 1px solid #e6ca72;
    text-align: center;
    font-size: .9rem;
    font-weight: 800;
}
.test-ribbon {
    position: fixed;
    top: 12px;
    left: 50%;
    z-index: 70;
    transform: translateX(-50%);
    padding: 7px 13px;
    color: #fff;
    background: #6d38ad;
    border-radius: 999px;
    box-shadow: 0 10px 24px rgba(74, 31, 127, .3);
    font-size: .7rem;
    font-weight: 900;
    letter-spacing: .12em;
}
.app-header {
    min-height: 108px;
    padding: 16px clamp(18px, 4vw, 54px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: var(--ink);
    background: rgba(255, 253, 249, .9);
    border-bottom: 1px solid rgba(104, 70, 43, .12);
    box-shadow: 0 10px 32px rgba(78, 48, 26, .07);
    backdrop-filter: blur(18px);
}
.brand-block { display: flex; align-items: center; gap: 17px; min-width: 0; }
.brand-logo {
    width: 112px;
    height: 76px;
    flex: 0 0 auto;
    object-fit: contain;
    background: #0b0705;
    border-radius: 13px;
    box-shadow: 0 8px 22px rgba(55, 29, 13, .13);
}
.brand-kicker { margin: 0 0 4px; color: var(--gold-deep) !important; font-size: .7rem !important; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.brand-block h1 { margin: 0; font: 700 clamp(1.12rem, 2.5vw, 1.9rem)/1.1 var(--serif); }
.brand-block h1 span { color: var(--gold-deep); white-space: nowrap; }
.brand-block p { margin: 5px 0 0; color: var(--muted); font-size: .88rem; }
.status-pill {
    min-width: 238px;
    padding: 11px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 17px;
    box-shadow: 0 8px 24px rgba(77, 47, 27, .07);
}
.status-dot { width: 12px; height: 12px; flex: 0 0 auto; border-radius: 50%; }
.status-pill.is-open .status-dot { background: #34b769; box-shadow: 0 0 0 6px rgba(52, 183, 105, .12), 0 0 16px rgba(52, 183, 105, .35); }
.status-pill.is-closed .status-dot { background: #e84f56; box-shadow: 0 0 0 6px rgba(232, 79, 86, .1), 0 0 15px rgba(232, 79, 86, .28); }
.status-pill strong { display: block; color: var(--ink); font-size: .92rem; }
.status-pill small { display: block; margin-top: 3px; color: var(--muted); font-size: .76rem; }

.app-main { width: min(1420px, calc(100% - 34px)); margin: 28px auto 0; }
.screen { display: none; animation: screenIn .32s ease; }
.screen.is-active { display: block; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero-card {
    min-height: clamp(560px, 68vh, 735px);
    display: grid;
    grid-template-columns: minmax(0, .94fr) minmax(470px, 1.06fr);
    overflow: hidden;
    background: rgba(255, 253, 249, .96);
    border: 1px solid rgba(99, 66, 39, .12);
    border-radius: 34px;
    box-shadow: var(--shadow);
}
.hero-content {
    padding: clamp(42px, 6vw, 88px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: var(--ink);
}
.hero-content .eyebrow { margin-bottom: 18px; }
.hero-content h2 {
    max-width: 660px;
    margin: 0;
    font: 700 clamp(3.4rem, 6.7vw, 6.6rem)/.92 var(--serif);
    letter-spacing: -.045em;
}
.hero-content h2 em { color: var(--gold-deep); font-weight: 500; }
.hero-content > p {
    max-width: 610px;
    margin: 24px 0 0;
    color: var(--muted);
    font-size: clamp(1rem, 1.55vw, 1.2rem);
    line-height: 1.72;
}
.hero-button {
    min-width: 265px;
    margin: 32px auto 0;
    font-size: 1.02rem;
}
.hero-button span { font-size: 1.25rem; line-height: 1; }
.closed-hint { margin: 13px auto 0 !important; color: #a33539 !important; font-size: .9rem !important; font-weight: 800; text-align: center; }
.hero-visual {
    position: relative;
    min-height: 100%;
    margin: 18px;
    overflow: hidden;
    isolation: isolate;
    border-radius: 27px;
    background: #25150c;
}
.hero-photo {
    position: absolute;
    inset: 0;
    background: url('../images/festival-cover.jpg') center 48%/cover no-repeat;
    transform: scale(1.018);
}
.hero-overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(21, 10, 5, .06) 35%, rgba(21, 10, 5, .82) 100%),
        linear-gradient(90deg, rgba(21, 10, 5, .16), transparent 50%);
}
.hero-image-copy {
    position: absolute;
    right: 28px;
    bottom: 28px;
    left: 28px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
    font: 600 clamp(.88rem, 1.2vw, 1.02rem)/1 var(--serif);
    letter-spacing: .08em;
    text-transform: uppercase;
    text-shadow: 0 2px 16px rgba(0,0,0,.55);
}
.hero-image-copy i { color: var(--gold-light); font-style: normal; }
.hero-count {
    position: absolute;
    top: 22px;
    left: 22px;
    z-index: 2;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    background: rgba(27, 13, 7, .55);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 17px;
    backdrop-filter: blur(12px);
}
.hero-count strong { color: var(--gold-light); font: 700 2.1rem/1 var(--serif); }
.hero-count span { font-size: .72rem; font-weight: 850; line-height: 1.2; text-transform: uppercase; letter-spacing: .08em; }
.trust-row {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.trust-row span {
    padding: 15px;
    color: #5d402b;
    background: rgba(255, 253, 249, .84);
    border: 1px solid rgba(100, 67, 41, .11);
    border-radius: 15px;
    box-shadow: 0 7px 22px rgba(76, 43, 25, .05);
    text-align: center;
    font-size: .92rem;
    font-weight: 850;
}

.flow-card {
    position: relative;
    padding: clamp(26px, 5vw, 54px);
    background: var(--surface);
    border: 1px solid #eadfce;
    border-radius: 30px;
    box-shadow: 0 24px 60px rgba(77, 43, 24, .1);
}
.narrow-card { max-width: 650px; margin: 70px auto; text-align: center; }
.flow-card h2, .flow-heading h2 { margin: 10px 0 12px; font: 700 clamp(2rem, 4vw, 3.5rem)/1.08 var(--serif); }
.flow-card p, .flow-heading p { color: var(--muted); line-height: 1.65; }
.back-button {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    color: #6c421f;
    background: #fff8ec;
    border: 1px solid #dfcfb9;
    border-radius: 50%;
    font-size: 2rem;
    line-height: 1;
}
.cpf-form { display: grid; gap: 14px; margin-top: 28px; text-align: left; }
.cpf-form label { font-weight: 900; }
.cpf-form input { font-size: 1.25rem; text-align: center; letter-spacing: .08em; }
.field-error {
    padding: 11px 13px;
    color: #9c2429;
    background: #fff0f0;
    border: 1px solid #efc4c5;
    border-radius: 12px;
    font-size: .9rem;
    font-weight: 850;
    text-align: center;
}
.flow-heading { max-width: 850px; margin: 12px auto 30px; text-align: center; }
.flow-heading p { font-size: 1.05rem; }

.dish-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.dish-card {
    position: relative;
    overflow: hidden;
    padding: 0;
    color: inherit;
    background: #fffdf9;
    border: 2px solid transparent;
    border-radius: 24px;
    box-shadow: 0 14px 40px rgba(77, 43, 24, .09);
    text-align: left;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.dish-card:hover { transform: translateY(-4px); box-shadow: 0 20px 46px rgba(77, 43, 24, .15); }
.dish-card.is-selected { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(217, 161, 38, .15), 0 18px 45px rgba(77, 43, 24, .15); }
.dish-card img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.dish-card-body { display: block; padding: 20px 22px 23px; }
.dish-card h3 { margin: 0 0 4px; color: #3b2012; font: 700 clamp(1.45rem, 2.4vw, 2rem)/1.12 var(--serif); }
.dish-stall { margin: 0 0 10px; color: var(--gold-deep); font-weight: 900; }
.dish-ingredients { margin: 0; color: #705f53; font-size: .94rem; line-height: 1.55; }
.dish-select-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: #5d3c24;
    background: rgba(255,255,255,.92);
    border-radius: 50%;
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
    font-weight: 900;
}
.dish-card.is-selected .dish-select-badge { color: #291207; background: var(--gold); }

.review-card { max-width: 1100px; margin: 28px auto; text-align: center; }
.review-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 28px; text-align: left; }
.review-choice { overflow: hidden; background: #f8f1e6; border: 1px solid #e2d3bf; border-radius: 20px; }
.review-choice img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.review-choice-body { padding: 18px; }
.review-choice .category { color: var(--gold-deep); font-size: .72rem; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
.review-choice h3 { margin: 7px 0 4px; font: 700 1.5rem/1.15 var(--serif); }
.review-choice p { margin: 4px 0; font-size: .92rem; }
.review-actions { display: flex; justify-content: center; gap: 12px; margin-top: 28px; flex-wrap: wrap; }

.thanks-card { max-width: 760px; margin: 36px auto; text-align: center; }
.success-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #4cbd6d, #258c4c);
    border-radius: 50%;
    box-shadow: 0 14px 32px rgba(47, 159, 89, .25);
    font-size: 2.2rem;
    font-weight: 900;
}
.receipt-ticket {
    position: relative;
    max-width: 560px;
    margin: 28px auto 18px;
    padding: 22px;
    background: #fff8ea;
    border: 2px dashed #c79a48;
    border-radius: 18px;
    text-align: left;
}
.receipt-ticket::before, .receipt-ticket::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 22px;
    height: 22px;
    background: var(--surface);
    border-radius: 50%;
    transform: translateY(-50%);
}
.receipt-ticket::before { left: -13px; }
.receipt-ticket::after { right: -13px; }
.receipt-ticket h3 { margin: 0 0 14px; font: 700 1.45rem/1.15 var(--serif); }
.ticket-row { display: flex; justify-content: space-between; gap: 20px; padding: 8px 0; border-bottom: 1px solid #ead7b8; }
.ticket-row:last-child { border-bottom: 0; }
.ticket-row span { color: #806a57; }
.ticket-row strong { text-align: right; }
.next-participant { font-weight: 800; }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(18, 8, 4, .72); backdrop-filter: blur(8px); }
.modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 520px);
    padding-bottom: 26px;
    overflow: hidden;
    background: #fffdf9;
    border-radius: 26px;
    box-shadow: 0 30px 100px rgba(0,0,0,.42);
    text-align: center;
}
.modal-dish-image { display: block; width: 100%; aspect-ratio: 16/8.5; object-fit: cover; }
.modal-check {
    position: relative;
    width: 54px;
    height: 54px;
    margin: -27px auto 10px;
    display: grid;
    place-items: center;
    color: #2a1408;
    background: var(--gold);
    border: 5px solid #fffdf9;
    border-radius: 50%;
    font-size: 1.6rem;
    font-weight: 900;
}
.modal-card h2 { margin: 10px 24px 8px; font: 700 2rem/1.12 var(--serif); }
.modal-card p { margin: 0 24px; color: var(--muted); font-weight: 800; }
.modal-actions { display: flex; gap: 12px; justify-content: center; margin: 24px 24px 0; }
.modal-actions button { flex: 1; }
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 120;
    max-width: calc(100% - 32px);
    padding: 13px 18px;
    color: #fff;
    background: #2f1a10;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0,0,0,.3);
    transform: translateX(-50%);
    font-weight: 800;
    text-align: center;
}

.app-footer {
    padding: 28px 18px 0;
    display: grid;
    grid-template-columns: repeat(4, auto);
    justify-content: center;
    gap: 10px 22px;
    color: #76675c;
    font-size: .8rem;
    text-align: center;
}
.panel-link { color: #9a8d84; text-decoration: none; opacity: .5; }
.panel-link:hover { opacity: 1; }

@media (max-width: 1040px) {
    .hero-card { grid-template-columns: minmax(0, .9fr) minmax(420px, 1.1fr); }
    .hero-content { padding: 45px; }
}

@media (max-width: 900px) {
    .app-header { align-items: flex-start; flex-direction: column; }
    .status-pill { width: 100%; min-width: 0; }
    .hero-card { grid-template-columns: 1fr; min-height: auto; }
    .hero-content { order: 2; padding: 42px; text-align: center; }
    .hero-content h2, .hero-content > p { margin-right: auto; margin-left: auto; }
    .hero-visual { order: 1; min-height: 340px; margin-bottom: 0; }
    .dish-grid, .review-grid { grid-template-columns: 1fr; }
    .trust-row { grid-template-columns: 1fr; }
    .app-footer { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .app-body { padding-bottom: 40px; }
    .app-main { width: min(100% - 18px, 1420px); margin-top: 12px; }
    .app-header { min-height: auto; padding: 13px; gap: 12px; }
    .brand-logo { width: 80px; height: 59px; }
    .brand-block { gap: 11px; }
    .brand-block h1 { font-size: 1rem; }
    .brand-block p { font-size: .75rem; }
    .status-pill { padding: 9px 12px; }
    .hero-card { border-radius: 23px; }
    .hero-visual { min-height: 280px; margin: 10px 10px 0; border-radius: 18px; }
    .hero-content { padding: 34px 22px 30px; }
    .hero-content h2 { font-size: clamp(3rem, 15vw, 4.5rem); }
    .hero-content > p { margin-top: 19px; font-size: .98rem; }
    .hero-button { width: 100%; min-width: 0; }
    .hero-image-copy { right: 16px; bottom: 17px; left: 16px; gap: 6px; font-size: .7rem; letter-spacing: .05em; }
    .hero-count { top: 13px; left: 13px; padding: 9px 11px; }
    .hero-count strong { font-size: 1.65rem; }
    .flow-card { padding: 26px 18px; border-radius: 22px; }
    .narrow-card { margin: 18px auto; }
    .flow-heading { margin: 8px auto 20px; padding: 0 8px; }
    .dish-grid { gap: 14px; }
    .dish-card { border-radius: 18px; }
    .dish-card-body { padding: 16px; }
    .modal-actions, .review-actions { flex-direction: column-reverse; }
    .review-actions button { width: 100%; }
    .ticket-row { flex-direction: column; gap: 3px; }
    .ticket-row strong { text-align: left; }
}

@media (orientation: landscape) and (max-height: 700px) and (min-width: 700px) {
    .app-header { min-height: 88px; padding-block: 9px; }
    .brand-logo { width: 88px; height: 58px; }
    .hero-card { min-height: calc(100vh - 135px); }
    .hero-content { padding-block: 28px; }
    .hero-content h2 { font-size: clamp(3rem, 6vw, 5rem); }
}
