/* Fight the Landlord (斗地主) at /landlord/. A standalone page: green felt, chunky friendly controls. */
:root {
  --felt: #13603f; --felt-hi: #1b7a52; --felt-lo: #0b3d2a; --ink: #1c1f24; --paper: #fffdf7;
  --red: #d8344a; --gold: #f5c542; --gold-deep: #c9971a; --sky: #60a5fa; --mint: #4ade80;
  --glass: rgba(0, 0, 0, .28); --glass-hi: rgba(255, 255, 255, .12); --line: rgba(255, 255, 255, .16);
  --text: #f3faf6; --muted: rgba(243, 250, 246, .66);
  --radius: 16px; --shadow: 0 6px 18px rgba(0, 0, 0, .28);
  --cw: 3.5rem;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body.ddz {
  font-family: "Nunito", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 700; color: var(--text); overscroll-behavior: none;
  background: radial-gradient(ellipse at 50% 35%, var(--felt-hi), var(--felt) 45%, var(--felt-lo) 100%) fixed var(--felt-lo);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .6rem; font-weight: 900; line-height: 1.15; }
.muted { color: var(--muted); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 46px; padding: .55rem 1.1rem; border: 0; border-radius: 999px;
  background: var(--glass-hi); color: var(--text); font-weight: 800; font-size: 1rem; text-decoration: none;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); transition: transform .08s, filter .15s, opacity .15s; user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(2px) scale(.98); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .18); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: linear-gradient(#ff6b5e, var(--red)); color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .22), 0 4px 14px rgba(216, 52, 74, .35); }
.btn.gold { background: linear-gradient(#ffd966, var(--gold)); color: #3b2a00; box-shadow: inset 0 -3px 0 var(--gold-deep), 0 4px 14px rgba(245, 197, 66, .3); }
.btn.ghost { background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 2px var(--line); }
.btn.small { min-height: 36px; padding: .3rem .8rem; font-size: .88rem; }
.btn.wide { width: 100%; }
.btn.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); filter: brightness(1.1); } }
.link-btn { display: block; margin: .7rem auto 0; padding: .4rem; border: 0; background: none; color: var(--muted); text-decoration: underline; font-size: .9rem; }
.icon-btn {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--glass); color: var(--text); font-size: 1.05rem; font-weight: 900; text-decoration: none;
}
.pill { border: 0; border-radius: 999px; padding: .45rem .9rem; background: var(--glass); color: var(--text); font-weight: 800; font-size: .9rem; white-space: nowrap; }
.icon-btn[data-lang-toggle] { width: auto; min-width: 40px; padding: 0 10px; border-radius: 999px; font-size: .8rem; white-space: nowrap; }
.pill b { color: var(--gold); letter-spacing: .08em; }

/* ---- cards ---- */
.card {
  --h: calc(var(--cw) * 1.4);
  position: relative; flex: none; width: var(--cw); height: var(--h); border-radius: calc(var(--cw) * .13);
  background: var(--paper); color: var(--ink); box-shadow: 0 1px 0 rgba(0, 0, 0, .15), -2px 2px 6px rgba(0, 0, 0, .22);
  user-select: none; transition: transform .14s ease, filter .15s;
}
.card.red { color: var(--red); }
.card .ix { position: absolute; top: 5%; left: 7%; display: flex; flex-direction: column; align-items: center; line-height: .95; }
.card .ix b { font-size: calc(var(--cw) * .36); font-weight: 900; letter-spacing: -.04em; }
.card .ix i { font-style: normal; font-size: calc(var(--cw) * .28); }
.card .pip { position: absolute; right: 8%; bottom: 4%; font-size: calc(var(--cw) * .52); line-height: 1; }
.card.joker .ix b { writing-mode: vertical-rl; text-orientation: upright; font-size: calc(var(--cw) * .2); letter-spacing: -.12em; }
.card.joker.red { color: var(--red); }
.card.joker.black { color: var(--ink); }
.card.joker .pip { font-size: calc(var(--cw) * .5); }
.card.back {
  background: repeating-linear-gradient(45deg, #b8283a 0 4px, #d8344a 4px 8px);
  box-shadow: inset 0 0 0 2px #fff, 0 1px 3px rgba(0, 0, 0, .3);
}
.cards { display: flex; justify-content: center; }
.cards .card + .card { margin-left: calc(var(--cw) * -.55); }
.cards.mini { --cw: 1.7rem; }
.cards.mini .card + .card { margin-left: calc(var(--cw) * -.42); }
.cards.mini .card .pip { display: none; }
.cards.mini .card .ix { left: 9%; }
.cards.mini .card .ix b { font-size: calc(var(--cw) * .44); }
.cards.mini .card .ix i { font-size: calc(var(--cw) * .36); }
.cards.mini .card.joker .ix b { font-size: calc(var(--cw) * .25); }
.cards.mid { --cw: 2.5rem; }
.cards.mid .card + .card { margin-left: calc(var(--cw) * -.5); }
.flip .card { animation: flip .6s ease both; }
.flip .card:nth-child(2) { animation-delay: .1s; }
.flip .card:nth-child(3) { animation-delay: .2s; }
@keyframes flip { from { transform: rotateY(90deg); } to { transform: none; } }

/* ---- home ---- */
.home { max-width: 460px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.home-top { display: flex; justify-content: space-between; align-items: center; }
.home-back { color: var(--muted); text-decoration: none; font-size: .9rem; }
.home-hero { text-align: center; padding: 10px 0 4px; }
.home-hero h1 { font-size: clamp(1.9rem, 8vw, 2.5rem); text-shadow: 0 3px 0 rgba(0, 0, 0, .25); margin: 14px 0 4px; }
.home-sub { margin: 0; color: var(--muted); }
.hero-cards { display: flex; justify-content: center; align-items: flex-end; height: 120px; }
.card.big { --cw: 4.6rem; box-shadow: var(--shadow); }
.card.big + .card.big { margin-left: -1.4rem; }
.tilt-l { transform: rotate(-14deg) translateY(10px); animation: bobL 3.2s ease-in-out infinite; }
.tilt-r { transform: rotate(14deg) translateY(10px); animation: bobR 3.2s ease-in-out infinite .4s; }
.hero-cards .joker { z-index: 1; animation: bob 3.2s ease-in-out infinite .2s; }
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes bobL { 50% { transform: rotate(-17deg) translateY(4px); } }
@keyframes bobR { 50% { transform: rotate(17deg) translateY(4px); } }
.sheet { background: rgba(255, 255, 255, .08); border: 1px solid var(--line); border-radius: 22px; padding: 18px; backdrop-filter: blur(6px); }
.sheet h2 { font-size: 1.25rem; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.field input, .code-input {
  width: 100%; min-height: 48px; padding: .6rem .9rem; border: 2px solid transparent; border-radius: 14px;
  background: var(--paper); color: var(--ink); font-size: 1.05rem; outline: none;
}
.field input:focus, .code-input:focus { border-color: var(--gold); }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.avatar-opt { aspect-ratio: 1; border: 0; border-radius: 14px; background: rgba(0, 0, 0, .2); font-size: 1.6rem; transition: transform .12s, background .12s; }
.avatar-opt.on { background: var(--gold); transform: scale(1.08); box-shadow: 0 0 0 3px #fff3; }
.code-row { display: flex; gap: 8px; }
.code-input { flex: 1; text-transform: uppercase; letter-spacing: .4em; text-align: center; font-weight: 900; }
.code-input::placeholder { color: #c9c6bd; }
.home-error { margin: 0; padding: .7rem 1rem; border-radius: 14px; background: rgba(216, 52, 74, .9); text-align: center; }
.home-recent { display: flex; flex-direction: column; gap: 8px; }

/* ---- table layout ---- */
.game {
  --hand-cw: 3.5;
  position: fixed; inset: 0; display: grid; grid-template-rows: auto auto 1fr auto; grid-template-columns: minmax(0, 1fr); overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; max-width: 62rem; width: 100%; margin: 0 auto; }
.bar-mid { flex: 1; display: flex; justify-content: center; align-items: center; gap: 6px; min-width: 0; }
.bottom-cards .cards.mini { --cw: 1.5rem; }
.bottom-cards .cards.mini .card + .card { margin-left: 2px; }
.mult { padding: .2rem .55rem; border-radius: 999px; background: var(--gold); color: #3b2a00; font-weight: 900; font-size: .9rem; }

.felt {
  position: relative; display: grid; gap: 6px; padding: 4px 10px; min-height: 0; max-width: 62rem; width: 100%; margin: 0 auto;
  grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr auto; grid-template-areas: "left right" "center center" "mine mine";
}
.opp.left { grid-area: left; }
.opp.right { grid-area: right; align-items: flex-end; }
.center { grid-area: center; display: flex; align-items: center; justify-content: center; min-height: 0; overflow-y: auto; }
.mine { grid-area: mine; min-height: 64px; display: flex; justify-content: center; align-items: flex-end; }
.opp { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.opp.right .seat-head { flex-direction: row-reverse; text-align: right; }
.opp.right .meta { justify-content: flex-end; }
.opp .plays { min-height: 54px; display: flex; flex: 1; align-items: center; padding-bottom: 12vh; }
.opp .cards.mini { --cw: 2.1rem; flex-wrap: wrap; row-gap: 4px; }
.opp.right .plays { justify-content: flex-end; }

.seat-head, .my-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.avatar {
  position: relative; flex: none; width: 52px; height: 52px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25);
  background: rgba(0, 0, 0, .25); font-size: 1.8rem; line-height: 1; display: grid; place-items: center; padding: 0;
  transition: box-shadow .2s, border-color .2s;
}
.avatar.landlord { border-color: var(--gold); }
.avatar.turn { border-color: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, .25), 0 0 22px 4px rgba(245, 197, 66, .7); animation: glow 1.2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, .15), 0 0 30px 8px rgba(245, 197, 66, .85); } }
.avatar.empty { font-size: 1.3rem; color: var(--muted); border-style: dashed; }
.avatar .crown { position: absolute; top: -14px; left: 50%; transform: translateX(-50%) rotate(-10deg); font-size: 1.05rem; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .4)); }
.avatar .bot-tag {
  position: absolute; bottom: -5px; right: -6px; padding: 1px 5px; border-radius: 6px; background: var(--sky); color: #06223f;
  font-size: .62rem; font-weight: 900; line-height: 1.3; white-space: nowrap;
}
.mine-avatar { width: 44px; height: 44px; font-size: 1.5rem; }
.who { min-width: 0; }
.name { font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9.5rem; }
.meta { display: flex; align-items: center; gap: 6px; font-size: .85rem; margin-top: 2px; }
.count {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 5px; border-radius: 999px; background: rgba(0, 0, 0, .3); font-weight: 900;
}
.count i { display: inline-block; width: 9px; height: 12px; border-radius: 2px; background: repeating-linear-gradient(45deg, #b8283a 0 2px, #e05a6c 2px 4px); box-shadow: 0 0 0 1px #fff; }
.count.alarm { background: var(--red); color: #fff; animation: pulse .8s ease-in-out infinite; }
.score { color: var(--mint); font-weight: 900; }
.score.neg { color: #ff9aa6; }

/* ---- plays and bubbles ---- */
.plays { position: relative; }
.played { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.opp.right .played { align-items: flex-end; }
.opp.left .played { align-items: flex-start; }
.combo-tag { padding: 1px 9px; border-radius: 999px; background: rgba(0, 0, 0, .35); font-size: .75rem; color: var(--muted); }
.combo-tag.big { background: var(--red); color: #fff; font-size: .85rem; }
.fly-up { animation: flyUp .32s cubic-bezier(.2, .9, .3, 1.2) both; }
.fly-left { animation: flyLeft .32s cubic-bezier(.2, .9, .3, 1.2) both; }
.fly-right { animation: flyRight .32s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes flyUp { from { transform: translateY(60px) scale(.8); opacity: 0; } }
@keyframes flyLeft { from { transform: translate(-40px, -20px) scale(.6); opacity: 0; } }
@keyframes flyRight { from { transform: translate(40px, -20px) scale(.6); opacity: 0; } }
.bubble {
  display: inline-flex; align-items: center; gap: 4px; padding: .35rem .8rem; border-radius: 14px; background: var(--paper); color: var(--ink);
  font-weight: 900; box-shadow: var(--shadow); animation: popIn .25s ease both;
}
.bubble.gold { background: var(--gold); color: #3b2a00; }
.bubble.muted { background: rgba(0, 0, 0, .3); color: var(--muted); box-shadow: none; }
.bubble.thinking i { width: 7px; height: 7px; border-radius: 50%; background: #9aa0a6; animation: dots 1s infinite; }
.bubble.thinking i:nth-child(2) { animation-delay: .15s; }
.bubble.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes dots { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } }
.plays.reveal .cards.mini { flex-wrap: wrap; max-width: 11rem; row-gap: 3px; }

/* ---- center panels ---- */
.panel {
  width: min(100%, 400px); max-height: 100%; overflow-y: auto; text-align: center; padding: 18px 16px;
  background: rgba(8, 40, 27, .82); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
}
.panel.pop { animation: popIn .3s ease both; }
.panel h2 { font-size: 1.35rem; }
.slots { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.slot { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 16px; background: rgba(255, 255, 255, .07); text-align: left; }
.slot.empty { border: 2px dashed var(--line); background: none; }
.slot-avatar { font-size: 1.7rem; width: 2.2rem; text-align: center; }
.slot-name { flex: 1; min-width: 0; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; padding: 0 7px; border-radius: 999px; background: rgba(255, 255, 255, .15); font-size: .72rem; color: var(--muted); vertical-align: 2px; }
.invite-box { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--muted); font-size: .88rem; }
.code-big {
  border: 2px dashed var(--gold); border-radius: 14px; background: rgba(245, 197, 66, .1); color: var(--gold);
  font-size: 2rem; font-weight: 900; letter-spacing: .3em; padding: .2rem .4rem .2rem .7rem;
}
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.row .btn { flex: 1 1 auto; }
.hint-text { color: var(--muted); margin: .4rem 0 0; }
.result-emoji { font-size: 3rem; line-height: 1; animation: bounce .7s ease both; }
@keyframes bounce { 0% { transform: scale(0); } 60% { transform: scale(1.25); } 100% { transform: none; } }
.result.won { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(245, 197, 66, .4), var(--shadow); }
.result h2 { font-size: 1.6rem; margin: .3rem 0 .1rem; }
.result.won h2 { color: var(--gold); }
.result .sub { margin: 0 0 .6rem; color: var(--muted); }
.levels { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; font-size: .88rem; color: var(--muted); }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 2px var(--line); }
.seg button { min-height: 32px; padding: .2rem .8rem; border: 0; border-radius: 999px; background: none; color: inherit; font: inherit; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--gold); color: #3b2a00; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: .5rem 0 .8rem; }
.chip { padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); font-size: .85rem; }
.chip.gold { background: var(--gold); color: #3b2a00; }
.chip.strong { background: var(--paper); color: var(--ink); }
.score-table { margin-bottom: 12px; }
.score-row { display: grid; grid-template-columns: 1fr auto 3.5rem; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 12px; text-align: left; }
.score-row.me { background: rgba(255, 255, 255, .08); }
.score-row.head { padding-top: 0; padding-bottom: 0; font-size: .75rem; color: var(--muted); }
.score-row.head span:last-child, .tot { text-align: right; }
.score-who { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.delta { font-weight: 900; }
.delta.up { color: var(--mint); }
.delta.down { color: #ff9aa6; }
.tot { font-weight: 900; }

/* ---- dock: my status, buttons and hand ---- */
.dock {
  max-width: 62rem; width: 100%; margin: 0 auto; padding: 4px 8px max(10px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
.status { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 4px; }
.status-text { flex: 1; text-align: right; font-size: .95rem; color: var(--muted); }
.status-text .ok { color: var(--mint); font-weight: 900; }
.status-text .bad { color: #ffb4bd; }
.role { padding: 0 8px; border-radius: 999px; font-size: .78rem; }
.role.landlord { background: var(--gold); color: #3b2a00; }
.role.farmer { background: rgba(74, 222, 128, .2); color: var(--mint); }
.controls { display: flex; gap: 8px; justify-content: center; min-height: 46px; }
.controls:empty { min-height: 0; }
.controls .btn { flex: 1 1 0; max-width: 11rem; }
.controls .btn.wide { max-width: 22rem; }
.hand { --cw: calc(var(--hand-cw) * 1rem); position: relative; padding: 18px 6px 0; touch-action: none; min-height: calc(var(--cw) * 1.4 + 18px); }
.hand-row { display: flex; justify-content: center; }
.hand.two-rows .hand-row + .hand-row { margin-top: calc(var(--cw) * -.7); }
.hand .card { cursor: pointer; }
.hand .card.sel { transform: translateY(-16px); box-shadow: 0 0 0 2px var(--gold), -2px 6px 10px rgba(0, 0, 0, .3); }
.hand.lord .card { background: linear-gradient(#fffdf7 75%, #fff6d8); }
.card.dim { filter: brightness(.65) saturate(.6); }
.card.deal { animation: deal .38s cubic-bezier(.2, .9, .3, 1.1) both; }
@keyframes deal { from { transform: translateY(-50vh) rotate(-25deg) scale(.5); opacity: 0; } }

/* phases */
.game[data-phase="bidding"] .felt, .game[data-phase="playing"] .felt { grid-template-areas: "left right" "left right" "mine mine"; }
.game[data-phase="bidding"] .center, .game[data-phase="playing"] .center { display: none; }
.game[data-phase="lobby"] .opp, .game[data-phase="lobby"] .mine, .game[data-phase="lobby"] .dock .hand { display: none; }
.game[data-phase="lobby"] .felt { grid-template-areas: "center center" "center center" "center center"; }
.game[data-phase="lobby"] .status { display: none; }
.game[data-phase="done"] .mine { display: none; }
.game[data-phase="done"] .opp .plays { padding-bottom: 0; }

/* ---- effects ---- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.banner {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); white-space: nowrap;
  font-size: clamp(2.2rem, 11vw, 4rem); font-weight: 900; color: #fff; letter-spacing: .02em;
  text-shadow: 0 4px 0 rgba(0, 0, 0, .3), 0 0 30px rgba(0, 0, 0, .3); animation: bannerIn 1.8s ease both;
}
.banner.boom { color: var(--gold); -webkit-text-stroke: 2px #7a1020; }
.banner.soft { font-size: clamp(1.6rem, 8vw, 2.6rem); color: #e0f2ff; }
.banner.lord { font-size: clamp(1.6rem, 8vw, 2.8rem); color: var(--gold); }
@keyframes bannerIn {
  0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  25%, 80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(1); opacity: 0; }
}
.particle { position: absolute; font-size: 1.6rem; transform: translate(-50%, -50%); animation: particle 1s ease-out forwards; }
@keyframes particle { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.4); opacity: 0; } }
.flyer { position: absolute; font-size: 3.5rem; }
.flyer.up { left: 50%; bottom: -60px; animation: rocket 1.4s ease-in forwards; }
.flyer.across { top: 30%; left: -80px; animation: plane 1.6s linear forwards; }
@keyframes rocket { to { transform: translateY(-120vh) rotate(-45deg); } }
@keyframes plane { 0% { transform: translateX(0) translateY(0); } 50% { transform: translateX(55vw) translateY(-20px); } 100% { transform: translateX(calc(100vw + 160px)) translateY(10px); } }
.float-bubble {
  position: absolute; transform: translate(-50%, -100%); padding: .4rem .8rem; border-radius: 16px; background: var(--paper); color: var(--ink);
  font-weight: 900; white-space: nowrap; box-shadow: var(--shadow); animation: floatUp 2.6s ease both;
}
.float-bubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; background: inherit; transform: translateX(-50%) rotate(45deg); }
.float-bubble.alarm { background: var(--red); color: #fff; }
.float-bubble.emoji { background: none; box-shadow: none; padding: 0; }
.float-bubble.emoji::after { display: none; }
.big-emoji { font-size: 2.6rem; }
@keyframes floatUp {
  0% { transform: translate(-50%, -80%) scale(.4); opacity: 0; }
  12% { transform: translate(-50%, -110%) scale(1.1); opacity: 1; }
  20%, 80% { transform: translate(-50%, -110%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -150%); opacity: 0; }
}
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 31; }
.toast {
  position: fixed; left: 50%; bottom: calc(40% + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; max-width: calc(100% - 32px);
  padding: .65rem 1.1rem; border-radius: 999px; background: rgba(15, 20, 18, .92); color: #fff; text-align: center; box-shadow: var(--shadow);
}
.toast.in { animation: popIn .25s ease both; }
.game.shake { animation: shake .5s ease; }
@keyframes shake { 20% { transform: translate(-8px, 4px); } 40% { transform: translate(8px, -4px); } 60% { transform: translate(-5px, 2px); } 80% { transform: translate(4px, -1px); } }

/* ---- modals ---- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .5); animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.modal > .sheet {
  position: relative; width: min(100%, 460px); max-height: 88dvh; overflow-y: auto; border-radius: 24px 24px 0 0;
  background: #0f4a32; border: 0; padding: 20px 18px max(20px, env(safe-area-inset-bottom)); animation: slideUp .28s cubic-bezier(.2, .9, .3, 1) both;
}
.modal > .sheet > .btn + .btn { margin-top: 8px; }
@keyframes slideUp { from { transform: translateY(100%); } }
@media (min-width: 640px) { .modal { align-items: center; } .modal > .sheet { border-radius: 24px; } }
.close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .25); font-size: 1rem; }
.help { font-weight: 600; line-height: 1.5; }
.help h2 { padding-right: 40px; }
.help b { font-weight: 900; }
.help p { margin: 0 0 .8rem; }
.help .order { padding: .5rem .8rem; border-radius: 12px; background: rgba(0, 0, 0, .25); font-weight: 800; text-align: center; }
.help-list { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: 10px; }
.help-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(255, 255, 255, .06); }
.help-combo { display: flex; flex-direction: column; min-width: 0; }
.help-combo span { font-size: .8rem; color: var(--muted); }
.help-list .cards { flex: none; }
.react-sheet h3 { text-align: center; }
.emoji-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.emoji-grid button { aspect-ratio: 1.3; border: 0; border-radius: 16px; background: rgba(0, 0, 0, .22); font-size: 2rem; transition: transform .1s; }
.emoji-grid button:active { transform: scale(.9); }
.phrase-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---- bigger screens ---- */
@media (min-width: 760px) {
  .game { --hand-cw: 4.2; }
  .felt { grid-template-columns: 1fr 1.6fr 1fr; grid-template-rows: 1fr auto; grid-template-areas: "left center right" "left mine right"; padding: 10px 16px; }
  .game[data-phase="lobby"] .felt { grid-template-areas: "center center center" "center center center"; }
  .game[data-phase="bidding"] .felt, .game[data-phase="playing"] .felt { grid-template-areas: "left mine right" "left mine right"; }
  .opp .plays { padding-bottom: 0; flex: 0 0 auto; }
  .opp { justify-content: flex-start; padding-top: 20px; }
  .opp .seat-head { flex-direction: column; text-align: center; }
  .opp.right .seat-head { flex-direction: column; text-align: center; }
  .opp.left, .opp.right { align-items: center; }
  .opp .meta, .opp.right .meta { justify-content: center; }
  .opp .plays, .opp.right .plays { justify-content: center; margin-top: 8px; }
  .opp .played, .opp.right .played, .opp.left .played { align-items: center; }
  .avatar { width: 64px; height: 64px; font-size: 2.2rem; }
  .mine-avatar { width: 50px; height: 50px; font-size: 1.7rem; }
  .cards.mini { --cw: 2.1rem; }
  .cards.mid { --cw: 3rem; }
  .bottom-cards .cards.mini { --cw: 1.8rem; }
}
@media (max-height: 640px) and (max-width: 759px) { .game { --hand-cw: 3; } .avatar { width: 44px; height: 44px; font-size: 1.5rem; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
@media (max-width: 520px) {
  .bar { gap: 4px; padding: 8px 8px; }
  .bar .icon-btn { width: 36px; height: 36px; font-size: .95rem; }
  .game:not([data-phase="lobby"]) .code-pill { padding: .45rem .6rem; }
  .game:not([data-phase="lobby"]) .code-pill span { display: none; }
  .bottom-cards .cards.mini { --cw: 1.35rem; }
  .mult { font-size: .8rem; padding: .15rem .45rem; }
}

/* ---- card counter (记牌器) ---- */
.bar { grid-row: 1; }
.tracker { grid-row: 2; }
.felt { grid-row: 3; }
.dock { grid-row: 4; }
.tracker {
  display: flex; align-items: center; justify-content: center; gap: 3px; max-width: 62rem; width: calc(100% - 16px); margin: 0 auto 4px;
  padding: 4px 8px; border-radius: 14px; background: rgba(0, 0, 0, .25);
}
.tr-label { font-size: .75rem; color: var(--muted); margin-right: 6px; white-space: nowrap; }
.tr-cell { flex: 0 1 2.2rem; min-width: 0; display: flex; flex-direction: column; align-items: center; line-height: 1.15; padding: 2px 0; border-radius: 8px; }
.tr-cell b { font-size: .85rem; font-weight: 900; }
.tr-cell i { font-style: normal; font-size: .95rem; font-weight: 900; color: var(--gold); }
.tr-cell.gone { opacity: .3; }
.tr-cell.gone i { color: var(--muted); }
.tr-cell.four { background: rgba(216, 52, 74, .35); }
@media (max-width: 520px) { .tr-label { display: none; } .tracker { gap: 1px; padding: 3px 4px; } .tr-cell b { font-size: .72rem; } .tr-cell i { font-size: .82rem; } }

/* ---- grow with the screen on laptops and monitors ---- */
@media (min-width: 760px) {
  html.ll-table { font-size: clamp(16px, calc(.45vw + 1.05vh + 3px), 28px); }
  .avatar { width: 4rem; height: 4rem; font-size: 2.3rem; }
  .mine-avatar { width: 3.2rem; height: 3.2rem; font-size: 1.8rem; }
  .btn { min-height: 2.9rem; }
  .bar .icon-btn { width: 2.6rem; height: 2.6rem; }
  .name { max-width: 12rem; }
  .cards.mini, .opp .cards.mini { --cw: 2.6rem; }
  .cards.mid { --cw: 3.4rem; }
  .bottom-cards .cards.mini { --cw: 2rem; }
  .opp { padding-top: 1.5rem; }
  .opp .plays { margin-top: 1.5rem; }
}
.cards.mini .card.joker .ix { display: none; }
.cards.mini .card.joker .pip { display: block; left: 0; right: 0; top: 50%; bottom: auto; transform: translateY(-50%); text-align: center; font-size: calc(var(--cw) * .62); }
