:root {
    --ink: #191b23;
    --muted: #707585;
    --line: #e9eaf0;
    --paper: #ffffff;
    --canvas: #f7f8fc;
    --red: #ef493d;
    --red-dark: #d9372e;
    --yellow: #ffc847;
    --green: #1fa971;
    --blue: #4f65e8;
    --shadow: 0 20px 60px rgba(36, 38, 50, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--canvas);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.ambient {
    position: fixed;
    z-index: -1;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    filter: blur(10px);
    opacity: .38;
    pointer-events: none;
}
.ambient-one { top: -220px; right: -120px; background: radial-gradient(circle, #ffd7ba, transparent 67%); }
.ambient-two { top: 480px; left: -250px; background: radial-gradient(circle, #d9ddff, transparent 67%); }
.page-shell { width: min(1120px, calc(100% - 36px)); margin: 0 auto; }

.topbar {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 800; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: #fff;
    background: var(--red);
    border-radius: 11px 11px 14px 14px;
    box-shadow: 0 7px 18px rgba(239, 73, 61, .24);
}
.text-button { border: 0; background: transparent; color: var(--muted); padding: 8px 0; }
.text-button:hover { color: var(--red); }

.hero {
    min-height: 370px;
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    align-items: center;
    gap: 40px;
    padding: 28px 44px 32px;
    border-radius: 32px;
    background: linear-gradient(135deg, #fff 0%, #fff8f1 100%);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.eyebrow { display: inline-flex; align-items: center; gap: 8px; color: var(--red); font-size: 14px; font-weight: 700; }
.eyebrow i, .live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(31, 169, 113, .12); }
.hero h1 { margin: 18px 0 16px; font-size: clamp(44px, 6vw, 68px); line-height: 1.06; letter-spacing: -3px; }
.hero h1 em { color: var(--red); font-style: normal; }
.hero-copy p { max-width: 560px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.85; }
.hero-visual { position: relative; min-height: 300px; display: grid; place-items: center; }
.lucky-bag {
    position: relative;
    z-index: 2;
    width: 200px;
    height: 210px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    background: linear-gradient(145deg, #ff6658, #db2f28);
    border-radius: 40% 40% 30% 30% / 32% 32% 23% 23%;
    box-shadow: 0 30px 60px rgba(222, 49, 42, .28), inset 0 8px 20px rgba(255,255,255,.14);
    transform: rotate(2deg);
}
.bag-knot { position: absolute; top: -31px; width: 78px; height: 48px; background: var(--yellow); clip-path: polygon(50% 45%, 0 0, 13% 100%, 50% 67%, 87% 100%, 100% 0); }
.bag-mouth { position: absolute; top: 12px; width: 138px; height: 22px; border-radius: 50%; background: #b72724; box-shadow: 0 -9px 0 var(--yellow); }
.lucky-bag strong { font-family: Georgia, serif; font-size: 74px; line-height: 1; text-shadow: 0 4px 0 rgba(153, 30, 27, .22); }
.lucky-bag span { margin-top: 10px; font-size: 14px; letter-spacing: 4px; }
.orbit { position: absolute; border: 1px dashed rgba(239, 73, 61, .22); border-radius: 50%; }
.orbit-one { width: 290px; height: 290px; }
.orbit-two { width: 360px; height: 230px; transform: rotate(-16deg); }
.coin { position: absolute; z-index: 3; display: grid; place-items: center; width: 50px; height: 50px; color: #8d5a00; background: var(--yellow); border: 5px solid #fff0b9; border-radius: 50%; font-weight: 900; box-shadow: 0 12px 25px rgba(130, 91, 0, .18); }
.coin-one { left: 8%; top: 18%; transform: rotate(-14deg); }
.coin-two { right: 5%; bottom: 18%; transform: rotate(12deg); }
.spark { position: absolute; color: var(--yellow); font-size: 30px; }
.spark-one { right: 12%; top: 7%; }
.spark-two { left: 12%; bottom: 7%; font-size: 22px; }

.stats-card {
    width: min(760px, calc(100% - 48px));
    margin: -28px auto 34px;
    position: relative;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: #202129;
    color: #fff;
    border-radius: 20px;
    box-shadow: 0 18px 36px rgba(25, 27, 35, .18);
}
.stats-card div { padding: 20px 28px; text-align: center; }
.stats-card div + div { border-left: 1px solid rgba(255,255,255,.1); }
.stats-card strong { display: block; font-size: 25px; }
.stats-card span { color: #aeb0ba; font-size: 12px; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.panel { padding: 30px; background: var(--paper); border: 1px solid rgba(232, 233, 239, .8); border-radius: 24px; box-shadow: 0 12px 36px rgba(36, 38, 50, .05); }
.panel-heading, .panel-heading > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading h2 { margin: 0; font-size: 21px; }
.step-badge { display: inline-grid; place-items: center; width: 37px; height: 28px; color: var(--red); background: #fff0ee; border-radius: 9px; font-size: 12px; font-weight: 900; }
.step-badge.dark { color: #fff; background: #23242c; }
.safe-note { color: var(--green); font-size: 12px; }
.panel-description { min-height: 48px; margin: 18px 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.input-wrap { display: flex; align-items: center; gap: 12px; height: 54px; padding: 0 15px; background: #fafafc; border: 1px solid var(--line); border-radius: 13px; transition: .2s; }
.input-wrap:focus-within { background: #fff; border-color: var(--red); box-shadow: 0 0 0 4px rgba(239, 73, 61, .08); }
.input-wrap span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.input-wrap input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 17px; letter-spacing: 1px; }
.primary-button {
    width: 100%;
    min-height: 52px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #fff;
    background: var(--red);
    border: 0;
    border-radius: 13px;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(239, 73, 61, .2);
    transition: .2s;
}
.primary-button:hover { background: var(--red-dark); transform: translateY(-1px); }
.primary-button:disabled, .match-button:disabled { cursor: wait; opacity: .65; }
.primary-button.loading span, .match-button.loading span:nth-child(2) { opacity: .5; }
.mini-steps { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; color: #8b8e9a; font-size: 11px; }
.mini-steps span { display: flex; align-items: center; gap: 5px; }
.mini-steps b { display: grid; place-items: center; width: 18px; height: 18px; color: var(--red); background: #fff0ee; border-radius: 50%; }
.mini-steps i { width: 22px; border-top: 1px dashed #d5d6dc; }
.match-button {
    width: 100%;
    min-height: 94px;
    padding: 14px 18px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    align-items: center;
    text-align: left;
    color: #fff;
    background: linear-gradient(135deg, #262832, #181920);
    border: 0;
    border-radius: 16px;
    box-shadow: 0 14px 28px rgba(29, 30, 38, .2);
}
.match-icon { display: grid; place-items: center; width: 48px; height: 48px; background: var(--yellow); color: #302000; border-radius: 15px; }
.match-button strong, .match-button small { display: block; }
.match-button strong { margin-bottom: 5px; font-size: 17px; }
.match-button small { color: #aeb0b8; font-size: 11px; }
.match-button > b { color: var(--yellow); font-size: 22px; }
.match-tip { display: flex; justify-content: center; gap: 6px; margin-top: 17px; color: #8b8e99; font-size: 12px; }
.match-tip button { padding: 0; border: 0; color: var(--red); background: transparent; }
.recent-match { width: 100%; margin-top: 12px; padding: 9px; color: #666b7a; background: #f5f5f8; border: 0; border-radius: 10px; font-size: 12px; }
.recent-match:hover { color: var(--ink); background: #ededf2; }

.my-status-card {
    margin-top: 24px;
    padding: 22px 26px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 12px 36px rgba(36, 38, 50, .05);
}
.my-status-card[hidden] { display: none; }
.my-status-icon { display: grid; place-items: center; width: 44px; height: 44px; color: var(--blue); background: #eef0ff; border-radius: 14px; font-size: 20px; font-weight: 900; }
.my-status-card.claimed .my-status-icon,
.my-status-card.verified .my-status-icon { color: #fff; background: var(--green); }
.my-status-card.expired .my-status-icon,
.my-status-card.blocked .my-status-icon { color: #fff; background: #858895; }
.my-status-kicker { color: #9699a4; font-size: 11px; font-weight: 700; }
.my-status-card h2 { margin: 3px 0 4px; font-size: 17px; }
.my-status-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.my-status-actions { display: flex; align-items: center; gap: 8px; }
.confirm-success-button, .requeue-button { padding: 11px 15px; border: 0; border-radius: 11px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.confirm-success-button { color: #fff; background: var(--green); }
.requeue-button { color: #fff; background: var(--red); }
.confirm-success-button:disabled,
.requeue-button:disabled { color: #9295a0; background: #eeeef2; cursor: not-allowed; }

.queue-section { margin-top: 24px; padding: 30px; background: var(--paper); border-radius: 24px; box-shadow: 0 12px 36px rgba(36, 38, 50, .05); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-title > div { display: flex; align-items: center; gap: 10px; }
.section-title h2 { margin: 0; font-size: 21px; }
.section-title p { color: #9a9da8; font-size: 12px; }
.queue-count { padding: 3px 8px; color: var(--red); background: #fff0ee; border-radius: 8px; font-size: 11px; }
.queue-list { border-top: 1px solid var(--line); }
.queue-item { min-height: 76px; display: grid; grid-template-columns: auto 1fr minmax(130px, .7fr) auto; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; color: var(--red); background: #fff0ee; border-radius: 12px; font-family: Georgia, serif; font-weight: 800; }
.queue-code strong, .queue-code span { display: block; }
.queue-code strong { font-size: 16px; letter-spacing: .5px; }
.queue-code span, .queue-progress span { margin-top: 4px; color: #999ca7; font-size: 11px; }
.queue-progress span { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: #8d909c; }
.queue-progress span::before { content: ""; width: 6px; height: 6px; background: var(--yellow); border-radius: 50%; }
.queue-status { min-width: 68px; padding: 7px 9px; text-align: center; border-radius: 9px; font-size: 11px; font-weight: 700; }
.queue-status.active { color: var(--green); background: #eaf8f2; }
.queue-status.claimed { color: #a56800; background: #fff7df; }
.queue-status.verified { color: var(--green); background: #eaf8f2; }
.queue-footnote { display: flex; justify-content: space-between; margin-top: 16px; color: #a0a2ac; font-size: 11px; }
.skeleton-row { height: 76px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, transparent 0%, #f7f7fa 45%, transparent 80%); background-size: 220% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -220% 0; } }
.empty-state { padding: 55px 20px; text-align: center; }
.empty-state b, .empty-state span { display: block; }
.empty-state span { margin-top: 8px; color: var(--muted); font-size: 13px; }

.notice { margin: 24px 0 34px; padding: 22px 24px; display: flex; align-items: flex-start; gap: 15px; color: #705a1b; background: #fff9e8; border: 1px solid #f6e7b4; border-radius: 18px; }
.notice-icon { flex: 0 0 28px; display: grid; place-items: center; height: 28px; color: #fff; background: var(--yellow); border-radius: 50%; font-weight: 900; }
.notice h3 { margin: 0 0 6px; font-size: 14px; }
.notice p { margin: 0; font-size: 12px; line-height: 1.7; }
footer { padding: 6px 0 34px; display: flex; justify-content: space-between; color: #9a9ca6; font-size: 12px; }
footer a { color: inherit; }

.dialog { width: min(480px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 32px; overflow-y: auto; border: 0; border-radius: 24px; box-shadow: 0 28px 90px rgba(19, 20, 27, .3); }
.dialog::backdrop { background: rgba(20, 21, 28, .62); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: #f3f3f6; color: #777; font-size: 22px; }
.dialog-kicker { color: var(--red); font-size: 12px; font-weight: 800; }
.dialog h2 { margin: 8px 0 22px; }
.activity-entry { margin-bottom: 20px; padding: 13px 15px; color: #7f392f; background: #fff2ef; border-radius: 12px; }
.activity-entry strong { font-size: 13px; }
.activity-entry p { margin: 5px 0 0; color: #9b4b40; font-size: 13px; line-height: 1.6; }
.activity-guide-visual { margin: 0 0 22px; }
.activity-guide-visual > div { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; -webkit-overflow-scrolling: touch; }
.activity-guide-visual img { display: block; width: 900px; max-width: none; height: auto; }
.activity-guide-visual figcaption { margin-top: 7px; color: var(--muted); text-align: center; font-size: 11px; }
.dialog ol { padding: 0; margin: 0; list-style: none; }
.dialog li { display: flex; gap: 14px; margin: 17px 0; }
.dialog li > b { flex: 0 0 32px; display: grid; place-items: center; height: 32px; color: #fff; background: #24252d; border-radius: 10px; }
.dialog li strong, .dialog li span { display: block; }
.dialog li span { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.result-sheet { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(20, 21, 28, .65); backdrop-filter: blur(6px); }
.result-sheet[hidden] { display: none; }
.result-sheet > div { position: relative; width: min(390px, 100%); padding: 34px; text-align: center; background: #fff; border-radius: 25px; box-shadow: 0 28px 90px rgba(19, 20, 27, .3); }
.result-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; display: grid; place-items: center; color: #8b8e98; background: #f2f2f5; border: 0; border-radius: 50%; font-size: 22px; line-height: 1; }
.result-close:hover { color: var(--ink); background: #e9e9ee; }
.success-ring { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 16px; color: #fff; background: var(--green); border-radius: 50%; font-size: 25px; }
.result-sheet p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.result-sheet strong { display: block; font-size: 34px; letter-spacing: 3px; }
.result-sheet small { display: block; margin: 8px 0 16px; color: #999ca7; }
.helper-feedback { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); }
.helper-feedback p { margin: 0 0 10px; color: #777b88; font-size: 12px; }
.helper-feedback > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.helper-feedback button { min-height: 38px; padding: 6px; color: #696d79; background: #f5f5f8; border: 1px solid transparent; border-radius: 9px; font-size: 11px; }
.helper-feedback button:hover { color: var(--ink); background: #ededf2; }
.helper-feedback button.selected { color: var(--green); background: #eaf8f2; border-color: #bee8d7; }
.toast { position: fixed; z-index: 40; left: 50%; bottom: 30px; max-width: calc(100% - 32px); padding: 12px 18px; color: #fff; background: #22242b; border-radius: 12px; box-shadow: 0 12px 36px rgba(0,0,0,.2); opacity: 0; transform: translate(-50%, 18px); pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #b72e29; }

.admin-body { padding: 30px 18px; }
.login-card { width: min(420px, 100%); margin: 8vh auto 0; padding: 34px; background: #fff; border-radius: 24px; box-shadow: var(--shadow); }
.login-card h1 { margin: 30px 0 8px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.admin-error { margin: 12px 0; padding: 12px; color: #9b2824; background: #fff0ee; border-radius: 10px; }
.admin-shell { width: min(1180px, 100%); margin: 0 auto; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 25px; }
.admin-header > div { display: flex; align-items: center; gap: 28px; }
.admin-header h1 { margin: 0; font-size: 23px; }
.admin-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.admin-stats div { padding: 20px; background: #fff; border-radius: 16px; }
.admin-stats strong, .admin-stats span { display: block; }
.admin-stats strong { font-size: 26px; }
.admin-stats span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.status-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.status-tabs a { padding: 8px 13px; color: var(--muted); text-decoration: none; background: #fff; border-radius: 9px; font-size: 13px; }
.status-tabs a.active { color: #fff; background: #24252d; }
.table-card { overflow-x: auto; background: #fff; border-radius: 18px; box-shadow: 0 12px 36px rgba(36, 38, 50, .05); }
table { width: 100%; border-collapse: collapse; min-width: 1480px; }
th, td { padding: 15px 18px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-size: 11px; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.fingerprint { display: block; width: 210px; color: #596071; font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; user-select: all; }
.device-details { width: 210px; margin-top: 7px; color: #777b88; font-size: 10px; }
.device-details summary { color: var(--blue); cursor: pointer; user-select: none; }
.device-details span { display: block; margin-top: 5px; line-height: 1.45; overflow-wrap: anywhere; user-select: all; }
.status { padding: 5px 8px; border-radius: 7px; font-size: 11px; }
.status-active { color: var(--green); background: #eaf8f2; }
.status-claimed { color: #a56800; background: #fff7df; }
.status-verified { color: var(--green); background: #eaf8f2; }
.status-expired { color: #777; background: #f1f1f4; }
.status-blocked { color: #a32c27; background: #fff0ee; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { padding: 5px 8px; border: 1px solid var(--line); background: #fff; border-radius: 7px; }
.empty-cell { padding: 60px; text-align: center; color: var(--muted); }

@media (max-width: 760px) {
    .page-shell { width: min(100% - 24px, 640px); }
    .topbar { height: 66px; }
    .hero { min-height: auto; grid-template-columns: 1fr; gap: 8px; padding: 30px 24px 18px; border-radius: 24px; }
    .hero h1 { font-size: 43px; letter-spacing: -2px; }
    .hero-copy p { font-size: 15px; }
    .hero-visual { min-height: 230px; transform: scale(.84); margin: -12px 0; }
    .stats-card { width: calc(100% - 20px); margin-top: -14px; border-radius: 16px; }
    .stats-card div { padding: 16px 8px; }
    .stats-card strong { font-size: 21px; }
    .action-grid { grid-template-columns: 1fr; gap: 14px; }
    .my-status-card { grid-template-columns: auto 1fr; padding: 18px; }
    .my-status-actions { grid-column: 1 / 3; width: 100%; }
    .confirm-success-button, .requeue-button { flex: 1; }
    .panel, .queue-section { padding: 22px 18px; border-radius: 20px; }
    .panel-description { min-height: 0; }
    .queue-item {
        min-height: 0;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "avatar code status"
            "avatar progress progress";
        align-items: start;
        gap: 7px 12px;
        padding: 15px 0;
    }
    .avatar { grid-area: avatar; margin-top: 2px; }
    .queue-code { grid-area: code; min-width: 0; }
    .queue-progress { grid-area: progress; display: flex; align-items: center; }
    .queue-progress span { margin: 0; white-space: nowrap; }
    .queue-status { grid-area: status; align-self: start; }
    .section-title { align-items: flex-start; flex-wrap: wrap; gap: 6px 12px; }
    .section-title p { margin: 5px 0 0 auto; }
    .queue-footnote { flex-direction: column; gap: 6px; }
    .notice { margin-bottom: 24px; }
    .admin-stats { grid-template-columns: 1fr 1fr; }
    .admin-header > div { gap: 12px; }
    .admin-header h1 { font-size: 18px; }
}

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