:root {
  --gold: #f5c451;
  --ink: #fff;
  --muted: rgba(255, 255, 255, .66);
  --line: rgba(255, 255, 255, .13);
  --red: #d3233f;
  --good: #5fdc8f;
  --bad: #ff7a85;
  /* trick-card width and hand-card width scale with the viewport */
  --cw: clamp(48px, min(12vw, 10vh), 88px);
  --hw: clamp(56px, min(15vw, 13vh), 104px);
  color-scheme: dark;
}
@supports (height: 1dvh) {
  :root { --cw: clamp(48px, min(12vw, 10dvh), 88px); --hw: clamp(56px, min(15vw, 13dvh), 104px); }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.4 'Outfit', system-ui, sans-serif; color: var(--ink); overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, #145c3b 0%, #0a3a26 55%, #04190f 100%) fixed #0a3a26;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
input { user-select: text; -webkit-user-select: text; font-size: 16px; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
.hide { display: none !important; }


/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 12px; font-weight: 600; letter-spacing: .2px; transition: transform .12s, filter .15s, background .2s, opacity .2s; }
.btn:active { transform: scale(.96); }
.btn.gold { background: linear-gradient(180deg, #ffd774, #e9a923); color: #2a1c00; box-shadow: 0 6px 18px rgba(233, 169, 35, .35), inset 0 1px 0 rgba(255, 255, 255, .6); }
.btn.gold:hover { filter: brightness(1.07); }
.btn.ghost { background: rgba(255, 255, 255, .1); border: 1px solid var(--line); }
.btn.ghost:hover { background: rgba(255, 255, 255, .17); }
.btn.big { padding: 15px 20px; font-size: 17px; width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; }
.btn.danger { color: #ffb3bb; }
.btn:disabled { opacity: .4; cursor: default; transform: none; filter: grayscale(.4); }
.btn:focus-visible, .icon:focus-visible, .link:focus-visible, .card:focus-visible, .bids button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.link { color: var(--muted); font-size: 14px; padding: 6px 8px; text-decoration: underline; text-underline-offset: 3px; display: inline-flex; align-items: center; gap: 6px; }
.link:hover { color: #fff; }
.link svg, .btn svg { width: 18px; height: 18px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.96); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- setup: your character, your name, and the three ways to play ----------
   One rhythm everywhere: sections 22px apart (12px on sideways phones), 10-14px inside a section. */
#home { place-items: start center; padding: 0; }
.setup { --gap: 22px; width: 100%; max-width: 460px; min-height: 100%; display: flex; flex-direction: column; gap: var(--gap);
  padding: calc(12px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.su-side { display: contents; } /* phones: one column, ordered below */
.su-top { order: 0; } .su-invite { order: 1; } .su-head { order: 2; } .su-pick { order: 3; } .su-name, .su-me { order: 4; } .su-modes { order: 5; } .su-foot { order: 6; }
.su-top { display: flex; align-items: center; justify-content: space-between; }
.su-back { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); color: var(--ink); }
.su-back svg { width: 20px; height: 20px; }
.su-brand { font: 900 22px/1 'Playfair Display', serif; }
.su-brand span { color: var(--gold); }
.su-head h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.4px; line-height: 1.15; }
.su-head p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.su-label { display: block; margin-bottom: 10px; font-size: 12px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
.su-pick { display: grid; gap: 14px; }
.su-hero { position: relative; height: 200px; border-radius: 26px; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(ellipse at 50% 72%, rgba(245, 196, 81, .22), transparent 60%), rgba(255, 255, 255, .06); border: 1px solid var(--line); }
.su-hero img { position: absolute; top: 3%; left: 50%; translate: -50% 0; height: 94%; width: auto; filter: drop-shadow(0 16px 22px rgba(0, 0, 0, .45)); }
.su-hero img.swap { animation: pop .3s both; }
.su-arrow { position: absolute; top: 50%; translate: 0 -50%; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .3); transition: background .2s; }
.su-arrow:hover { background: rgba(0, 0, 0, .5); }
.su-arrow svg { width: 20px; height: 20px; }
#charPrev { left: 12px; } #charNext { right: 12px; }
.charpick { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 8px; }
.charpick button { aspect-ratio: 1; width: 100%; padding: 0; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, .16), rgba(255, 255, 255, .04));
  border: 2px solid rgba(255, 255, 255, .1); transition: transform .15s, border-color .15s, box-shadow .15s; }
.charpick button:hover { border-color: rgba(245, 196, 81, .6); }
.charpick button[aria-checked='true'] { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 196, 81, .25); }
.charpick button:focus-visible, .su-card:focus-visible, .su-arrow:focus-visible, .su-back:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.charpick img { display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(1.35) translateY(9%); }
.namewrap { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; border-radius: 16px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); transition: border-color .2s; }
.namewrap:focus-within { border-color: var(--gold); }
.namewrap input { flex: 1; min-width: 0; width: 100%; background: none; border: 0; outline: 0; color: #fff; font: 600 18px 'Outfit', sans-serif; padding: 8px 0; }
.su-dice { flex: none; width: 44px; height: 44px; border-radius: 12px; background: rgba(255, 255, 255, .1); font-size: 20px; transition: transform .2s; }
.su-dice:active { transform: rotate(90deg) scale(.92); }
.su-cards { display: grid; gap: 10px; }
.su-card { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border-radius: 20px; text-align: left; background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
  transition: transform .12s, background .2s, border-color .2s; }
.su-card:hover { background: rgba(255, 255, 255, .1); border-color: rgba(245, 196, 81, .45); }
.su-card:active { transform: scale(.98); }
.su-card:disabled { opacity: .5; cursor: default; }
.su-card.hot { background: linear-gradient(180deg, rgba(245, 196, 81, .16), rgba(245, 196, 81, .05)); border-color: rgba(245, 196, 81, .55); }
.su-ic { flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #2a1c00; background: linear-gradient(180deg, #ffd774, #e9a923); }
.su-ic svg { width: 24px; height: 24px; }
.su-txt { display: grid; gap: 2px; min-width: 0; }
.su-txt b { font-size: 17px; font-weight: 700; }
.su-txt small { color: var(--muted); font-size: 13.5px; }
.su-go { margin-left: auto; color: var(--gold); font-weight: 800; font-size: 0; }
.su-go::after { content: '\203A'; font-size: 24px; }
.su-foot { display: grid; gap: 12px; justify-items: center; }
.su-code { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 6px; color: var(--muted); font-size: 14px; width: 100%; }
.su-code .link { padding: 4px 2px; color: var(--ink); text-decoration-color: var(--gold); }
#codeRow { display: none; width: 100%; max-width: 300px; }
.su-code.open #codeRow { display: flex; }
.su-code.open > span, .su-code.open #codeToggle { display: none; }
#codeRow input { flex: 1; min-width: 0; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: #fff; font: 700 20px 'Outfit', sans-serif; letter-spacing: 6px; text-align: center; outline: 0; }
#codeRow input:focus { border-color: var(--gold); }
/* an invite link: who invited you, who's already at the table, then you */
.su-invite, .su-me, .su-table, #inviteJoin, #inviteSkip { display: none; }
.su-invite { align-items: center; gap: 12px; padding: 12px 14px; border-radius: 20px; background: linear-gradient(180deg, rgba(245, 196, 81, .16), rgba(245, 196, 81, .05)); border: 1px solid rgba(245, 196, 81, .45); }
.su-invite b { display: block; font-size: 17px; }
.su-invite small, .su-me small { color: var(--muted); font-size: 13.5px; display: block; }
.su-face { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--gold); background: radial-gradient(circle at 50% 35%, #2a5a45, #12392a); overflow: hidden; }
.su-face img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.35) translateY(9%); display: block; }
.su-me { align-items: center; gap: 12px; padding: 10px 12px; border-radius: 18px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); }
.su-me b { font-size: 17px; }
.su-change { margin-left: auto; color: var(--gold); font-weight: 700; font-size: 14px; padding: 8px; }
.su-table { position: relative; height: 196px; margin: 32px 36px 60px; border-radius: 100px; background: radial-gradient(ellipse at 50% 42%, #24a063, #0e5532 75%);
  box-shadow: 0 24px 50px rgba(0, 0, 0, .4), inset 0 0 0 8px #3a1c13, inset 0 0 0 10px #d9b45a; }
.su-seat { position: absolute; translate: -50% -50%; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.su-seat i { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; font-style: normal; font-size: 20px; color: rgba(255, 255, 255, .7);
  border: 2px dashed rgba(255, 255, 255, .4); background: rgba(0, 0, 0, .25); }
.su-seat i img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.35) translateY(9%); }
.su-seat.taken i { border: 2px solid var(--gold); background: radial-gradient(circle at 50% 35%, #2a5a45, #12392a); }
.su-seat.host i { box-shadow: 0 0 0 4px rgba(245, 196, 81, .3); }
.su-seat.you i { width: 62px; height: 62px; border: 2px dashed var(--gold); }
.su-seat.you.taken i { border-style: solid; }
.su-seat small { font-size: 11.5px; font-weight: 700; background: rgba(0, 0, 0, .55); padding: 1px 9px; border-radius: 999px; white-space: nowrap; }
.su-mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 0 70px; }
.su-mid b, .su-mid small { display: block; }
.su-mid b { font-size: 16px; }
.su-mid small { color: var(--muted); font-size: 12.5px; }
.setup.invite .su-invite { display: flex; }
.setup.invite .su-table { display: block; }
.setup.invite #inviteJoin { display: flex; }
.setup.invite #inviteSkip { display: inline-flex; }
.setup.invite .su-head, .setup.invite .su-hero, .setup.invite .su-modes, .setup.invite .su-code { display: none; }
.setup.invite.known .su-name, .setup.invite.known .charpick { display: none; }
.setup.invite.known .su-me { display: flex; }

/* phones held upright: everything on one screen - a smaller preview, and the three ways to play as tiles in a row */
@media (max-width: 599px) {
  .setup { --gap: 16px; }
  .su-head h1 { font-size: 26px; }
  .su-head p { display: none; }
  /* the character preview takes whatever height is left, so the screen is filled on tall phones
     and everything still fits on short ones */
  .su-pick { flex: 1 1 auto; display: flex; flex-direction: column; }
  .su-hero { flex: 1 1 140px; height: auto; min-height: 110px; max-height: 380px; }
  .setup.invite .su-pick { flex: none; }
  .su-label { margin-bottom: 8px; }
  .su-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .su-card { flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 14px 6px; }
  .su-txt b { font-size: 14px; line-height: 1.2; }
  .su-txt small, .su-go { display: none; }
}
/* desktop: your character on the left, everything else on the right */
@media (min-width: 900px) and (min-height: 600px) {
  #home { place-items: center; }
  .setup { --gap: 24px; max-width: 1080px; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-areas: 'top top' 'pick side';
    column-gap: 56px; row-gap: 26px; align-items: center; padding: 28px 36px; }
  .su-top { grid-area: top; } .su-pick { grid-area: pick; } .su-side { grid-area: side; display: flex; flex-direction: column; gap: var(--gap); }
  .su-head h1 { font-size: 42px; }
  .su-hero { height: min(460px, 56vh); }
  .charpick { gap: 10px; }
  .su-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .su-card { flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px 16px 16px; min-height: 168px; }
  .su-go { margin: auto 0 0; font-size: 14px; }
  .su-go::after { content: ' \203A'; font-size: 14px; }
  .su-table { height: min(240px, 32vh); margin: 44px 44px 68px; border-radius: 160px; }
  .su-seat i { width: 60px; height: 60px; } .su-seat.you i { width: 74px; height: 74px; }
}
/* sideways phones: the same two columns, compact */
@media (orientation: landscape) and (max-height: 520px) {
  #home { place-items: center; }
  .setup { --gap: 12px; max-width: 900px; min-height: 0; display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); grid-template-areas: 'top top' 'pick side';
    column-gap: 28px; row-gap: 10px; align-items: center; padding: calc(8px + env(safe-area-inset-top)) max(28px, calc(env(safe-area-inset-right) + 12px)) 12px max(28px, calc(env(safe-area-inset-left) + 12px)); }
  .su-top { grid-area: top; } .su-pick { grid-area: pick; gap: 10px; } .su-side { grid-area: side; display: flex; flex-direction: column; gap: var(--gap); }
  .su-back { width: 34px; height: 34px; }
  .su-head h1 { font-size: 22px; }
  .su-head p, .su-label { display: none; }
  .su-hero { height: calc(100dvh - 140px); min-height: 120px; max-height: 260px; border-radius: 20px; }
  .charpick { gap: 6px; }
  .namewrap { padding: 4px 4px 4px 14px; }
  .namewrap input { font-size: 16px; padding: 6px 0; }
  .su-dice { width: 38px; height: 38px; font-size: 17px; }
  .su-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .su-card { flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; border-radius: 16px; }
  .su-ic { width: 36px; height: 36px; border-radius: 11px; } .su-ic svg { width: 19px; height: 19px; }
  .su-txt b { font-size: 14.5px; } .su-txt small { font-size: 12px; }
  .su-go { display: none; }
  .su-foot { gap: 6px; }
  .su-foot .links { display: none; }
  .su-table { height: min(150px, calc(100dvh - 210px)); margin: 30px 34px 50px; }
  .su-seat i { width: 42px; height: 42px; } .su-seat.you i { width: 50px; height: 50px; }
  .su-invite { padding: 8px 12px; } .su-invite .su-face { width: 38px; height: 38px; }
}

/* ---------- lobby ---------- */
.screen { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; overflow: auto; }
.panel { width: 100%; max-width: 400px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 24px 20px; background: rgba(6, 30, 20, .62); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); border: 1px solid rgba(255, 255, 255, .1); border-radius: 22px; box-shadow: 0 24px 60px rgba(0, 0, 0, .45); animation: pop .5s cubic-bezier(.2, .9, .3, 1.2) both; }
.brand { font-family: 'Playfair Display', serif; font-weight: 900; font-size: 38px; text-align: center; line-height: 1.05; letter-spacing: -.5px; }
/* online matchmaking lobby */
.match-head { display: grid; justify-items: center; gap: 6px; text-align: center; }
.match-head h3 { margin: 6px 0 0; font-family: 'Playfair Display', serif; font-size: 26px; }
.match-head p { margin: 0; color: var(--muted); font-size: 13px; }
.match-head p b { color: var(--gold); }
.radar { position: relative; width: 56px; height: 56px; }
.radar::before { content: '♠\FE0E'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 24px; color: var(--gold); }
.radar span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--gold); opacity: 0; animation: radar 2.4s ease-out infinite; }
.radar span:nth-child(2) { animation-delay: .8s; }
.radar span:nth-child(3) { animation-delay: 1.6s; }
@keyframes radar { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.join { display: flex; gap: 8px; }
.join .btn { flex: none; min-width: 88px; }
#code { flex: 1; min-width: 0; width: 100%; text-align: center; letter-spacing: .45em; text-indent: .45em; font-size: 22px; font-weight: 700; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); border-radius: 12px; color: #fff; padding: 10px; outline: 0; font-family: inherit; }
#code:focus { border-color: var(--gold); }
#code::placeholder { color: rgba(255, 255, 255, .2); }
.err { color: var(--bad); text-align: center; font-size: 13px; }
.err:empty { display: none; }
.err.info { color: var(--muted); }
.links { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.av { --c: var(--gold); position: relative; width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #1b1300; background: var(--c); background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--c) 60%, #fff), var(--c)); box-shadow: 0 2px 8px rgba(0, 0, 0, .4), inset 0 -2px 0 rgba(0, 0, 0, .15); }
.av.ghost { background: rgba(255, 255, 255, .06); border: 1px dashed rgba(255, 255, 255, .3); box-shadow: none; color: var(--muted); }

.lobby-head { text-align: center; display: grid; gap: 12px; }
.label { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.code-tiles { display: flex; justify-content: center; gap: 8px; perspective: 400px; }
.code-tiles span { width: 50px; height: 64px; display: grid; place-items: center; font-size: 36px; font-weight: 800; background: linear-gradient(180deg, #fff, #ece6d6); color: #0b3d27; border-radius: 10px; box-shadow: 0 4px 0 #b9b19c, 0 10px 20px rgba(0, 0, 0, .35); animation: flip .55s both; }
@keyframes flip { from { transform: rotateX(90deg); opacity: 0; } }
#seats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sbox { position: relative; display: grid; justify-items: center; gap: 6px; padding: 12px 8px; border-radius: 18px; background: rgba(255, 255, 255, .07); border: 1px solid var(--line); min-width: 0; }
.sbox.new { animation: pop .4s both; }
.sbox .pic { width: 84px; height: 84px; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 50% 35%, #2a5a45, #12392a); border: 2px solid rgba(255, 255, 255, .18); }
.sbox .pic img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.3) translateY(8%); display: block; }
.sbox.me { border-color: rgba(245, 196, 81, .6); background: linear-gradient(180deg, rgba(245, 196, 81, .14), rgba(245, 196, 81, .04)); }
.sbox.me .pic { border-color: var(--gold); }
.sbox b { font-size: 15px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sbox small { font-size: 11.5px; font-weight: 700; padding: 1px 9px; border-radius: 999px; background: rgba(0, 0, 0, .35); color: var(--muted); }
.sbox small.ok { color: #7ef0b0; }
.sbox small.you { color: var(--gold); }
.sbox .x { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; background: rgba(255, 255, 255, .1); font-size: 12px; }
.sbox .x:hover { background: rgba(255, 120, 130, .3); }
.sbox.empty { background: none; border-style: dashed; color: var(--muted); }
.sbox.empty .pic { border: 2px dashed rgba(255, 255, 255, .3); background: rgba(0, 0, 0, .18); display: grid; place-items: center; font-size: 30px; color: rgba(255, 255, 255, .45); animation: breathe 1.6s infinite; }
.sbox.empty b { font-weight: 600; font-size: 14px; }
.dots::after { content: '…'; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- table ---------- */
#table { position: fixed; inset: 0; z-index: 5; display: grid; grid-template-rows: auto 1fr auto auto; background: radial-gradient(ellipse 90% 70% at 50% 45%, #1f8052 0%, #11603c 45%, #083a24 85%, #052a1a 100%); }
#table::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .3; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
/* loading screen while the 3D table is built: fades out once it's ready (no fade in, so nothing flashes) */
#tload { position: absolute; inset: 0; z-index: 40; display: grid; place-content: center; justify-items: center; gap: 18px; opacity: 0; pointer-events: none; transition: opacity .4s;
  background: radial-gradient(120% 90% at 50% 40%, #145c3b 0%, #0a3a26 55%, #04190f 100%); }
#tload.on { opacity: 1; pointer-events: auto; transition: none; }
#tload p { margin: 0; color: rgba(255, 255, 255, .8); font-weight: 600; font-size: 15px; letter-spacing: .3px; }
/* a card flipping over and back, showing the next suit each time (it keeps moving even with the
   reduce-motion setting: a still loader looks frozen) */
.tl-flip { position: relative; width: 58px; height: 81px; perspective: 400px; }
.tl-flip i { position: absolute; inset: 0; transform-style: preserve-3d; animation: tlflip 1.5s ease-in-out infinite !important; animation-duration: 1.5s !important; animation-iteration-count: infinite !important; }
.tl-flip b { position: absolute; inset: 0; border-radius: 6px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-items: center; box-shadow: 0 6px 16px rgba(0, 0, 0, .45); }
.tl-flip .bk { border: 2px solid #fff; background: repeating-linear-gradient(45deg, rgba(255, 215, 120, .18) 0 3px, transparent 3px 7px), linear-gradient(160deg, #b01c35, #5e0c1c); }
.tl-flip .fr { background: #fff; color: #111; font: 400 38px/1 'Segoe UI Symbol', 'Noto Sans Symbols 2', system-ui, sans-serif; transform: rotateY(180deg); }
.tl-flip .fr.red { color: #d3233f; }
@keyframes tlflip { 0%, 12% { transform: rotateY(0); } 38%, 62% { transform: rotateY(180deg); } 88%, 100% { transform: rotateY(360deg); } }
/* played cards: flat DOM images drawn at their exact on-screen size each frame (table3d.js) */
.cards2d { position: absolute; inset: 0; overflow: hidden; pointer-events: none; display: none; }
body.three .cards2d { display: block; }
.c3d { position: absolute; left: 0; top: 0; transform-origin: 50% 50%; will-change: transform; border-radius: 6% / 4.3%; background: #fff;
  box-shadow: 0 0 0 1px rgba(40, 25, 10, .28), 3px 7px 12px rgba(30, 18, 5, .45), 1px 2px 3px rgba(30, 18, 5, .35); }
.c3d img { display: block; width: 100%; height: 100%; border-radius: inherit; }
body.three #stage { display: block; }
body.three #table { background: #4a443d; }
body.three #table::before, body.three .rim, body.three #trick { display: none; }

#bar { position: relative; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
body.three #bar { background: linear-gradient(180deg, rgba(0, 0, 0, .45), transparent); }
.chips { display: flex; gap: 6px; min-width: 0; }
.chip { padding: 5px 11px; border-radius: 999px; background: rgba(0, 0, 0, .35); font-size: 13px; font-weight: 600; border: 1px solid var(--line); white-space: nowrap; backdrop-filter: blur(6px); }
.chip.dim { color: var(--muted); font-weight: 500; }
.icons { display: flex; gap: 6px; }
.icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); backdrop-filter: blur(6px); transition: background .2s; }
.icon:hover { background: rgba(0, 0, 0, .5); }
.icon svg { width: 20px; height: 20px; }

#felt { position: relative; min-height: 0; z-index: 1; }
.rim { position: absolute; left: 6%; right: 6%; top: 4%; bottom: 4%; border-radius: 50%; border: 2px solid rgba(245, 196, 81, .14); box-shadow: inset 0 0 60px rgba(0, 0, 0, .35), 0 0 0 10px rgba(0, 0, 0, .08); pointer-events: none; }

/* seats */
.seat { position: absolute; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: opacity .3s; pointer-events: none; }
.seat.top { top: 6px; left: 50%; transform: translateX(-50%); }
.seat.left { left: max(8px, env(safe-area-inset-left)); top: 42%; transform: translateY(-50%); }
.seat.right { right: max(8px, env(safe-area-inset-right)); top: 42%; transform: translateY(-50%); }
.seat .av { width: clamp(36px, 8vmin, 50px); height: clamp(36px, 8vmin, 50px); font-size: clamp(15px, 3.4vmin, 20px); }
.seat .av em { position: absolute; right: -4px; bottom: -4px; width: 18px; height: 18px; border-radius: 50%; background: #fff; color: #0b3d27; font-size: 10px; font-style: normal; font-weight: 800; display: grid; place-items: center; box-shadow: 0 1px 3px #0008; }
.seat.turn .av::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 3px solid var(--gold); animation: ring 1.2s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(245, 196, 81, .6); } 100% { box-shadow: 0 0 0 12px rgba(245, 196, 81, 0); } }
.tag { display: flex; flex-direction: column; align-items: center; background: rgba(0, 0, 0, .45); border: 1px solid var(--line); border-radius: 10px; padding: 3px 9px; min-width: 80px; max-width: 120px; backdrop-filter: blur(6px); }
.tag b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.st { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pill { background: rgba(255, 255, 255, .14); color: #fff; border-radius: 999px; padding: 0 7px; font-weight: 700; }
.pill.made { background: rgba(95, 220, 143, .25); color: var(--good); }
.pill.think { display: inline-flex; gap: 2px; padding: 5px 7px; }
.pill.think i { width: 4px; height: 4px; border-radius: 50%; background: #fff; animation: dot 1s infinite; }
.pill.think i:nth-child(2) { animation-delay: .15s; }
.pill.think i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-2px); } }
.seat.off { opacity: .55; }
.seat.off .tag::after { content: 'offline'; font-size: 10px; color: var(--bad); }
.seat.off.auto .tag::after { content: 'left · auto-playing'; }
/* turn countdown (server-enforced 30s) */
.tag { position: relative; }
.tbar { position: absolute; left: 6px; right: 6px; bottom: 2px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.tbar::after { content: ''; position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--p, 1)); background: var(--gold); transition: transform .2s linear; }
#msg.urgent span { background: linear-gradient(180deg, #ff6b6b, #d6283f); color: #fff; }
#bidsheet.urgent { border-color: #ff6b6b; box-shadow: 0 0 0 3px rgba(255, 107, 107, .3), 0 20px 50px rgba(0, 0, 0, .5); }
#bidsheet [data-left] { color: #fff; font-weight: 700; }
.fan { display: flex; height: calc(var(--cw) * .42); }
.fan i { width: calc(var(--cw) * .3); height: calc(var(--cw) * .42); border-radius: 3px; margin-left: calc(var(--cw) * -.22); border: 1px solid rgba(255, 255, 255, .6); box-shadow: 0 1px 2px #0007; background: repeating-linear-gradient(45deg, rgba(255, 215, 120, .18) 0 2px, transparent 2px 5px), linear-gradient(160deg, #b01c35, #5e0c1c); }
.fan i:first-child { margin-left: 0; }
.seat.flash .av { animation: flash .7s; }
@keyframes flash { 30% { transform: scale(1.18); box-shadow: 0 0 0 6px rgba(245, 196, 81, .5), 0 0 30px rgba(245, 196, 81, .8); } }

/* 3D mode: seat labels float above each player's head */
body.three .seat:not(.me) { position: fixed; transform: translate(-50%, -100%); flex-direction: row; gap: 6px; width: max-content; white-space: nowrap; }
body.three .seat:not(.me) .fan { display: none; }
body.three .seat:not(.me) { z-index: 20; } /* name tags stay readable over cards thrown past them */
body.three .seat:not(.me) .av { width: 32px; height: 32px; font-size: 14px; }
body.three .seat:not(.me) .tag { min-width: 0; }

.seat.me { position: relative; z-index: 3; flex-direction: row; justify-content: center; gap: 10px; padding: 4px 12px; transform: none; }
.seat.me .av { width: 34px; height: 34px; font-size: 15px; }
.seat.me .tag { flex-direction: row; gap: 8px; max-width: none; padding: 5px 12px; }
.seat.me.turn .tag { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 196, 81, .2); }
/* 3D: your name tag sits in the bottom-right corner so it never covers the card you just played */
body.three .seat.me { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: calc(var(--hw) * 1.4 + 38px + env(safe-area-inset-bottom)); padding: 0; z-index: 4; }

/* trick (2D fallback) */
#trick { position: absolute; left: 50%; top: 46%; width: calc(var(--cw) * 3.3); height: calc(var(--cw) * 1.4 * 2.05); transform: translate(-50%, -50%); z-index: 1; }
#trick .card { position: absolute; }
#trick .t0 { bottom: 0; left: calc(50% - var(--cw) / 2); }
#trick .t2 { top: 0; left: calc(50% - var(--cw) / 2); }
#trick .t1 { right: 0; top: calc(50% - var(--cw) * .7); }
#trick .t3 { left: 0; top: calc(50% - var(--cw) * .7); }
#trick .card.win { box-shadow: 0 0 0 3px var(--gold), 0 0 24px rgba(245, 196, 81, .8); z-index: 5; }

#msg { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-weight: 600; font-size: 15px; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); pointer-events: none; z-index: 2; padding: 0 12px; }
#msg span { display: inline-block; padding: 5px 14px; border-radius: 999px; background: rgba(0, 0, 0, .4); backdrop-filter: blur(6px); }
#msg.you span { color: #2a1c00; background: linear-gradient(180deg, #ffd774, #e9a923); text-shadow: none; animation: breathe 1.6s infinite; }
@keyframes breathe { 50% { transform: scale(1.05); } }
#msg:empty { display: none; }
/* 3D: keep the status pill off the middle of the mat, where your card lands */
body.three #msg { left: max(12px, env(safe-area-inset-left)); right: auto; bottom: 14px; text-align: left; padding: 0; max-width: 55%; }

/* cards */
.card { --w: var(--cw); position: relative; width: var(--w); height: calc(var(--w) * 1.4); flex: none; border-radius: calc(var(--w) * .09); color: #17191e; font-size: calc(var(--w) * .26); font-weight: 700; line-height: 1; overflow: hidden;
  background: radial-gradient(120% 90% at 30% 10%, #ffffff 0%, #fbf8f1 55%, #f1ecdf 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1), inset 0 0 0 calc(var(--w) * .035) #fff, 0 1px 1px rgba(0, 0, 0, .25), 0 4px 10px rgba(0, 0, 0, .35); }
.card.red { color: #cc1f3a; }
/* corner index */
.card .ci { position: absolute; left: .16em; top: .2em; display: flex; flex-direction: column; align-items: center; width: 1em; z-index: 1; }
.card .ci b { font-size: .95em; font-weight: 800; letter-spacing: -.08em; }
.card .ci i { font-style: normal; font-size: .74em; margin-top: .08em; }
.card .ci.br { left: auto; top: auto; right: .16em; bottom: .2em; transform: rotate(180deg); }
/* number cards: real pip layout inside the index margins */
.card .pips { position: absolute; inset: 0; }
.card .pips i { position: absolute; font-style: normal; font-size: .92em; line-height: 1; transform: translate(-50%, -50%); }
.card .pips i.dn { transform: translate(-50%, -50%) rotate(180deg); }
/* ace: one large ornamental pip */
.card .cc { position: absolute; inset: 0; display: grid; place-items: center; }
.card.ace .cc { font-size: 3em; }
.card.ace .cc::before { content: ''; position: absolute; width: 1.15em; height: 1.15em; border-radius: 50%; border: .02em solid currentColor; opacity: .25; }
/* face cards: framed portrait panel with an emblem */
.card.face .fp { position: absolute; left: 22%; right: 22%; top: 13%; bottom: 13%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .04em; border-radius: .14em;
  border: .05em solid currentColor; box-shadow: inset 0 0 0 .08em #fff, inset 0 0 0 .11em currentColor;
  background: linear-gradient(180deg, color-mix(in srgb, currentColor 14%, #fff), color-mix(in srgb, currentColor 5%, #fff) 50%, color-mix(in srgb, currentColor 14%, #fff)); }
.card.face .fp b { font-family: 'Playfair Display', serif; font-weight: 900; font-size: 1.8em; line-height: .9; }
/* standard deck art covers the CSS fallback face once it loads */
.card .art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.card:has(.art) { background: #fff; }
.card.face .fp i { font-style: normal; font-size: .75em; line-height: 1; }

#hand { --hide: 0; position: relative; z-index: 3; height: calc(var(--hw) * 1.4 * (1 - var(--hide)) + 30px + env(safe-area-inset-bottom)); }
#hand .card { --w: var(--hw); --lift: 0px; position: absolute; left: 0; top: 0; z-index: 1; will-change: transform; transition: transform .2s cubic-bezier(.2, .8, .2, 1), opacity .2s; box-shadow: -4px 0 10px rgba(0, 0, 0, .22), 0 6px 16px rgba(0, 0, 0, .4); }
#hand .card.ok { cursor: pointer; --lift: -14px; }
#hand .card.ok::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 2px rgba(245, 196, 81, .9); }
@media (hover: hover) { #hand .card.ok:hover { --lift: -30px; } }
/* unplayable cards: a dark veil that fades (opacity is cheap to animate; a filter repainted every card) */
#hand .card::before { content: ''; position: absolute; inset: 0; z-index: 3; border-radius: inherit; background: rgba(8, 22, 15, .42); opacity: 0; transition: opacity .2s; pointer-events: none; }
#hand .card.no::before { opacity: 1; }
#hand .card.ok { touch-action: none; } /* a drag moves the card, not the page */
#hand.dragging { z-index: 30; }
#hand.await .card { opacity: 0; } /* the round's deal is waiting for the 3D table */
#hand .card.dragging { transition: none; z-index: 60 !important; box-shadow: 0 18px 30px rgba(0, 0, 0, .5); cursor: grabbing; }
#hand .card.played { --lift: -70px; opacity: 0; transition: transform .18s, opacity .18s; }
body.three #hand::before { content: ''; position: absolute; inset: -30px 0 0; background: linear-gradient(0deg, rgba(0, 0, 0, .55), transparent); pointer-events: none; }

/* bid sheet */
#bidsheet { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); width: min(640px, calc(100% - 24px)); z-index: 4; padding: 14px; border-radius: 18px; background: rgba(5, 26, 17, .85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(245, 196, 81, .4); box-shadow: 0 20px 50px rgba(0, 0, 0, .5); animation: pop .35s both; text-align: center; }
body.three #bidsheet { bottom: 54px; z-index: 25; }
#bidsheet h3 { margin: 0 0 2px; font-family: 'Playfair Display', serif; font-size: 22px; }
#bidsheet p { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
#bidsheet p b { color: var(--gold); }
/* desktop: all 13 calls in one row; phones: two compact rows (see the media queries below) */
.bids { display: grid; grid-template-columns: repeat(13, 1fr); gap: 6px; }
@media (max-width: 600px) { .bids { grid-template-columns: repeat(7, 1fr); } #bidsheet { width: min(440px, calc(100% - 24px)); } }
.bids button { aspect-ratio: 1; max-height: 52px; border-radius: 10px; background: rgba(255, 255, 255, .1); border: 1px solid var(--line); font-weight: 700; font-size: 17px; transition: background .15s, transform .1s; }
.bids button:hover { background: rgba(255, 255, 255, .2); }
.bids button:active { transform: scale(.92); }
.bids button.sug { background: linear-gradient(180deg, #ffd774, #e9a923); color: #2a1c00; border: 0; }

/* floating fx: call bubbles */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 15; }
.bubble { position: absolute; transform: translate(-50%, -100%); background: #fff; color: #0b3d27; font-weight: 800; padding: 6px 12px; border-radius: 12px; white-space: nowrap; box-shadow: 0 6px 16px rgba(0, 0, 0, .4); animation: bub 2s both; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }
@keyframes bub { 0% { opacity: 0; transform: translate(-50%, -70%) scale(.6); } 12% { opacity: 1; transform: translate(-50%, -100%) scale(1.06); } 20% { transform: translate(-50%, -100%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -125%); } }

/* ---------- modals ---------- */
#overlay { position: fixed; inset: 0; z-index: 12; display: grid; place-items: center; padding: 16px; background: rgba(2, 14, 9, .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .25s both; }
#box { width: 100%; max-width: 480px; max-height: min(88vh, 760px); overflow: auto; background: linear-gradient(180deg, #134430, #0a2c1d); border: 1px solid rgba(255, 255, 255, .12); border-radius: 22px; padding: 20px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: pop .4s cubic-bezier(.2, .9, .3, 1.2) both; display: grid; gap: 14px; user-select: text; }
#box h2 { margin: 0; text-align: center; font-family: 'Playfair Display', serif; font-size: 26px; line-height: 1.15; }
#box p { margin: 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.note { text-align: center; font-size: 12px; color: var(--muted); }
.trophy { font-size: 56px; text-align: center; line-height: 1; animation: bounce 1s .2s both; }
@keyframes bounce { 0% { transform: scale(0) rotate(-20deg); } 60% { transform: scale(1.2) rotate(8deg); } 100% { transform: none; } }
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sum { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); animation: pop .4s both; min-width: 0; }
.sum .av { width: 30px; height: 30px; font-size: 13px; }
.sum div:nth-child(2) { flex: 1; min-width: 0; }
.sum b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum small { color: var(--muted); font-size: 11px; }
.sum .delta { font-weight: 800; font-variant-numeric: tabular-nums; }
.sum.ok .delta { color: var(--good); }
.sum.bad .delta { color: var(--bad); }
@media (max-width: 360px) { .summary { grid-template-columns: 1fr; } }
.tablewrap { overflow-x: auto; }
table.sc { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.sc th, .sc td { padding: 6px 5px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sc th { font-size: 12px; color: var(--muted); font-weight: 600; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
.sc th:first-child, .sc td:first-child { text-align: left; color: var(--muted); }
.sc td small { display: block; font-size: 10px; color: var(--muted); }
.sc .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.sc tfoot td { font-weight: 800; border: 0; font-size: 15px; color: #fff; }
.sc .neg { color: var(--bad) !important; }
.sc .lead { color: var(--gold) !important; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); animation: pop .45s both; }
.rank li.gold { background: linear-gradient(90deg, rgba(245, 196, 81, .25), rgba(245, 196, 81, .05)); border-color: rgba(245, 196, 81, .5); }
.rank .pos { width: 28px; text-align: center; font-size: 20px; font-weight: 800; color: var(--muted); }
.rank b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .tot { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; text-align: center; margin-bottom: 8px; }
.rules { font-size: 14px; line-height: 1.55; display: grid; gap: 10px; }
.rules ol { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.menu { display: grid; gap: 8px; }

/* toasts + connection */
#toasts { position: fixed; top: calc(64px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 30; display: grid; gap: 6px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100% - 32px); }
.toast { padding: 9px 16px; border-radius: 12px; background: rgba(10, 30, 20, .94); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); font-size: 14px; animation: pop .3s both; text-align: center; }
.toast.err { background: #8e1529; border-color: rgba(255, 107, 127, .35); }
/* Phones: no live background blur. Over an animating WebGL canvas the blur is recomputed every
   frame, which makes phone animations stutter; slightly more opaque backgrounds stand in for it. */
body.lite * { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
body.lite .panel { background: rgba(6, 30, 20, .88); }
body.lite .chip, body.lite .icon, body.lite .tag, body.lite #msg:not(.you) span { background: rgba(0, 0, 0, .55); }
body.lite #bidsheet { background: rgba(5, 26, 17, .95); }
/* stays up until tapped: shows why the 3D table isn't available on this device */
#diag { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40; padding: 10px 14px; border-radius: 12px; background: #8e1529; color: #fff; font-size: 12px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.toast.out { transition: opacity .3s, transform .3s; opacity: 0; transform: translateY(-8px); }
#conn { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 31; padding: 9px 16px; border-radius: 999px; background: rgba(0, 0, 0, .8); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .3); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* rotate-your-phone gate (phones, in game, portrait) */
#rotate { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; background: radial-gradient(120% 90% at 50% 40%, #145c3b 0%, #0a3a26 55%, #04190f 100%); }
#rotate h2 { margin: 8px 0 0; font-family: 'Playfair Display', serif; font-size: 28px; }
#rotate p { margin: 0; color: var(--muted); max-width: 300px; }
.phone { width: 64px; height: 110px; border: 4px solid #fff; border-radius: 14px; display: grid; place-items: center; animation: turn 2.2s ease-in-out infinite; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.screen-in { color: var(--gold); font-size: 30px; }
@keyframes turn { 0%, 20% { transform: rotate(0); } 50%, 80% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
/* Narrow screens held upright (3D; phones get the rotate screen instead): name badges around the felt table, the side ones stacked upright;
   your badge and a small status pill share one row just above your hand. */
body.three .seat.v { flex-direction: column; gap: 3px; }
@media (orientation: portrait) and (max-width: 600px) {
  body.three .seat:not(.me) .av { width: 26px; height: 26px; font-size: 12px; }
  body.three .seat.me { bottom: calc(var(--hw) * 1.4 + 34px + env(safe-area-inset-bottom)); }
  body.three .seat.me .av { width: 28px; height: 28px; font-size: 13px; }
  body.three .seat.me .tag { padding: 3px 9px; }
  body.three #msg { bottom: calc(var(--hw) * 1.4 + 40px + env(safe-area-inset-bottom)); font-size: 12px; }
  body.three #msg span { padding: 3px 10px; }
}
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 25; display: none; }

/* short landscape phones */
@media (max-height: 520px) and (orientation: landscape) {
  /* phones in landscape: hold the hand partly below the screen edge to give the mat more room */
  #hand { --hide: .2; }
  /* 3D: your badge in the bottom-left corner beside your hand, a small status pill above it */
  body.three .seat.me { left: max(28px, calc(env(safe-area-inset-left) + 12px)); right: auto; bottom: 14px; }
  body.three .seat.me .av { width: 26px; height: 26px; font-size: 12px; }
  body.three .seat.me .tag { padding: 2px 8px; }
  body.three .seat:not(.me) .av { width: 26px; height: 26px; font-size: 12px; }
  body.three #msg { left: max(28px, calc(env(safe-area-inset-left) + 12px)); bottom: 54px; font-size: 11.5px; }
  body.three #msg span { padding: 2px 10px; }
  /* keep the corner buttons clear of the phone's rounded screen corners */
  #bar { padding: calc(10px + env(safe-area-inset-top)) max(28px, calc(env(safe-area-inset-right) + 12px)) 4px max(28px, calc(env(safe-area-inset-left) + 12px)); }
  .icon { width: 34px; height: 34px; }
  .seat.top { flex-direction: row; top: 2px; }
  .seat.top .fan { display: none; }
  .seat .av { width: 32px; height: 32px; }
  #trick { top: 56%; height: calc(var(--cw) * 1.4 * 1.75); }
  .seat.left, .seat.right { top: 50%; }
  .seat.me { padding: 0 12px; }
  /* a compact call sheet that fits between the side players' name tags */
  .bids { grid-template-columns: repeat(7, 1fr); gap: 5px; }
  .bids button { max-height: 36px; font-size: 15px; border-radius: 8px; }
  #bidsheet { width: min(340px, calc(100% - 340px)); min-width: 280px; padding: 8px 10px; border-radius: 14px; }
  #bidsheet h3 { font-size: 16px; }
  #bidsheet p { margin-bottom: 5px; font-size: 11.5px; }
}

/* Sideways phones, 3D: the mat layout. Big cards across the screen, opponents' name tags beside
   their chibis (name, countdown, won/called), your badge over the middle of your hand, the call sheet
   on the mat. No status line: whose turn it is shows on the name tags and your badge. */
@media (max-height: 520px) and (orientation: landscape) {
  body.three { --hw: clamp(56px, min(13vw, 27vh), 120px); }
  @supports (height: 1dvh) { body.three { --hw: clamp(56px, min(13vw, 27dvh), 120px); } }
  body.three #hand { --hide: .28; --hpad: 30px; }
  body.three #hand::before { display: none; }
  body.three #msg { display: none; }
  body.three .seat:not(.me) .av { display: none; }
  body.three .seat:not(.me) .tag, body.lite.three .seat:not(.me) .tag { background: none; border: 0; padding: 0; gap: 2px; backdrop-filter: none; -webkit-backdrop-filter: none; }
  body.three .seat:not(.me) .tag b { background: rgba(0, 0, 0, .62); border: 1px solid rgba(255, 255, 255, .16); border-radius: 999px; padding: 1px 10px; font-size: 11.5px; line-height: 1.35; }
  body.three .seat.turn:not(.me) .tag b { background: linear-gradient(180deg, #ffd774, #e9a923); color: #2a1c00; border-color: transparent; box-shadow: 0 0 0 3px rgba(245, 196, 81, .25), 0 0 14px rgba(245, 196, 81, .55); }
  body.three .seat:not(.me) .tbar { position: relative; left: auto; right: auto; bottom: auto; width: 100%; order: 1; background: rgba(0, 0, 0, .5); }
  body.three .seat:not(.me) .st { order: 2; }
  body.three .seat:not(.me) .st > span:not(.pill) { display: none; }
  body.three .seat:not(.me) .st .pill { background: rgba(0, 0, 0, .62); color: var(--gold); font-size: 11px; font-weight: 800; padding: 0 9px; }
  body.three .seat:not(.me) .st .pill.made { color: var(--good); }
  body.three .seat:not(.me) .st .pill.think { padding: 5px 9px; }
  body.three .seat.me { left: 50%; right: auto; bottom: calc(6px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6; }
  body.three .seat.me > .av, body.three .seat.me > .tag { display: none; }
  body.three .seat.me .mebadge { display: flex; }
  body.three #bidsheet { position: fixed; left: 0; right: 0; top: 76px; bottom: calc(var(--hw) * 1.4 * .72 + 30px); margin: auto; height: fit-content; transform: none;
    width: min(330px, 44vw); min-width: 0; padding: 10px 12px 12px; border-radius: 16px; z-index: 25;
    background: linear-gradient(180deg, rgba(44, 22, 12, .92), rgba(26, 12, 6, .94)); border-color: rgba(245, 196, 81, .35); }
  body.three #bidsheet h3 { font-size: 16px; color: var(--gold); }
  body.three #bidsheet p { margin-bottom: 8px; color: #e9dcc4; }
  body.three .bids button { max-height: 32px; }
}
/* your badge (sideways phones): who's playing, your character, your won/called */
.mebadge { display: none; align-items: center; pointer-events: none; }
.mebadge .face { width: 40px; height: 40px; border-radius: 50%; background: #2b2b2b center / cover; border: 2.5px solid var(--gold); box-shadow: 0 3px 10px rgba(0, 0, 0, .5); position: relative; z-index: 2; flex: none; }
.mebadge .l, .mebadge .r { background: rgba(0, 0, 0, .7); height: 26px; display: flex; align-items: center; font-weight: 800; font-size: 12px; white-space: nowrap; }
.mebadge .l { border-radius: 999px 0 0 999px; padding: 0 16px 0 12px; margin-right: -10px; }
.mebadge .r { border-radius: 0 999px 999px 0; padding: 0 12px 0 16px; margin-left: -10px; color: var(--gold); }
.mebadge.go .l { background: linear-gradient(180deg, #ffd774, #e9a923); color: #2a1c00; }
.mebadge.go .l b { font-weight: 800; }
.seat.me.urgent .mebadge.go .l { background: linear-gradient(180deg, #ff6b6b, #d6283f); color: #fff; }
/* Safari: size the table to the visible screen, not the one behind its toolbars */
@supports (height: 100dvh) { #table { bottom: auto; height: 100dvh; } }

/* Sideways phones: the home panel, lobby and results go side by side instead of one tall column
   that doesn't fit the short screen. */
@media (max-height: 520px) and (orientation: landscape) {
  .screen { padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); }
  .panel { max-width: 760px; padding: 16px 20px; gap: 10px; }

  /* lobby + finding players: header and buttons on the left, the four seats (2 x 2) on the right */
  #lobby .panel { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); column-gap: 22px;
    grid-template-areas: 'head seats' 'start seats' 'leave bots'; align-items: center; }
  #lobby #matchHead, #lobby .lobby-head { grid-area: head; }
  #lobby #seats { grid-area: seats; }
  #lobby .sbox { padding: 8px 6px; gap: 4px; }
  #lobby .sbox .pic { width: 58px; height: 58px; }
  #lobby #botRow { grid-area: bots; }
  #lobby #start { grid-area: start; }
  #lobby #leave { grid-area: leave; justify-self: center; }
  .code-tiles span { width: 40px; height: 52px; font-size: 28px; }
  .match-head h3 { font-size: 22px; }

  /* results: the summary / ranking on the left, the score table on the right */
  #box { max-height: calc(100vh - 20px); padding: 16px 18px; gap: 10px; }
  #box[data-kind='round'], #box[data-kind='over'] { max-width: 820px; column-gap: 20px; align-items: start; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
  #box[data-kind='round'] { grid-template-areas: 'title table' 'sum table' 'go table' 'note table'; }
  #box[data-kind='round'] h2 { grid-area: title; }
  #box[data-kind='round'] .summary { grid-area: sum; grid-template-columns: 1fr; gap: 6px; }
  #box[data-kind='round'] .sum { padding: 6px 10px; }
  #box[data-kind='round'] .sum div:nth-child(2) { display: flex; align-items: baseline; gap: 10px; }
  #box[data-kind='round'] .tablewrap { grid-area: table; align-self: center; }
  #box[data-kind='round'] [data-act] { grid-area: go; }
  #box[data-kind='round'] .note { grid-area: note; }
  #box[data-kind='over'] { grid-template-areas: 'trophy rank' 'title rank' 'go rank' 'leave details'; align-content: center; }
  #box[data-kind='over'] .trophy { grid-area: trophy; font-size: 44px; align-self: end; }
  #box[data-kind='over'] h2 { grid-area: title; }
  #box[data-kind='over'] .rank { grid-area: rank; gap: 6px; }
  #box[data-kind='over'] .rank li { padding: 5px 10px; }
  #box[data-kind='over'] .rank .av { width: 30px; height: 30px; font-size: 13px; }
  #box[data-kind='over'] .rank .pos { font-size: 17px; }
  #box[data-kind='over'] .rank .tot { font-size: 16px; }
  #box[data-kind='over'] details { grid-area: details; }
  #box[data-kind='over'] [data-act] { grid-area: go; }
  #box[data-kind='over'] [data-leave] { grid-area: leave; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
