:root {
    --bg: #120c08;
    --bg-soft: #1d140d;
    --gold: #e6c36a;
    --gold-deep: #b8872b;
    --cream: #f6e7c1;
    --wine: #7a1f24;
    --ok: #46c38b;
    --danger: #e26a6a;
    --card: rgba(32, 22, 14, .88);
    --line: rgba(230, 195, 106, .28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; min-height: 100%; overflow-x: hidden; color: var(--cream); font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; background: transparent; }
html[dir="rtl"] { font-family: "Segoe UI", "Tahoma", "Noto Naskh Arabic", "PingFang SC", sans-serif; }
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: #2b1c12 url('/h5/img/beijing.jpg') center top / cover no-repeat;
}
#app { min-height: 100%; max-width: 480px; margin: 0 auto; position: relative; background: transparent; }
button, input { font: inherit; }
button { border: 0; cursor: pointer; }
img { max-width: 100%; }

.page { min-height: 100vh; padding: 18px 16px calc(88px + env(safe-area-inset-bottom)); }
.auth-page { display: flex; flex-direction: column; justify-content: center; min-height: 100vh; padding-top: 64px; padding-bottom: 24px; position: relative; }
.auth-top { position: absolute; top: 16px; inset-inline-end: 16px; z-index: 5; }
.brand { text-align: center; margin-bottom: 28px; }
.brand .mark { width: 78px; height: 78px; margin: 0 auto 12px; border-radius: 50%; border: 2px solid var(--gold); display: grid; place-items: center; background: radial-gradient(circle, #3a2614, #140c08); box-shadow: 0 0 24px rgba(230,195,106,.25); }
.brand .mark img { width: 34px; height: 34px; object-fit: contain; display: block; }
.brand h1 { margin: 0; font-size: 28px; letter-spacing: 4px; color: var(--gold); }
html[lang="en"] .brand h1,
html[dir="rtl"] .brand h1,
html[dir="rtl"] .btn { letter-spacing: 0; }
.brand p { margin: 8px 0 0; color: rgba(246,231,193,.68); font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.28); }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: rgba(246,231,193,.72); }
.field input { width: 100%; height: 46px; border-radius: 12px; border: 1px solid rgba(230,195,106,.24); background: #24180f; color: var(--cream); padding: 0 12px; outline: none; }
.field input:focus { border-color: var(--gold); }
html[dir="rtl"] input[inputmode="numeric"] { direction: ltr; text-align: right; }

.btn { width: 100%; height: 48px; border-radius: 14px; background: linear-gradient(180deg, #f0d58a, #b8872b); color: #3a2308; font-weight: 700; letter-spacing: 1px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--gold); margin-top: 10px; }
.hint { text-align: center; margin-top: 12px; color: rgba(246,231,193,.6); font-size: 13px; }
.toast { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); background: rgba(20,12,8,.92); border: 1px solid var(--gold); color: var(--gold); padding: 10px 16px; border-radius: 999px; z-index: 50; font-size: 13px; max-width: 86%; text-align: center; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.topbar .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: rgba(246,231,193,.8); }
.topbar .uid { color: var(--gold); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.bgm-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(36,24,15,.92);
    border: 1px solid var(--line);
    color: var(--gold);
    line-height: 28px;
    padding: 0;
}
.bgm-btn.off { color: rgba(246,231,193,.4); text-decoration: line-through; }
.lang-switch { display: flex; flex-shrink: 0; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: rgba(36,24,15,.92); }
.lang-switch button { height: 30px; min-width: 34px; padding: 0 9px; background: transparent; color: rgba(246,231,193,.55); font-size: 12px; line-height: 30px; }
.lang-switch button.on { background: rgba(230,195,106,.2); color: var(--gold); font-weight: 700; }
.points-box { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat { background: rgba(36,24,15,.9); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 22px; color: var(--gold); margin-top: 4px; }
.stat span { font-size: 12px; color: rgba(246,231,193,.6); }

.table-stage {
    position: relative;
    width: min(96vw, 460px);
    aspect-ratio: 1 / 1;
    margin: 0 auto 10px;
    background: transparent;
    overflow: visible;
}
.plate {
    position: absolute;
    inset: 0;
    background: url('/h5/img/panzi.png') center 46% / 100% auto no-repeat;
    pointer-events: none;
    z-index: 1;
    background-color: transparent;
    filter: drop-shadow(0 14px 16px rgba(0,0,0,.35));
}
.cup-ring { position: absolute; inset: 0; z-index: 2; }
.cup-ring.spinning { pointer-events: none; }
.fly-die {
    position: absolute;
    z-index: 8;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: linear-gradient(160deg, #fff4cc 0%, #e6c36a 52%, #b8872b 100%);
    box-shadow: 0 8px 14px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.55);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left .7s cubic-bezier(.22,.9,.28,1), top .7s cubic-bezier(.22,.9,.28,1), transform .7s ease, opacity .32s ease;
}
.cup {
    position: absolute;
    width: 16%;
    height: 16%;
    transform-origin: 50% 78%;
    cursor: pointer;
}
.cup img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 8px 8px rgba(0,0,0,.38));
    transition: transform .28s ease, opacity .28s ease, filter .28s ease;
}
.cup .mark {
    position: absolute;
    left: 50%;
    bottom: 8%;
    transform: translateX(-50%);
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(20,12,8,.55);
    color: #f6e7c1;
    font-size: 10px;
    line-height: 18px;
    text-align: center;
    pointer-events: none;
}
.cup.lifted:not(.opened) img {
    transform: translateY(-22px) scale(.92);
    opacity: .18;
    filter: drop-shadow(0 14px 10px rgba(0,0,0,.2));
}
.cup.opened img {
    opacity: 0;
    pointer-events: none;
    transform: translate(var(--fly-x, 40vw), var(--fly-y, -70vh)) rotate(var(--fly-rot, 28deg)) scale(.4);
    filter: drop-shadow(0 18px 12px rgba(0,0,0,.2));
}
.cup.fly-out img {
    animation: cup-fly-out .62s cubic-bezier(.15, .72, .22, 1) forwards;
}
@keyframes cup-fly-out {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    16% {
        transform: translate(0, -12px) scale(1.18) rotate(8deg);
        opacity: 1;
    }
    100% {
        transform: translate(var(--fly-x), var(--fly-y)) rotate(var(--fly-rot)) scale(.42);
        opacity: 0;
    }
}
.cup .reveal {
    position: absolute;
    left: 50%;
    top: 58%;
    transform: translate(-50%, -50%);
    width: 34%;
    height: 22%;
    border-radius: 50%;
    background: radial-gradient(circle, #2a1c10 0%, #120c08 70%);
    box-shadow: inset 0 2px 6px rgba(0,0,0,.6);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #f0d58a;
    z-index: 0;
}
.cup.opened .reveal,
.cup.lifted .reveal { display: flex; }
.cup.hit .reveal {
    width: 52%;
    height: 38%;
    background: radial-gradient(circle, #4a3218 0%, #1a1008 78%);
    z-index: 5;
}
.stay-die,
.mini-die {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: linear-gradient(160deg, #fff4cc 0%, #e6c36a 52%, #b8872b 100%);
    box-shadow: 0 6px 12px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.stay-die {
    position: absolute;
    z-index: 45;
}
.mini-die { width: 20px; height: 20px; }
.stay-die span,
.mini-die span,
.fly-die span {
    width: 16px;
    height: 16px;
    background:
        radial-gradient(circle at 22% 22%, #3a2308 1.5px, transparent 1.6px),
        radial-gradient(circle at 78% 22%, #3a2308 1.5px, transparent 1.6px),
        radial-gradient(circle at 50% 50%, #3a2308 1.5px, transparent 1.6px),
        radial-gradient(circle at 22% 78%, #3a2308 1.5px, transparent 1.6px),
        radial-gradient(circle at 78% 78%, #3a2308 1.5px, transparent 1.6px);
}
.mini-die span { width: 13px; height: 13px; }
.cup.disabled { cursor: default; }
.table-status { text-align: center; margin: -6px 0 14px; font-size: 12px; color: rgba(246,231,193,.7); }

.tabbar { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 480px; display: flex; background: rgba(18,12,8,.94); border-top: 1px solid var(--line); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
.tabbar a { flex: 1; text-align: center; color: rgba(246,231,193,.55); text-decoration: none; font-size: 12px; padding: 8px 0; }
.tabbar a.active { color: var(--gold); }

.profile-head { display: flex; gap: 14px; align-items: center; }
.avatar { width: 68px; height: 68px; border-radius: 50%; border: 2px solid var(--gold); object-fit: cover; background: #2a1b10; }
.avatar-upload { position: relative; }
.avatar-upload input { position: absolute; inset: 0; opacity: 0; }
.list { margin-top: 14px; }
.log-item { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid rgba(230,195,106,.12); font-size: 13px; }
.log-item .plus { color: var(--ok); }
.log-item .minus { color: var(--danger); }
.muted { color: rgba(246,231,193,.5); font-size: 12px; }

.mask { position: fixed; inset: 0; background: rgba(0,0,0,.62); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 20px; }
.modal { width: min(86vw, 360px); background: #23180f; border: 1px solid var(--gold); border-radius: 18px; padding: 22px 18px; text-align: center; }
.modal h3 { margin: 0 0 8px; color: var(--gold); }
.modal p { margin: 0 0 16px; color: rgba(246,231,193,.8); }

.empty { text-align: center; padding: 24px 0; color: rgba(246,231,193,.5); }
.rule { font-size: 12px; line-height: 1.7; color: rgba(246,231,193,.62); margin: 0 0 12px; }
