:root {
    color-scheme: dark;
    --bg: #07121d;
    --panel: rgba(18, 25, 38, 0.88);
    --panel-strong: rgba(22, 31, 46, 0.96);
    --field: rgba(20, 27, 40, 0.92);
    --line: rgba(148, 163, 184, 0.22);
    --line-strong: rgba(148, 163, 184, 0.38);
    --text: #f8fafc;
    --muted: #9ba7b8;
    --soft: #cbd5e1;
    --purple: #a855f7;
    --blue: #4f73ff;
    --cyan: #08b6d7;
    --green: #00d166;
    --danger: #fb7185;
    --shadow: 0 26px 70px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
    color: var(--text);
    background:
        linear-gradient(115deg, rgba(168, 85, 247, 0.2), transparent 24%),
        linear-gradient(245deg, rgba(8, 182, 215, 0.22), transparent 28%),
        linear-gradient(180deg, #121620 0%, #07121d 54%, #031017 100%);
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.checkin-page {
    min-height: 100svh;
}

.checkin-shell {
    width: min(980px, calc(100% - 40px));
    min-height: 100svh;
    margin: 0 auto;
    padding: clamp(24px, 5vw, 48px) 0;
}

.checkin-panel {
    position: relative;
    width: min(860px, 100%);
    margin: 0 auto;
    padding: clamp(24px, 5vw, 48px);
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.01)),
        var(--panel);
    border: 1px solid rgba(125, 167, 255, 0.5);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
    animation: riseIn 520ms ease both;
}

.checkin-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 48%);
}

.checkin-header {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
    gap: 10px;
    margin-bottom: 28px;
    text-align: center;
}

.logo {
    display: block;
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.brand-line,
.eyebrow {
    margin: 0;
    color: var(--green);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.checkin-header h1,
.workspace-header h1,
.admin-brand h1 {
    margin: 0;
    font-size: clamp(34px, 5vw, 44px);
    line-height: 1.08;
}

.checkin-header p:last-child,
.admin-brand p,
.lottery-panel p,
.section-heading p {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.65;
}

.checkin-form {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 24px;
}

label,
fieldset {
    display: grid;
    gap: 12px;
    min-width: 0;
    margin: 0;
    padding: 0;
    color: var(--soft);
    border: 0;
    font-size: clamp(18px, 3vw, 26px);
    font-weight: 800;
}

legend {
    margin-bottom: 12px;
    padding: 0;
    color: var(--soft);
}

label strong,
legend strong {
    color: #c084fc;
}

input,
select,
textarea {
    width: 100%;
    min-height: 72px;
    padding: 0 24px;
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder,
textarea::placeholder {
    color: rgba(203, 213, 225, 0.42);
}

input:disabled {
    color: rgba(203, 213, 225, 0.55);
    background: rgba(20, 27, 40, 0.55);
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(8, 182, 215, 0.9);
    box-shadow: 0 0 0 4px rgba(8, 182, 215, 0.16);
    background: rgba(23, 31, 46, 0.98);
}

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #8e9aae 50%), linear-gradient(135deg, #8e9aae 50%, transparent 50%);
    background-position: calc(100% - 31px) 50%, calc(100% - 22px) 50%;
    background-size: 9px 9px, 9px 9px;
    background-repeat: no-repeat;
}

.wechat-fieldset {
    gap: 10px;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--soft);
    font-size: 20px;
    font-weight: 800;
}

.inline-check input {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    accent-color: var(--green);
}

.legal-box {
    display: grid;
    gap: 18px;
    padding: clamp(22px, 4vw, 34px);
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.legal-box h2 {
    margin: 0;
    color: var(--soft);
    font-size: clamp(20px, 3vw, 24px);
}

.legal-box p {
    margin: 0;
    color: var(--muted);
    font-size: clamp(16px, 2.5vw, 20px);
    font-weight: 700;
    line-height: 1.9;
}

.consent-row {
    margin-top: 8px;
}

.hidden-field {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.primary-button,
.secondary-button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 900;
    text-decoration: none;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
    min-height: 80px;
    padding: 0 28px;
    color: #ffffff;
    background: linear-gradient(100deg, var(--purple), var(--blue) 50%, var(--cyan));
    box-shadow: 0 18px 42px rgba(79, 115, 255, 0.26);
    font-size: clamp(22px, 3vw, 30px);
}

.primary-button.compact {
    min-height: 46px;
    padding: 0 20px;
    font-size: 15px;
}

.secondary-button {
    min-height: 44px;
    padding: 0 16px;
    color: var(--soft);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
}

.icon-button {
    width: 42px;
    min-height: 42px;
    color: var(--soft);
    background: rgba(255, 255, 255, 0.08);
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
    transform: translateY(-2px);
}

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

.form-message {
    min-height: 24px;
    margin: 0;
    color: var(--soft);
    font-size: 15px;
    font-weight: 800;
    text-align: center;
}

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

.form-message.success {
    color: #5eead4;
}

.admin-page {
    min-height: 100svh;
}

.admin-shell {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0;
}

.login-view {
    display: grid;
    gap: 24px;
    max-width: 460px;
    margin: 12vh auto 0;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.admin-card,
.lottery-panel,
.summary-strip,
.admin-controls,
.table-wrap,
.draw-history {
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.18);
}

.admin-card {
    display: grid;
    gap: 16px;
    padding: 22px;
}

.admin-card label,
.admin-controls label,
.draw-form input {
    color: var(--soft);
    font-size: 13px;
    font-weight: 800;
}

.admin-card input,
.admin-controls input,
.admin-controls select,
.draw-form input {
    min-height: 46px;
    padding: 0 14px;
    font-size: 15px;
}

.workspace-view {
    display: grid;
    gap: 20px;
}

.workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.summary-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: hidden;
}

.summary-strip div {
    display: grid;
    gap: 6px;
    padding: 22px;
    border-right: 1px solid var(--line);
}

.summary-strip div:last-child {
    border-right: 0;
}

.summary-strip strong {
    font-size: clamp(30px, 4vw, 44px);
    line-height: 1;
}

.summary-strip span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.lottery-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
    gap: 22px;
    align-items: end;
    padding: 22px;
}

.lottery-panel h2,
.draw-history h2 {
    margin: 0;
    font-size: 26px;
}

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

.admin-controls {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 180px auto;
    gap: 16px;
    align-items: end;
    padding: 18px;
}

.admin-count {
    color: var(--muted);
    font-size: 14px;
    font-weight: 900;
    text-align: right;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    padding: 14px 16px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

th {
    position: sticky;
    top: 0;
    color: var(--soft);
    background: #111827;
    font-size: 12px;
}

td {
    color: var(--muted);
}

td strong {
    color: var(--text);
}

td small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.status,
.muted-tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 8px;
    color: var(--soft);
    background: rgba(255, 255, 255, 0.08);
    font-size: 12px;
    font-weight: 900;
}

.status.winner {
    color: #06121a;
    background: #5eead4;
}

.muted-tag {
    margin-left: 8px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.draw-history {
    display: grid;
    gap: 16px;
    padding: 22px;
}

.section-heading {
    display: grid;
    gap: 4px;
}

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

.draw-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    padding: 14px 16px;
    color: var(--soft);
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
}

.draw-item strong,
.draw-item small {
    display: block;
}

.draw-item small,
.empty-text {
    margin: 4px 0 0;
    color: var(--muted);
}

.winner-dialog {
    width: min(720px, calc(100% - 32px));
    color: var(--text);
    background: #101827;
    border: 1px solid rgba(94, 234, 212, 0.38);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.winner-dialog::backdrop {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(8px);
}

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

.dialog-head h2 {
    margin: 0;
    font-size: 32px;
}

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

.winner-card {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 14px;
    align-items: center;
    padding: 16px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.winner-card > span {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    color: #06121a;
    background: #5eead4;
    border-radius: 8px;
    font-weight: 900;
}

.winner-card strong {
    font-size: 22px;
}

.winner-card p {
    margin: 4px 0 0;
    color: var(--muted);
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 1ms !important;
        transition-duration: 1ms !important;
    }
}

@media (max-width: 860px) {
    .checkin-shell,
    .admin-shell {
        width: min(100% - 24px, 760px);
    }

    .checkin-panel {
        padding: 24px 18px;
    }

    input,
    select,
    textarea,
    .primary-button {
        min-height: 60px;
    }

    label,
    fieldset {
        font-size: 20px;
    }

    .workspace-header,
    .lottery-panel {
        grid-template-columns: 1fr;
    }

    .workspace-header {
        align-items: start;
        flex-direction: column;
    }

    .summary-strip,
    .admin-controls,
    .draw-form {
        grid-template-columns: 1fr;
    }

    .summary-strip div {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .summary-strip div:last-child {
        border-bottom: 0;
    }

    .admin-count,
    .pagination {
        justify-content: flex-start;
        text-align: left;
    }
}
