:root {
  --ink: #4a3346;
  --soft: #8c7287;
  --bg: #ffe9d6;
  --card: #ffffff;
  --pink: #ff8fab;
  --pink-d: #f06a8e;
  --mint: #7ed99b;
  --line: #f3dccb;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.card { background: var(--card); border-radius: 28px; padding: 24px; box-shadow: 0 10px 0 #f6d2bb, 0 18px 40px rgba(120, 70, 60, .12); }
.center { text-align: center; }
.big { font-size: 64px; line-height: 1; }
.spin { display: inline-block; animation: wob 1.2s ease-in-out infinite; }
h1 { margin: 6px 0 10px; font-size: 26px; font-weight: 900; line-height: 1.2; }
h2 { margin: 0 0 14px; font-size: 20px; font-weight: 900; }
em { font-style: normal; color: var(--soft); font-weight: 600; font-size: .85em; }

.field { display: block; margin: 0 0 16px; }
.field > span { display: block; font-weight: 800; margin-bottom: 6px; }
.field input { width: 100%; padding: 14px 16px; border-radius: 16px; border: 3px solid var(--line); background: #fffaf5; font-size: 18px; outline: none; transition: border-color .15s; }
.field input:focus { border-color: var(--pink); }
.field small { display: block; color: var(--soft); margin-top: 6px; }

.primary { width: 100%; border: 0; border-radius: 18px; padding: 16px; font-size: 19px; font-weight: 900; color: #fff; background: var(--pink); box-shadow: 0 6px 0 var(--pink-d); transition: transform .08s, box-shadow .08s; }
.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--pink-d); }
.primary:disabled { opacity: .6; }
.ghost { border: 3px solid var(--line); background: #fffaf5; border-radius: 16px; padding: 10px 16px; font-weight: 800; }
.err { color: #d6455d; font-weight: 800; min-height: 1.2em; margin: 6px 0 10px; }
.tip { color: var(--soft); font-size: 14px; margin: 12px 0 0; }

/* ---------- 手机签到页 ---------- */
.join { min-height: 100dvh; background: radial-gradient(circle at 20% 0%, #fff6ec 0, var(--bg) 60%); }
.phone { max-width: 440px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 14px 40px; }
.phone .card { padding: 20px 18px; }
#form .avatar { position: sticky; top: 0; z-index: 2; background: linear-gradient(#fff 80%, rgba(255,255,255,0)); padding-bottom: 6px; }
.hello { color: var(--soft); font-weight: 800; text-align: center; margin-top: 2px; }
.join h1 { text-align: center; }
.avatar { display: flex; justify-content: center; margin: 4px 0 12px; }
.avatar svg { filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .05)); }
.bounce { animation: hop .7s cubic-bezier(.3, 1.6, .5, 1); }
.picker { margin-bottom: 12px; }
.picker > span { display: block; font-weight: 800; margin-bottom: 6px; font-size: 15px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 3px solid var(--line); background: #fffaf5; border-radius: 999px; padding: 7px 11px; font-weight: 800; font-size: 15px; }
.chips button[aria-pressed="true"] { border-color: var(--pink); background: #ffe3ea; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 0 0 2px var(--line); transition: transform .1s; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--pink); transform: scale(1.12); }
#dice { width: 100%; margin: 4px 0 6px; }
.lead { font-size: 18px; margin: 6px 0 16px; }
.seat-pill { display: inline-block; line-height: 1.5; background: #e5f8ec; color: #2e7a4b; border-radius: 999px; padding: 10px 20px; font-weight: 800; font-size: 18px; margin-bottom: 22px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: fall linear forwards; }

/* ---------- 首页 ---------- */
.home { min-height: 100dvh; background: radial-gradient(circle at 80% 0%, #fff6ec 0, var(--bg) 55%); }
.home-wrap { max-width: 520px; margin: 0 auto; padding: 28px 16px 60px; display: grid; gap: 22px; }
.hero { text-align: center; }
.hero h1 { font-size: 40px; margin: 8px 0; }
.hero p { margin: 0; font-size: 17px; line-height: 1.6; color: #6a5066; }
.hero-kids { display: flex; justify-content: center; gap: 2px; }
.hero-kids span { animation: hop2 1.6s ease-in-out infinite; display: inline-block; }
.slim .row { display: flex; gap: 10px; }
.slim input { flex: 1; min-width: 0; padding: 14px; border-radius: 16px; border: 3px solid var(--line); background: #fffaf5; font-size: 18px; letter-spacing: 3px; text-transform: uppercase; outline: none; }
.slim .primary { width: auto; padding: 14px 20px; }
.recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.recent li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 14px; background: #fff7f0; }
.recent a { color: var(--ink); font-weight: 800; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent span { color: var(--soft); font-size: 14px; white-space: nowrap; }

/* ---------- 大屏幕 ---------- */
.screen { overflow: hidden; height: 100vh; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hud { position: fixed; top: 2.2vh; left: 2vw; display: flex; gap: 1.2vw; align-items: stretch; pointer-events: none; }
.title-card, .count-card, .qr-card { background: rgba(255, 255, 255, .93); border-radius: 26px; box-shadow: 0 8px 0 rgba(240, 190, 160, .6), 0 14px 30px rgba(100, 60, 50, .12); }
.title-card { padding: 1.4vh 1.6vw; max-width: 46vw; }
.class-name { font-size: clamp(22px, 2.6vw, 52px); font-weight: 900; line-height: 1.15; }
.sub { display: flex; gap: 1vw; align-items: center; color: var(--soft); font-weight: 800; font-size: clamp(13px, 1vw, 20px); margin-top: .5vh; }
.live { display: inline-flex; align-items: center; gap: 6px; color: #3d9a63; }
.live i { width: 10px; height: 10px; border-radius: 50%; background: #3fcf7a; box-shadow: 0 0 0 0 rgba(63, 207, 122, .6); animation: pulse 1.6s infinite; }
.live.off { color: #d07a3f; }
.live.off i { background: #f0a14f; animation: none; }
.count-card { padding: 1.2vh 1.6vw; text-align: center; min-width: 9vw; }
.count-label { color: var(--soft); font-weight: 800; font-size: clamp(13px, 1vw, 20px); }
.count-num { font-size: clamp(34px, 3.6vw, 72px); font-weight: 900; line-height: 1; color: var(--pink-d); }
.count-num small { font-size: .42em; color: var(--soft); margin-left: 4px; }
#count { display: inline-block; }
#count.bump { animation: bump .5s cubic-bezier(.3, 1.8, .5, 1); }

.qr-card { position: fixed; right: 2vw; bottom: 3vh; padding: 1.6vh 1.4vw; text-align: center; width: clamp(180px, 15vw, 300px); transition: width .3s, right .3s, bottom .3s; }
.qr-title { font-weight: 900; font-size: clamp(16px, 1.35vw, 28px); }
.qr-en { color: var(--soft); font-weight: 700; font-size: clamp(11px, .8vw, 16px); margin-bottom: .8vh; }
#qr { width: 100% !important; height: auto !important; border-radius: 12px; display: block; }
.qr-code { margin-top: .8vh; font-weight: 800; font-size: clamp(12px, .95vw, 18px); color: var(--soft); }
.qr-code b { color: var(--ink); letter-spacing: 2px; font-size: 1.25em; }
.qr-url { color: var(--soft); font-size: clamp(10px, .75vw, 14px); word-break: break-all; }
.qr-big .qr-card { width: min(36vw, 60vh); right: 50%; bottom: 50%; transform: translate(50%, 50%); }

.toasts { position: fixed; left: 2vw; bottom: 3vh; display: flex; flex-direction: column-reverse; gap: 10px; pointer-events: none; }
.toast { background: #fff; border-radius: 999px; padding: 1vh 1.4vw; font-size: clamp(15px, 1.3vw, 26px); font-weight: 800; box-shadow: 0 6px 0 rgba(240, 190, 160, .6); animation: slidein .45s cubic-bezier(.3, 1.6, .5, 1); transition: opacity .5s, transform .5s; }
.toast b { color: var(--pink-d); }
.toast.leave, .toast.update { background: #f6f1f5; }
.toast.out { opacity: 0; transform: translateX(-20px); }
.wave { display: inline-block; animation: wave 1s ease-in-out 2; transform-origin: 70% 70%; }

.toolbar { position: fixed; top: 2.2vh; right: 2vw; display: flex; gap: 8px; opacity: .35; transition: opacity .2s; }
.toolbar:hover, .toolbar:focus-within { opacity: 1; }
.toolbar button { width: 46px; height: 46px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, .92); font-size: 20px; box-shadow: 0 4px 0 rgba(240, 190, 160, .6); }
.admin-only { display: none; }
.is-admin .admin-only { display: initial; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); background: #fffaf5; box-shadow: -10px 0 40px rgba(100, 60, 50, .2); transform: translateX(105%); transition: transform .3s cubic-bezier(.3, 1.2, .5, 1); display: flex; flex-direction: column; z-index: 5; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; font-size: 20px; border-bottom: 2px solid var(--line); }
.drawer-head button { border: 0; background: none; font-size: 22px; }
.drawer ol { list-style: none; margin: 0; padding: 10px 14px; overflow: auto; flex: 1; }
.drawer li { display: grid; grid-template-columns: 30px 1fr auto; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 10px; border-radius: 14px; }
.drawer li:nth-child(odd) { background: #fff1e6; }
.drawer .no { grid-row: span 2; font-weight: 900; color: var(--soft); text-align: center; }
.drawer .nm { font-weight: 800; overflow-wrap: anywhere; }
.drawer .meta { grid-column: 2; color: var(--soft); font-size: 13px; }
.drawer .rm { grid-row: 1 / span 2; grid-column: 3; border: 0; background: #ffe3ea; color: #d6455d; width: 34px; height: 34px; border-radius: 10px; font-weight: 900; }
.drawer .empty { display: block; text-align: center; color: var(--soft); background: none; padding: 30px; }
.drawer-note { margin: 0; padding: 12px 20px 18px; color: var(--soft); font-size: 14px; }
.is-admin .drawer-note.admin-only { display: block; }

.fatal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(255, 233, 214, .92); z-index: 9; }
.fatal-card { background: #fff; padding: 36px; border-radius: 28px; text-align: center; max-width: 420px; box-shadow: 0 10px 0 #f6d2bb; }
.fatal-card p { font-size: 18px; font-weight: 700; }
.fatal-card a { color: var(--pink-d); font-weight: 900; }

@media (max-width: 760px) {
  .hud { flex-direction: column; gap: 8px; }
  .title-card { max-width: 70vw; }
  .qr-card { width: 150px; }
}

@keyframes hop { 0% { transform: scale(.8) translateY(10px); } 60% { transform: scale(1.06) translateY(-8px); } 100% { transform: none; } }
@keyframes hop2 { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes wob { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes slidein { from { opacity: 0; transform: translateX(-30px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(20deg); } 75% { transform: rotate(-12deg); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(63, 207, 122, .6); } 100% { box-shadow: 0 0 0 10px rgba(63, 207, 122, 0); } }
@keyframes fall { to { top: 110vh; transform: rotate(720deg) translateX(40px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
