/* htmlbridge — casino-felt Contract Bridge, mobile-first, compass table. */
* { box-sizing: border-box; }
:root {
  --felt: #12633f; --felt2: #0c4a2f; --gold: #e7c66a; --ink: #0d1a12;
  --panel: rgba(0, 0, 0, 0.28);
  --card-w: 58px;
  --ns: #7fd1ff; --ew: #ffb37f;
}
html, body {
  margin: 0; padding: 0; min-height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  color: #f3f6f2;
  background: radial-gradient(120% 120% at 50% 0%, #1b7a4e 0%, var(--felt) 45%, var(--felt2) 100%) fixed;
}
.screen { max-width: 1080px; margin: 0 auto; padding: 8px 12px 160px; }
.hidden { display: none !important; }
b { color: var(--gold); }
.muted { opacity: .62; }
.hint { font-size: .85rem; opacity: .75; margin-top: 6px; }
h1, h2, h3, h4 { margin: 0 0 8px; }

/* ---- top bar ---- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 8px 14px;
  background: linear-gradient(180deg, rgba(6,40,26,.96), rgba(6,40,26,.82));
  border-bottom: 1px solid rgba(231,198,106,.3);
}
.brand { font-weight: 800; letter-spacing: .5px; color: var(--gold); font-size: 1.25rem; cursor: pointer; }
.top-right { display: flex; gap: 10px; align-items: center; }
.icon-btn { background: transparent; border: none; font-size: 1.2rem; cursor: pointer; }
.langsw { display: flex; border: 1px solid rgba(231,198,106,.4); border-radius: 8px; overflow: hidden; }
.langsw .lang { font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
  border: none; padding: 5px 10px; background: transparent; color: #f3f6f2; }
.langsw .lang.on { background: var(--gold); color: var(--ink); }

/* ---- buttons ---- */
.btn { font: inherit; cursor: pointer; border: none; border-radius: 10px;
  padding: 10px 16px; font-weight: 700; color: #fff; background: rgba(255,255,255,.16); }
.btn:hover { background: rgba(255,255,255,.26); }
.btn.primary { background: var(--gold); color: var(--ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border: 1px solid rgba(255,255,255,.3); }
.btn.danger { background: #8e2b22; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.big { padding: 13px 22px; font-size: 1.05rem; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.btnrow.center { justify-content: center; }

/* =====================  CENTER / LOBBY  ===================== */
.hero { text-align: center; margin: 14px 0 6px; }
.hero h1 { font-size: 2rem; color: var(--gold); }
.tagline { opacity: .8; }
.namebar, .createbox, .tables {
  background: var(--panel); border: 1px solid rgba(231,198,106,.25);
  border-radius: 16px; padding: 16px 18px; margin: 12px 0;
}
.namebar { display: flex; flex-direction: column; gap: 6px; }
.namebar label { font-weight: 700; color: var(--gold); }
.namebar input, .createbox input {
  width: 100%; padding: 12px; font: inherit; font-size: 1.05rem;
  border-radius: 10px; border: none; background: #fff; color: #111;
}
.createbox { display: flex; flex-direction: column; gap: 10px; }
.seatpick-lbl { font-weight: 700; color: var(--gold); font-size: .9rem; }
.seat-choose { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seat-choose-btn { padding: 10px; border-radius: 10px; border: 1px solid rgba(231,198,106,.4);
  background: rgba(0,0,0,.25); color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.seat-choose-btn small { display: block; font-weight: 500; opacity: .75; }
.seat-choose-btn.sel { background: var(--gold); color: var(--ink); }

.room-list { display: flex; flex-direction: column; gap: 10px; }
.room-list .empty { opacity: .6; font-style: italic; padding: 10px; }
.room-card { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; padding: 12px 14px; }
.room-card-title { font-weight: 800; }
.rc-code { color: var(--gold); font-family: monospace; letter-spacing: 1px; }
.room-card-sub { font-size: .85rem; opacity: .8; margin-top: 3px; }
.room-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: .68rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.badge.open { background: #2a6b47; color: #fff; }
.badge.playing { background: var(--gold); color: var(--ink); }

/* =====================  ROOM head  ===================== */
.room-head { display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap; margin: 8px 0 12px; }
.room-title { font-weight: 800; font-size: 1.15rem; }
.room-title .code { color: var(--gold); font-family: monospace; }
.room-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* =====================  ROOM LOBBY  ===================== */
.lobby-card { background: var(--panel); border: 1px solid rgba(231,198,106,.25);
  border-radius: 16px; padding: 16px 18px; margin-bottom: 12px; }
.lobby-msg { font-weight: 700; margin-bottom: 10px; }
.seatgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 620px) { .seatgrid { grid-template-columns: 1fr 1fr; } }
.seatcard { position: relative; background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px; padding: 12px 10px; text-align: center; min-height: 84px; }
.seatcard .pos { font-weight: 800; color: var(--gold); }
.seatcard .pos small { font-weight: 500; opacity: .7; }
.seatcard .who { margin-top: 6px; font-weight: 600; min-height: 1.2em; font-size: .9rem; }
.seatcard .who.empty { opacity: .5; font-style: italic; }
.seatcard.ns { border-top: 3px solid var(--ns); }
.seatcard.ew { border-top: 3px solid var(--ew); }
.seatcard.sit { cursor: pointer; }
.seatcard.sit:hover { background: rgba(231,198,106,.15); border-color: var(--gold); }
.seatcard .sit-hint { margin-top: 6px; font-size: .8rem; color: var(--gold); font-weight: 700; }
.seatcard .mini-badge { position: absolute; top: 6px; right: 6px; font-size: .6rem;
  font-weight: 800; background: #444e63; padding: 1px 5px; border-radius: 5px; }
.waiting { font-size: 1.02rem; }
.you_are { color: var(--gold); }

/* conventions */
.conv-groups { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.conv-group h4 { color: var(--gold); font-size: .95rem;
  border-bottom: 1px solid rgba(255,255,255,.12); padding-bottom: 4px; }
.conv-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 6px;
  border-bottom: 1px dashed rgba(255,255,255,.08); }
.conv-item .cv-main { flex: 1; }
.conv-item .cv-name { font-weight: 700; }
.conv-item .cv-intro { font-size: .84rem; opacity: .82; margin-top: 2px; }
.switch { position: relative; width: 46px; height: 26px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: rgba(255,255,255,.2); transition: .2s; }
.switch .track::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + .track { background: var(--gold); }
.switch input:checked + .track::before { transform: translateX(20px); }
.conv-readonly { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.conv-readonly .tagc { background: rgba(231,198,106,.18); border: 1px solid rgba(231,198,106,.4);
  border-radius: 999px; padding: 3px 10px; font-size: .8rem; }

/* =====================  TABLE  ===================== */
.pillrow { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pill { background: rgba(0,0,0,.35); border: 1px solid rgba(231,198,106,.35);
  padding: 3px 12px; border-radius: 999px; font-weight: 700; font-size: .82rem; }
.pill.gold { background: var(--gold); color: var(--ink); border: none; }
.pill.vul { background: #b5342b; border: none; color: #fff; }

.tablewrap { position: relative;
  background: radial-gradient(120% 90% at 50% 40%, #1a7d51, #0f5636 74%, #0a3f28);
  border: 3px solid rgba(231,198,106,.35); border-radius: 26px;
  padding: 12px; margin-bottom: 12px; box-shadow: inset 0 0 60px rgba(0,0,0,.35); }
.compass { display: grid; gap: 8px;
  grid-template-columns: 1fr auto 1fr; grid-template-rows: auto auto auto;
  grid-template-areas: ".    top    ." "left center right" ".    bottom ."; align-items: center; }
.zone-top { grid-area: top; justify-self: center; }
.zone-bottom { grid-area: bottom; justify-self: center; }
.zone-left { grid-area: left; justify-self: end; }
.zone-right { grid-area: right; justify-self: start; }
.zone-center { grid-area: center; }
.seat.z-left { margin-right: 40px; }
.seat.z-right { margin-left: 40px; }

.seat { position: relative; background: var(--panel); border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px; padding: 8px 10px; width: 158px; min-height: 118px; text-align: center;
  transition: box-shadow .2s, border-color .2s, transform .2s; }
.seat.ns { border-top: 3px solid var(--ns); }
.seat.ew { border-top: 3px solid var(--ew); }
.seat.active { border-color: #ff5a5a; transform: translateY(-2px); animation: seat-pulse 1s ease-in-out infinite; }
.seat.active::after { content: ""; position: absolute; inset: -7px; border-radius: 18px;
  border: 3px solid #ff4d4d; pointer-events: none; animation: ring-pulse 1s ease-in-out infinite; }
@keyframes seat-pulse { 0%,100% { box-shadow: 0 0 0 2px #ff4d4d, 0 0 14px rgba(255,60,60,.55); }
  50% { box-shadow: 0 0 0 3px #ff6b6b, 0 0 30px rgba(255,60,60,.95); } }
@keyframes ring-pulse { 0%,100% { opacity: .55; transform: scale(1); } 50% { opacity: 1; transform: scale(1.05); } }
.seat.me { background: rgba(231,198,106,.1); }
.seat-head { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; }
.seat-pos { font-weight: 800; color: var(--gold); }
.seat-name { font-weight: 700; font-size: .9rem; }
.badge2 { display: inline-block; font-size: .6rem; font-weight: 800; padding: 1px 6px;
  border-radius: 6px; letter-spacing: .4px; }
.badge2.dl { background: #fff; color: #000; }
.badge2.dec { background: #35507a; color: #fff; }
.badge2.dum { background: #7a5a35; color: #fff; }
.badge2.vul { background: #b5342b; color: #fff; }
.badge2.bot { background: #444e63; color: #fff; }
.seat .cardcount { margin-top: 6px; height: 46px; display: flex; align-items: center;
  justify-content: center; font-size: .82rem; opacity: .85; }

.seat .hand-grid { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.seat .hand-row { display: flex; justify-content: center; align-items: flex-start; gap: 8px; }
.seat .suitgrp { display: flex; flex-wrap: nowrap; }
.seat .suitgrp img.card.sm { margin-left: -20px; }
.seat .suitgrp img.card.sm:first-child { margin-left: 0; }
.seat .voidsuit { width: 26px; height: 40px; display: flex; align-items: center;
  justify-content: center; opacity: .35; font-size: .8rem; }

.seat-calls { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; margin-top: 5px; }
.bcall { font-size: .72rem; font-weight: 800; line-height: 1; padding: 2px 5px; border-radius: 5px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.18); }
.bcall.red { color: #ff9a9a; }
.bcall.pass { opacity: .55; font-weight: 600; }
.seat-contract { margin-top: 5px; display: inline-block; font-weight: 900; font-size: 1.05rem;
  padding: 2px 10px; border-radius: 8px; color: var(--ink); background: var(--gold);
  box-shadow: 0 0 12px rgba(231,198,106,.6); }
.seat-contract.red { color: #7a0d0d; }

.centerbox { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px; }
.contractline { text-align: center; font-size: .9rem; opacity: .85; }
.trickmat { position: relative; width: 168px; height: 168px; background: rgba(0,0,0,.22);
  border-radius: 16px; border: 1px solid rgba(255,255,255,.1); }
.trickmat .tc { position: absolute; }
.trickmat .tc.faint { opacity: .38; }
.trickmat .tc.top { top: 4px; left: 50%; margin-left: calc(var(--card-w) / -2); }
.trickmat .tc.bottom { bottom: 4px; left: 50%; margin-left: calc(var(--card-w) / -2); }
.trickmat .tc.left { left: 4px; top: 50%; margin-top: calc(var(--card-w) * -0.7); }
.trickmat .tc.right { right: 4px; top: 50%; margin-top: calc(var(--card-w) * -0.7); }
.trickcount { display: flex; gap: 14px; font-size: .9rem; }
.trickcount .ns b { color: var(--ns); }
.trickcount .ew b { color: var(--ew); }

.trick-pack { position: absolute; top: 50%; height: 30px; width: 30px; transform: translateY(-50%);
  pointer-events: none; background: repeating-linear-gradient(45deg, #b22 0 4px, #901 4px 8px), #a11;
  border: 1px solid #fff; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.trick-pack.side-right { left: 100%; margin-left: 8px; }
.trick-pack.side-left { right: 100%; margin-right: 8px; }
.trick-pack .pk-n { position: absolute; right: -6px; bottom: -6px; font-size: .68rem; font-weight: 800;
  color: var(--gold); background: rgba(0,0,0,.75); border-radius: 6px; padding: 0 5px; }

/* cards */
img.card { width: var(--card-w); height: calc(var(--card-w) * 1.4); border-radius: 6px;
  object-fit: contain; background: #fff; filter: drop-shadow(0 2px 3px rgba(0,0,0,.45)); }
img.card.sm { width: 28px; height: 40px; border-radius: 4px; }
.card.back { width: var(--card-w); height: calc(var(--card-w) * 1.4); border-radius: 6px;
  display: inline-block; background: repeating-linear-gradient(45deg, #b22 0 7px, #901 7px 14px), #a11;
  border: 2px solid #fff; box-shadow: 0 2px 3px rgba(0,0,0,.45); }

/* your hand area */
.myhand { margin-top: 10px; }
.myhand h3 { text-align: center; }
.dummy-hint { text-align: center; color: var(--gold); font-weight: 700; margin: 6px 0; }
.handwrap { display: flex; justify-content: center; }
.hand-grid.big { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 4px; }
.hand-grid.big .hand-row { display: flex; justify-content: center; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.hand-grid.big .suitgrp { display: flex; flex-wrap: nowrap; }
.hand-grid.big .suitgrp img.card { margin-left: -24px; position: relative; transition: transform .12s; }
.hand-grid.big .suitgrp img.card:first-child { margin-left: 0; }
.hand-grid.big img.card.playable { cursor: pointer; outline: 2px solid #7fffb0; outline-offset: 1px; }
.hand-grid.big img.card.playable:hover { transform: translateY(-10px); z-index: 5; }
.hand-grid.big .voidsuit.big { width: var(--card-w); height: calc(var(--card-w) * 1.4);
  display: flex; align-items: center; justify-content: center; opacity: .3; }
.handlabel { text-align: center; font-size: .85rem; opacity: .8; }

/* =====================  BIDDING BOX  ===================== */
.bidbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: linear-gradient(180deg, rgba(8,40,26,.7), rgba(6,30,20,.98));
  border-top: 2px solid var(--gold); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
.bidgrid { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.bidrow { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.bidbtn { font: inherit; font-weight: 800; cursor: pointer; border: none; border-radius: 8px;
  padding: 8px 10px; min-width: 44px; background: rgba(255,255,255,.16); color: #fff; }
.bidbtn .st.red { color: #ff9a9a; }
.bidbtn:hover:not([disabled]) { background: rgba(255,255,255,.3); }
.bidbtn[disabled] { opacity: .28; cursor: not-allowed; }
.bidbtn.pass { background: #2a6b47; }
.bidbtn.dbl { background: #8e2b22; }
.bidbtn.rdbl { background: #2f4d8a; }
.bidbtn.lvl { min-width: 36px; background: rgba(231,198,106,.2); border: 1px solid rgba(231,198,106,.4); }
.bidbtn.lvl.sel { background: var(--gold); color: var(--ink); }

/* =====================  panels / auction / result / score ============== */
.panel { background: var(--panel); border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.panel h3 { color: var(--gold); font-size: .95rem; }
.auction-table { width: 100%; border-collapse: collapse; text-align: center; font-size: .9rem; }
.auction-table th { color: var(--gold); padding: 4px; font-size: .85rem; }
.auction-table td { padding: 4px; border-top: 1px solid rgba(255,255,255,.07); }
.auction-table .call.red { color: #ff9a9a; }
.auction-table .call.pass { opacity: .6; }

.result { text-align: center; background: rgba(0,0,0,.34); border: 2px solid var(--gold);
  border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; }
.result-title { color: var(--gold); font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.result .r-contract { font-size: 1.6rem; font-weight: 800; color: var(--gold); }
.result .r-made { font-size: 1.1rem; font-weight: 700; margin-top: 4px; }
.result .r-made.made { color: #8fe6a4; }
.result .r-made.down { color: #ff9c9c; }
.result .r-detail { font-size: .86rem; opacity: .8; margin-top: 6px; }
.result .r-score { margin-top: 8px; font-size: 1.05rem; }
.waiting-next { margin-top: 12px; opacity: .85; }

.scoreboard .score-totals { display: flex; gap: 12px; margin: 6px 0 10px; }
.score-totals .st { flex: 1; text-align: center; background: rgba(0,0,0,.3);
  border-radius: 10px; padding: 8px; }
.score-totals .st span { display: block; font-size: .8rem; opacity: .8; }
.score-totals .st b { font-size: 1.4rem; }
.score-totals .st.ns b { color: var(--ns); }
.score-totals .st.ew b { color: var(--ew); }
.score-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.score-table th { color: var(--gold); text-align: left; padding: 3px 6px; font-size: .78rem; }
.score-table td { padding: 3px 6px; border-top: 1px solid rgba(255,255,255,.07); }

/* =====================  CHAT + LOG  ===================== */
.chat-box, .log-box { background: var(--panel); border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.chat-head, .log-title { color: var(--gold); font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.chat-input-row { display: flex; gap: 6px; }
.chat-input-row input { flex: 1; padding: 8px; border-radius: 8px; border: none; font: inherit; }
.chat-area { max-height: 140px; overflow-y: auto; margin-top: 8px; font-size: .86rem; }
.chat-line { padding: 2px 0; }
.log-area { max-height: 160px; overflow-y: auto; font-size: .84rem; }
.log-line { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.06); opacity: .9; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.88); color: #fff; padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--gold); font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 60; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 620px) {
  :root { --card-w: 40px; }
  .seat { width: 116px; min-height: 96px; }
  .seat.z-left { margin-right: 22px; }
  .seat.z-right { margin-left: 22px; }
  .seat .cardcount { height: 34px; }
  .seat .suitgrp img.card.sm { margin-left: -15px; }
  img.card.sm { width: 20px; height: 28px; }
  .trickmat { width: 140px; height: 140px; }
  .hero h1 { font-size: 1.6rem; }
}
