:root {
  --ink: #0e0b10;
  --warm: #f2a14a;
  --warm-hi: #ffd08a;
  --cold: #26303e;
  --cold-hi: #8fb4d8;
  --paper: #e9dbb8;
  --paper-dk: #c9b48a;
  --red: #b0281c;
  --blue: #2e5b86;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", "BiauKai", "Songti SC", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #07080b; overflow: hidden; }
body { font-family: var(--sans); color: #efe6d4; user-select: none; -webkit-user-select: none; }
button { font-family: inherit; }

#stage {
  position: absolute; left: 50%; top: 50%; width: 390px; height: 844px;
  margin: -422px 0 0 -195px; overflow: hidden; background: #0b0d12;
  transform-origin: 50% 50%;
}
#world { position: absolute; inset: 0; }
#bg {
  position: absolute; left: 0; top: 0; width: 390px; height: 699px;
  background: url(../img/table.jpg) center / 100% 100% no-repeat;
}
#bg::after { /* fade the bottom of the room into the panel */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 120px;
  background: linear-gradient(transparent, #0b0d12);
}
#lamp {
  position: absolute; left: 0; top: 0; width: 390px; height: 699px; pointer-events: none;
  background: radial-gradient(ellipse 150px 260px at 196px 300px, rgba(255,170,80,.22), transparent 70%);
  mix-blend-mode: screen; animation: flicker 5s infinite;
}
@keyframes flicker { 0%,100% { opacity: 1 } 47% { opacity: 1 } 48% { opacity: .72 } 49% { opacity: 1 } 76% { opacity: .9 } 77% { opacity: 1 } }
#dark {
  position: absolute; left: 0; top: 0; width: 390px; height: 699px; pointer-events: none;
  background: radial-gradient(ellipse 230px 330px at 196px 320px, transparent 40%, rgba(5,8,16,.85));
  opacity: 0; transition: opacity .6s;
}
#world.tense #dark { opacity: 1; }
#world.tense #lamp { animation: none; opacity: .55; transition: opacity .4s; }

/* ---------- people ---------- */
.tok { position: absolute; z-index: 3; width: 58px; height: 58px; margin: -29px 0 0 -29px; transition: filter .5s, opacity .5s; }
.tok .ph {
  width: 58px; height: 58px; border-radius: 9px; border: 3px solid var(--ink);
  background-size: 150%; background-position: 50% 38%; background-color: #1b1512;
  box-shadow: inset 0 0 0 2px rgba(255,190,120,.35), 0 4px 8px rgba(0,0,0,.6);
  transition: box-shadow .25s, transform .25s;
}
.tok .tag {
  position: absolute; left: 50%; top: 52px; transform: translateX(-50%) rotate(-2deg);
  background: var(--paper); color: #2a2018; font-size: 11px; font-weight: 700; line-height: 1;
  padding: 3px 5px 3px; border: 2px solid var(--ink); border-radius: 2px; white-space: nowrap;
  box-shadow: 0 2px 3px rgba(0,0,0,.5);
}
.tok.lead .tag { background: linear-gradient(#e6b55a, #b9802f); }
.tok.talk .ph { transform: scale(1.14); box-shadow: inset 0 0 0 2px rgba(255,210,140,.7), 0 0 0 3px var(--warm), 0 0 26px 6px rgba(242,161,74,.6); }
.tok.me .ph {
  background: rgba(12,10,14,.55); border: 3px dashed #e9c58f; display: grid; place-items: center;
  font: 700 26px var(--kai); color: #ffd9a0; text-shadow: 0 0 10px rgba(242,161,74,.7);
}
.tok.dim { filter: grayscale(1) brightness(.45); }
.tok.fallen { filter: grayscale(.9) brightness(.6); }
.tok.q::after {
  content: "？"; position: absolute; right: -10px; top: -12px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ink); color: var(--warm-hi); font: 700 16px/24px var(--sans); text-align: center;
  border: 2px solid var(--warm); animation: pop .3s;
}
.tok.ghost { opacity: 0; }
@keyframes pop { from { transform: scale(0) } to { transform: scale(1) } }

.sealbadge { position: absolute; z-index: 5; width: 34px; height: 36px; margin: -18px 0 0 -17px; pointer-events: none;
  background: url(../img/seal.png) center / contain no-repeat; filter: drop-shadow(0 3px 2px rgba(0,0,0,.7)); }
.chip {
  position: absolute; margin: -11px 0 0 -38px; width: 76px; height: 22px; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; color: #dff1ff; background: #2b5b84; border: 2px solid var(--ink);
  border-radius: 3px; transform: rotate(-4deg); box-shadow: 0 0 12px rgba(140,200,255,.6);
}

/* ---------- paper on the table ---------- */
.paper {
  position: absolute; left: 196px; top: 330px; width: 146px; height: 128px; margin: -64px 0 0 -73px;
  background: var(--paper); color: #2b2117; border: 2px solid var(--ink);
  clip-path: polygon(0 2%, 8% 0, 22% 1.5%, 40% 0, 63% 1%, 80% 0, 100% 1.5%, 99% 30%, 100% 62%, 98.5% 100%, 70% 98.5%, 45% 100%, 20% 98.5%, 0 100%, 1.5% 66%, 0 35%);
  box-shadow: 0 6px 14px rgba(0,0,0,.55); transform: rotate(-3deg);
  background-image: radial-gradient(circle at 20% 30%, rgba(120,80,40,.12), transparent 40%), radial-gradient(circle at 80% 85%, rgba(120,80,40,.16), transparent 35%);
}
.paper .pt { font-size: 10px; letter-spacing: 1px; text-align: center; padding-top: 7px; color: #6b5338; }
.paper .bp {
  margin: 5px auto 3px; width: 70px; height: 36px; border: 2px solid var(--ink); border-radius: 2px;
  background-color: #23466e;
  background-image: repeating-linear-gradient(0deg, transparent 0 7px, rgba(255,255,255,.18) 7px 8px),
                    repeating-linear-gradient(90deg, transparent 0 7px, rgba(255,255,255,.18) 7px 8px);
  position: relative;
}
.paper .bp::after { content: ""; position: absolute; left: 14px; top: 8px; width: 28px; height: 14px; border: 1.5px solid rgba(255,255,255,.8); border-radius: 50% 50% 2px 2px; }
.paper .pn { text-align: center; font: 700 16px var(--kai); }
.paper .pq { text-align: center; font-size: 12px; color: #5a4430; margin-top: 1px; }
.paper .pq.won { font: 700 16px var(--kai); color: #2b2117; margin-top: 0; }
.paper.small { }
.stamp { position: absolute; pointer-events: none; }

.sheet .rows { display: flex; justify-content: space-around; margin-top: 12px; }
.sheet .slot { width: 36px; text-align: center; font-size: 10px; color: #5a4430; }
.sheet .slot i { display: block; width: 32px; height: 40px; margin: 0 auto 3px; border-bottom: 1.5px solid #8a7050; position: relative; }
.sheet .slot svg { position: absolute; left: 1px; top: 2px; }

/* ---------- vote cards ---------- */
.card { position: absolute; z-index: 4; width: 40px; height: 56px; margin: -28px 0 0 -20px; perspective: 400px; }
.card .in { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .42s cubic-bezier(.3,.7,.3,1.2); }
.card.up .in { transform: rotateY(180deg); }
.card .bk, .card .fr { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border: 2px solid var(--ink); border-radius: 4px; box-shadow: 0 3px 6px rgba(0,0,0,.55); }
.card .bk {
  background: #5b412b repeating-linear-gradient(45deg, rgba(0,0,0,.12) 0 3px, transparent 3px 6px);
  display: grid; place-items: center;
}
.card .bk::after { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #c08a45; box-shadow: inset 0 0 0 3px #5b412b, inset 0 0 0 6px #c08a45; opacity: .8; }
.card .fr { transform: rotateY(180deg); background: var(--paper); display: grid; place-items: center; font: 700 24px var(--kai); }
.card .fr .vf { position: absolute; left: 2px; top: 2px; width: 15px; height: 15px; border-radius: 3px; border: 1.5px solid var(--ink); background-size: 150%; background-position: 50% 38%; }
.card .fr.a { color: var(--blue); }
.card .fr.b { color: var(--red); }
.card.tremble { animation: tremble .09s infinite; }
@keyframes tremble { 0% { transform: translate(0,0) } 25% { transform: translate(1px,-1px) } 50% { transform: translate(-1px,0) } 75% { transform: translate(0,1px) } }
.card.hot .bk { box-shadow: 0 0 0 2px var(--warm), 0 0 18px 4px rgba(242,161,74,.75); }
.card.mine .bk { box-shadow: 0 0 0 2px #e9c58f, 0 3px 6px rgba(0,0,0,.55); }

/* ---------- big seal ---------- */
.bigseal { position: absolute; z-index: 7; width: 190px; height: 203px; margin: -150px 0 0 -82px; pointer-events: none;
  background: url(../img/seal.png) center / contain no-repeat; filter: drop-shadow(0 14px 10px rgba(0,0,0,.6)); }
.midseal { position: absolute; z-index: 7; width: 100px; height: 107px; margin: -66px 0 0 -33px; pointer-events: none;
  background: url(../img/seal.png) center / contain no-repeat; filter: drop-shadow(0 10px 8px rgba(0,0,0,.65)) drop-shadow(0 0 14px rgba(255,190,110,.55)); }
.sshadow { position: absolute; width: 150px; height: 60px; margin: -30px 0 0 -75px; border-radius: 50%; background: radial-gradient(rgba(0,0,0,.65), transparent 70%); pointer-events: none; }
.dust { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: #cdb894; pointer-events: none; }
.frost { position: absolute; width: 170px; height: 170px; margin: -85px 0 0 -85px; border-radius: 50%; border: 4px solid #a8dcff; box-shadow: 0 0 30px 8px rgba(140,200,255,.6), inset 0 0 30px rgba(140,200,255,.5); pointer-events: none; }
.flash { position: absolute; inset: 0; background: #fff3dc; pointer-events: none; mix-blend-mode: overlay; }

/* ---------- hud ---------- */
#hud { position: absolute; left: 0; right: 0; top: 0; height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; z-index: 30; pointer-events: none; }
#day { pointer-events: none; font-size: 12px; font-weight: 700; color: #2a2018; background: var(--paper); border: 2px solid var(--ink); padding: 4px 8px; transform: rotate(-1.5deg); box-shadow: 0 2px 4px rgba(0,0,0,.6); }
#mute { pointer-events: auto; width: 34px; height: 34px; border-radius: 8px; border: 2px solid var(--ink); background: #2a3442; color: var(--warm-hi); font-size: 14px; font-weight: 700; box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 2px 4px rgba(0,0,0,.6); }
#mute.off { color: #6f7c8c; text-decoration: line-through; }

/* ---------- panel ---------- */
#panel {
  position: absolute; left: 0; right: 0; bottom: 0; height: 226px; z-index: 20; padding: 16px 16px 20px;
  background: linear-gradient(#232c39, #161c25 60%); border-top: 3px solid var(--ink);
  box-shadow: 0 -2px 0 rgba(255,190,120,.18) inset, 0 -10px 24px rgba(0,0,0,.6);
}
#panel::before, #panel::after { content: ""; position: absolute; top: 9px; width: 7px; height: 7px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #9aa6b4, #3a4350); box-shadow: 0 1px 0 #000; }
#panel::before { left: 9px; } #panel::after { right: 9px; }
#line { display: flex; gap: 12px; align-items: flex-start; min-height: 74px; }
#line .face { flex: none; width: 64px; height: 64px; border-radius: 9px; border: 3px solid var(--ink); background-size: 150%; background-position: 50% 38%; background-color: #1b1512; box-shadow: inset 0 0 0 2px rgba(255,190,120,.35); }
#line .face.none { display: none; }
#line .face.me { background: #1b1512; display: grid; place-items: center; font: 700 28px var(--kai); color: #ffd9a0; }
#line .txt { flex: 1; min-width: 0; }
#line .who { display: inline-block; font-size: 12px; font-weight: 700; color: #2a2018; background: var(--warm); padding: 2px 7px; border: 2px solid var(--ink); transform: rotate(-1.5deg); margin-bottom: 6px; }
#line .who:empty { display: none; }
#line .said { font-size: 20px; line-height: 1.45; color: #f3ead8; font-weight: 600; }
#line .said.nar { font-size: 17px; color: #b9c3cf; font-weight: 500; }
#line .said.big { font: 700 30px var(--kai); color: var(--warm-hi); letter-spacing: 2px; }
#line .more { flex: none; align-self: flex-end; color: var(--warm); font-size: 12px; opacity: 0; }
#stage.wait #line .more { opacity: 1; animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(3px) } }

#choices { position: absolute; left: 16px; right: 16px; bottom: 20px; display: flex; gap: 12px; }
#choices button {
  flex: 1; height: 62px; border: 3px solid var(--ink); border-radius: 6px; background: var(--paper); color: #241a12;
  font: 700 19px var(--sans); display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 4px 0 #6c5638, 0 6px 10px rgba(0,0,0,.5); transform: rotate(-.8deg);
}
#choices button:nth-child(2) { transform: rotate(.8deg); }
#choices button:active { transform: translateY(3px); box-shadow: 0 1px 0 #6c5638; }
#choices button .bf { width: 36px; height: 36px; border-radius: 6px; border: 2px solid var(--ink); background-size: 150%; background-position: 50% 38%; }
#choices button.hot { background: linear-gradient(#ffc777, #f09a3c); }
#choices button.cold { background: linear-gradient(#b9cde0, #8fa9c2); }
#choices.in button { animation: rise .3s backwards; }
#choices.in button:nth-child(2) { animation-delay: .07s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px) } }

#tally { position: absolute; left: 16px; right: 16px; bottom: 22px; height: 104px; display: none; align-items: center; justify-content: center; gap: 10px; }
#tally.on { display: flex; }
#tally .side { display: flex; flex-direction: column; align-items: center; width: 76px; gap: 4px; }
#tally .side .sf { width: 44px; height: 44px; border-radius: 7px; border: 2px solid var(--ink); background-size: 150%; background-position: 50% 38%; }
#tally .side .sl { font: 700 15px var(--kai); }
#tally .side .sl.solo { font-size: 30px; }
#tally .side.a .sl { color: var(--cold-hi); } #tally .side.b .sl { color: #ff8f6e; }
#tally .num { font: 800 54px/1 var(--sans); width: 56px; text-align: center; color: #fff4e0; text-shadow: 0 3px 0 var(--ink), 0 0 18px rgba(242,161,74,.45); }
#tally .colon { font: 800 40px/1 var(--sans); color: #7e8896; }
#tally .need { position: absolute; left: 0; right: 0; bottom: -16px; text-align: center; font-size: 12px; color: #9aa6b4; }
#tally .pips { display: flex; gap: 5px; justify-content: center; margin-top: 6px; }
#tally .pip { width: 12px; height: 12px; border-radius: 3px; border: 2px solid #6b7684; }
#tally .pip.on { background: #ff8f6e; border-color: var(--ink); box-shadow: 0 0 8px #ff8f6e; }
.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.35); color: var(--warm-hi) } }

/* ---------- phone (the chat happens outside the game) ---------- */
#phone {
  position: absolute; left: 50%; bottom: 0; width: 318px; height: 430px; margin-left: -159px; z-index: 40;
  background: #11141a; border: 3px solid #000; border-bottom: none; border-radius: 30px 30px 0 0; padding: 12px 10px 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.8), inset 0 0 0 2px #2b313c; transform: translateY(110%); transition: transform .45s cubic-bezier(.2,.8,.2,1);
}
#phone.on { transform: translateY(0); }
#phone .scr { height: 100%; background: #ededed; border-radius: 20px 20px 0 0; overflow: hidden; display: flex; flex-direction: column; color: #111; }
#phone .bar { height: 46px; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; background: #f5f5f5; border-bottom: 1px solid #ddd; position: relative; }
#phone .bar::before { content: "‹"; position: absolute; left: 14px; font-size: 26px; font-weight: 300; top: 4px; }
#phone .bar small { display: block; font-size: 10px; color: #888; font-weight: 400; text-align: center; }
#phone .msgs { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 12px; }
#phone .m { display: flex; gap: 8px; align-items: flex-start; animation: rise .25s; }
#phone .m .av { flex: none; width: 36px; height: 36px; border-radius: 4px; background: url(../img/f_xu.jpg) 50% 38% / 150%; }
#phone .m .bb { background: #fff; padding: 8px 11px; border-radius: 4px; font-size: 15px; line-height: 1.45; max-width: 200px; position: relative; }
#phone .m .bb::before { content: ""; position: absolute; left: -6px; top: 12px; border: 6px solid transparent; border-left: none; border-right-color: #fff; }
#phone .m.me { flex-direction: row-reverse; }
#phone .m.me .bb { background: #95ec69; }
#phone .m.me .bb::before { left: auto; right: -6px; border-left: 6px solid #95ec69; border-right: none; }
#phone .m.me .av { background: #2a2018; color: #ffd9a0; font: 700 18px/36px var(--kai); text-align: center; }
#phone .close { margin: 0 12px 16px; height: 44px; border-radius: 6px; border: none; background: #d9d9d9; font-size: 15px; color: #333; }
#phone .close:active { background: #c8c8c8; }

.toast {
  position: absolute; left: 14px; right: 14px; top: 58px; z-index: 45; display: flex; gap: 10px; align-items: center;
  background: rgba(245,245,245,.96); color: #111; border-radius: 12px; padding: 9px 11px; box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.toast .av { flex: none; width: 34px; height: 34px; border-radius: 4px; background: url(../img/f_xu.jpg) 50% 38% / 150%; }
.toast b { display: block; font-size: 12px; color: #666; font-weight: 500; }
.toast span { font-size: 15px; }

/* ---------- day change ---------- */
#fade { position: absolute; inset: 0; z-index: 60; background: #05060a; display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity .35s; }
#fade.on { opacity: 1; }
#fade div { font: 700 30px var(--kai); color: var(--warm-hi); letter-spacing: 4px; }

/* ---------- ending ---------- */
#end { position: absolute; inset: 0; z-index: 50; background: rgba(7,9,13,.9); padding: 62px 18px 0; display: flex; flex-direction: column; gap: 14px; align-items: center; animation: fadein .5s; }
@keyframes fadein { from { opacity: 0 } }
#end .lab { align-self: flex-start; font-size: 12px; font-weight: 700; color: #2a2018; background: var(--warm); border: 2px solid var(--ink); padding: 2px 7px; transform: rotate(-1.5deg); margin-bottom: -6px; }
.grp { width: 354px; background: #ededed; border-radius: 10px; padding: 10px 12px 12px; color: #111; box-shadow: 0 10px 30px rgba(0,0,0,.6); }
.grp .gh { font-size: 12px; color: #888; text-align: center; margin-bottom: 8px; }
.grp .row { display: flex; gap: 8px; }
.grp .av { flex: none; width: 36px; height: 36px; border-radius: 4px; background: url(../img/f_lin.jpg) 50% 38% / 150%; }
.grp .nm { font-size: 11px; color: #888; margin-bottom: 3px; }
.mini { width: 236px; background: #fff; border-radius: 6px; overflow: hidden; }
.mini .mh { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #777; padding: 7px 9px 5px; }
.mini .mh i { width: 14px; height: 14px; border-radius: 50%; background: url(../img/seal.png) center / 80% no-repeat, #2a3442; }
.mini .mt { font-size: 14px; font-weight: 600; padding: 0 9px 6px; line-height: 1.35; }
.mini .cov { height: 112px; position: relative; background: url(../img/table.jpg) 50% 40% / 130%; border-top: 1px solid #eee; }
.mini .cov::before { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(10,12,18,.25), rgba(10,12,18,.8)); }
.mini .cov .vs { position: absolute; left: 0; right: 0; top: 18px; text-align: center; font: 800 38px/1 var(--sans); color: #fff4e0; text-shadow: 0 3px 0 #000; }
.mini .cov .vs small { font-size: 13px; font-weight: 700; color: #ffcf8f; margin: 0 6px; vertical-align: middle; }
.mini .cov .bar2 { position: absolute; left: 16px; right: 16px; bottom: 28px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.2); display: flex; overflow: hidden; }
.mini .cov .bar2 b { background: #ff8f6e; } .mini .cov .bar2 u { background: #8fb4d8; }
.mini .cov .left { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 12px; color: #ffe3b8; font-weight: 700; }
.mini .mf { font-size: 10px; color: #999; padding: 5px 9px; border-top: 1px solid #eee; }
.hist {
  width: 354px; background: var(--paper); color: #2b2117; border: 3px solid var(--ink); padding: 12px 14px 10px; transform: rotate(-.6deg);
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}
.hist h3 { margin: 0 0 6px; font: 700 18px var(--kai); text-align: center; letter-spacing: 3px; }
.hist .h { display: flex; gap: 8px; font-size: 13px; line-height: 1.45; padding: 4px 0; border-bottom: 1px dashed #a98d63; }
.hist .h:last-child { border-bottom: none; }
.hist .h b { flex: none; width: 62px; white-space: nowrap; color: #7a5c3a; font-weight: 700; }
.hist .h em { font-style: normal; color: var(--red); font-weight: 700; }
#again { width: 200px; height: 52px; border: 3px solid var(--ink); border-radius: 6px; background: linear-gradient(#ffc777, #f09a3c); color: #241a12; font-size: 18px; font-weight: 700; box-shadow: 0 4px 0 #7a4f1f, 0 6px 12px rgba(0,0,0,.5); }
#again:active { transform: translateY(3px); box-shadow: 0 1px 0 #7a4f1f; }
