@font-face { font-family: 'Baloo2'; src: url(../vendor/fonts/baloo2-800.ttf) format('truetype'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Baloo2'; src: url(../vendor/fonts/baloo2-600.ttf) format('truetype'); font-weight: 600; font-display: swap; }
:root {
  --night: #241A45; --night2: #33265F; --plum: #4A3592; --purple: #8E6CFF; --purple-d: #6E4BE0; --lilac: #C9B8FF;
  --orange: #FF8A3D; --orange-d: #E0662A; --green: #8EE06A; --green-d: #5DB842; --cream: #FFF3DC; --cream-d: #E9D6B4;
  --pink: #FF7BAC; --pink-d: #E45A8E; --yellow: #FFD23F; --yellow-d: #E3B21C; --ink: #1C1433; --red: #FF5D5D;
  --bounce: cubic-bezier(.34, 1.56, .64, 1); --soft: cubic-bezier(.22, 1, .36, 1);
  --font: 'Baloo2', 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei', 'Noto Sans CJK SC', 'Noto Sans SC', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-weight: 800; color: var(--cream); background: var(--night);
  background-image: radial-gradient(circle at 20px 20px, rgba(255,255,255,.035) 6px, transparent 7px);
  background-size: 56px 56px; overflow: hidden; -webkit-font-smoothing: antialiased; user-select: none;
}
button { font: inherit; }
.art { display: inline-block; line-height: 0; }
.art svg { width: 100%; height: 100%; display: block; overflow: visible; }
.hidden { display: none !important; }

/* ---------- buttons ---------- */
.pill {
  --c: var(--orange); --cd: var(--orange-d); --t: var(--ink);
  border: 0; outline: 0; cursor: pointer; border-radius: 999px; padding: .7em 1.6em; font-size: 22px; font-weight: 800;
  color: var(--t); background: var(--c); box-shadow: 0 6px 0 var(--cd); transform: translateY(0);
  transition: transform .25s var(--bounce), box-shadow .25s var(--bounce), background .2s; display: inline-flex; align-items: center; gap: .45em; justify-content: center;
  letter-spacing: .02em; white-space: nowrap;
}
.pill:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 9px 0 var(--cd); }
.pill:active, .pill.down { transform: translateY(5px) scale(.98); box-shadow: 0 1px 0 var(--cd); transition-duration: .08s; }
.pill:disabled { opacity: .45; cursor: default; transform: none; box-shadow: 0 6px 0 var(--cd); }
.pill.green { --c: var(--green); --cd: var(--green-d); }
.pill.purple { --c: var(--purple); --cd: var(--purple-d); --t: #fff; }
.pill.pink { --c: var(--pink); --cd: var(--pink-d); }
.pill.cream { --c: var(--cream); --cd: var(--cream-d); }
.pill.yellow { --c: var(--yellow); --cd: var(--yellow-d); }
.pill.dim { --c: rgba(255,255,255,.12); --cd: rgba(0,0,0,.25); --t: var(--cream); }
.pill.big { font-size: 30px; padding: .65em 1.8em; }
.pill.small { font-size: 16px; padding: .5em 1.1em; box-shadow: 0 4px 0 var(--cd); }
.pill.small:active { box-shadow: 0 0 0 var(--cd); transform: translateY(4px); }

/* ---------- motion ---------- */
@keyframes popIn { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
@keyframes riseIn { 0% { transform: translateY(40px) scale(.96); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-14px) rotate(2deg); } }
@keyframes wob { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes squish { 0%, 100% { transform: scale(1, 1); } 30% { transform: scale(1.12, .88); } 60% { transform: scale(.94, 1.06); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-14px); } 40% { transform: translateX(12px); } 60% { transform: translateX(-8px); } 80% { transform: translateX(5px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes flap { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(.7); } }
@keyframes fly { 0% { transform: translate(0, 0); } 100% { transform: translate(var(--dx), var(--dy)); } }
.enter { animation: riseIn .55s var(--soft) both; }
.pop { animation: popIn .5s var(--bounce) both; }
.bob { animation: bob 3.2s ease-in-out infinite; }
.wob { animation: wob 2.4s ease-in-out infinite; }
.squish { animation: squish .5s var(--bounce); }
.shake { animation: shake .5s ease; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
.confetti { position: fixed; left: 50%; top: 45%; pointer-events: none; z-index: 99; }
.confetti i { position: absolute; width: 14px; height: 14px; animation: conf 1.5s var(--soft) forwards; }
@keyframes conf { 0% { transform: translate(0, 0) rotate(0) scale(.4); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(var(--dx), calc(var(--dy) + 260px)) rotate(var(--r)) scale(1); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); background: var(--cream); color: var(--ink); padding: 14px 26px; border-radius: 999px; z-index: 100; animation: popIn .4s var(--bounce); transition: opacity .4s, transform .4s; font-size: 18px; }
.toast.out { opacity: 0; transform: translateX(-50%) translateY(20px); }

/* ---------- shared bits ---------- */
.logo { font-size: 92px; line-height: .95; letter-spacing: -.01em; text-align: center; margin: 0; }
.logo .l1 { color: var(--orange); display: block; }
.logo .l2 { color: var(--green); display: block; }
.logo span.ch { display: inline-block; animation: bob 2.8s ease-in-out infinite; }
.sub { color: var(--lilac); font-size: 22px; font-weight: 600; text-align: center; }
.card { background: var(--night2); border-radius: 32px; padding: 28px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.1); border-radius: 999px; padding: 6px 16px 6px 6px; font-size: 18px; }
.chip .art { width: 34px; height: 34px; }
.av { position: relative; display: inline-block; border-radius: 50%; }
.av .art { width: 100%; height: 100%; }
.tag { display: inline-block; padding: 4px 14px; border-radius: 999px; background: var(--purple); color: #fff; font-size: 15px; }

/* ---------- HOST ---------- */
body.host #app { position: absolute; inset: 0; }
.home { height: 100%; display: grid; grid-template-rows: auto 1fr; padding: 40px 56px 28px; gap: 18px; }
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.home-top .brand { display: flex; align-items: center; gap: 26px; }
.home-top .brand .art { width: 120px; height: 120px; }
.home .logo { text-align: left; font-size: 80px; }
.home-top .cta { display: flex; flex-direction: column; align-items: flex-end; gap: 14px; }
.games { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; align-content: start; }
.gcard {
  --c: var(--orange); position: relative; border-radius: 30px; background: var(--c); color: var(--ink); padding: 22px 24px; min-height: 150px;
  display: grid; grid-template-columns: 1fr 110px; align-items: center; gap: 10px; cursor: pointer; border: 0; text-align: left;
  transition: transform .35s var(--bounce); animation: popIn .6s var(--bounce) both; overflow: hidden;
}
.gcard:hover { transform: translateY(-6px) rotate(-1deg) scale(1.02); }
.gcard:active { transform: scale(.97); }
.gcard h3 { margin: 0 0 6px; font-size: 30px; line-height: 1.1; }
.gcard p { margin: 0; font-size: 16px; font-weight: 600; opacity: .75; line-height: 1.35; }
.gcard .art { width: 110px; height: 110px; transition: transform .4s var(--bounce); }
.gcard:hover .art { transform: rotate(8deg) scale(1.1); }
.gcard .kind { position: absolute; top: 16px; right: 18px; font-size: 13px; background: rgba(28,20,51,.85); color: var(--cream); border-radius: 999px; padding: 3px 12px; }
.gcard.cam { --c: var(--orange); } .gcard.pk { --c: var(--green); } .gcard.co { --c: var(--purple); color: #fff; }
.gcard.pink { --c: var(--pink); } .gcard.yellow { --c: var(--yellow); } .gcard.cream { --c: var(--cream); }

.lobby { height: 100%; display: grid; grid-template-columns: 420px 1fr; gap: 28px; padding: 32px 40px; }
.joinbox { background: var(--cream); color: var(--ink); border-radius: 36px; padding: 30px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.joinbox .lbl { font-size: 20px; color: var(--plum); }
.joinbox .code { font-size: 104px; line-height: .9; letter-spacing: .08em; color: var(--ink); }
.joinbox .code span { display: inline-block; animation: popIn .6s var(--bounce) both; }
.joinbox .qr { width: 230px; height: 230px; background: #fff; border-radius: 24px; padding: 12px; }
.joinbox .qr svg { width: 100%; height: 100%; }
.joinbox .url { font-size: 15px; font-weight: 600; color: var(--plum); word-break: break-all; background: rgba(74,53,146,.08); padding: 8px 14px; border-radius: 16px; }
.joinbox .net { font-size: 13px; font-weight: 600; color: #8a7fa8; }
.lobby-main { display: grid; grid-template-rows: auto auto 1fr; gap: 18px; min-height: 0; }
.lobby-head { display: flex; justify-content: space-between; align-items: center; }
.lobby-head h2 { margin: 0; font-size: 40px; }
.players { display: flex; flex-wrap: wrap; gap: 14px; min-height: 120px; align-content: flex-start; }
.pl { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 104px; animation: popIn .6s var(--bounce) both; }
.pl .av { width: 84px; height: 84px; background: var(--c, var(--plum)); padding: 10px; }
.pl .av .art { animation: bob 3s ease-in-out infinite; }
.pl .nm { font-size: 17px; max-width: 104px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl.off { opacity: .4; filter: grayscale(.7); }
.empty { color: var(--lilac); font-size: 20px; font-weight: 600; display: flex; align-items: center; gap: 14px; }
.empty .art { width: 64px; height: 64px; }
.lobby .games { grid-template-columns: repeat(3, 1fr); gap: 16px; overflow: auto; padding: 6px 4px 12px; }
.lobby .gcard { min-height: 118px; grid-template-columns: 1fr 84px; padding: 18px 20px; }
.lobby .gcard h3 { font-size: 25px; } .lobby .gcard .art { width: 84px; height: 84px; } .lobby .gcard p { font-size: 14px; }

.modal-bg { position: absolute; inset: 0; background: rgba(20,14,40,.72); display: grid; place-items: center; z-index: 20; animation: fadeIn .25s ease both; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { background: var(--cream); color: var(--ink); border-radius: 40px; padding: 40px 48px; width: min(820px, 90vw); display: grid; grid-template-columns: 180px 1fr; gap: 30px; animation: popIn .5s var(--bounce) both; }
.modal .art { width: 180px; height: 180px; }
.modal h2 { margin: 0 0 8px; font-size: 44px; }
.modal ol { margin: 0 0 22px; padding-left: 1.2em; font-size: 21px; font-weight: 600; line-height: 1.55; }
.modal .row { display: flex; gap: 14px; flex-wrap: wrap; }
.modal .camnote { font-size: 15px; color: var(--plum); font-weight: 600; margin-bottom: 18px; }

.game { position: absolute; inset: 0; display: grid; grid-template-rows: 76px 1fr; }
.hud { display: flex; align-items: center; gap: 16px; padding: 12px 24px; }
.hud .gname { font-size: 28px; }
.hud .grow { flex: 1; }
.hud .roomtag { font-size: 16px; color: var(--lilac); }
.hud .timer { min-width: 110px; text-align: center; background: var(--cream); color: var(--ink); border-radius: 999px; font-size: 30px; padding: 2px 20px; }
.hud .timer.low { background: var(--pink); animation: pulse .6s infinite; }
.stage { position: relative; margin: 0 20px 20px; border-radius: 32px; overflow: hidden; background: var(--night2); }
.stage canvas.full { position: absolute; inset: 0; width: 100%; height: 100%; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 96px; color: var(--cream); text-align: center; pointer-events: none; text-shadow: 0 6px 0 rgba(28,20,51,.5); white-space: nowrap; }
.banner.pop { animation: bannerPop .7s var(--bounce) both; }
@keyframes bannerPop { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 60% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }
.camfail { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; background: var(--night2); z-index: 5; }
.camfail .box { display: flex; flex-direction: column; align-items: center; gap: 16px; font-size: 24px; }
.camfail .art { width: 140px; height: 140px; }
.fakebar { position: absolute; left: 16px; bottom: 16px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 6; pointer-events: auto; }
.fakebar .lab { background: rgba(28,20,51,.8); color: var(--yellow); border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.scorebig { position: absolute; top: 18px; left: 22px; background: var(--cream); color: var(--ink); border-radius: 26px; padding: 8px 24px; font-size: 44px; display: flex; align-items: center; gap: 10px; }
.scorebig small { font-size: 16px; color: var(--plum); }
.popnum { position: absolute; font-size: 40px; pointer-events: none; animation: floatUp .9s var(--soft) forwards; text-shadow: 0 4px 0 rgba(28,20,51,.45); }
@keyframes floatUp { 0% { transform: translate(-50%, -30%) scale(.5); opacity: 0; } 30% { transform: translate(-50%, -80%) scale(1.15); opacity: 1; } 100% { transform: translate(-50%, -180%) scale(1); opacity: 0; } }

.results { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 30px; }
.results h1 { margin: 0; font-size: 72px; color: var(--yellow); }
.results .subt { font-size: 26px; color: var(--lilac); font-weight: 600; margin-top: -10px; }
.podium { display: flex; align-items: flex-end; gap: 22px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 8px; animation: riseIn .7s var(--bounce) both; }
.pod .av { width: 110px; height: 110px; padding: 12px; background: var(--c); }
.pod .bar { width: 150px; border-radius: 26px 26px 12px 12px; background: var(--c); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 12px; font-size: 40px; }
.pod .bar small { font-size: 16px; }
.pod .nm { font-size: 22px; }
.ranklist { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 1000px; }
.results .row { display: flex; gap: 16px; }

/* ---------- PHONE ---------- */
body.phone { overflow: hidden; position: fixed; inset: 0; touch-action: manipulation; }
body.phone #app { position: absolute; inset: 0; display: flex; flex-direction: column; }
.ptop { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); }
.ptop .av { width: 44px; height: 44px; padding: 5px; background: var(--c, var(--plum)); }
.ptop .nm { font-size: 20px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptop .room { font-size: 14px; background: rgba(255,255,255,.1); padding: 4px 12px; border-radius: 999px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); transition: background .3s; }
.dot.bad { background: var(--red); animation: pulse .8s infinite; }
.pbody { flex: 1; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.pview { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 18px 20px 28px; text-align: center; }
.pview h2 { margin: 0; font-size: 30px; line-height: 1.2; }
.pview p { margin: 0; font-size: 18px; color: var(--lilac); font-weight: 600; line-height: 1.5; }
.pview .hero { width: 150px; height: 150px; }
.join { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; }
.join .logo { font-size: 54px; }
.join .hero { width: 96px; height: 96px; }
.field { width: 100%; max-width: 360px; border: 0; outline: 0; border-radius: 22px; background: var(--cream); color: var(--ink); font: inherit; font-size: 24px; padding: 16px 22px; text-align: center; box-shadow: 0 0 0 0 var(--purple); transition: box-shadow .25s var(--bounce); }
.field:focus { box-shadow: 0 0 0 5px var(--purple); }
.field.code { font-size: 40px; letter-spacing: .3em; text-transform: uppercase; padding: 10px 22px; }
.field::placeholder { color: #b7a98f; letter-spacing: normal; }
.avpick { display: flex; align-items: center; gap: 12px; }
.avpick .av { width: 110px; height: 110px; padding: 12px; background: var(--c); transition: background .3s; }
.avpick .av .art { animation: bob 3s ease-in-out infinite; }
.round { width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: var(--cream); font-size: 26px; cursor: pointer; transition: transform .2s var(--bounce); }
.round:active { transform: scale(.85); }
.err { color: var(--pink); font-size: 17px; min-height: 24px; font-weight: 600; }
.holdbtn { width: 230px; height: 230px; border-radius: 50%; border: 0; background: var(--green); color: var(--ink); font-size: 34px; box-shadow: 0 12px 0 var(--green-d); transition: transform .12s, box-shadow .12s; touch-action: none; }
.holdbtn.on { transform: translateY(10px) scale(.96); box-shadow: 0 2px 0 var(--green-d); background: #A8EE88; }
.holdbtn.out { background: var(--pink); box-shadow: 0 12px 0 var(--pink-d); }
.bigstat { font-size: 64px; color: var(--yellow); line-height: 1; }
.cluecard { background: var(--cream); color: var(--ink); border-radius: 28px; padding: 18px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; align-items: center; animation: popIn .5s var(--bounce) both; }
.cluecard h3 { margin: 0; font-size: 20px; color: var(--plum); }
.cluecard .syms { display: flex; gap: 8px; }
.cluecard .syms .art { width: 58px; height: 58px; }
.legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.legend div { display: flex; align-items: center; gap: 6px; justify-content: center; font-size: 30px; background: rgba(74,53,146,.08); border-radius: 16px; padding: 4px; }
.legend .art { width: 40px; height: 40px; }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 10px; }
.keypad button { height: 56px; border-radius: 22px; border: 0; background: var(--purple); color: #fff; font-size: 30px; box-shadow: 0 5px 0 var(--purple-d); transition: transform .1s, box-shadow .1s; }
.keypad button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--purple-d); }
.codeview { font-size: 44px; letter-spacing: .25em; background: var(--night2); border-radius: 20px; padding: 4px 18px; min-width: 200px; min-height: 64px; }
.dpad { display: grid; grid-template-columns: repeat(3, 84px); grid-template-rows: repeat(3, 84px); gap: 8px; }
.dpad button { border: 0; border-radius: 26px; background: var(--orange); font-size: 36px; color: var(--ink); box-shadow: 0 6px 0 var(--orange-d); }
.dpad button:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--orange-d); }
.minimap { display: grid; gap: 4px; }
.minimap i { width: 46px; height: 46px; border-radius: 12px; background: var(--cream-d); display: grid; place-items: center; font-style: normal; font-size: 18px; }
.minimap i.trap { background: var(--ink); } .minimap i.start { background: var(--green); } .minimap i.goal { background: var(--yellow); }
.minimap i .art { width: 34px; height: 34px; }
.bottles { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.bottles button { width: 66px; height: 86px; border-radius: 24px; border: 0; background: var(--night2); display: grid; place-items: center; transition: transform .2s var(--bounce); padding: 8px; }
.bottles button:active { transform: scale(.9); }
.bottles .art { width: 48px; height: 62px; }
.votegrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: 100%; max-width: 380px; overflow: auto; }
.votegrid button { border: 0; border-radius: 24px; background: var(--night2); padding: 8px; position: relative; transition: transform .25s var(--bounce), background .2s; color: var(--cream); font-size: 22px; }
.votegrid button canvas { width: 100%; aspect-ratio: 1; display: block; }
.votegrid button.sel { background: var(--purple); transform: scale(1.04); }
.votegrid button:disabled { opacity: .35; }
.votegrid button .num { position: absolute; top: 6px; left: 10px; }
.carve { display: flex; flex-direction: column; align-items: center; gap: 12px; flex: 1; padding: 6px 14px 18px; }
.carve canvas { width: min(88vw, 52vh); height: min(88vw, 52vh); background: var(--night2); border-radius: 28px; touch-action: none; }
.carve .tools { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.candyfield { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.candyfield .it { position: absolute; left: 0; top: 0; width: 76px; height: 76px; will-change: transform; }
.candyfield video, .candyfield canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.candyhud { position: absolute; top: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 10px; z-index: 3; pointer-events: none; }
.candyhud .b { background: var(--cream); color: var(--ink); padding: 4px 18px; border-radius: 999px; font-size: 26px; }

.home .games { gap: 26px; }
.home .gcard { min-height: 200px; grid-template-columns: 1fr 140px; padding: 28px 30px; }
.home .gcard .art { width: 140px; height: 140px; }
.home .gcard h3 { font-size: 36px; } .home .gcard p { font-size: 18px; }
.joinbox { justify-content: center; }

/* collection cards: name + art only (rules live in the rules screen) */
.gcard, .home .gcard, .lobby .gcard { grid-template-columns: 1fr; justify-items: center; align-content: center; text-align: center; gap: 10px; }
.gcard h3 { margin: 0; white-space: nowrap; }
.home .gcard { min-height: 200px; padding: 24px 20px; }
.home .gcard .art { width: 130px; height: 130px; }
.home .gcard h3 { font-size: 34px; }
.lobby .gcard { min-height: 0; padding: 14px 12px; gap: 6px; }
.lobby .gcard .art { width: 76px; height: 76px; }
.lobby .gcard h3 { font-size: 24px; }

/* dim pills sit on dark backgrounds; on cream cards they'd vanish, so give them ink text there */
.modal .pill.dim, .cream-bg .pill.dim { --c: rgba(28,20,51,.1); --cd: rgba(28,20,51,.22); --t: var(--ink); }
/* presence: greyed + "离线" tag while we wait for a reconnect, then a squishy exit */
.pl { position: relative; transition: opacity .3s ease, filter .3s ease; }
.pl.off::after { content: '离线'; position: absolute; top: 58px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--cream); font-size: 13px; border-radius: 999px; padding: 2px 10px; }
.pl.leaving { animation: plOut .38s var(--bounce) both; pointer-events: none; }
@keyframes plOut { 0% { transform: scale(1); opacity: 1; } 35% { transform: scale(1.08); } 100% { transform: scale(0); opacity: 0; } }
.ptop .leave { margin-left: 8px; }

/* ---- taps on phones: no double-tap zoom / 300 ms delay swallowing presses ---- */
button, .pill, .dpad button, .keypad button, .bottles button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.dpad button { cursor: pointer; }
.dpad button.hit { animation: dpadHit .22s var(--bounce); }
@keyframes dpadHit { 0% { transform: translateY(5px) scale(.94); box-shadow: 0 1px 0 var(--orange-d); } 100% { transform: none; } }

/* ---- game cards: type tag + player count (still no description) ---- */
.gcard .gtag { position: absolute; top: 12px; left: 14px; font-size: 14px; background: rgba(28,20,51,.82); color: var(--cream); border-radius: 999px; padding: 3px 12px; }
.gcard .gcount { font-size: 15px; background: rgba(255,255,255,.55); color: var(--ink); border-radius: 999px; padding: 2px 12px; }
.gcard.co .gcount { background: rgba(255,255,255,.22); color: #fff; }
.lobby .gcard .gtag { top: 8px; left: 10px; font-size: 12px; padding: 2px 9px; }
.lobby .gcard .gcount { font-size: 12px; padding: 1px 9px; }

/* ---- 红心鬼宅大逃亡: pairing + side-by-side race board ---- */
.esc-wrap { position: absolute; inset: 0; padding: 22px; display: flex; }
.esc-pairing { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.esc-pairing h1 { margin: 0; font-size: 48px; }
.esc-pairs { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.esc-pair { background: var(--c); color: var(--ink); border-radius: 30px; padding: 18px 22px; width: 250px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.esc-pair h3 { margin: 0; font-size: 28px; }
.esc-pair .mem { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.esc-pair .chip { background: rgba(255,255,255,.55); font-size: 18px; }
.esc-pairing .row { display: flex; gap: 16px; }
.esc-board { flex: 1; display: grid; gap: 16px; }
.esc-col { position: relative; background: rgba(28,20,51,.55); border-radius: 30px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; border-top: 10px solid var(--c); overflow: hidden; transition: background .4s ease; }
.esc-col.done { background: color-mix(in srgb, var(--c) 35%, rgba(28,20,51,.55)); }
.esc-head { display: flex; align-items: center; gap: 10px; align-self: stretch; }
.esc-head .tn { font-size: 26px; color: var(--c); line-height: 1.1; }
.esc-head .tm { font-size: 15px; opacity: .8; }
.esc-pips { display: flex; gap: 6px; align-self: stretch; }
.esc-pips span { flex: 1; height: 12px; border-radius: 6px; background: rgba(255,255,255,.12); transition: background .4s ease; }
.esc-pips .ok { background: var(--green); } .esc-pips .now { background: var(--yellow); }
.esc-room { font-size: 20px; }
.esc-goal { font-size: 14px; opacity: .7; text-align: center; }
.esc-viz { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 0; }
.esc-maze { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: min(100%, 320px); }
.esc-maze i { aspect-ratio: 1; border-radius: 10px; background: rgba(255,255,255,.08); display: grid; place-items: center; transition: background .25s ease; }
.esc-maze i.seen { background: rgba(142,224,106,.38); } .esc-maze i.trap { background: var(--red, #FF5A5F); }
.esc-maze .art { width: 90%; height: 90%; } .esc-maze .tok { animation: popIn .3s var(--bounce) both; }
.esc-viz .pot { width: min(100%, 200px); height: 150px; }
.esc-slots { display: flex; gap: 10px; } .esc-slots span { width: 40px; height: 40px; border-radius: 50%; }
.esc-lock { position: absolute; inset: 0; background: rgba(28,20,51,.82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 26px; opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.esc-lock.on { opacity: 1; } .esc-lock .n { font-size: 40px; color: var(--pink); }
.esc-teamtag { background: var(--c); color: var(--ink); border-radius: 999px; padding: 4px 16px; font-size: 16px; }
.esc-plock { position: fixed; inset: 0; z-index: 30; background: rgba(28,20,51,.9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.esc-plock.on { opacity: 1; pointer-events: auto; } .esc-plock .art { width: 120px; height: 120px; } .esc-plock .t { font-size: 28px; } .esc-plock .n { font-size: 48px; color: var(--pink); }

/* ---- phone-only party games ---- */
.pt-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 28px 40px; text-align: center; }
.pt-wrap h1 { margin: 0; font-size: 56px; line-height: 1.15; color: var(--yellow); }
.pt-wrap .subt { font-size: 24px; color: var(--lilac); font-weight: 600; }
.pt-q { background: var(--cream); color: var(--ink); border-radius: 36px; padding: 26px 40px; font-size: 44px; line-height: 1.3; max-width: 1100px; animation: popIn .6s var(--bounce) both; }
.pt-status { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.pt-status .pl { width: 92px; }
.pt-status .pl .av { width: 70px; height: 70px; padding: 8px; transition: transform .35s var(--bounce); }
.pt-status .pl:not(.ok) { opacity: .5; }
.pt-status .pl.ok .av { transform: scale(1.08); }
.pt-status .tick { font-size: 13px; border-radius: 999px; padding: 1px 10px; background: rgba(255,255,255,.1); }
.pt-status .pl.ok .tick { background: var(--green); color: var(--ink); }
.pt-cards { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; max-width: 1300px; }
.pt-card { position: relative; background: var(--cream); color: var(--ink); border-radius: 28px; padding: 18px 22px 16px; width: 280px; min-height: 120px; font-size: 24px; line-height: 1.35; display: flex; flex-direction: column; gap: 8px; animation: popIn .5s var(--bounce) both; transition: transform .4s var(--bounce), opacity .4s ease; }
.pt-card .no { position: absolute; top: -12px; left: -8px; background: var(--purple); color: #fff; border-radius: 999px; padding: 2px 12px; font-size: 18px; }
.pt-card .who { display: flex; align-items: center; gap: 8px; font-size: 18px; color: var(--plum); }
.pt-card .who .art { width: 34px; height: 34px; }
.pt-card.big { width: min(900px, 80vw); font-size: 40px; padding: 30px 40px; }
.pt-card.win { box-shadow: 0 0 0 8px var(--green); transform: scale(1.06); }
.pt-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.pt-chips .chip { font-size: 16px; }
.pt-text { font-size: 20px; text-align: left; resize: none; min-height: 110px; }
.pt-count { font-size: 14px; color: var(--lilac); margin-top: -10px; }
.pt-prompt { background: var(--cream); color: var(--ink); border-radius: 24px; padding: 14px 18px; font-size: 20px; line-height: 1.4; width: 100%; max-width: 380px; }
.pt-opts { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 380px; }
.pt-opt { --c: var(--purple); display: flex; align-items: center; gap: 12px; border: 0; border-radius: 22px; background: var(--night2); color: var(--cream); font-size: 20px; padding: 12px 16px; text-align: left; transition: transform .25s var(--bounce), background .2s; box-shadow: 0 5px 0 rgba(0,0,0,.25); }
.pt-opt .av { width: 44px; height: 44px; padding: 5px; flex: none; background: var(--c); }
.pt-opt .lb { display: flex; flex-direction: column; } .pt-opt small { font-size: 14px; opacity: .7; }
.pt-opt.sel { background: var(--c); color: var(--ink); transform: scale(1.03); }
.pt-opt:disabled { opacity: .35; }
/* queen: off-with-their-head */
.pt-card .head { position: absolute; top: -26px; right: -14px; width: 64px; height: 64px; }
.pt-card.chop .head { animation: chop 1.1s cubic-bezier(.3,.7,.4,1) forwards; }
.pt-card.chop { opacity: .55; transform: rotate(-2deg) scale(.96); }
@keyframes chop { 0% { transform: none; } 20% { transform: translateY(-30px) rotate(-20deg); } 100% { transform: translate(120px, 260px) rotate(540deg); opacity: 0; } }
.pt-card .stamp { position: absolute; right: 10px; bottom: 6px; font-size: 26px; color: var(--pink); border: 4px solid var(--pink); border-radius: 14px; padding: 0 10px; transform: rotate(-12deg); animation: popIn .4s var(--bounce) both; }
.pt-card.win .stamp { color: var(--green-d); border-color: var(--green-d); }
/* monster */
.mon-row { display: flex; gap: 28px; justify-content: center; flex-wrap: wrap; }
.mon { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.mon .stack { display: flex; flex-direction: column; background: var(--cream); border-radius: 28px; padding: 10px; }
.mon .stack canvas { width: 200px; height: 133px; display: block; }
.mon .stack canvas.drop { animation: monDrop .7s var(--bounce) both; }
@keyframes monDrop { 0% { transform: translateY(-80px) scale(.8); opacity: 0; } 100% { transform: none; opacity: 1; } }
.mon .nmtag { font-size: 24px; background: var(--purple); color: #fff; border-radius: 999px; padding: 4px 18px; }
.mon .by { font-size: 15px; color: var(--lilac); }
.pad-wrap { position: relative; width: 100%; max-width: 380px; }
.pad-wrap canvas { width: 100%; aspect-ratio: 3 / 2; background: #FFF9EE; border-radius: 22px; touch-action: none; display: block; }
.pad-cols { display: flex; gap: 8px; } .pad-cols button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--c); box-shadow: 0 0 0 0 var(--cream); transition: box-shadow .2s; }
.pad-cols button.sel { box-shadow: 0 0 0 4px var(--cream); }
.mon-names { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 380px; }
.mon-names .grp { background: var(--night2); border-radius: 22px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.mon-names .grp canvas { width: 100%; border-radius: 14px; background: #FFF9EE; }
.mon-names .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.mon-names .opts button { border: 0; border-radius: 999px; padding: 6px 12px; background: rgba(255,255,255,.12); color: var(--cream); font-size: 15px; }
.mon-names .opts button.sel { background: var(--yellow); color: var(--ink); }
.mon-names .fav { border: 0; border-radius: 999px; padding: 8px; background: rgba(255,255,255,.12); color: var(--cream); font-size: 16px; }
.mon-names .fav.sel { background: var(--pink); color: var(--ink); }
/* trick or treat */
.tt-candy { display: inline-flex; align-items: center; gap: 6px; font-size: 30px; }
.tt-candy .art { width: 44px; height: 44px; }
.tt-acts { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(900px, 90%); }
.tt-act { display: flex; align-items: center; gap: 14px; background: var(--night2); border-radius: 22px; padding: 10px 18px; font-size: 26px; animation: riseIn .5s var(--bounce) both; }
.tt-act .av { width: 50px; height: 50px; padding: 6px; background: var(--c); border-radius: 50%; }
.tt-act .verb { border-radius: 999px; padding: 2px 14px; color: var(--ink); }
.tt-act .verb.give { background: var(--green); } .tt-act .verb.prank { background: var(--pink); } .tt-act .verb.crash { background: var(--yellow); }
.tt-board { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.tt-board .pl { width: 110px; } .tt-board .cnt { font-size: 28px; color: var(--yellow); }
.tt-board .pl.out { filter: grayscale(.9); opacity: .55; } .tt-board .pl.out .cnt { color: var(--pink); }
.tt-board .pl.win .av { box-shadow: 0 0 0 6px var(--green); }
.tt-me { display: flex; align-items: center; gap: 10px; font-size: 22px; background: var(--night2); border-radius: 999px; padding: 6px 18px; }
.tt-me .art { width: 40px; height: 40px; }
.tt-modes { display: flex; gap: 12px; }
/* phone: big screen lost overlay */
.lobby .pl { cursor: pointer; }
/* camera calibration card */
.calib { position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%); z-index: 8; background: var(--cream, #FFF3DC); color: #2B1648; border-radius: 28px; padding: 18px 28px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 10px 0 rgba(0,0,0,.18); transition: background .3s ease; }
.calib.ok { background: #C9F2B4; }
.calib .caltitle { font-weight: 800; font-size: 20px; opacity: .7; }
.calib .calmsg { font-weight: 800; font-size: 30px; }
.calib .caltip { font-size: 18px; color: #C2410C; min-height: 1em; }
/* ---------- loading screen (ghost + pumpkin hop, squash & stretch) ---------- */
.loader { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 60vh; width: 100%; color: var(--cream, #FFF3DC); text-align: center; }
.loader.compact { min-height: 0; }
.ld-stage { display: flex; gap: 22px; align-items: flex-end; height: 170px; }
.loader.compact .ld-stage { height: 130px; }
.ld-hop { position: relative; width: 92px; height: 92px; }
.loader.compact .ld-hop { width: 70px; height: 70px; }
.ld-hop .art { position: absolute; inset: 0; transform-origin: 50% 100%; animation: ldHop 1.1s cubic-bezier(.45, 0, .55, 1) infinite; will-change: transform; }
.ld-hop .art svg { width: 100%; height: 100%; }
.ld-hop.b .art, .ld-hop.b .ld-shadow { animation-delay: -.55s; }
.ld-shadow { position: absolute; left: 14%; right: 14%; bottom: -10px; height: 12px; border-radius: 50%; background: rgba(0, 0, 0, .25); animation: ldShadow 1.1s cubic-bezier(.45, 0, .55, 1) infinite; will-change: transform; }
@keyframes ldHop {
  0%, 100% { transform: translateY(0) scale(1.14, .84); }
  12% { transform: translateY(-8px) scale(.9, 1.12); }
  50% { transform: translateY(-62px) scale(1, 1) rotate(-4deg); }
  86% { transform: translateY(-6px) scale(.94, 1.08); }
}
@keyframes ldShadow { 0%, 100% { transform: scale(1.1); opacity: .9; } 50% { transform: scale(.6); opacity: .45; } }
.ld-title { font-weight: 800; font-size: 30px; letter-spacing: .5px; color: var(--orange, #FF8A3D); }
.ld-text { font-weight: 800; font-size: 22px; }
.ld-bar { width: min(320px, 70vw); height: 16px; border-radius: 99px; background: rgba(255, 255, 255, .16); overflow: hidden; }
.ld-fill { height: 100%; width: 100%; border-radius: 99px; background: var(--orange, #FF8A3D); transform-origin: 0 50%; transform: scaleX(.04); transition: transform .45s cubic-bezier(.22, 1, .36, 1); will-change: transform; }
.ld-bar.ind .ld-fill { width: 38%; transform: none; animation: ldSlide 1.3s cubic-bezier(.45, 0, .55, 1) infinite; transition: none; }
@keyframes ldSlide { 0% { transform: translateX(-110%); } 100% { transform: translateX(280%); } }
.ld-overlay { position: fixed; inset: 0; z-index: 70; background: rgba(43, 22, 72, .9); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; animation: ldFade .25s ease both; }
.ld-overlay.out { animation: ldFadeOut .25s ease both; }
.ld-sub { color: var(--cream, #FFF3DC); opacity: .8; max-width: 300px; text-align: center; margin-top: 10px; font-size: 16px; }
@keyframes ldFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ldFadeOut { from { opacity: 1; } to { opacity: 0; } }
.camload { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 6; background: rgba(43, 22, 72, .85); }
.netchip { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 65; background: var(--cream, #FFF3DC); color: #2B1648; font-weight: 800; border-radius: 99px; padding: 8px 18px 8px 12px; display: flex; align-items: center; gap: 8px; box-shadow: 0 6px 0 rgba(0,0,0,.18); animation: ldFade .25s ease both; }
.netchip .art { width: 30px; height: 30px; animation: ldHop 1.1s cubic-bezier(.45, 0, .55, 1) infinite; transform-origin: 50% 100%; }
@media (prefers-reduced-motion: reduce) { .ld-hop .art, .ld-shadow, .netchip .art { animation-duration: 2.4s; } }
.bootwrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; }
#app > .loader { min-height: 100vh; min-height: 100dvh; }

/* ---------- scrolling (home / lobby / phone menus) ----------
   The page itself never scrolls (body is locked so game screens can't rubber-band); instead the
   screen container scrolls. Game screens are exactly 100% tall, so they never get a scrollbar. */
body.host #app { overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.home { height: auto; min-height: 100%; grid-template-rows: auto auto; }
.lobby .games { min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.lobby-main > .games { align-self: stretch; }
/* short or narrow screens: the whole lobby flows and scrolls as one page (QR box first, then games) */
@media (max-height: 700px), (max-width: 1000px) {
  .lobby { height: auto; min-height: 100%; grid-template-columns: 1fr; padding: 20px; }
  .lobby .games { overflow: visible; }
  .joinbox { flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 18px; }
  .joinbox .qr { width: 170px; height: 170px; }
  .joinbox .code { font-size: 72px; }
}
@media (max-width: 1000px) {
  .home { padding: 24px 20px; }
  .home-top { flex-wrap: wrap; }
  .home .logo { font-size: 52px; }
  .home-top .cta { align-items: flex-start; }
  .games, .lobby .games { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .home { padding: 18px 14px; gap: 14px; }
  .home-top .brand { gap: 14px; } .home-top .brand .art { width: 72px; height: 72px; }
  .home .logo { font-size: 38px; }
  .games, .home .games, .lobby .games { gap: 12px; }
  .home .gcard { min-height: 150px; padding: 16px 10px; }
  .home .gcard .art { width: 88px; height: 88px; }
  .home .gcard h3, .lobby .gcard h3 { font-size: 20px; white-space: normal; }
  .lobby { padding: 14px; gap: 16px; }
  .lobby-head h2 { font-size: 28px; }
  .joinbox .code { font-size: 60px; }
}
/* phone: menus scroll inside their own box; centred content stays reachable when it overflows */
body.phone #app > .join, .pbody.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.pbody.scroll > .pview, body.phone #app > .join { justify-content: flex-start; }
.pbody.scroll > .pview > :first-child, body.phone #app > .join > :first-child { margin-top: auto; }
.pbody.scroll > .pview > :last-child, body.phone #app > .join > :last-child { margin-bottom: auto; }
.pbody.scroll > .pview { flex: 1 0 auto; }
/* overlays never swallow scroll/taps once they are going away */
.ld-overlay.out { pointer-events: none; }
/* cards keep their natural height; the list scrolls instead of squashing the cards */
.games, .lobby .games { grid-auto-rows: max-content; align-content: start; }
.lobby .gcard { min-height: 150px; }
