:root {
    color-scheme: light;
    --ink: #1e1a15;
    --muted: #6e665c;
    --paper: #fbf8f1;
    --surface: #ffffff;
    --line: #e7dfd2;
    --gold: #b88435;
    --gold-deep: #7c521e;
    --teal: #1f766f;
    --teal-soft: #e5f3ef;
    --coral: #c95d46;
    --red: #b83e3e;
    --shadow: 0 18px 45px rgba(43, 30, 15, .12);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    overflow-x: hidden;
    background:
        linear-gradient(135deg, rgba(184, 132, 53, .08), transparent 36%),
        linear-gradient(225deg, rgba(31, 118, 111, .08), transparent 34%),
        var(--paper);
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 76px;
    padding: 12px clamp(16px, 4vw, 52px);
    border-bottom: 1px solid rgba(231, 223, 210, .82);
    background: rgba(251, 248, 241, .9);
    backdrop-filter: blur(16px);
}

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

.brand-mark {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
}

.brand-mark img {
    width: 58px;
    height: 58px;
    object-fit: cover;
    object-position: left center;
}

.brand strong {
    display: block;
    font-size: 1.1rem;
    letter-spacing: 0;
}

.brand small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: .78rem;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ghost-link {
    color: var(--muted);
    font-weight: 700;
    font-size: .9rem;
}

.ghost-link:hover {
    color: var(--ink);
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
    min-height: 44px;
    border: 0;
    border-radius: var(--radius);
    font-weight: 800;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
}

.primary-button {
    padding: 0 18px;
    color: #fff;
    background: var(--ink);
    box-shadow: 0 10px 22px rgba(30, 26, 21, .16);
}

.primary-button:hover {
    transform: translateY(-1px);
    background: #000;
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
    cursor: not-allowed;
    opacity: .55;
    transform: none;
}

.secondary-button {
    padding: 0 16px;
    color: var(--ink);
    border: 1px solid var(--line);
    background: var(--surface);
}

.secondary-button:hover {
    border-color: var(--gold);
    box-shadow: 0 10px 22px rgba(43, 30, 15, .08);
}

.danger-button {
    padding: 0 16px;
    color: #fff;
    background: var(--red);
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 44px;
    min-width: 44px;
    padding: 0;
    color: var(--gold-deep);
    border: 1px solid var(--line);
    background: var(--surface);
}

.compact {
    min-height: 42px;
}

.wide {
    width: 100%;
}

main {
    width: min(1220px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 72px;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(340px, .78fr);
    gap: clamp(20px, 4vw, 42px);
    align-items: stretch;
}

.prize-stage,
.purchase-panel,
.content-band,
.tickets-section,
.draw-section,
.my-orders,
.admin-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .8);
    box-shadow: var(--shadow);
}

.prize-stage {
    display: grid;
    grid-template-rows: 1fr auto;
    min-height: 570px;
    overflow: hidden;
}

.gallery-frame {
    display: grid;
    place-items: center;
    min-height: 480px;
    padding: clamp(18px, 4vw, 42px);
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, .88), rgba(255, 255, 255, .35)),
        repeating-linear-gradient(45deg, #f7f1e6 0 16px, #fff 16px 32px);
}

.gallery-frame img {
    width: 100%;
    max-width: 620px;
    height: auto;
    max-height: 420px;
    object-fit: contain;
    filter: drop-shadow(0 24px 28px rgba(45, 31, 15, .18));
}

.thumb-row {
    display: flex;
    gap: 10px;
    padding: 12px;
    overflow-x: auto;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .74);
}

.thumb {
    flex: 0 0 72px;
    width: 72px;
    height: 62px;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 6px;
    background: #fff;
}

.thumb.active {
    border-color: var(--gold);
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.purchase-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: clamp(20px, 3vw, 30px);
}

.panel-kicker,
.section-label {
    color: var(--gold-deep);
    font-size: .76rem;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(2.45rem, 6vw, 4.65rem);
    line-height: .94;
}

h2 {
    margin-bottom: 8px;
    font-size: clamp(1.55rem, 3vw, 2.35rem);
    line-height: 1.05;
}

h3 {
    margin-bottom: 8px;
    font-size: 1.05rem;
}

.muted {
    color: var(--muted);
    line-height: 1.6;
}

.price-strip {
    display: grid;
    gap: 4px;
    padding: 16px;
    border: 1px solid rgba(184, 132, 53, .32);
    border-radius: var(--radius);
    background: #fff8e8;
}

.price-strip span {
    color: var(--muted);
    font-weight: 700;
}

.price-strip strong {
    color: var(--gold-deep);
    font-size: 2rem;
}

.price-strip small {
    color: var(--muted);
    font-weight: 700;
}

.stats-grid,
.admin-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stats-grid div,
.admin-metrics div {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.stats-grid strong,
.admin-metrics strong {
    display: block;
    font-size: 1.35rem;
}

.stats-grid span,
.admin-metrics span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
}

.quick-pick {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-size: .88rem;
    font-weight: 800;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 13px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

input:focus,
textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(31, 118, 111, .12);
}

textarea {
    resize: vertical;
}

.inline-field {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.notice-card {
    padding: 14px;
    border-left: 4px solid var(--teal);
    border-radius: var(--radius);
    background: var(--teal-soft);
}

.notice-card p {
    margin: 6px 0 0;
    color: #315a56;
    line-height: 1.5;
}

.content-band,
.tickets-section,
.my-orders,
.draw-section,
.admin-section {
    margin-top: 24px;
}

.content-band {
    display: grid;
    grid-template-columns: minmax(240px, .58fr) 1fr;
    gap: 24px;
    padding: clamp(20px, 3vw, 30px);
}

.spec-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.spec-list li {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    font-weight: 700;
}

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

.bank-item {
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.bank-item span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: .77rem;
    font-weight: 800;
    text-transform: uppercase;
}

.bank-item strong {
    display: block;
    overflow-wrap: anywhere;
}

.tickets-section,
.my-orders,
.draw-section {
    padding: clamp(20px, 3vw, 30px);
}

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

.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 9px 14px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 800;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot.available { background: #fff; border: 1px solid #bcb2a4; }
.dot.pending { background: var(--coral); }
.dot.paid { background: var(--teal); }
.dot.mine { background: var(--gold); }

.board-tools {
    display: grid;
    grid-template-columns: minmax(0, 220px) auto;
    gap: 10px;
    margin-bottom: 14px;
}

.ticket-board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
    gap: 8px;
    max-height: 560px;
    overflow: auto;
    padding: 2px;
}

.ticket {
    aspect-ratio: 1.35 / 1;
    min-height: 44px;
    border: 1px solid #d8cdbd;
    border-radius: 6px;
    color: var(--ink);
    background: #fff;
    font-weight: 900;
    line-height: 1;
}

.ticket:hover:not(:disabled) {
    border-color: var(--gold);
    box-shadow: 0 9px 18px rgba(43, 30, 15, .11);
    transform: translateY(-1px);
}

.ticket.pending {
    color: #fff;
    border-color: var(--coral);
    background: var(--coral);
}

.ticket.paid {
    color: #fff;
    border-color: var(--teal);
    background: var(--teal);
}

.ticket.mine {
    color: #241806;
    border-color: var(--gold-deep);
    background: #f2ca77;
}

.ticket.highlight {
    outline: 3px solid rgba(184, 132, 53, .36);
}

.order-list,
.admin-orders {
    display: grid;
    gap: 10px;
}

.order-card,
.admin-order {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.order-card header,
.admin-order header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    color: #fff;
    font-size: .75rem;
    font-weight: 900;
    text-transform: uppercase;
}

.badge.pending { background: var(--coral); }
.badge.paid { background: var(--teal); }
.badge.cancelled { background: var(--muted); }

.ticket-pair {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ticket-chip {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fffaf1;
    font-weight: 900;
}

.draw-section {
    display: grid;
    grid-template-columns: minmax(260px, .75fr) minmax(320px, 1fr);
    gap: clamp(20px, 4vw, 42px);
    align-items: center;
    overflow: hidden;
}

.wheel-shell {
    position: relative;
    width: min(100%, 540px);
    margin: 0 auto;
}

#wheelCanvas {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
}

.wheel-pointer {
    position: absolute;
    top: 50%;
    right: -2px;
    width: 0;
    height: 0;
    border-top: 17px solid transparent;
    border-bottom: 17px solid transparent;
    border-right: 34px solid var(--ink);
    transform: translateY(-50%);
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .2));
}

.winner-banner,
.admin-result {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid rgba(184, 132, 53, .36);
    border-radius: var(--radius);
    background: #fff8e8;
    line-height: 1.55;
}

.winner-banner strong {
    color: var(--gold-deep);
}

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

.winner-banner > p + .winner-list {
    margin-top: 10px;
}

.winner-item {
    padding: 10px 12px;
    border: 1px solid rgba(184, 132, 53, .24);
    border-radius: 8px;
    background: rgba(255, 255, 255, .62);
}

.winner-item p {
    margin: 4px 0 0;
}

.admin-section {
    display: block;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(260px, .72fr);
    gap: 18px;
}

.admin-card {
    padding: 18px;
}

.danger-zone {
    border-color: rgba(184, 62, 62, .38);
    background: #fff7f5;
}

.raffle-form {
    grid-column: 1 / -1;
    display: grid;
    gap: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.admin-order footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-order .secondary-button,
.admin-order .danger-button {
    min-height: 38px;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(30, 26, 21, .48);
}

.modal[hidden] {
    display: none;
}

.modal-card {
    position: relative;
    width: min(100%, 460px);
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 30px 70px rgba(0, 0, 0, .22);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
}

.tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 0 58px 18px 0;
}

.tab {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: #fff;
    font-weight: 900;
}

.tab.active {
    color: #fff;
    border-color: var(--ink);
    background: var(--ink);
}

.login-form {
    display: grid;
    gap: 14px;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 100;
    width: min(360px, calc(100% - 36px));
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: #fff;
    background: var(--ink);
    box-shadow: var(--shadow);
    font-weight: 800;
}

[hidden] {
    display: none !important;
}

@media (max-width: 900px) {
    .hero-grid,
    .content-band,
    .draw-section,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .prize-stage {
        min-height: auto;
    }

    .gallery-frame {
        min-height: 350px;
    }

    .section-head {
        flex-direction: column;
    }

    .legend {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        width: 100%;
        max-width: 390px;
        min-height: 68px;
        margin: 0;
        padding: 10px 14px;
    }

    .brand small,
    .ghost-link {
        display: none;
    }

    .nav-actions {
        gap: 6px;
    }

    #loginButton {
        min-width: 68px;
        padding: 0 10px;
    }

    main {
        width: calc(100% - 24px);
        max-width: 366px;
        margin: 0 12px;
        padding-top: 18px;
    }

    .hero-grid {
        gap: 14px;
    }

    .purchase-panel,
    .tickets-section,
    .content-band,
    .draw-section,
    .my-orders,
    .admin-card {
        padding: 16px;
    }

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

    .inline-field,
    .board-tools {
        grid-template-columns: 1fr;
    }

    .ticket-board {
        grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
        gap: 6px;
    }

    .ticket {
        min-height: 40px;
        font-size: .86rem;
    }

    .gallery-frame img {
        max-width: 260px;
    }

    .wheel-pointer {
        right: -6px;
        border-top-width: 13px;
        border-bottom-width: 13px;
        border-right-width: 26px;
    }
}
