:root {
    --bg0: #2a070c;
    --gold: #f6d36b;
    --card: #fff8ef;
    --ink: #3a2418;
    --muted: #8d6b5a;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: #fff8ef;
    background:
        radial-gradient(900px 420px at 50% -80px, rgba(255, 206, 130, .38), transparent 55%),
        linear-gradient(180deg, #9a2433 0%, #5c1220 38%, #1c070b 100%);
}

.shell {
    width: min(480px, 100%);
    margin: 0 auto;
    padding: 12px 16px calc(28px + env(safe-area-inset-bottom));
}

.topbar {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    min-height: 48px;
}

.topbar.single { grid-template-columns: 1fr; }

.topbar h1 {
    margin: 0;
    font-size: 16px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.back, .records-link {
    color: #fff4d2;
    text-decoration: none;
    font-size: 28px;
    line-height: 1;
}

.records-link {
    justify-self: end;
    font-size: 14px;
}

.hero {
    margin-top: 8px;
    padding: 22px 18px 18px;
    border-radius: 22px;
    background-size: cover;
    background-position: center;
    box-shadow: inset 0 0 0 1px rgba(255, 236, 190, .25);
}

.hero.plain { background: rgba(255, 248, 239, .08); }

.hero h2 {
    margin: 8px 0 6px;
    font-size: 28px;
    line-height: 1.25;
}

.hero p, .eyebrow { margin: 0; color: #ffe7b8; }

.eyebrow { letter-spacing: .18em; font-size: 12px; }

.pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255, 244, 210, .18);
    color: var(--gold);
    font-size: 12px;
}

.stage-wrap { margin-top: 18px; text-align: center; }

.wheel-box {
    position: relative;
    width: min(86vw, 360px);
    height: min(86vw, 360px);
    margin: 0 auto;
}

.wheel-box canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.pointer {
    position: absolute;
    top: -2px;
    left: 50%;
    z-index: 3;
    width: 26px;
    height: 34px;
    transform: translateX(-50%);
    background: linear-gradient(#fff8dc, #e2a41b);
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3));
}

.hub {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 4;
    width: 78px;
    height: 78px;
    transform: translate(-50%, -50%);
    border: 4px solid #fff6d8;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fff6c8, #f0b429 55%, #c48409);
    color: #6b2a00;
    font: 800 18px/1 "Microsoft YaHei", sans-serif;
    letter-spacing: .12em;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(0, 0, 0, .25), inset 0 2px 0 rgba(255, 255, 255, .75);
    touch-action: manipulation;
}

.hub:disabled { cursor: not-allowed; filter: grayscale(.25); opacity: .82; }

.remain, .block-reason { margin: 12px 0 0; }

.block-reason { color: #ffd0d0; }

.legend {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 248, 239, .1);
}

.legend img, .thumb, .preview {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 8px;
    background: #fff;
}

.legend span { flex: 1; min-width: 0; }
.legend em { font-style: normal; color: var(--gold); }
.legend small { color: #ffb4b4; }

.fine { color: #f0d7c4; font-size: 12px; line-height: 1.6; }
.fine.center { text-align: center; }
.fine a, .text-link { color: var(--gold); }

.card, .activity-card, .record {
    display: block;
    margin-top: 14px;
    padding: 16px;
    border-radius: 18px;
    background: var(--card);
    color: var(--ink);
    text-decoration: none;
}

.card h3 { margin: 14px 0 6px; font-size: 15px; }
.card h3:first-child { margin-top: 0; }
.card p, .prose { margin: 0; line-height: 1.7; color: #5c4638; }
.empty { text-align: center; }

.activity-list, .record-list { display: grid; gap: 10px; }
.activity-card { display: grid; gap: 6px; }
.activity-card strong { font-size: 18px; }
.activity-card em { font-style: normal; color: var(--muted); font-size: 13px; }

.record header { display: flex; justify-content: space-between; gap: 8px; }
.record p { margin: 6px 0 0; color: #5c4638; }
.redeem-box { display: grid; gap: 8px; margin-top: 10px; }
.redeem-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e6d9c8;
    border-radius: 12px;
    font: inherit;
}
.flash { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: #fff; }
.flash.ok { background: #e8f6ee; color: #17693d; }
.flash.bad { background: #fff1f1; color: #9d2433; }

.mask {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: end center;
    padding: 16px;
    background: rgba(20, 4, 8, .62);
}

.dialog {
    width: min(420px, 100%);
    margin-bottom: calc(12px + env(safe-area-inset-bottom));
    padding: 20px 18px;
    border-radius: 20px;
    background: #fffaf3;
    color: var(--ink);
    text-align: center;
}

.dialog img {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 16px;
}

.dialog h2 { margin: 8px 0; }
.dialog p { white-space: pre-wrap; color: #5c4638; }
.dialog a { color: #9d2433; }

.dialog button, .button {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 18px;
    border: 0;
    border-radius: 999px;
    background: #9d2433;
    color: white;
    text-decoration: none;
    font: 700 15px/1 "Microsoft YaHei", sans-serif;
}

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

[hidden] { display: none !important; }

@media (min-width: 840px) {
    body { display: grid; align-items: start; }
}
