@font-face { font-family: "MJ Serif"; src: url(/fonts/mj-serif.woff2?v=3) format("woff2"); font-weight: 700 900; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url(/fonts/barlow-condensed-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url(/fonts/barlow-condensed-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url(/fonts/barlow-condensed-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Barlow"; src: url(/fonts/barlow-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url(/fonts/barlow-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow"; src: url(/fonts/barlow-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root {
  color-scheme: dark;
  --ink: #17110e; --rosewood: #2b120d; --lacquer: #4a1a12; --seal: #b4221c; --seal-hi: #d43a2c;
  --ivory: #f5eeda; --ivory-dim: #cfc5ab; --jade: #0f6a4d; --jade-hi: #1a8f69; --brass: #c8a04a; --felt: #1e5d45;
  --zh: "MJ Serif", "Noto Serif CJK TC", "Songti TC", "PMingLiU", serif;
  --head: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d0a09; color: var(--ivory); font: 400 16px/1.45 var(--body); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 55%, transparent 55%, rgba(0,0,0,.55) 100%); }
[hidden] { display: none !important; }
.zh { font-family: var(--zh); font-weight: 900; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

#boot { position: fixed; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; font: 600 22px var(--head); letter-spacing: .02em; color: var(--ivory-dim); background: #0d0a09; transition: opacity .5s; }
#boot.done { opacity: 0; pointer-events: none; }

/* ---- tile-shaped keys: ivory face on a jade base, like the tiles themselves ---- */
.key { border: 0; border-radius: 7px; padding: 10px 18px 11px; background: linear-gradient(#fbf6e8, #ece3cb); color: var(--ink); font: 600 19px/1.1 var(--head); letter-spacing: .01em;
  box-shadow: 0 5px 0 var(--jade), 0 9px 16px rgba(0,0,0,.45); transform: translateY(0); transition: transform .08s, box-shadow .08s, filter .15s; }
.key:hover { filter: brightness(1.04); }
.key:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--jade), 0 3px 6px rgba(0,0,0,.4); }
.key[disabled] { opacity: .45; cursor: not-allowed; }
.key.quiet { background: none; color: var(--ivory); box-shadow: inset 0 0 0 1.5px rgba(200,160,74,.55); padding: 9px 16px; }
.key.quiet:active { transform: none; background: rgba(200,160,74,.15); }
.key.small { font-size: 16px; padding: 6px 12px 7px; box-shadow: 0 3px 0 var(--jade), 0 5px 10px rgba(0,0,0,.4); }
.key.quiet.small { box-shadow: inset 0 0 0 1.5px rgba(200,160,74,.45); }

/* ---- lobby / home panel ---- */
#panel { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; overflow: auto; touch-action: pan-y; background: rgba(13,10,9,.86); }
#panel.home { background: linear-gradient(90deg, rgba(13,10,9,.95), rgba(13,10,9,.86) 36%, rgba(13,10,9,.3) 78%, rgba(13,10,9,.12)); }
.sheet { width: min(940px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 44px; align-items: start; }
.sheet.single { grid-template-columns: minmax(0, 400px); justify-content: start; width: min(1120px, 100%); }
.brand { margin: 0 0 22px; }
.brand .zh { display: block; font-size: clamp(52px, min(9vw, 17vh), 104px); line-height: 1; letter-spacing: .04em; color: var(--ivory); text-shadow: 0 3px 0 var(--seal), 0 14px 40px rgba(0,0,0,.6); }
.brand h1 { font: 600 17px/1 var(--head); margin: 16px 0 0 4px; letter-spacing: .42em; text-transform: uppercase; color: var(--brass); }
.lede { color: var(--ivory-dim); margin: 0 0 30px 4px; font-size: 17px; }
.lede .zh { display: block; font-size: 27px; line-height: 1.2; letter-spacing: .22em; color: var(--ivory); margin-bottom: 3px; }
input.text { display: block; width: 100%; padding: 12px 14px; border-radius: 6px; border: 1.5px solid rgba(200,160,74,.4); background: rgba(0,0,0,.4); color: var(--ivory); font: 500 19px var(--body); user-select: text; -webkit-user-select: text; }
input.text::placeholder { color: rgba(207,197,171,.5); }
input.code { text-transform: uppercase; letter-spacing: .3em; font: 700 22px var(--head); width: 6.4em; text-align: center; padding: 8px 6px 8px 12px; }
input.code::placeholder { font-weight: 500; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.sheet.single .row { margin-top: 16px; }
.join { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.link { border: 0; background: none; padding: 6px 0; color: var(--ivory-dim); font: 500 16px var(--head); letter-spacing: .02em; text-decoration: underline; text-decoration-color: rgba(200,160,74,.55); text-underline-offset: 4px; }
.link:hover { color: var(--ivory); }
.sheet.single .link { display: block; margin: 22px 0 0 2px; font-size: 17px; }
.note { color: var(--ivory-dim); font-size: 14.5px; margin: 0; }
.err { color: #ffb4a8; font-weight: 500; margin: -14px 0 16px 4px; }
.note-key { position: fixed; z-index: 2; top: max(12px, env(safe-area-inset-top)); right: 14px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(13,10,9,.6); color: var(--ivory-dim); font: 400 19px/1 var(--body); box-shadow: inset 0 0 0 1px rgba(200,160,74,.35); opacity: .6; }
.note-key.on { color: var(--brass); opacity: 1; box-shadow: inset 0 0 0 1.5px rgba(200,160,74,.7); }
.note-key:not(.on)::after { content: ""; position: absolute; left: 9px; right: 9px; top: 50%; height: 1.5px; background: currentColor; transform: rotate(-45deg); }

.tablecode { font: 700 54px/1 var(--head); letter-spacing: .12em; margin: 0 8px 0 0; }
.sub { font: 600 14px var(--head); letter-spacing: .3em; text-transform: uppercase; color: var(--brass); margin: 0 0 6px; }
.seats { position: relative; aspect-ratio: 1; width: min(100%, 440px); margin: 46px 0 50px; }
.seats::before { content: ""; position: absolute; inset: 31%; background: radial-gradient(circle at 50% 40%, #24705a, var(--felt) 70%); border: 6px solid var(--lacquer); border-radius: 8px; box-shadow: 0 14px 30px rgba(0,0,0,.55), inset 0 0 26px rgba(0,0,0,.35); z-index: 1; }
.seat { position: absolute; width: 27%; aspect-ratio: 1; }
.seat.s0 { left: 36.5%; top: 66%; } .seat.s2 { left: 36.5%; top: 7%; } .seat.s1 { left: 66%; top: 36.5%; } .seat.s3 { left: 7%; top: 36.5%; }
.chair { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; filter: drop-shadow(0 6px 7px rgba(0,0,0,.6)); transition: transform .18s, opacity .18s, filter .18s; }
.chair svg { display: block; width: 100%; height: 100%; }
.seat.s2 .chair { transform: rotate(180deg); } .seat.s1 .chair { transform: rotate(-90deg); } .seat.s3 .chair { transform: rotate(90deg); }
/* an empty chair is pulled out a little from the table, waiting */
.seat.empty .chair { opacity: .62; } .seat.empty .chair .silk { fill: #4a1a12; }
.seat.empty.s0 .chair { transform: translateY(9%); } .seat.empty.s2 .chair { transform: rotate(180deg) translateY(9%); } .seat.empty.s1 .chair { transform: rotate(-90deg) translateY(9%); } .seat.empty.s3 .chair { transform: rotate(90deg) translateY(9%); }
button.chair { cursor: pointer; }
button.chair:hover, button.chair:focus-visible { opacity: 1; filter: drop-shadow(0 6px 7px rgba(0,0,0,.6)) drop-shadow(0 0 10px rgba(255,214,120,.55)); outline: 0; }
.seat.me .chair { filter: drop-shadow(0 6px 7px rgba(0,0,0,.6)) drop-shadow(0 0 9px rgba(255,214,120,.5)); }
.seat .label { position: absolute; width: 170%; text-align: center; left: -35%; }
.seat.s0 .label { top: 102%; } .seat.s2 .label { bottom: 102%; }
.seat.s1 .label { top: 100%; left: auto; right: -24%; width: 112%; text-align: right; } .seat.s3 .label { top: 100%; left: -24%; width: 112%; text-align: left; }
.seat .who { font: 600 19px/1.15 var(--head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat.me .who { color: #ffe6a6; }
.seat .tag { font-size: 12.5px; line-height: 1.2; color: var(--ivory-dim); }
.seat .label .link { font-size: 13px; padding: 1px 0; }
.rules h2 { font: 600 14px var(--head); letter-spacing: .3em; text-transform: uppercase; color: var(--brass); margin: 0 0 8px; }
.opt { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(245,238,218,.1); }
.opt b { font: 600 17px var(--head); }
.opt select { background: rgba(0,0,0,.4); color: var(--ivory); border: 1.5px solid rgba(200,160,74,.4); border-radius: 6px; padding: 6px 8px; font: 500 15px var(--body); max-width: 60%; }
.opt select:disabled { opacity: 1; border-color: transparent; background: none; text-align: right; appearance: none; -webkit-appearance: none; padding-right: 0; }
.more summary { cursor: pointer; padding: 10px 0 6px; color: var(--ivory-dim); font: 500 16px var(--head); list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: "+"; margin-left: 8px; color: var(--brass); }
.more[open] summary::after { content: "−"; }
.startbar { margin-top: 20px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.startbar .link { margin-left: auto; }

/* ---- in-game HUD ---- */
#hud > * { position: fixed; }
#info { right: 16px; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; font: 500 15px/1.25 var(--head); color: var(--ivory-dim); pointer-events: none; text-shadow: 0 1px 3px #000; text-align: left; }
#info .zh { font-size: 34px; line-height: 1; color: var(--ivory); }
#info b { color: var(--ivory); font-weight: 600; font-size: 17px; }
#tools { top: max(10px, env(safe-area-inset-top)); right: 12px; z-index: 4; }
.tool { border: 0; background: rgba(13,10,9,.72); color: var(--ivory); border-radius: 6px; padding: 8px 14px; font: 600 16px var(--head); box-shadow: inset 0 0 0 1px rgba(200,160,74,.4); }
.menu { position: absolute; right: 0; top: 44px; width: 268px; max-height: calc(100vh - 62px); max-height: calc(100dvh - 62px); overflow-y: auto; touch-action: pan-y; background: rgba(20,13,10,.96); border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(200,160,74,.4), 0 18px 40px rgba(0,0,0,.6); padding: 6px; display: grid; }
.menu button { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; background: none; text-align: left; padding: 10px 12px; border-radius: 5px; font: 500 16px var(--body); }
.menu button:hover { background: rgba(200,160,74,.14); }
.menu button[data-tool=leave] { color: #ffb4a8; }
.menu i { font: 600 13px var(--head); font-style: normal; color: var(--ivory-dim); padding: 2px 8px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(245,238,218,.25); }
.menu i.on { background: var(--jade); color: var(--ivory); box-shadow: none; }
.plate { position: fixed; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 9px; padding: 5px 12px 5px 6px; border-radius: 30px; background: rgba(13,10,9,.78); box-shadow: inset 0 0 0 1px rgba(200,160,74,.3); white-space: nowrap; pointer-events: none; transition: box-shadow .25s, background .25s; }
.plate .wind { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--ivory); color: var(--ink); font: 900 21px/1 var(--zh); }
.plate.dealer .wind { background: var(--seal); color: var(--ivory); }
.plate .nm { font: 600 17px/1.05 var(--head); max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.plate .sc { font: 500 13.5px/1.1 var(--body); color: var(--ivory-dim); font-variant-numeric: tabular-nums; }
.plate.turn { background: rgba(74,26,18,.92); box-shadow: inset 0 0 0 2px var(--brass), 0 0 22px rgba(255,214,120,.35); }
.plate.off { opacity: .55; }
.plate .st { font-size: 12px; color: var(--brass); }
.plate.me { transform: none; left: 14px !important; top: auto !important; bottom: max(12px, env(safe-area-inset-bottom)); }
.call { position: fixed; transform: translate(-50%, -50%); font: 900 84px/1 var(--zh); color: var(--ivory); text-shadow: 0 0 2px var(--seal), 0 4px 0 var(--seal), 0 8px 30px rgba(0,0,0,.8); pointer-events: none; animation: call 1.5s cubic-bezier(.2,.9,.3,1) forwards; }
.call small { display: block; font: 700 22px var(--head); text-align: center; text-shadow: 0 2px 6px #000; margin-top: 2px; }
.call.soft { font-size: 46px; animation-duration: 1.1s; }
@keyframes call { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2) rotate(-6deg); } 14% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -62%) scale(1) rotate(-3deg); } }
#prompt { left: 50%; transform: translate(-50%, -100%); font: 600 15px var(--head); letter-spacing: .3em; text-transform: uppercase; color: var(--ivory-dim); text-shadow: 0 1px 4px #000, 0 0 12px #000; text-align: center; pointer-events: none; width: max-content; max-width: 92vw; }
#prompt.mine { color: #ffe6a6; }
#actions { left: 50%; transform: translate(-50%, -100%); display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; justify-content: center; max-width: 96vw; }
.stamp { position: relative; border: 0; width: 86px; height: 86px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--seal-hi), var(--seal) 60%, #8a150f); color: var(--ivory); display: grid; place-items: center; align-content: center; box-shadow: 0 6px 0 #5c0e0a, 0 12px 22px rgba(0,0,0,.55), inset 0 0 0 3px rgba(245,238,218,.28); transition: transform .08s, box-shadow .08s; animation: pop .22s cubic-bezier(.2,1.4,.4,1); }
.stamp:active { transform: translateY(5px); box-shadow: 0 1px 0 #5c0e0a, 0 3px 8px rgba(0,0,0,.5), inset 0 0 0 3px rgba(245,238,218,.28); }
.stamp .zh { font-size: 38px; line-height: 1; } .stamp span { font: 600 14px/1 var(--head); margin-top: 3px; letter-spacing: .03em; }
.stamp.win { background: radial-gradient(circle at 35% 30%, #f2cf6e, var(--brass) 60%, #8d6a1f); color: var(--ink); box-shadow: 0 6px 0 #5f4712, 0 12px 26px rgba(0,0,0,.55), 0 0 30px rgba(255,214,120,.5), inset 0 0 0 3px rgba(255,255,255,.3); }
.stamp.pass { width: 68px; height: 68px; background: rgba(13,10,9,.82); box-shadow: 0 4px 0 #000, inset 0 0 0 1.5px rgba(245,238,218,.4); }
.stamp.pass .zh { font-size: 27px; }
.stamp.wide { width: auto; height: 86px; border-radius: 43px; padding: 0 18px 0 16px; grid-auto-flow: column; gap: 10px; }
.stamp.win.wide { padding: 0 24px 0 22px; text-align: left; } .stamp.win.wide .zh { font-size: 36px; white-space: nowrap; } .stamp.win.wide span:last-child { font-size: 16px; line-height: 1.1; margin: 0; }
.stamp .tiles { display: flex; gap: 2px; } .stamp .tiles img { height: 46px; border-radius: 4px; box-shadow: 0 2px 0 var(--jade); }
.stamp .tiles img.claimed { outline: 2px solid var(--brass); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.clock { position: absolute; left: 8%; right: 8%; bottom: -16px; height: 4px; border-radius: 2px; background: rgba(245,238,218,.2); overflow: hidden; }
.clock i { display: block; height: 100%; background: var(--brass); transform-origin: left; }

/* ---- result ---- */
#result { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(13,10,9,.55); overflow: auto; touch-action: pan-y; animation: fade .35s; }
#result.peek { background: none; pointer-events: none; place-items: end center; }
#result.peek .slip > *:not(.peekbar) { display: none; }
#result.peek .slip { pointer-events: auto; padding: 10px 14px; width: auto; }
@keyframes fade { from { opacity: 0; } }
.slip { width: min(760px, 100%); background: linear-gradient(#fbf6e8, #efe6cf); color: var(--ink); border-radius: 10px; padding: 22px 24px 20px; box-shadow: 0 8px 0 var(--jade), 0 30px 70px rgba(0,0,0,.7); }
.slip h2 { font: 700 30px/1.1 var(--head); margin: 0; } .slip h2 .zh { color: var(--seal); font-size: 34px; margin-right: 10px; }
.slip .how { color: #5b4d3e; margin: 2px 0 14px; }
.handrow { display: flex; flex-wrap: wrap; gap: 3px 12px; align-items: flex-end; margin-bottom: 14px; }
.handrow .grp { display: flex; gap: 2px; } .handrow img { height: 58px; border-radius: 5px; box-shadow: 0 3px 0 var(--jade), 0 5px 8px rgba(0,0,0,.25); }
.handrow .grp.win img { outline: 3px solid var(--seal); outline-offset: 1px; } .handrow .grp.fl img { height: 44px; }
.handrow .back { height: 58px; aspect-ratio: 26/35; border-radius: 5px; background: var(--jade); box-shadow: 0 3px 0 #0a4a36; }
.cols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 22px; }
table.faan, table.pay { width: 100%; border-collapse: collapse; font-size: 15.5px; }
table.faan td, table.pay td { padding: 4px 0; border-bottom: 1px solid rgba(23,17,14,.12); }
table.faan td:first-child { font: 900 18px var(--zh); width: 5.2em; } table.faan td:last-child, table.pay td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
table.faan tr.total td { border-bottom: 0; border-top: 2px solid var(--ink); font: 700 20px var(--head); padding-top: 7px; }
table.faan tr.total td:first-child { font: 700 20px var(--head); }
table.pay td.pos { color: var(--jade); } table.pay td.neg { color: var(--seal); } table.pay td.tot { color: #5b4d3e; font-weight: 500; text-align: right; padding-right: 14px; }
table.pay .zh { font-size: 16px; margin-right: 6px; }
.slip .foot { display: flex; align-items: center; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.slip .foot .wait { color: #5b4d3e; font-size: 14.5px; flex: 1; }
.slip .key.quiet { color: var(--ink); box-shadow: inset 0 0 0 1.5px rgba(23,17,14,.35); }
.peekbar { display: none; } #result.peek .peekbar { display: flex; gap: 12px; align-items: center; font: 600 17px var(--head); }
.rank { counter-reset: r; list-style: none; padding: 0; margin: 14px 0; } .rank li { display: flex; gap: 14px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid rgba(23,17,14,.12); font: 600 22px var(--head); }
.rank li::before { counter-increment: r; content: counter(r); width: 1.2em; color: #8a7a62; } .rank li span { margin-left: auto; font-variant-numeric: tabular-nums; }
.rank li:first-child { font-size: 28px; color: var(--seal); }

/* ---- modal, banner, toast ---- */
#modal { position: fixed; inset: 0; background: rgba(13,10,9,.7); display: grid; place-items: center; padding: 16px; overflow: auto; touch-action: pan-y; z-index: 5; }
#modal .slip { max-height: 92vh; overflow: auto; user-select: text; -webkit-user-select: text; }
.styles { display: inline-flex; margin: 12px 0 2px; border-radius: 8px; box-shadow: inset 0 0 0 1.5px rgba(23,17,14,.3); padding: 3px; gap: 3px; }
.styles button { border: 0; background: none; padding: 6px 14px 7px; border-radius: 6px; font: 600 16px var(--head); color: #5b4d3e; }
.styles button.on { background: var(--ink); color: var(--ivory); }
.sheet.single .row.links { gap: 22px; margin-top: 18px; } .sheet.single .row.links .link { margin: 0; }
.slipbar { position: sticky; top: 6px; height: 0; display: flex; justify-content: flex-end; z-index: 2; }
.x { width: 38px; height: 38px; margin: -8px -10px 0 0; border: 0; border-radius: 50%; background: #efe6cf; color: var(--ink); font: 400 26px/1 var(--body); box-shadow: 0 2px 0 var(--jade), 0 4px 10px rgba(0,0,0,.25); display: grid; place-items: center; padding: 0 0 3px; }
.x:hover { background: #fffaf0; } .x:active { transform: translateY(2px); box-shadow: 0 0 0 var(--jade); }
#modal h3 { font: 700 20px var(--head); margin: 18px 0 6px; } #modal p, #modal li { font-size: 15.5px; margin: 0 0 6px; max-width: 64ch; } #modal ul { padding-left: 20px; margin: 0; }
#modal table.faan td:first-child { width: 9.5em; } #modal table.faan { margin-top: 12px; }
table.sheet { width: 100%; border-collapse: collapse; font-size: 15px; white-space: nowrap; }
table.sheet th { text-align: left; font: 600 15px var(--head); color: #5b4d3e; padding: 4px 10px 6px 0; border-bottom: 2px solid var(--ink); }
table.sheet td { padding: 5px 10px 5px 0; border-bottom: 1px solid rgba(23,17,14,.12); font-variant-numeric: tabular-nums; }
table.sheet td.pos { color: var(--jade); font-weight: 600; } table.sheet td.neg { color: var(--seal); font-weight: 600; }
table.sheet tr.total td { border-bottom: 0; border-top: 2px solid var(--ink); font: 700 18px var(--head); }
table.sheet .zh { font-size: 16px; }
#banner { position: fixed; top: 0; left: 0; right: 0; padding: 9px; text-align: center; background: var(--seal); font: 600 16px var(--head); z-index: 6; }
#toast { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); background: rgba(13,10,9,.9); box-shadow: inset 0 0 0 1px rgba(200,160,74,.5); padding: 10px 18px; border-radius: 8px; font: 600 17px var(--head); z-index: 7; animation: fade .2s; pointer-events: none; text-align: center; max-width: 90vw; }

/* ---- video call ---- */
#cams { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.cam { position: absolute; left: 0; top: 0; width: 200px; height: 150px; border-radius: 10px; overflow: hidden; background: #17110e; box-shadow: 0 0 0 1.5px rgba(200,160,74,.55), 0 8px 18px rgba(0,0,0,.55); pointer-events: auto; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; background: #17110e; }
.cam.me video { transform: scaleX(-1); }
.cam.me { width: 150px; height: 113px; }
body.incall #waits { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 184px); }
.cam .zh { position: absolute; inset: 0; display: none; place-items: center; font-size: 46px; color: var(--ivory-dim); background: radial-gradient(circle at 50% 40%, #3a1a14, #17110e); }
.cam.novid .zh { display: grid; } .cam.novid video { visibility: hidden; }
.cam.wait { opacity: .7; }
.cam .link-state { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); display: none; text-align: center; font: 600 12px var(--head); letter-spacing: .08em; color: var(--ivory); text-shadow: 0 1px 3px #000; }
.cam.wait .link-state { display: block; } .cam.wait .link-state::before { content: "connecting…"; }
.cam.stuck .link-state::before { content: "can't connect"; }
.cam i { position: absolute; left: 6px; bottom: 6px; display: none; padding: 1px 7px 2px; border-radius: 9px; background: rgba(180,34,28,.92); font: 600 11px/1.4 var(--head); font-style: normal; color: var(--ivory); }
.cam.nomic i { display: block; } .cam.nomic i::before { content: "muted"; }
.cam .ctl { position: absolute; right: 5px; bottom: 5px; display: flex; gap: 4px; }
.cam .ctl button { border: 0; border-radius: 9px; padding: 2px 8px 3px; background: rgba(13,10,9,.72); color: var(--ivory); font: 600 12px/1.3 var(--head); box-shadow: inset 0 0 0 1px rgba(200,160,74,.5); }
.cam .ctl button.off { background: rgba(180,34,28,.92); box-shadow: none; text-decoration: line-through; }
.cam.me.nomic i { display: none; }
#waits { left: 14px; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 58px); display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(13,10,9,.72); box-shadow: inset 0 0 0 1px rgba(200,160,74,.3); max-width: 46vw; flex-wrap: wrap; }
#waits b { font: 600 14px var(--head); color: var(--ivory-dim); align-self: center; margin-right: 2px; }
#waits span { display: grid; justify-items: center; gap: 3px; } #waits img { height: 44px; border-radius: 4px; box-shadow: 0 2px 0 var(--jade); } #waits i { font: 500 11px var(--body); font-style: normal; color: var(--ivory-dim); white-space: nowrap; }
#waits span.thin img { opacity: .5; }
/* ---- the tutorial coach ---- */
#coach { position: fixed; z-index: 4; left: 14px; bottom: max(17vh, 96px); width: min(376px, calc(100vw - 28px)); background: linear-gradient(#fbf6e8, #efe6cf); color: var(--ink); border-radius: 10px; padding: 12px 14px; box-shadow: 0 5px 0 var(--jade), 0 18px 40px rgba(0,0,0,.6); font-size: 15.5px; line-height: 1.4; }
#coach.top { bottom: auto; top: max(12px, env(safe-area-inset-top)); }
body.tutoring #result { place-items: center end; padding-right: max(16px, 3vw); }
#coach.big { left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(590px, calc(100vw - 28px)); max-height: calc(100% - 28px); overflow: auto; padding: 20px 24px 18px; font-size: 17px; touch-action: pan-y; }
#coach .who { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
#coach .who .zh { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--seal); color: var(--ivory); font-size: 18px; line-height: 1; }
#coach .who b { font: 700 17px var(--head); }
#coach .who i { margin-left: auto; display: flex; gap: 3px; }
#coach .who s { width: 6px; height: 6px; border-radius: 50%; background: rgba(23,17,14,.16); }
#coach .who s.d { background: var(--jade); } #coach .who s.c { background: var(--seal); transform: scale(1.4); }
#coach .say h3 { font: 700 26px/1.1 var(--head); margin: 0 0 8px; }
#coach .say p { margin: 0 0 8px; } #coach .say ul { margin: 0 0 8px; padding-left: 20px; } #coach .say li { margin-bottom: 4px; }
#coach .ct { display: flex; gap: 8px 18px; flex-wrap: wrap; margin: 8px 0 12px; }
#coach .ct figure { margin: 0; } #coach .ct span { display: flex; gap: 2px; } #coach .ct img { height: 50px; border-radius: 4px; box-shadow: 0 2px 0 var(--jade), 0 3px 6px rgba(0,0,0,.2); }
#coach figcaption { font: 600 13.5px var(--head); color: #5b4d3e; margin-top: 5px; }
#coach .go { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
#coach .go:empty { display: none; }
#coach .key.quiet { color: var(--ink); box-shadow: inset 0 0 0 1.5px rgba(23,17,14,.35); }
#coach .skip { margin-left: auto; border: 0; background: none; color: #7a6a55; font: 500 13px var(--body); text-decoration: underline; padding: 4px 0; }
#coach.shake { animation: shake .36s; } #coach.big.shake { animation: none; }
@keyframes shake { 20% { transform: translateX(-7px); } 45% { transform: translateX(6px); } 70% { transform: translateX(-4px); } }
.stamp.coach { outline: 4px solid #ffd76a; outline-offset: 5px; animation: pop .22s cubic-bezier(.2,1.4,.4,1), ring 0.9s ease-in-out .25s infinite alternate; }
.stamp.dim { opacity: .38; filter: saturate(.5); }
@keyframes ring { to { outline-offset: 10px; outline-color: rgba(255,215,106,.35); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 8; overflow: hidden; }
.confetti i { position: absolute; top: -24px; width: 9px; height: 15px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 106%; transform: rotate(700deg) translateX(60px); } }
#peek { position: fixed; z-index: 3; pointer-events: none; display: grid; justify-items: center; gap: 5px; }
#peek img { height: 118px; border-radius: 9px; box-shadow: 0 5px 0 var(--jade), 0 14px 26px rgba(0,0,0,.6); }
#peek span { font: 600 14px var(--head); background: rgba(13,10,9,.85); padding: 2px 9px; border-radius: 10px; margin-top: 5px; white-space: nowrap; }
@media (max-width: 820px) {
  .sheet { grid-template-columns: 1fr; gap: 26px; } .cols { grid-template-columns: 1fr; gap: 12px; }
  #panel { place-items: start center; } #panel.home { place-items: center; background: rgba(13,10,9,.84); } .sheet.single { justify-content: center; }
  .tablecode { font-size: 42px; } .seats { margin-inline: auto; width: min(100%, 380px); }
  .stamp { width: 70px; height: 70px; } .stamp .zh { font-size: 30px; } .stamp span { font-size: 12px; } .stamp.pass { width: 56px; height: 56px; } .stamp.wide { height: 70px; } .stamp .tiles img { height: 36px; }
  .handrow img, .handrow .back { height: 42px; } .handrow .grp.fl img { height: 32px; }
  .plate .nm { max-width: 90px; font-size: 15px; } .plate .wind { width: 28px; height: 28px; font-size: 17px; }
  #info { font-size: 13px; } #info .zh { font-size: 24px; } #info b { font-size: 14px; }
  .call { font-size: 60px; }
}
@media (max-height: 520px), (max-width: 620px) {
  .plate { padding: 3px 9px 3px 4px; gap: 6px; } .plate .wind { width: 24px; height: 24px; font-size: 15px; } .plate .nm { font-size: 14px; max-width: 78px; } .plate .sc { font-size: 11.5px; } .plate .st { display: none; }
  #prompt { font-size: 15px; } #info b { font-size: 13px; } #info { font-size: 12px; gap: 7px; } #info .zh { font-size: 22px; }
  .stamp { width: 60px; height: 60px; } .stamp .zh { font-size: 26px; } .stamp span { font-size: 11px; } .stamp.pass { width: 50px; height: 50px; } .stamp.wide { height: 60px; padding: 0 12px; } .stamp .tiles img { height: 32px; }
  .tool { padding: 6px 10px; font-size: 14px; } .call { font-size: 48px; } .call small { font-size: 15px; }
  .slip { padding: 14px 16px; } .slip h2 { font-size: 22px; } .slip h2 .zh { font-size: 25px; } .handrow img, .handrow .back { height: 36px; } .handrow .grp.fl img { height: 28px; }
}
@media (max-height: 520px), (max-width: 620px) { .cam { width: 132px; height: 99px; } .cam.me { width: 104px; height: 78px; } .cam .zh { font-size: 30px; } .cam .ctl button { padding: 1px 6px 2px; font-size: 11.5px; } }
@media (max-height: 430px) { .cam { width: 116px; height: 87px; } .cam.me { width: 96px; height: 72px; } .cam .zh { font-size: 24px; } .cam .ctl button { padding: 1px 5px 2px; font-size: 11px; } }
@media (max-height: 520px), (max-width: 620px) { #coach { font-size: 13.5px; padding: 9px 11px; width: min(310px, calc(100vw - 28px)); } #coach.big { font-size: 15px; padding: 14px 16px; } #coach .ct img { height: 38px; } #coach .say h3 { font-size: 21px; } }
@media (max-height: 520px) {
  .seats { width: min(100%, 300px); margin: 40px 0 44px; } .seat .who { font-size: 16px; } .tablecode { font-size: 38px; }
  .menu { width: min(500px, calc(100vw - 24px)); grid-template-columns: 1fr 1fr; top: 38px; } .menu button { padding: 7px 10px; font-size: 15px; }
  .brand { margin-bottom: 8px; } .brand h1 { margin-top: 8px; font-size: 14px; } .lede { margin-bottom: 14px; font-size: 14px; } .lede .zh { font-size: 21px; }
  input.text { padding: 8px 12px; font-size: 17px; } .sheet.single .row { margin-top: 10px; } .sheet.single .link { margin-top: 10px; }
  .key { font-size: 17px; padding: 8px 14px 9px; }
}
@media (max-width: 1060px) { #panel.lobby { padding-top: 58px; } }
@media (prefers-reduced-motion: reduce) { .call, .stamp, #result, #coach.shake { animation-duration: .01s; } }
