/* Bid Whist — late-night card party. Felt, mahogany, aged gold, cream stock. */

:root {
  --room-dark: #170d0b;
  --room: #241310;
  --mahogany: #3d1d16;
  --felt: #14523c;
  --felt-deep: #0a2e21;
  --gold: #d4a94e;
  --gold-bright: #f0cd78;
  --gold-dim: #8a6d33;
  --cream: #f6efdd;
  --cream-dim: #d8cdb2;
  --ink: #26211c;
  --red: #b3382e;
  --burgundy: #5c1a20;
  --good: #7fc97f;
  --bad: #e0705f;
  --card-w: 74px;
  --card-h: 104px;
  --font-display: "Fraunces", "Georgia", serif;
  --font-body: "Libre Franklin", "Helvetica Neue", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }
/* Stop iOS from inflating text in landscape; kill the grey tap flash. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }
/* Buttons and cards respond instantly to taps (no double-tap-zoom delay). */
button, .card, .chipbtn, summary, .splash-profile { touch-action: manipulation; }

body {
  font-family: var(--font-body);
  color: var(--cream);
  background:
    radial-gradient(120% 90% at 50% 0%, #33180f 0%, var(--room) 45%, var(--room-dark) 100%);
  min-height: 100vh; min-height: 100dvh;
  overflow-x: hidden;
}

.room {
  position: relative; min-height: 100vh; min-height: 100dvh;
  /* respect iPhone notch / home-indicator safe areas */
  padding: 0 max(20px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 40; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- top bar ---------- */

.topbar {
  display: flex; align-items: baseline; gap: 18px;
  padding: 18px 6px 12px; max-width: 1440px; margin: 0 auto;
  border-bottom: 1px solid rgba(212, 169, 78, .25);
}

.brand {
  font-family: var(--font-display);
  font-weight: 800; font-size: 34px; letter-spacing: .5px; color: var(--gold-bright);
  text-shadow: 0 2px 12px rgba(0,0,0,.6);
}
.brand em { font-style: italic; font-weight: 400; color: var(--cream); }
.brand-name { display: block; line-height: 1; white-space: nowrap; }
.brand-sub {
  display: block; margin-top: 4px;
  font-family: var(--font-body); font-size: 10px; font-weight: 700; line-height: 1;
  letter-spacing: .42em; text-transform: uppercase; color: var(--gold-dim); text-shadow: none;
}

.tagline {
  font-size: 12px; letter-spacing: .28em; text-transform: uppercase;
  color: var(--gold-dim); flex: 1;
}

.topnav { display: flex; gap: 10px; }

/* ---------- buttons ---------- */

.btn {
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--gold-dim); color: var(--gold-bright);
  background: transparent; transition: all .18s ease;
}
.btn:hover { border-color: var(--gold-bright); background: rgba(212,169,78,.12); }
.btn.primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #2c1a06; border-color: transparent; box-shadow: 0 4px 18px rgba(0,0,0,.45);
}
.btn.primary:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn.big { font-size: 15px; padding: 13px 30px; }
.btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.btn.ghost { border-color: rgba(212,169,78,.4); }

/* ---------- layout ---------- */

.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px;
  max-width: 1440px; margin: 18px auto 0; align-items: start;
}

/* ---------- the table ---------- */

.table-zone { position: relative; }

.table {
  position: relative; height: 640px; border-radius: 46px;
  background:
    radial-gradient(75% 75% at 50% 42%, #1c6a4e 0%, var(--felt) 48%, var(--felt-deep) 100%);
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, .55),
    0 24px 60px rgba(0, 0, 0, .55);
  overflow: hidden;
}

.rail {
  position: absolute; inset: 10px; border-radius: 38px; pointer-events: none;
  border: 3px solid rgba(212, 169, 78, .5);
  box-shadow: inset 0 0 0 8px rgba(20, 10, 6, .35), inset 0 0 34px rgba(0,0,0,.4);
}

/* seats */

.seat { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 8px; }
/* Fixed width so the nameplate doesn't shift when a bid chip appears/grows. */
.seat-north, .seat-west, .seat-east { width: 210px; }
.seat-north { top: 46px; left: 50%; transform: translateX(-50%); }
.seat-south { bottom: 18px; left: 50%; transform: translateX(-50%); width: 100%; }
.seat-west  { left: 24px; top: 50%; transform: translateY(-50%); }
.seat-east  { right: 24px; top: 50%; transform: translateY(-50%); }

.nameplate {
  display: flex; flex-direction: row; align-items: center; gap: 9px; line-height: 1.15;
  background: rgba(10, 26, 19, .72); border: 1px solid rgba(212,169,78,.35);
  border-radius: 12px; padding: 5px 14px 5px 7px; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  transition: box-shadow .25s, border-color .25s;
}
.nameplate .np-text { display: flex; flex-direction: column; align-items: flex-start; }
.nameplate .pname { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--cream); }
.nameplate .prole { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-dim); }

/* avatars — cartoon emoji on a gradient, or an uploaded photo (cover). */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 18px; line-height: 1;
  background: #3a2a44 center / cover no-repeat;
  border: 1.5px solid rgba(212, 169, 78, .55); overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.45); user-select: none;
}
/* Cartoon avatars are live emoji text: name every platform's color-emoji font
   explicitly so iOS, Android/Samsung, Windows and Linux all pick theirs. Size
   scales with the circle (0.62em of the avatar's font-size). */
.avatar-emoji {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
    "Samsung Color Emoji", "Twemoji Mozilla", "EmojiOne Color", "Segoe UI Symbol", sans-serif;
  font-style: normal; font-weight: 400; line-height: 1;
  display: block; transform: translateY(.04em);
  -webkit-text-size-adjust: none; text-size-adjust: none;
}
.avatar.photo { background-size: cover; background-position: center; }
.avatar.big { width: 56px; height: 56px; font-size: 30px; }
.avatar.huge { width: 92px; height: 92px; font-size: 48px; border-width: 2px; }
.nameplate.turn { border-color: var(--gold-bright); box-shadow: 0 0 18px rgba(240,205,120,.5); }
.nameplate.dealer .prole::after { content: " · dealer"; color: var(--gold-bright); }

/* Opponents' hands aren't drawn — each seat is a clean player tag. */
.opp-hand { display: none; }

/* bid chips — a solid badge that sits above the card backs so a bid is always
   readable, even next to the tall side stacks. */

.bid-chip {
  position: relative; z-index: 8; max-width: 194px; text-align: center; line-height: 1.35;
  font-family: var(--font-display); font-size: 13.5px; font-style: italic;
  color: var(--gold-bright); text-shadow: 0 1px 5px rgba(0,0,0,.8);
  background: rgba(8, 22, 16, .92); border: 1px solid rgba(212, 169, 78, .5);
  border-radius: 13px; padding: 4px 13px;
  opacity: 0; transform: translateY(4px); transition: opacity .3s ease, transform .3s ease;
  box-shadow: 0 3px 10px rgba(0,0,0,.45);
}
.bid-chip:empty { padding: 0; border: 0; background: none; box-shadow: none; }
.bid-chip.show { opacity: 1; transform: translateY(0); }
.bid-chip .chip-pass { color: var(--cream-dim); font-style: normal; letter-spacing: .1em; }
.bid-chip .chip-suit { font-style: normal; font-weight: 700; }
.bid-chip .chip-suit.red { color: #ef7a68; }
.bid-chip .chip-suit.blk { color: #f0e7d2; }

/* Made / set stamp on the declarer's seat at hand end. */
.bid-chip.chip-made { border-color: rgba(127, 201, 127, .8); box-shadow: 0 0 14px rgba(127,201,127,.3), 0 3px 10px rgba(0,0,0,.45); }
.bid-chip.chip-set { border-color: rgba(224, 112, 95, .85); box-shadow: 0 0 14px rgba(224,112,95,.35), 0 3px 10px rgba(0,0,0,.45); }
.bid-chip .chip-result { font-style: normal; font-weight: 700; }
.bid-chip.chip-made .chip-result { color: var(--good); }
.bid-chip.chip-set .chip-result { color: var(--bad); }

/* center: kitty + trick */

.center { position: absolute; inset: 0; pointer-events: none; }

.kitty {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 4px; transition: opacity .5s;
}
.kitty .card { width: 40px; height: 56px; border-radius: 5px; margin: 0 -14px; }
.kitty::after {
  content: "the kitty"; font-size: 10px; letter-spacing: .25em; text-transform: uppercase;
  color: rgba(246, 239, 221, .55); margin-left: 24px;
}
.kitty.gone { opacity: 0; }
.kitty.sported .card { margin: 0 2px; }
.kitty.sported::after { content: "sported"; }

.trick { position: absolute; inset: 0; }
.trick .played {
  position: absolute; left: 50%; top: 44%;
  animation: playIn .32s cubic-bezier(.2, .8, .3, 1) both;
}
.trick .played.from-0 { transform: translate(-50%, -50%) translateY(64px) rotate(-2deg); }
.trick .played.from-1 { transform: translate(-50%, -50%) translateX(-78px) rotate(5deg); }
.trick .played.from-2 { transform: translate(-50%, -50%) translateY(-64px) rotate(2deg); }
.trick .played.from-3 { transform: translate(-50%, -50%) translateX(78px) rotate(-5deg); }
.trick.collect .played { transition: all .5s cubic-bezier(.5, 0, .8, .4); opacity: 0; }
.trick.collect.to-0 .played { transform: translate(-50%, 220px) scale(.5); }
.trick.collect.to-1 .played { transform: translate(-420%, -50%) scale(.5); }
.trick.collect.to-2 .played { transform: translate(-50%, -300px) scale(.5); }
.trick.collect.to-3 .played { transform: translate(320%, -50%) scale(.5); }

@keyframes playIn {
  from { opacity: 0; margin-top: -26px; }
  to { opacity: 1; margin-top: 0; }
}

.table-msg {
  position: absolute; left: 50%; top: 63%; transform: translateX(-50%);
  font-family: var(--font-display); font-style: italic; font-size: 17px;
  color: var(--gold-bright); text-shadow: 0 2px 10px rgba(0,0,0,.8);
  text-align: center; white-space: nowrap; pointer-events: none;
  transition: opacity .3s;
}

/* ---------- cards ---------- */

.card {
  width: var(--card-w); height: var(--card-h); border-radius: 8px; position: relative;
  background: linear-gradient(160deg, #fbf6e8, var(--cream) 60%, #eadfc4);
  border: 1px solid #b9ad8d;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .4);
  font-family: var(--font-display); user-select: none; flex-shrink: 0;
}
.card .idx {
  position: absolute; top: 4px; left: 6px; line-height: .95; text-align: center;
  font-size: 15px; font-weight: 700;
}
.card .idx small { display: block; font-size: 12px; font-weight: 400; }
.card .idx.flip { top: auto; left: auto; bottom: 4px; right: 6px; transform: rotate(180deg); }
.card .pip {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 34px; opacity: .9;
}
.card.red { color: var(--red); }
.card.black { color: var(--ink); }

.card.joker { color: var(--burgundy); }
.card.joker .pip { font-size: 30px; }
.card.joker .idx { font-size: 10px; letter-spacing: .08em; writing-mode: vertical-rl; text-orientation: upright; font-weight: 700; }
.card.joker.big .pip::after { content: "★"; color: var(--gold); font-size: 14px; position: absolute; margin-top: -44px; }

.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(212,169,78,.28) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(-45deg, rgba(212,169,78,.28) 0 2px, transparent 2px 9px),
    linear-gradient(160deg, #6e2229, var(--burgundy) 65%, #431318);
  border-color: #2e0d11;
}
.card.back::after {
  content: ""; position: absolute; inset: 5px; border-radius: 5px;
  border: 1px solid rgba(212, 169, 78, .55);
}

/* ---------- human hand ---------- */

.hand {
  width: 100%; /* measure the available width, not the cards (layoutHand) */
  display: flex; justify-content: center; align-items: flex-end;
  min-height: calc(var(--card-h) + 26px); padding: 0 40px;
}
.hand .card {
  margin: 0; cursor: pointer; /* overlap is set per card by layoutHand() */
  transition: transform .16s ease, box-shadow .16s ease, filter .16s;
  animation: dealIn .4s cubic-bezier(.2,.8,.3,1) both;
  animation-delay: var(--deal-delay, 0s);
}
/* Hover-lift only on real mice — on touch screens :hover "sticks" after a tap. */
@media (hover: hover) and (pointer: fine) {
  .hand .card:hover { transform: translateY(-14px); box-shadow: 0 10px 22px rgba(0,0,0,.5); z-index: 5; }
  .hand .card.disabled:hover { transform: none; box-shadow: 0 3px 8px rgba(0,0,0,.4); }
}
.hand .card.disabled { cursor: default; filter: brightness(.62) saturate(.7); }
/* Big hands on narrow screens fan into two overlapping rows (see layoutHand). */
.hand.two-rows { flex-wrap: wrap; align-content: flex-end; min-height: calc(var(--card-h) * 1.6 + 26px); }
.hand-break { flex-basis: 100%; height: 0; }
.hand .card.row2 { margin-top: calc(var(--card-h) * -0.4); }
.hand .card.selected {
  transform: translateY(-20px);
  box-shadow: 0 0 0 2px var(--gold-bright), 0 12px 22px rgba(0,0,0,.55);
}

@keyframes dealIn {
  from { opacity: 0; transform: translateY(40px) rotate(4deg); }
  to { opacity: 1; }
}

/* ---------- action bar ---------- */

.action-bar {
  margin-top: 14px; min-height: 92px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(61,29,22,.9), rgba(36,19,16,.9));
  border: 1px solid rgba(212, 169, 78, .3);
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 14px 18px; flex-wrap: wrap;
}
.action-hint {
  font-family: var(--font-display); font-style: italic; font-size: 16px; color: var(--cream-dim);
}
.bid-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.bid-group .lbl {
  font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold-dim);
  margin-right: 4px; width: 100%; text-align: center;
}
.chipbtn {
  font-family: var(--font-display); font-size: 16px; font-weight: 600;
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--gold-dim); color: var(--cream); background: rgba(0,0,0,.25);
  transition: all .15s;
}
.chipbtn.wide { width: auto; border-radius: 999px; padding: 0 16px; font-size: 14px; }
.chipbtn:hover:not(:disabled) { border-color: var(--gold-bright); }
.chipbtn.on {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #2c1a06; border-color: transparent; font-weight: 700;
}
.chipbtn:disabled { opacity: .28; cursor: not-allowed; }
.bid-col { display: flex; flex-direction: column; gap: 6px; align-items: center; }

/* ---------- side panels ---------- */

.side { display: flex; flex-direction: column; gap: 14px; }

.panel {
  background: linear-gradient(180deg, rgba(61,29,22,.85), rgba(30,15,12,.9));
  border: 1px solid rgba(212, 169, 78, .3); border-radius: 18px; padding: 16px 18px;
}
.panel-title {
  font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: .04em;
  color: var(--gold-bright); margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.panel-title small { font-size: 11px; color: var(--gold-dim); font-family: var(--font-body); letter-spacing: .12em; }

.score-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.score-box { text-align: center; flex: 1; }
.score-team { display: block; font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: var(--gold-dim); }
.score-num { font-family: var(--font-display); font-size: 44px; font-weight: 700; color: var(--cream); line-height: 1.05; }
.score-vs { color: var(--gold-dim); }
.score-box.us .score-num { color: var(--gold-bright); }

.contract-line { font-family: var(--font-display); font-style: italic; font-size: 15px; color: var(--cream); min-height: 22px; }
.books-row { display: flex; gap: 10px; margin-top: 10px; }
.books-box {
  flex: 1; display: flex; justify-content: space-between; align-items: center;
  background: rgba(0,0,0,.28); border-radius: 10px; padding: 7px 12px;
}
.books-box span { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold-dim); }
.books-box b { font-family: var(--font-display); font-size: 22px; color: var(--cream); }

.set-meter { margin-top: 10px; font-size: 12.5px; line-height: 1.5; color: var(--cream-dim); min-height: 18px; }
.set-meter .safe { color: var(--good); }
.set-meter .danger { color: var(--bad); }

.log-panel { flex: 1; }
.log { max-height: 220px; overflow-y: auto; font-size: 12.5px; line-height: 1.55; color: var(--cream-dim); }
.log p { padding: 3px 0; border-bottom: 1px dashed rgba(212,169,78,.14); }
.log p b { color: var(--cream); font-weight: 600; }
.log p.hl { color: var(--gold-bright); }

/* ---------- overlays & modals ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 60; display: none;
  /* Dialogs taller than the screen (phones, landscape) scroll instead of being
     cut off: flex + margin:auto on the dialog centers it when it fits and
     top-aligns it when it doesn't. */
  align-items: flex-start; justify-content: center;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(12, 5, 3, .78); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.overlay.show { display: flex; }

.modal, .splash-card {
  background:
    radial-gradient(120% 100% at 50% 0%, #47231a 0%, #2c1512 55%, #1d0e0b 100%);
  border: 1px solid rgba(212, 169, 78, .45); border-radius: 24px;
  padding: 34px 38px; max-width: 480px; width: 100%; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.7); margin: auto;
  animation: modalIn .35s cubic-bezier(.2, .9, .3, 1.15) both;
}
.modal.wide { max-width: 640px; text-align: left; }

@keyframes modalIn { from { opacity: 0; transform: scale(.92) translateY(14px); } }

.modal-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--cream); margin-bottom: 12px; }
.modal-note { font-size: 12.5px; color: var(--cream-dim); margin-bottom: 16px; font-style: italic; }

.splash-kicker { font-size: 11px; letter-spacing: .4em; text-transform: uppercase; color: var(--gold-dim); margin-bottom: 10px; }
.splash-title { text-wrap: balance; font-family: var(--font-display); font-size: 58px; font-weight: 800; color: var(--gold-bright); line-height: 1; margin-bottom: 16px; }
.splash-title em { font-style: italic; font-weight: 300; color: var(--cream); }
.splash-tag { text-wrap: balance; font-family: var(--font-display); font-style: italic; font-size: 18px; color: var(--cream); opacity: .85; margin: -6px 0 14px; }
.splash-copy { font-size: 14.5px; line-height: 1.65; color: var(--cream-dim); margin-bottom: 26px; }

.stamp {
  display: inline-block; font-family: var(--font-display); font-weight: 800; font-size: 20px;
  letter-spacing: .18em; text-transform: uppercase; padding: 6px 18px; margin-bottom: 14px;
  border: 3px double currentColor; border-radius: 6px; transform: rotate(-4deg);
}
.stamp.made { color: var(--good); }
.stamp.set { color: var(--bad); }

.summary-body { font-size: 14px; line-height: 1.7; color: var(--cream-dim); margin-bottom: 22px; }
.summary-body b { color: var(--cream); }
.summary-body .delta { font-family: var(--font-display); font-size: 30px; display: block; margin: 8px 0; }
.summary-body .delta.pos { color: var(--good); }
.summary-body .delta.neg { color: var(--bad); }

.settings { display: flex; flex-direction: column; gap: 10px; text-align: left; margin-bottom: 22px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13.5px; }
.setting select {
  background: rgba(0,0,0,.4); color: var(--cream); border: 1px solid var(--gold-dim);
  border-radius: 8px; padding: 5px 10px; font-family: var(--font-body);
}
.setting.check { justify-content: flex-start; cursor: pointer; }
.setting.check input { accent-color: var(--gold); width: 16px; height: 16px; }

/* ---------- online / lobby ---------- */

.splash-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.splash-actions .btn { width: 100%; max-width: 280px; }
.splash-profile {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 20px;
  background: rgba(0,0,0,.25); border: 1px solid rgba(212,169,78,.3);
  border-radius: 999px; padding: 6px 16px 6px 6px; cursor: pointer;
  color: var(--cream-dim); font-size: 13px; font-family: var(--font-body);
  transition: border-color .2s;
}
.splash-profile:hover { border-color: var(--gold-bright); }
.splash-profile b { color: var(--cream); }
.edit-link { color: var(--gold-bright); }

.setting input[type="text"] {
  background: rgba(0,0,0,.4); color: var(--cream); border: 1px solid var(--gold-dim);
  border-radius: 8px; padding: 6px 10px; font-family: var(--font-body); width: 190px;
}
.setting input[type="text"]:focus { outline: none; border-color: var(--gold-bright); }

/* Server URL — full-width field with the label above it. */
.online-field { text-align: left; margin: 4px 0 14px; }
.online-field label {
  display: block; font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--gold-dim); margin-bottom: 5px;
}
.online-field input {
  width: 100%; background: rgba(0,0,0,.4); color: var(--cream);
  border: 1px solid var(--gold-dim); border-radius: 8px; padding: 8px 12px;
  font-family: var(--font-body); font-size: 14px;
}
.online-field input:focus { outline: none; border-color: var(--gold-bright); }

/* Host / Join — two balanced panels with an "or" between them. */
.online-split { display: flex; gap: 12px; margin: 6px 0 4px; align-items: stretch; }
.online-col {
  flex: 1; display: flex; flex-direction: column; gap: 9px; padding: 16px 14px;
  justify-content: center; text-align: center;
  background: rgba(0,0,0,.25); border: 1px solid rgba(212,169,78,.25); border-radius: 14px;
}
.online-col .btn { width: 100%; white-space: nowrap; font-size: 12.5px; letter-spacing: .04em; }
.online-or {
  align-self: center; font-family: var(--font-display); font-style: italic;
  font-size: 14px; color: var(--gold-dim); padding: 0 2px;
}
.online-sub { font-size: 11.5px; color: var(--gold-dim); text-align: center; font-style: italic; }

.code-badge, .code-key { font-family: var(--font-display); letter-spacing: .28em; text-transform: uppercase; }
.code-input {
  width: 100%; background: rgba(0,0,0,.4); color: var(--gold-bright);
  border: 1px solid var(--gold-dim); border-radius: 8px; padding: 8px 10px;
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
  letter-spacing: .22em; text-transform: uppercase; text-align: center;
}
.code-input::placeholder { color: rgba(212,169,78,.4); letter-spacing: .14em; }
.code-input:focus { outline: none; border-color: var(--gold-bright); }
.online-error { color: var(--bad); font-size: 12.5px; min-height: 18px; margin: 8px 0; }

/* profile summary (in the online setup) + editor */
.btn.small { font-size: 11px; padding: 6px 12px; }
.profile-summary {
  display: flex; align-items: center; gap: 14px; justify-content: flex-start;
  background: rgba(0,0,0,.25); border: 1px solid rgba(212,169,78,.25);
  border-radius: 14px; padding: 10px 14px; margin: 4px 0 14px;
}
.profile-summary-name { font-family: var(--font-display); font-size: 18px; color: var(--cream); flex: 1; text-align: left; }
.profile-editor { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-bottom: 22px; }
.profile-name { width: 100%; max-width: 280px; justify-content: space-between; }
.profile-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

.code-badge {
  color: var(--gold-bright); background: rgba(0,0,0,.3); border: 1px solid var(--gold-dim);
  border-radius: 8px; padding: 2px 12px; font-size: 22px;
}
.copy-key { margin-bottom: 14px; }

/* Lobby invite: QR + copy buttons. */
.share-box { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 2px 0 16px; }
.qr { width: 150px; height: 150px; border-radius: 10px; overflow: hidden; background: #f6efdd; box-shadow: 0 3px 12px rgba(0,0,0,.45); }
.qr:empty { display: none; }
.qr svg { display: block; width: 100%; height: 100%; }
.share-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.roster { list-style: none; display: flex; flex-direction: column; gap: 8px; margin: 4px 0 20px; text-align: left; }
.roster li {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 12px;
  background: rgba(0,0,0,.28); border: 1px solid rgba(212,169,78,.2);
}
.roster .seat-dot {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-display); font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.roster .team-a .seat-dot { background: rgba(212,169,78,.25); color: var(--gold-bright); }
.roster .team-b .seat-dot { background: rgba(120,120,140,.2); color: var(--cream-dim); }
.avatar.seat-empty { background: rgba(120,120,140,.18); border-style: dashed; color: var(--cream-dim); font-size: 13px; font-family: var(--font-display); }
.roster .r-name { font-family: var(--font-display); font-size: 15px; color: var(--cream); flex: 1; }
.roster .r-tag { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-dim); }
.roster .r-tag.you { color: var(--gold-bright); }


.howto { font-size: 13.5px; line-height: 1.7; color: var(--cream-dim); margin-bottom: 20px; }
.howto p { margin-bottom: 10px; }
.howto b { color: var(--gold-bright); font-weight: 600; }
.howto i { color: var(--cream); }

/* ---------- responsive ---------- */

@media (max-width: 1120px) {
  .layout { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; }
  .side .panel { flex: 1 1 240px; }
}

@media (max-width: 760px) {
  :root { --card-w: 52px; --card-h: 74px; }
  .table { height: 480px; border-radius: 28px; }
  .card .pip { font-size: 22px; }
  .card .idx { font-size: 12px; }
  .brand { font-size: 24px; }
  .tagline { display: none; }
  .topbar { flex-wrap: wrap; }
  .splash-title { font-size: 40px; }
  .hand { padding: 0 8px; }
  .opp-hand.vertical .card { margin: -34px 0; }
}

/* Server URL tucked away — it's this site, so players never need it. */
.online-advanced { text-align: left; margin: 0 0 12px; }
.online-advanced summary {
  cursor: pointer; font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--gold-dim); list-style: none; padding: 4px 0;
}
.online-advanced summary::-webkit-details-marker { display: none; }
.online-advanced summary::before { content: "▸ "; }
.online-advanced[open] summary::before { content: "▾ "; }
.online-advanced .online-field { margin: 8px 0 4px; }
.online-advanced .online-sub { text-align: left; margin-top: 6px; }


/* Text fields at 16px+ so iPhone/iPad Safari doesn't zoom the page on focus. */
input[type="text"], input:not([type]), select { font-size: 16px; }

/* =====================================================================
   RESPONSIVE — phones, tablets, short laptop screens, phones sideways
   ===================================================================== */

/* Compact header score + ☰ menu (hidden on wide screens). */
.topbar { position: relative; }
.mini-score, .menu-toggle { display: none; }
.mini-score {
  align-items: baseline; gap: 6px; font-family: var(--font-display);
  background: rgba(0,0,0,.28); border: 1px solid rgba(212,169,78,.3);
  border-radius: 999px; padding: 4px 12px; white-space: nowrap;
}
.mini-score b { font-size: 18px; color: var(--cream); }
.mini-score span:first-child b { color: var(--gold-bright); }
.mini-score small { font-family: var(--font-body); font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-dim); }
.mini-dash { color: var(--gold-dim); }

/* Score panel drops below the table here, so keep the score in the header. */
@media (max-width: 1120px) {
  .mini-score { display: inline-flex; }
}

/* Laptops / iPad landscape with short screens: scale the table so the action
   bar stays on screen. */
@media (min-width: 761px) and (min-height: 501px) and (max-height: 900px) {
  :root { --card-w: 64px; --card-h: 90px; }
  .table { height: clamp(460px, calc(100vh - 275px), 640px); height: clamp(460px, calc(100dvh - 275px), 640px); }
  .card .pip { font-size: 28px; }
  .trick .played { top: 48%; }
}

/* ---------- phones (portrait) ---------- */
@media (max-width: 600px) {
  :root { --card-w: 50px; --card-h: 72px; }
  .room { padding: 0 max(10px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }

  .topbar { align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 2px 8px; flex-wrap: nowrap; }
  .brand { font-size: clamp(17px, 5.6vw, 22px); flex: 1; min-width: 0; white-space: nowrap; }
  .brand-sub { font-size: 8px; margin-top: 3px; letter-spacing: .36em; }
  .brand-name { overflow: hidden; text-overflow: ellipsis; padding-right: 2px; }
  .tagline { display: none; }
  .menu-toggle { display: inline-flex; align-items: center; padding: 7px 13px; font-size: 17px; line-height: 1; letter-spacing: 0; }
  .topnav {
    display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 55;
    flex-direction: column; gap: 8px; padding: 12px; min-width: 200px;
    background: #2a1511; border: 1px solid rgba(212,169,78,.4); border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0,0,0,.6);
  }
  .topbar.menu-open .topnav { display: flex; }
  .topnav .btn { width: 100%; padding: 11px 14px; }

  .layout { margin-top: 10px; gap: 12px; }
  .table {
    height: clamp(330px, calc(100vh - 244px), 540px);
    height: clamp(330px, calc(100dvh - 244px), 540px);
    border-radius: 24px;
  }
  .rail { inset: 6px; border-radius: 19px; }

  /* Opponents in a row across the top: left · partner · right. */
  .seat-north, .seat-west, .seat-east { width: 32%; top: 10px; transform: none; gap: 4px; }
  .seat-north { left: 34%; }
  .seat-west { left: 1.5%; }
  .seat-east { left: auto; right: 1.5%; }
  .seat:not(.seat-south) .nameplate { flex-direction: column; gap: 3px; padding: 6px 4px; width: 100%; }
  .seat:not(.seat-south) .nameplate .np-text { align-items: center; max-width: 100%; text-align: center; }
  .nameplate .pname, .nameplate .prole { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nameplate .pname { font-size: 13px; }
  .nameplate .prole { font-size: 8px; letter-spacing: .12em; }
  .seat:not(.seat-south) .avatar { width: 30px; height: 30px; font-size: 17px; }
  .bid-chip { font-size: 11px; padding: 3px 8px; max-width: 100%; line-height: 1.3; }

  /* You: hand on top, then [nameplate | your bid] in one row beneath it. */
  .seat-south {
    bottom: 6px; flex-direction: row; flex-wrap: wrap;
    justify-content: center; align-items: center; column-gap: 8px; row-gap: 4px;
  }
  .seat-south .hand { order: 1; flex: 0 0 100%; padding: 0 6px; min-height: calc(var(--card-h) + 12px); }
  .seat-south .hand.two-rows { min-height: calc(var(--card-h) * 1.6 + 12px); }
  .seat-south .nameplate { order: 2; padding: 3px 10px 3px 4px; }
  .seat-south .bid-chip { order: 3; }
  .seat-south .bid-chip:empty { display: none; }
  .seat-south .avatar { width: 24px; height: 24px; font-size: 14px; }

  .card { border-radius: 6px; }
  .card .pip { font-size: 21px; }
  .card .idx { font-size: 12px; top: 3px; left: 4px; }
  .card .idx.flip { bottom: 3px; right: 4px; }
  .card.joker .pip { font-size: 19px; }
  .card.joker .idx { font-size: 8px; }

  .kitty { top: 50%; }
  .kitty .card { width: 30px; height: 42px; margin: 0 -11px; }
  .kitty::after { margin-left: 16px; font-size: 9px; }
  .trick .played { top: 50%; }
  .trick .played.from-0 { transform: translate(-50%, -50%) translateY(38px) rotate(-2deg); }
  .trick .played.from-1 { transform: translate(-50%, -50%) translateX(-52px) rotate(5deg); }
  .trick .played.from-2 { transform: translate(-50%, -50%) translateY(-38px) rotate(2deg); }
  .trick .played.from-3 { transform: translate(-50%, -50%) translateX(52px) rotate(-5deg); }
  .table-msg { top: calc(50% + 34px); font-size: 14px; white-space: normal; width: 88%; }

  /* Bid panel: three compact rows — amounts, direction, Place Bid / Pass. */
  .action-bar { margin-top: 10px; min-height: 0; padding: 10px; gap: 8px; border-radius: 14px; }
  .bid-group .lbl { display: none; }
  .bid-col { width: 100%; gap: 6px; }
  .bid-col:last-child { flex-direction: row; justify-content: center; }
  .bid-col:last-child .btn { flex: 1; max-width: 170px; }
  .chipbtn { width: 40px; height: 40px; font-size: 15px; }
  .chipbtn.wide { padding: 0 12px; font-size: 13px; }
  .action-hint { font-size: 14px; text-align: center; }

  .side { flex-direction: column; }
  .score-num { font-size: 34px; }

  /* Dialogs */
  .modal, .splash-card { padding: 24px 18px; border-radius: 20px; }
  .modal-title { font-size: 22px; }
  .splash-title { font-size: 46px; }
  .splash-kicker { letter-spacing: .22em; }
  .splash-copy { font-size: 14px; }
  .online-split { flex-direction: column; }
  .online-or { padding: 0; }
  .profile-summary { flex-wrap: wrap; justify-content: center; }
  .profile-summary-name { flex: 1 1 auto; }
  .qr { width: 136px; height: 136px; }
  .share-actions .btn { flex: 1 1 140px; }
  .settings .setting { flex-wrap: wrap; }
  .profile-name input { width: 100%; }
}

/* ---------- phones held sideways (short landscape) ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --card-w: 46px; --card-h: 66px; }
  .room { padding: 0 max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .topbar { align-items: center; gap: 10px; padding: 6px 2px 4px; flex-wrap: nowrap; }
  .brand { font-size: 20px; flex: 1; white-space: nowrap; }
  .brand-sub { display: none; }
  .splash-tag { font-size: 15px; margin: -2px 0 8px; }
  .tagline { display: none; }
  .mini-score { display: inline-flex; }
  .menu-toggle { display: inline-flex; align-items: center; padding: 6px 12px; font-size: 16px; line-height: 1; }
  .topnav {
    display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 55;
    flex-direction: column; gap: 6px; padding: 10px; min-width: 190px;
    background: #2a1511; border: 1px solid rgba(212,169,78,.4); border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0,0,0,.6);
  }
  .topbar.menu-open .topnav { display: flex; }
  .topnav .btn { width: 100%; padding: 9px 14px; }

  /* Table on the left, controls in a column on the right. */
  .layout { margin-top: 6px; gap: 10px; }
  .table-zone { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 10px; align-items: stretch; }
  .table { height: calc(100vh - 62px); height: calc(100dvh - 62px); min-height: 250px; border-radius: 22px; }
  .rail { inset: 6px; border-radius: 17px; }
  .action-bar { margin-top: 0; flex-direction: column; justify-content: center; padding: 10px; gap: 8px; }
  .bid-group .lbl { display: none; }
  .bid-col { width: 100%; gap: 6px; }
  .bid-col:last-child { flex-direction: row; }
  .bid-col:last-child .btn { flex: 1; }
  .chipbtn { width: 36px; height: 36px; font-size: 14px; }
  .chipbtn.wide { padding: 0 9px; font-size: 12px; }
  .action-hint { font-size: 14px; text-align: center; }

  /* Seats: partner top-center as a slim row; opponents mid-left/right. */
  .seat-north, .seat-west, .seat-east { width: auto; max-width: 30%; gap: 3px; }
  .seat-north { top: 8px; flex-direction: row; align-items: center; }
  .seat-west { left: 10px; }
  .seat-east { right: 10px; }
  .nameplate { padding: 3px 9px 3px 3px; gap: 6px; }
  .nameplate .pname { font-size: 12.5px; }
  .nameplate .prole { font-size: 8px; letter-spacing: .12em; }
  .avatar { width: 24px; height: 24px; font-size: 14px; }
  .bid-chip { font-size: 10.5px; padding: 2px 8px; max-width: 150px; }

  /* You: just the hand along the bottom; your bid pill tucked top-left. */
  .seat-south { bottom: 6px; }
  .seat-south .nameplate { display: none; }
  .seat-south .hand { padding: 0 8px; min-height: calc(var(--card-h) + 10px); }
  .seat-south .bid-chip { position: absolute; left: 4px; bottom: calc(100% + 4px); }
  .seat-south .bid-chip::before { content: "You · "; font-style: normal; color: var(--gold-dim); }
  .seat-south .bid-chip:empty::before { content: none; }

  .card .pip { font-size: 19px; }
  .card .idx { font-size: 11px; top: 3px; left: 4px; }
  .card .idx.flip { bottom: 3px; right: 4px; }
  .card.joker .idx { font-size: 7px; }
  .kitty { top: 42%; }
  .kitty .card { width: 28px; height: 40px; margin: 0 -10px; }
  .trick .played { top: 44%; }
  .trick .played.from-0 { transform: translate(-50%, -50%) translateY(30px) rotate(-2deg); }
  .trick .played.from-1 { transform: translate(-50%, -50%) translateX(-50px) rotate(5deg); }
  .trick .played.from-2 { transform: translate(-50%, -50%) translateY(-30px) rotate(2deg); }
  .trick .played.from-3 { transform: translate(-50%, -50%) translateX(50px) rotate(-5deg); }
  .table-msg { top: 62%; font-size: 13px; }

  .modal, .splash-card { padding: 20px 18px; }
  .splash-title { font-size: 38px; margin-bottom: 8px; }
  .splash-copy { margin-bottom: 14px; }
}

/* ---------- lobby teams ---------- */
.teams-hint { font-size: 12px; color: var(--cream-dim); font-style: italic; margin: 2px 0 10px; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 18px; text-align: left; }
.team-card {
  background: rgba(0,0,0,.25); border: 1px solid rgba(212,169,78,.22); border-radius: 14px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.team-card.mine { border-color: var(--gold-bright); box-shadow: 0 0 0 1px rgba(240,205,120,.25), 0 0 18px rgba(240,205,120,.12); }
.team-card.team-b.mine { border-color: #b9b6d6; }
.team-head { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.team-title {
  font-family: var(--font-display); font-size: 18px; color: var(--cream);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.team-name-input {
  width: 100%; font-family: var(--font-display); font-size: 17px; font-weight: 600;
  color: var(--gold-bright); background: rgba(0,0,0,.4);
  border: 1px dashed var(--gold); border-radius: 8px; padding: 6px 9px;
}
.team-name-input:focus { outline: none; border-style: solid; border-color: var(--gold-bright); }
.team-captain { font-size: 10.5px; letter-spacing: .06em; color: var(--gold-dim); }
.team-card .roster { margin: 0; gap: 6px; }
.team-card .roster li { padding: 7px 9px; gap: 8px; }
.team-card .roster .r-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.team-card .roster .avatar { width: 28px; height: 28px; font-size: 16px; }
.roster .r-tag.cap { color: var(--gold-bright); }
.join-team { width: 100%; }
.team-you { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-bright); text-align: center; }
/* Long team names truncate instead of pushing the score layout around. */
.score-team { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.books-box span { max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-score small { display: inline-block; max-width: 8ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
@media (max-width: 600px) {
  .teams { grid-template-columns: 1fr; }
}

.team-card .roster .r-name { flex: 1 1 auto; min-width: 3ch; }
.team-card .roster .r-tag { flex-shrink: 0; font-size: 9px; letter-spacing: .12em; }
.cap-star { color: var(--gold-bright); margin-right: 4px; font-size: 12px; }

/* ---------- host seat controls (lobby) ---------- */
.teams-hint.active { color: var(--gold-bright); font-style: normal; font-weight: 600; }
.team-card .roster li.assignable { cursor: pointer; transition: border-color .15s, background .15s; }
@media (hover: hover) and (pointer: fine) {
  .team-card .roster li.assignable:hover { border-color: rgba(240,205,120,.6); }
}
.team-card .roster li.picked {
  border-color: var(--gold-bright); background: rgba(240,205,120,.14);
  box-shadow: 0 0 0 1px var(--gold-bright) inset;
}
.team-card .roster li.drop-target { border-style: dashed; border-color: rgba(240,205,120,.55); }
.seat-act {
  flex-shrink: 0; margin-left: auto; font-family: var(--font-body); font-size: 10px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--gold-bright);
  background: rgba(0,0,0,.35); border: 1px solid var(--gold-dim); border-radius: 999px;
  padding: 5px 8px; cursor: pointer; min-height: 28px; white-space: nowrap;
}
.team-card .roster li.assignable { padding-right: 6px; }
.seat-act:hover { border-color: var(--gold-bright); }
#modal-gameover #btn-to-lobby { margin-top: 10px; }

/* narrowest phones: the header goes by its short name, "Da Kitty" */
@media (max-width: 380px) { .brand-gm { display: none; } .brand { font-size: 22px; } }
