:root {
    --bg-deep: #2d120f;
    --bg-mid: #5f1d1a;
    --bg-soft: #f3e2cc;
    --card: rgba(255, 247, 237, 0.92);
    --card-strong: rgba(255, 250, 244, 0.98);
    --text: #341814;
    --text-soft: #704539;
    --accent: #c2410c;
    --accent-strong: #8f1d14;
    --gold: #e8b04f;
    --danger: #b42318;
    --success: #256f47;
    --shadow: 0 18px 50px rgba(43, 17, 14, 0.22);
    --radius: 28px;
    --radius-sm: 18px;
    --font-head: Georgia, "Times New Roman", serif;
    --font-body: "Avenir Next", "Trebuchet MS", sans-serif;
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-body);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 214, 153, 0.2), transparent 28%),
        radial-gradient(circle at bottom right, rgba(255, 225, 195, 0.18), transparent 24%),
        linear-gradient(160deg, var(--bg-deep), var(--bg-mid) 54%, #8a301d 100%);
}

button,
input,
summary {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

input {
    width: 100%;
    border: 1px solid rgba(112, 69, 57, 0.18);
    border-radius: 18px;
    padding: 14px 16px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

input:focus {
    outline: 3px solid rgba(194, 65, 12, 0.16);
    border-color: rgba(194, 65, 12, 0.45);
}

.app-frame {
    min-height: 100svh;
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 12px;
}

.app-header {
    padding: 8px 6px 0;
    color: #fff6eb;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-copy {
    min-width: 0;
}

.brand-logo-image {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    display: block;
    object-fit: contain;
}

.logout-form {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

.logout-button {
    min-height: 52px;
    white-space: nowrap;
    padding: 0 18px;
    background: rgba(143, 29, 20, 0.78);
    color: #fffaf4;
    font-weight: 800;
    box-shadow: none;
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(113, 65, 0, 0.82);
}



.app-header h1,
.hero-copy h2,
.panel-head h2,
.lottery-head h3 {
    margin: 0;
    font-family: var(--font-head);
    letter-spacing: -0.02em;
}

.app-header h1 {
    font-size: clamp(1.8rem, 7vw, 2.35rem);
}

.app-header p {
    margin: 0 0 6px;
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 230, 196, 0.82);
}

.lead {
    margin: 8px 0 0;
    max-width: 32rem;
    color: rgba(255, 244, 232, 0.88);
}

.screen-shell {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.auth-shell {
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-panel {
    width: 100%;
    max-width: 480px;
    height: auto;
    background:
        linear-gradient(180deg, rgba(255, 248, 239, 0.98), rgba(255, 239, 220, 0.94)),
        var(--card);
}

.auth-panel h2 {
    margin: 0;
    font-family: var(--font-head);
    letter-spacing: -0.02em;
}

.auth-lead {
    color: var(--text-soft);
}

.auth-alert {
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(180, 35, 24, 0.12);
    color: #7d1b12;
    border-left: 5px solid var(--danger);
}

.status-banner,
.setup-warning {
    position: absolute;
    left: 10px;
    right: 10px;
    z-index: 4;
    border-radius: 18px;
    padding: 12px 14px;
    box-shadow: var(--shadow);
}

.status-banner {
    top: 8px;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.22s ease, transform 0.22s ease;
    background: rgba(255, 249, 243, 0.98);
    color: var(--text);
    pointer-events: none;
}

.status-banner[data-type="success"] {
    border-left: 5px solid var(--success);
}

.status-banner[data-type="error"] {
    border-left: 5px solid var(--danger);
}

.status-banner.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.setup-warning {
    top: 8px;
    background: rgba(255, 241, 214, 0.97);
    color: #67360c;
    border-left: 5px solid var(--gold);
}

[hidden] {
    display: none !important;
}

.view {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(18px);
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.view.is-active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.panel {
    height: 100%;
    background: var(--card);
    backdrop-filter: blur(18px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: hidden;
}

.hero-panel {
    justify-content: space-between;
    background:
        linear-gradient(180deg, rgba(255, 248, 239, 0.98), rgba(255, 239, 220, 0.92)),
        var(--card);
}

.hero-copy p {
    margin: 10px 0 0;
    color: var(--text-soft);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(143, 29, 20, 0.1);
    color: var(--accent-strong);
    font-size: 0.86rem;
    font-weight: 700;
}

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

.stat-card {
    padding: 14px;
    border-radius: 22px;
    background: var(--card-strong);
    border: 1px solid rgba(95, 29, 26, 0.08);
}

.stat-label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-soft);
}

.stat-value {
    display: block;
    margin-top: 4px;
    font-size: 1.35rem;
    font-family: var(--font-head);
}

.home-actions,
.form-actions {
    display: grid;
    gap: 10px;
}

.action-button,
.ghost-button,
.icon-button {
    min-height: 56px;
    border-radius: 20px;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.action-button:hover,
.ghost-button:hover,
.icon-button:hover,
.action-button:active,
.ghost-button:active,
.icon-button:active {
    transform: translateY(-1px);
}

.action-button {
    width: 100%;
    padding: 14px 18px;
    background: rgba(95, 29, 26, 0.08);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: inset 0 0 0 1px rgba(95, 29, 26, 0.08);
}

.action-button.primary {
    background: linear-gradient(135deg, #8f1d14, #c2410c);
    color: #fffaf4;
}

.action-button.accent {
    background: linear-gradient(135deg, #d97706, #f59e0b);
    color: #2b110e;
}

.action-button.muted {
    background: rgba(112, 69, 57, 0.12);
}

.action-button.compact {
    min-height: 52px;
    justify-content: center;
}

.button-symbol {
    font-size: 1.15rem;
    font-weight: 700;
}

.ghost-button {
    padding: 12px 14px;
    color: var(--text);
    color: #ffffff;
background: rgb(70, 68, 68);
border: 3px solid white;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.field {
    display: grid;
    gap: 8px;
    font-weight: 600;
    color: var(--text-soft);
}

.entry-form {
    display: grid;
    gap: 12px;
}

.list-wrap,
.winner-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

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

.entry-card,
.winner-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border-radius: 22px;
    background: var(--card-strong);
    border: 1px solid rgba(95, 29, 26, 0.08);
}

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

.winner-card.is-champion {
    position: relative;
    overflow: hidden;
    border-color: rgba(245, 158, 11, 0.42);
    background:
        radial-gradient(circle at top right, rgba(250, 204, 21, 0.38), transparent 34%),
        linear-gradient(180deg, rgba(255, 248, 225, 0.98), rgba(255, 243, 214, 0.96));
    box-shadow: 0 16px 36px rgba(194, 65, 12, 0.18);
}

.winner-card.is-champion strong {
    font-size: 1.2rem;
}

.winner-chip {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, #b45309, #f59e0b);
    color: #fffaf0;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.entry-copy,
.winner-card {
    gap: 4px;
}

.entry-copy strong,
.winner-card strong {
    display: block;
}

.entry-copy span,
.winner-card span,
.result-summary,
.privacy-content p {
    color: var(--text-soft);
}

.entry-actions {
    display: flex;
    gap: 8px;
}

.icon-button {
    width: 48px;
    min-height: 48px;
    background: rgba(95, 29, 26, 0.08);
    color: var(--text);
    font-size: 1rem;
}

.icon-button.danger {
    background: rgba(180, 35, 24, 0.12);
    color: var(--danger);
}

.empty-state,
.result-summary {
    padding: 16px;
    border-radius: 22px;
    background: rgba(95, 29, 26, 0.06);
}

.public-display-controls {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: 22px;
    background: rgba(95, 29, 26, 0.06);
}

.public-display-copy {
    display: grid;
    gap: 6px;
}

.public-display-status {
    margin: 0;
    color: var(--text-soft);
}

.display-actions {
    display: grid;
    gap: 10px;
}

.result-summary {
    flex: 0 0 auto;
}

.result-panel {
    overflow: auto;
    overscroll-behavior: contain;
}

.result-panel .winner-list {
    flex: 0 0 auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
}

.lottery-block {
    margin-top: 0;
    flex: 0 0 auto;
    display: grid;
    gap: 10px;
    padding: 14px;
    border-radius: 24px;
    background:
        radial-gradient(circle at top, rgba(255, 222, 159, 0.55), transparent 42%),
        linear-gradient(180deg, rgba(143, 29, 20, 0.12), rgba(95, 29, 26, 0.06));
}

.lottery-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.lottery-stage {
    position: relative;
    overflow: hidden;
    min-height: 166px;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(60, 21, 17, 0.95), rgba(100, 29, 22, 0.92));
    color: #fff7ee;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 18px;
}

.lottery-stage.is-running {
    animation: pulse-stage 0.85s infinite alternate;
}

.lottery-stage.is-finished {
    background:
        radial-gradient(circle at center, rgba(255, 218, 128, 0.35), transparent 42%),
        linear-gradient(180deg, rgba(86, 28, 18, 0.98), rgba(143, 29, 20, 0.96));
}

.lottery-reel {
    font-family: var(--font-head);
    font-size: clamp(1.4rem, 6vw, 2rem);
    line-height: 1.2;
}

.lottery-final {
    display: grid;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.lottery-final strong {
    font-size: clamp(1.45rem, 6vw, 2.1rem);
    font-family: var(--font-head);
}

.lottery-label {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.72rem;
    color: rgba(255, 240, 214, 0.82);
}

.winner-burst {
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 214, 126, 0.32);
    animation: burst 1.4s ease-out infinite;
}

.confetti-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 30;
}

.confetti-piece {
    position: absolute;
    top: -12vh;
    left: var(--confetti-left);
    width: var(--confetti-size);
    height: calc(var(--confetti-size) * 1.5);
    background: var(--confetti-color);
    opacity: 0;
    border-radius: 2px;
    transform: translate3d(0, 0, 0) rotate(0deg);
    animation: confetti-fall var(--confetti-duration) linear var(--confetti-delay) forwards;
}

.confetti-piece.is-round {
    border-radius: 999px;
    height: var(--confetti-size);
}

.app-footer {
    color: #fff4e7;
}

.privacy-panel {
    background: rgba(43, 17, 14, 0.4);
    border-radius: 20px;
    padding: 0 14px;
    backdrop-filter: blur(12px);
}

.privacy-panel summary {
    list-style: none;
    padding: 14px 0;
    font-weight: 700;
    cursor: pointer;
}

.privacy-panel summary::-webkit-details-marker {
    display: none;
}

.privacy-content {
    padding: 0 0 14px;
}

.privacy-content p {
    margin: 0 0 8px;
    color: rgba(255, 243, 227, 0.92);
}

code {
    font-family: "SFMono-Regular", Consolas, monospace;
}

@keyframes pulse-stage {
    from {
        box-shadow: 0 0 0 0 rgba(255, 217, 141, 0.12);
        transform: scale(1);
    }
    to {
        box-shadow: 0 0 0 10px rgba(255, 217, 141, 0.02);
        transform: scale(1.01);
    }
}

@keyframes burst {
    0% {
        opacity: 0.65;
        transform: scale(0.84);
    }
    100% {
        opacity: 0;
        transform: scale(1.18);
    }
}

@keyframes confetti-fall {
    0% {
        opacity: 0;
        transform: translate3d(0, -4vh, 0) rotate(0deg);
    }
    10% {
        opacity: 1;
    }
    100% {
        opacity: 0.96;
        transform: translate3d(var(--confetti-drift), 112vh, 0) rotate(var(--confetti-rotate));
    }
}

@media (max-width: 420px) {
    .app-frame {
        padding-left: 10px;
        padding-right: 10px;
    }

    .panel {
        padding: 14px;
    }

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

    .entry-actions {
        justify-content: flex-end;
    }

    .brand-row {
        align-items: flex-start;
    }

    .brand-logo-image {
        flex-basis: 56px;
        width: 56px;
        height: 56px;
    }

    .result-panel {
        padding-bottom: 18px;
    }

    .lottery-stage {
        min-height: 132px;
    }
}
