:root {
  --kayal: #0E3B43;        /* backwater night */
  --kayal-deep: #082A30;
  --pai: #C9A063;          /* palm mat */
  --pai-dark: #8A6531;
  --ivory: #FBF6E9;
  --kasavu: #C8962E;       /* gold border of a kasavu mundu */
  --kumkum: #A3232F;
  --ink: #1E1A14;
  --mist: #CFE3E2;
  --teamA: #D9A93A;
  --teamB: #C2394A;
  --cw: clamp(46px, 7.2vw, 78px);
  --radius-card: 7px;
  --rail: 300px;
  font-family: 'Manjari', system-ui, sans-serif;
  color: var(--mist);
  background: radial-gradient(120% 90% at 50% 40%, #13505A 0%, var(--kayal) 45%, var(--kayal-deep) 100%);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--teamA); outline-offset: 2px; }

/* ---------------------------------------------------------- buttons */
.btn {
  border: 1px solid rgba(207,227,226,.35); background: rgba(8,42,48,.7); color: var(--mist);
  padding: .7em 1.2em .55em; border-radius: 999px; cursor: pointer; font-weight: 700; letter-spacing: .01em;
}
.btn:hover { border-color: var(--mist); }
.btn.primary { background: var(--kasavu); color: var(--ink); border-color: var(--kasavu); }
.btn.primary:hover { background: #DDAA3F; }
.btn.warn { border-color: rgba(194,57,74,.7); }
.btn.ghost { background: transparent; }
.btn.small { padding: .45em .9em .3em; font-size: .9rem; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

/* ---------------------------------------------------------- lobby */
.screen { height: 100dvh; }
#lobby { display: grid; place-items: center; padding: 24px; overflow: auto; }
.lobby-card { width: min(460px, 100%); display: grid; gap: 18px; }
.wordmark { margin: 0; display: flex; align-items: baseline; gap: 14px; line-height: 1; }
.wordmark .num {
  font-size: clamp(110px, 26vw, 168px); font-weight: 700; color: var(--pai);
  text-shadow: 0 0 0 transparent; letter-spacing: -.04em;
  background: repeating-linear-gradient(90deg, var(--pai) 0 6px, #B88D50 6px 8px);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.wordmark .ml { font-size: clamp(20px, 5vw, 28px); font-weight: 400; color: var(--kasavu); }
.lede { margin: 0; font-size: 1.08rem; line-height: 1.55; max-width: 38ch; }
.field { display: grid; gap: 6px; font-size: .92rem; }
.field input {
  background: rgba(8,42,48,.8); color: var(--ivory); border: 1px solid rgba(207,227,226,.3);
  border-radius: 10px; padding: .8em .9em .65em; font-size: 1.05rem;
}
.field input:focus { border-color: var(--kasavu); outline: none; }
.join-row { display: flex; gap: 10px; align-items: end; }
.hint { margin: 4px 0 -8px; font-size: .95rem; line-height: 1.5; color: var(--pai); }
.grow { flex: 1; }
#codeInput { text-transform: uppercase; letter-spacing: .2em; }
.howto { margin: 0; padding-left: 1.3em; line-height: 1.55; font-size: .95rem; color: var(--pai); }
.howto li { margin: .25em 0; }
.rules { border-top: 1px solid rgba(207,227,226,.18); padding-top: 12px; }
.rules summary { cursor: pointer; color: var(--pai); font-weight: 700; }
.rules ul { padding-left: 1.1em; line-height: 1.55; font-size: .95rem; max-width: 62ch; }
.rules li { margin: .35em 0; }

/* ---------------------------------------------------------- table layout */
#table {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail);
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas: "top rail" "arena rail" "bid rail" "hand rail";
}
.topbar { grid-area: top; display: flex; gap: 10px; align-items: center; padding: 10px 14px; flex-wrap: wrap; }
.chip {
  border: 1px solid rgba(207,227,226,.25); background: rgba(8,42,48,.6); color: var(--mist);
  border-radius: 999px; padding: .45em .9em .3em; font-size: .92rem; cursor: default;
}
.chip.code { cursor: pointer; }
.chip.code b { letter-spacing: .14em; color: var(--ivory); }
.chip.code.fixed b { letter-spacing: 0; }
.chip.code.fixed .pre { display: none; }
.chip.contract .stake { font-weight: 400; opacity: .75; margin-left: 6px; }
.chip.contract .suit.red { color: #c4161c; }
.chip.contract { background: var(--ivory); color: var(--ink); border-color: var(--kasavu); font-weight: 700; }
.chip.icon { display: none; cursor: pointer; margin-left: auto; }
.chip.full { cursor: pointer; padding: .3em .65em .2em; font-size: 1rem; line-height: 1; }
.rail-close { display: none; }
.chip.watch { cursor: pointer; opacity: .8; }
.chip.watch:hover { opacity: 1; border-color: var(--mist); }
.chip.watch .eye { font-size: .95em; margin-right: 2px; }
.scores { display: flex; gap: 8px; margin-left: auto; }
.team-score { display: flex; gap: 8px; align-items: baseline; padding: .4em .8em .25em; border-radius: 10px; background: rgba(8,42,48,.6); border-left: 4px solid; }
.team-score.t0 { border-color: var(--teamA); }
.team-score.t1 { border-color: var(--teamB); }
.team-score .tname { font-weight: 700; font-size: .9rem; }
.team-score .tables { font-size: 1.15rem; font-weight: 700; color: var(--ivory); }
.team-score .hpts { font-size: .85rem; opacity: .8; }

.arena { grid-area: arena; position: relative; min-height: 0; margin: 4px 70px 10px; }
.mat {
  position: absolute; inset: 9% 6% 9%;
  border-radius: 50%;
  background:
    repeating-linear-gradient(90deg, rgba(110,72,26,.22) 0 2px, transparent 2px 13px),
    repeating-linear-gradient(0deg, rgba(255,238,196,.16) 0 6px, rgba(110,72,26,.12) 6px 12px),
    radial-gradient(ellipse at 50% 45%, #D6AE6F 0%, var(--pai) 55%, #B58A4E 100%);
  box-shadow:
    inset 0 0 0 7px #7A2026, inset 0 0 0 10px var(--kasavu), inset 0 0 0 14px #7A2026,
    inset 0 0 60px rgba(60,35,10,.45), 0 24px 60px rgba(0,0,0,.45);
}
.center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  text-align: center; color: var(--ink); width: min(70%, 420px);
}
.center .big { font-size: clamp(26px, 4vw, 40px); font-weight: 700; line-height: 1.1; }
.center .sub { font-size: .98rem; margin-top: 6px; }
.center .btn { margin-top: 14px; }
.center .bidval { font-size: clamp(36px, 5.5vw, 60px); font-weight: 700; line-height: 1; }
.center .bidval.pulse { animation: bidpulse .3s ease-out; }
@keyframes bidpulse { 0% { transform: scale(.92); opacity: .4; } 100% { transform: none; opacity: 1; } }
.mat-info { position: absolute; left: 50%; top: 13%; transform: translateX(-50%); display: flex; gap: 14px; color: var(--ink); font-size: .95rem; opacity: .8; white-space: nowrap; }
.mat-info .suit { font-size: 1.2em; } .mat-info .suit.red { color: #c4161c; }
.center .bidval .suit { font-size: .95em; }
.center .bidval .sname { font-size: .45em; font-weight: 600; vertical-align: middle; }
.center .bidval .suit.red { color: #c4161c; }
.center .bidval .suit.black { color: #111; }
.center .sub.wait { margin-top: 14px; }
.center .dbl { background: var(--kumkum); color: var(--ivory); border-radius: 999px; padding: 0 8px; font-weight: 700; font-size: .85rem; margin-left: 4px; }
.center .who { font-weight: 700; padding: 0 5px; border-radius: 6px; }
.center .who.t0 { color: #7a5200; background: rgba(217,169,58,.35); }
.center .who.t1 { color: #7a1420; background: rgba(194,57,74,.30); }

/* seats */
#seats { position: absolute; inset: 0; pointer-events: none; }
.seat {
  position: absolute; transform: translate(calc(-50% + var(--nudge, 0px)), -50%); pointer-events: auto;
  min-width: 128px; padding: 8px 12px 6px; border-radius: 14px;
  background: rgba(8,42,48,.92); border: 2px solid transparent; text-align: center;
  transition: border-color .2s, box-shadow .2s;
}
.seat.t0 { border-color: var(--teamA); background: linear-gradient(rgba(217,169,58,.28), rgba(217,169,58,.28)), rgba(8,42,48,.94); }
.seat.t1 { border-color: var(--teamB); background: linear-gradient(rgba(194,57,74,.30), rgba(194,57,74,.30)), rgba(8,42,48,.94); }
.seat.t0 .nm { color: #F3D27A; }
.seat.t1 .nm { color: #F5A3AD; }
.seat.turn { box-shadow: 0 0 0 4px rgba(251,246,233,.85), 0 0 28px rgba(251,246,233,.5); }
.seat .toks { position: absolute; left: 8px; top: -9px; display: flex; gap: 4px; }
.seat .tok { background: var(--ivory); color: var(--ink); border-radius: 999px; padding: 1px 7px 0; font-weight: 700; font-size: .68rem; line-height: 1.3; }
.seat .cnt { position: absolute; right: 8px; top: 4px; font-size: .72rem; font-weight: 700; opacity: .65; }
.seat.away { opacity: .55; }
.seat.ingame:not(.empty) .seat-actions { display: none; }
.seat.ingame:not(.empty):hover .seat-actions, .seat.ingame:not(.empty):focus-within .seat-actions { display: flex; }
@media (hover: none) { .seat.ingame:not(.empty) .seat-actions { display: none; } .seat.ingame:not(.empty).open .seat-actions { display: flex; } }
.seat .nm { font-weight: 700; color: var(--ivory); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.seat .meta { font-size: .78rem; opacity: .7; white-space: nowrap; }
.seat .said {
  position: absolute; left: 50%; top: -12px; transform: translate(-50%, -100%);
  background: var(--ivory); color: var(--ink); border-radius: 10px; padding: 4px 10px 2px; font-weight: 700; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.seat .said.red { color: var(--kumkum); }
.seat.top .said { top: auto; bottom: -12px; transform: translate(-50%, 100%); }
.seat.left .said { left: auto; right: -12px; top: 50%; transform: translate(100%, -50%); }
.seat.right .said { left: -12px; top: 50%; transform: translate(-100%, -50%); }
.seat .said.quiet { background: rgba(251,246,233,.55); color: rgba(30,26,20,.8); font-weight: 400; font-size: .85rem; padding: 2px 9px 1px; box-shadow: none; }
.seat .said.high { font-size: 1.2rem; padding: 5px 13px 3px; box-shadow: 0 0 0 3px var(--kasavu), 0 6px 16px rgba(0,0,0,.35); }
.seat .said.dbl { background: var(--kumkum); color: var(--ivory); }
.seat .seat-actions .btn { white-space: nowrap; }
.seat .seat-actions { display: flex; gap: 6px; justify-content: center; margin-top: 6px; }
.seat.empty { border-style: dashed; border-color: rgba(207,227,226,.35); background: rgba(8,42,48,.6); }
.seat.me .nm::after { content: ' (you)'; font-weight: 400; opacity: .7; }

/* trick */
.trick { position: absolute; inset: 0; pointer-events: none; }
.trick .card { position: absolute; transform: translate(-50%, -50%); animation: land .28s ease-out both; }
.trick .card.win { box-shadow: 0 0 0 3px var(--ivory), 0 0 0 6px var(--ink), 0 10px 24px rgba(0,0,0,.4); }
@keyframes land { from { opacity: 0; transform: translate(-50%, -50%) scale(.82); } }
.trick .card.gather { animation: none; transition: left .45s cubic-bezier(.4,0,.2,1), top .45s cubic-bezier(.4,0,.2,1), transform .45s; transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)); box-shadow: 0 4px 10px rgba(0,0,0,.35); }
.trick .card.swept { transition: left .6s cubic-bezier(.4,0,.2,1), top .6s cubic-bezier(.4,0,.2,1), transform .6s, opacity .6s; transform: translate(-50%, -50%) scale(.5) rotate(var(--tilt, 0deg)); opacity: 0; box-shadow: none; }
.seat.won { border-color: var(--ivory); animation: wonpulse .6s ease-out 2; }
.seat.won.collect { animation: collect .7s ease-out both; }
.seat .said.won { background: var(--ivory); color: var(--ink); font-weight: 700; }
@keyframes wonpulse { 0% { box-shadow: 0 0 0 0 rgba(255,250,230,.8); } 100% { box-shadow: 0 0 0 14px rgba(255,250,230,0); } }
@keyframes collect { 0% { transform: translate(calc(-50% + var(--nudge, 0px)), -50%) scale(1); } 60% { transform: translate(calc(-50% + var(--nudge, 0px)), -50%) scale(1.12); } 100% { transform: translate(calc(-50% + var(--nudge, 0px)), -50%) scale(1); } }

.group-label { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: .92rem; margin-top: 6px; }
.group-label span { font-weight: 700; color: var(--kasavu); letter-spacing: .04em; text-transform: uppercase; font-size: .8rem; }
.group-label em { font-style: normal; opacity: .75; }
.fixed-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 6px; }
.fixed-col { display: flex; flex-direction: column; gap: 6px; }
.fixed-col .big-btn { width: 100%; }
.big-btn .status { font-size: .8rem; font-weight: 600; margin-top: 4px; min-height: 1em; }
.big-btn .live { display: inline-block; background: #c4161c; color: #fff; border-radius: 999px; padding: 0 7px; font-size: .7rem; letter-spacing: .08em; animation: livepulse 1.4s ease-in-out infinite; }
@keyframes livepulse { 50% { opacity: .55; } }
.big-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 10px; }
.big-btn .sub { font-size: .78rem; font-weight: 400; opacity: .85; }
.field .req { font-style: normal; font-size: .75rem; opacity: .7; margin-left: 4px; }
/* ---------------------------------------------------------- cards */
.card {
  width: var(--cw); height: calc(var(--cw) * 1.42); border-radius: var(--radius-card);
  background: var(--ivory); color: var(--ink); position: relative; flex: none;
  box-shadow: inset 0 0 0 3px var(--ivory), inset 0 0 0 4.5px var(--kasavu), 0 3px 10px rgba(0,0,0,.35);
  user-select: none;
}
.card.red { color: var(--kumkum); }
.card .r { position: absolute; left: 9%; top: 6%; font-weight: 700; font-size: calc(var(--cw) * .34); line-height: 1; }
.card .s1 { position: absolute; left: 10%; top: 32%; font-size: calc(var(--cw) * .22); line-height: 1; }
.card .r2 { left: auto; top: auto; right: 9%; bottom: 6%; }
.card .s3 { left: auto; top: auto; right: 10%; bottom: 32%; }
.card .s2 { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: calc(var(--cw) * .5); line-height: 1; }
.card .pt { position: absolute; right: 9%; top: 7%; font-size: calc(var(--cw) * .17); opacity: .6; font-weight: 700; }

/* hand */
.hand { grid-area: hand; display: flex; justify-content: center; padding: 6px 12px max(14px, env(safe-area-inset-bottom)); min-height: calc(var(--cw) * 1.42 + 30px); }
.hand .card { margin-left: calc(var(--cw) * -.22); transition: transform .15s; cursor: default; border: 0; padding: 0; }
.hand .card:first-child { margin-left: 0; }
.hand .card.gap { margin-left: calc(var(--cw) * .12); }
.hand.active .card.legal { cursor: pointer; transform: translateY(-10px); }
.hand.active .card.legal:hover, .hand.active .card.legal:focus-visible { transform: translateY(-22px); }
.hand.active .card:not(.legal) { filter: brightness(.6) saturate(.6); }

/* ---------------------------------------------------------- bidding */
.bid-panel {
  grid-area: bid; margin: 0 auto 6px; width: min(640px, calc(100% - 20px));
  background: var(--ivory); color: var(--ink); border-radius: 16px; padding: 12px 14px;
  display: grid; gap: 10px; box-shadow: 0 0 0 2px var(--kasavu), 0 18px 40px rgba(0,0,0,.4);
}
.bid-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#bidPrompt { font-weight: 700; }
.conv { display: flex; gap: 6px; flex-wrap: wrap; }
.conv:not(:has(.btn)) { display: none; }
.raise { display: flex; align-items: center; gap: 10px; opacity: .6; transition: opacity .15s; }
.raise:hover, .raise:focus-within { opacity: 1; }
.raise-label { font-size: .85rem; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper output { font-size: 1.3rem; font-weight: 700; min-width: 2.2ch; text-align: center; line-height: 1; padding-top: 4px; }
.suits .btn { position: relative; }
.suits .tag { position: absolute; right: 7px; top: 4px; font-size: .62rem; font-weight: 700; letter-spacing: .06em; color: var(--ink); background: rgba(200,150,46,.28); border-radius: 999px; padding: 1px 5px 0; }
.bid-panel .btn { background: #fff; color: var(--ink); border-color: #CDBF9F; }
.bid-panel .btn:hover { border-color: var(--ink); }
.levels { display: flex; gap: 6px; flex-wrap: wrap; }
.levels .btn { padding: .35em .7em .2em; }
.suits { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.suits .btn { font-size: 1.15rem; padding: .55em 0 .4em; border-radius: 12px; }
.suits .btn.red { color: var(--kumkum); }
.suits .sname, .seat .said .sname { font-size: .78em; font-weight: 600; }
.bid-actions { display: flex; gap: 8px; }
.bid-actions .btn { flex: 1; }
.bid-actions .btn.warn { flex: 0 0 auto; }
.bid-panel .btn.warn { color: var(--kumkum); border-color: rgba(163,35,47,.5); }

/* ---------------------------------------------------------- rail */
.rail {
  grid-area: rail; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(80px, 38%) 1fr auto;
  background: rgba(8,42,48,.75); border-left: 1px solid rgba(207,227,226,.12); min-height: 0;
}
.rail-head { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; justify-content: space-between; }
.log, .chat { list-style: none; margin: 0; padding: 6px 14px; overflow-y: auto; font-size: .92rem; line-height: 1.45; }
.log { border-bottom: 1px solid rgba(207,227,226,.12); opacity: .85; }
.log li.head { margin-top: 8px; font-weight: 700; color: var(--ivory); }
.log li.head:first-child { margin-top: 0; }
.log li.call, .log li.trick-line { padding-left: 10px; }
.log li b { color: var(--ivory); font-weight: 700; }
.log li .n { display: inline-block; min-width: 1.6em; opacity: .6; }
.log .suit.red { color: #F5A3AD; }
.chat li b { color: var(--ivory); }
.chat li.sys { opacity: .65; font-style: italic; }
.chat-form { display: flex; gap: 6px; padding: 10px; }
.chat-form input { flex: 1; min-width: 0; background: rgba(8,42,48,.9); color: var(--ivory); border: 1px solid rgba(207,227,226,.25); border-radius: 999px; padding: .5em .9em .35em; }

/* ---------------------------------------------------------- modal + toast */
.modal { position: fixed; inset: 0; background: rgba(4,20,24,.55); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal-card { background: var(--ivory); color: var(--ink); border-radius: 18px; padding: 22px 24px; width: min(440px, 100%); box-shadow: 0 0 0 3px var(--kasavu), 0 30px 70px rgba(0,0,0,.5); }
.modal-card h2 { margin: 0 0 6px; font-size: 1.7rem; line-height: 1.15; }
.modal-card p { margin: .4em 0; line-height: 1.5; }
.modal-card .row { display: flex; gap: 10px; margin-top: 14px; justify-content: flex-end; }
.modal-card .btn { background: #fff; color: var(--ink); border-color: #CDBF9F; }
.modal-card .btn.primary { background: var(--kasavu); border-color: var(--kasavu); }
.modal-card .team-pick .btn { flex: 1; }
.tally { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; margin: 12px 0; font-size: 1.05rem; }
.tally .v { font-weight: 700; text-align: right; }
.deal-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; max-height: 60vh; overflow: auto; }
.deal-row { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; }
.deal-row.t0 { background: rgba(217,169,58,.14); } .deal-row.t1 { background: rgba(194,57,74,.14); }
.deal-row.bidder .who::after { content: ' (bid)'; font-weight: 400; opacity: .7; }
.deal-row .who { font-weight: 700; } .deal-row .who.t0 { color: #F3D27A; } .deal-row .who.t1 { color: #F5A3AD; }
.deal-cards { display: flex; flex-wrap: wrap; gap: 4px; --cw: 42px; }
.mini-trick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0; --cw: 52px; }
.mini-trick figure { margin: 0; text-align: center; font-size: .78rem; }
.mini-trick figure.win .card { box-shadow: inset 0 0 0 3px var(--ivory), inset 0 0 0 4.5px var(--kasavu), 0 0 0 3px var(--ink); }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); opacity: 0;
  background: var(--ivory); color: var(--ink); padding: .7em 1.2em .55em; border-radius: 999px;
  font-weight: 700; transition: .2s; z-index: 30; pointer-events: none; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------- team names */
.chip.pen { cursor: pointer; padding: .3em .6em .2em; font-size: 1rem; line-height: 1; align-self: center; opacity: .75; }
.chip.pen:hover { opacity: 1; border-color: var(--mist); }
.team-edit { display: grid; gap: 12px; margin: 12px 0 4px; }
.team-edit .field span { font-weight: 700; }
.team-edit .field.t0 span { color: #8a5a00; } .team-edit .field.t1 span { color: #8a1420; }
.team-edit .field input { background: #fff; color: var(--ink); border: 1px solid #CDBF9F; border-left-width: 5px; }
.team-edit .field.t0 input { border-left-color: var(--teamA); } .team-edit .field.t1 input { border-left-color: var(--teamB); }
.team-edit .field input:focus { border-color: var(--kasavu); }
.team-edit .field.t0 input:focus { border-left-color: var(--teamA); } .team-edit .field.t1 input:focus { border-left-color: var(--teamB); }

/* ---------------------------------------------------------- match won */
.cheer {
  position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; cursor: pointer; overflow: hidden;
  background: radial-gradient(80% 70% at 50% 45%, rgba(19,80,90,.92), rgba(4,20,24,.96));
  animation: cheerin .4s ease-out both;
}
.cheer.out { animation: cheerout .4s ease-in both; }
@keyframes cheerin { from { opacity: 0; } }
@keyframes cheerout { to { opacity: 0; } }
.cheer-card { position: relative; text-align: center; color: var(--ivory); padding: 20px; max-width: 92vw; }
.cheer .rays {
  position: absolute; left: 50%; top: 34%; width: 160vmax; height: 160vmax; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255,230,160,.14) 0 9deg, transparent 9deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 0%, transparent 42%); mask: radial-gradient(circle, #000 0%, transparent 42%);
  animation: spin 24s linear infinite; pointer-events: none;
}
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.cheer:not(.match) .trophy { width: clamp(110px, 22vmin, 170px); }
.cheer:not(.match) .team { font-size: clamp(30px, 6.5vmin, 54px); }
.cheer:not(.match) .tap { animation-delay: 1.4s; }
.cheer .trophy { position: relative; width: clamp(150px, 32vmin, 260px); margin: 0 auto 6px; filter: drop-shadow(0 18px 30px rgba(0,0,0,.5)) drop-shadow(0 0 28px rgba(255,220,140,.45)); animation: trophy 1s cubic-bezier(.2,1.4,.4,1) .15s both; }
.cheer .trophy svg { display: block; width: 100%; height: auto; }
@keyframes trophy { 0% { transform: translateY(60px) scale(.2) rotate(-14deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; opacity: 1; } }
.cheer .kicker { font-size: .95rem; letter-spacing: .32em; text-transform: uppercase; color: var(--kasavu); animation: rise .6s ease-out .7s both; }
.cheer .team { font-size: clamp(38px, 9vmin, 76px); font-weight: 700; line-height: 1.05; margin-top: 4px; animation: rise .6s ease-out .85s both; text-shadow: 0 6px 24px rgba(0,0,0,.5); }
.cheer.t0 .team { color: #F3D27A; } .cheer.t1 .team { color: #F5A3AD; }
.cheer .sub { font-size: 1.15rem; margin-top: 6px; opacity: .9; animation: rise .6s ease-out 1s both; }
.cheer .tap { margin-top: 26px; font-size: .8rem; opacity: 0; letter-spacing: .1em; animation: fadein .6s ease-out 2.4s both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes fadein { to { opacity: .55; } }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
  position: absolute; top: -4vh; left: var(--x); width: 10px; height: 16px; border-radius: 2px; transform: scale(var(--s));
  animation: fall var(--t) linear var(--d) both;
}
.confetti i.c0 { background: var(--teamA); } .confetti i.c1 { background: var(--teamB); } .confetti i.c2 { background: var(--ivory); border-radius: 50%; width: 10px; height: 10px; }
.confetti i.c3 { background: var(--kasavu); } .confetti i.c4 { background: var(--mist); width: 6px; height: 18px; }
@keyframes fall { 0% { transform: translateY(0) rotate(0) scale(var(--s)); opacity: 1; } 100% { transform: translateY(108vh) rotate(var(--r)) scale(var(--s)); opacity: .3; } }

/* ---------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  #table { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "arena" "bid" "hand"; }
  .chip.icon { display: inline-block; }
  .scores { margin-left: 0; }
  .rail {
    position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 88vw); z-index: 15;
    transform: translateX(100%); transition: transform .25s;
    background: var(--kayal-deep);   /* solid while it slides over the table */
  }
  .rail.open { transform: none; box-shadow: -20px 0 50px rgba(0,0,0,.5); }
  .rail-close { display: inline-block; order: -1; width: 100%; background: var(--ivory); color: var(--ink); border-color: var(--ivory); }
}
@media (max-width: 700px) {
  :root { --cw: clamp(38px, 11.4vw, 60px); }
  .arena { margin: 0 8px 4px; }
  .mat { inset: 12% 10% 12%; }
  .seat { min-width: 0; padding: 5px 8px 3px; font-size: .85rem; }
  .seat .nm { max-width: 84px; }
  .seat .seat-actions { gap: 4px; margin-top: 4px; }
  .seat .seat-actions .btn { padding: .35em .6em .2em; font-size: .78rem; }
  .hand { --cw: min(64px, calc((100vw - 28px) / 6.2)); padding-top: 14px; }
  .hand .card { margin-left: calc(var(--cw) * -.3); }
  .hand .card.gap { margin-left: calc(var(--cw) * -.12); }
  .rail-head .btn, .chat-form .btn { white-space: nowrap; }
  .topbar { padding: 8px; gap: 6px; }
  .team-score { padding: .3em .55em .15em; }
  .team-score .hpts { display: none; }
  .team-score .tname { max-width: 10ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .levels { margin-left: 0; }
  .bid-panel { width: calc(100% - 12px); padding: 10px; gap: 8px; }
  .suits { grid-template-columns: repeat(3, 1fr); }
  .suits .btn { font-size: 1.05rem; }
  .raise { flex-wrap: wrap; }
  .mat-info { font-size: .8rem; top: 4%; }
  .seat .cnt { top: -9px; right: 6px; background: rgba(8,42,48,.9); color: var(--mist); border-radius: 999px; padding: 1px 6px 0; opacity: 1; font-size: .65rem; line-height: 1.3; }
  .chip.contract .stake { display: none; }
}
/* phone held sideways: the bid panel floats over the mat instead of taking its height */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --cw: 44px; }
  #table { grid-template-rows: auto 1fr auto; grid-template-areas: "top" "arena" "hand"; grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 3px 8px; gap: 6px; flex-wrap: nowrap; overflow: hidden; }
  .chip, .team-score { padding: .25em .6em .15em; font-size: .8rem; }
  .chip.contract .stake, .team-score .hpts { display: none; }
  .team-score .tables { font-size: .95rem; }
  .scores { margin-left: auto; }
  .chip.icon { display: inline-block; margin-left: 0; }
  .arena { margin: 0 56px 2px; }
  .mat { inset: 6% 3%; }
  .mat-info { top: 3%; font-size: .78rem; }
  .center .bidval { font-size: clamp(24px, 7vh, 40px); }
  .center .sub { font-size: .82rem; margin-top: 2px; }
  .center .sub.wait { margin-top: 6px; }
  .seat { min-width: 0; padding: 3px 8px 2px; font-size: .78rem; border-radius: 10px; }
  .seat .nm { max-width: 90px; }
  .seat .meta { display: none; }
  .seat .said { padding: 2px 8px 1px; font-size: .85rem; }
  .seat .said.high { font-size: .95rem; }
  .seat .tok { font-size: .6rem; }
  .seat .cnt { top: -8px; right: 4px; background: rgba(8,42,48,.9); color: var(--mist); border-radius: 999px; padding: 1px 5px 0; opacity: 1; font-size: .6rem; line-height: 1.3; }
  .hand { padding: 2px 8px 6px; min-height: 0; }
  .hand .card { margin-left: calc(var(--cw) * -.25); }
  .hand.active .card.legal { transform: translateY(-4px); }
  .hand.active .card.legal:hover, .hand.active .card.legal:focus-visible { transform: translateY(-10px); }
  .bid-panel {
    position: fixed; left: 50%; bottom: calc(var(--cw) * 1.42 + 12px); transform: translateX(-50%); z-index: 6;
    width: min(600px, 96vw); margin: 0; padding: 6px 8px; gap: 5px; border-radius: 12px;
  }
  .bid-head { font-size: .82rem; }
  .suits { gap: 5px; }
  .suits .btn { font-size: .95rem; padding: .3em 0 .2em; border-radius: 9px; }
  .suits .tag { top: 2px; right: 4px; font-size: .55rem; }
  .levels .btn, .conv .btn { padding: .25em .6em .15em; font-size: .8rem; }
  .raise { gap: 6px; }
  .raise-label { font-size: .75rem; }
  .stepper output { font-size: 1.05rem; }
  .bid-actions .btn { padding: .35em 1em .25em; font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
