/* Card look and felt table borrowed from ../spider. */
@font-face {
  font-family: "Spider Symbola";
  src: url("fonts/Symbola.ttf") format("truetype");
  font-display: block;
}
@font-face {
  font-family: "Spider Cantarell";
  src: url("fonts/Cantarell-VF.otf") format("opentype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --felt: #177954;
  --felt-mid: #126545;
  --felt-dark: #092d25;
  --felt-line: rgba(232, 255, 238, 0.09);
  --ink: #f7f0dc;
  --muted: rgba(247, 240, 220, 0.66);
  --card: #ffffff;
  --card-edge: #d9dee7;
  --card-ink: #1a2027;
  --red: #bc1f3c;
  --black: #17202a;
  --gold: #e6bb55;
  --gold-deep: #b98a1f;
  --copper: #b45c38;
  --partner: #9b6cf0;
  --defender: #5aa9e6;
  --good: #7fe0a6;
  --bad: #ff8a8a;
  --panel: rgba(6, 17, 19, 0.74);
  --panel-border: rgba(255, 242, 199, 0.16);
  --shadow: 0 1.2rem 3rem rgba(0, 0, 0, 0.34);
  --suit-font: "Spider Symbola", Symbola, "Noto Sans Symbols 2", "DejaVu Sans", "Segoe UI Symbol", "Apple Symbols", sans-serif;
  --ui-font: "Spider Cantarell", Cantarell, ui-sans-serif, system-ui, sans-serif;
  --card-back:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 28%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.14) 0 0.28rem, transparent 0.28rem 0.56rem),
    repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.16) 0 0.28rem, transparent 0.28rem 0.56rem),
    linear-gradient(145deg, #2a4960, #1a2e3d);
  --card-ratio: 1.5;
  --trick-w: clamp(3.6rem, 12vw, 5.4rem);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }

body {
  font-family: var(--ui-font);
  color: var(--ink);
  background:
    linear-gradient(90deg, var(--felt-line) 1px, transparent 1px) 0 0 / 2.05rem 2.05rem,
    linear-gradient(0deg, var(--felt-line) 1px, transparent 1px) 0 0 / 2.05rem 2.05rem,
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 6px),
    linear-gradient(160deg, var(--felt) 0%, var(--felt-mid) 48%, var(--felt-dark) 100%);
  background-attachment: fixed;
}

button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.center { text-align: center; }
.sym { font-family: var(--suit-font); }

/* ---------- buttons, pills, panels ---------- */

.btn {
  height: 2.45rem;
  padding: 0 0.95rem;
  border: 1px solid rgba(196, 224, 241, 0.26);
  border-radius: 7px;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)), #213b4e;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.13), 0 0.35rem 0.8rem rgba(0, 0, 0, 0.18);
  font-weight: 650;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: rgba(196, 224, 241, 0.52); background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.035)), #29485e; }
.btn.primary { color: #1b242d; border-color: rgba(255, 230, 160, 0.7); background: linear-gradient(145deg, #ffe08a, var(--gold)); }
.btn.primary:hover:not(:disabled) { background: linear-gradient(145deg, #ffe9a8, #f0c766); }
.btn.danger { background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent), #6b2533; }
.btn.small { height: 2rem; padding: 0 0.65rem; font-size: 0.88rem; }
.btn.tiny { height: 1.5rem; padding: 0 0.45rem; font-size: 0.72rem; border-radius: 5px; }
.btn.big { height: 3rem; padding: 0 1.4rem; font-size: 1.05rem; }

.pill {
  display: inline-flex;
  align-items: center;
  height: 1.3rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  white-space: nowrap;
}
.pill.dealer { background: #e9eef5; color: #1b242d; }
.pill.picker { background: var(--gold); color: #1b242d; }
.pill.partner { background: var(--partner); color: #fff; }
.pill.partner.secret { background: transparent; border: 1.5px dashed var(--partner); color: #d5c2ff; }
.pill.off { background: #6b2533; }
.pill.bot { background: #355a73; }
.pill.you { background: var(--gold); color: #1b242d; }
.pill.mult { background: var(--copper); }
.pill.new { background: #2f8f5b; color: #fff; }
.pill.rec { background: #2f8f5b; color: #fff; }

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0)), var(--panel);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.panel h2 { margin: 0 0 0.7rem; font-size: 1.1rem; }

.coin {
  display: inline-grid;
  place-items: center;
  min-width: 1.35em;
  height: 1.35em;
  padding: 0 0.2em;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, #fff1b8, var(--gold) 60%, var(--gold-deep));
  color: #3a2a00;
  font-weight: 900;
  font-size: 0.82em;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  vertical-align: 0.05em;
}

/* Inline card chip: "Q♥". Trump chips are gold-backed, like trump cards. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.05em;
  padding: 0.05em 0.35em;
  border-radius: 5px;
  background: #fff;
  border: 1px solid var(--card-edge);
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
}
.chip.red { color: var(--red); }
.chip.black { color: var(--black); }
.chip.trump { background: linear-gradient(180deg, #fff6d8, #f6dd96); border-color: var(--gold-deep); }
.chip.big { font-size: 1.25em; padding: 0.1em 0.45em; }
.chip.alone-chip { color: #1b242d; background: var(--gold); text-transform: uppercase; font-size: 0.75em; }

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

.card {
  position: relative;
  container-type: inline-size;
  flex: 0 0 auto;
  width: var(--w, 5rem);
  aspect-ratio: 1 / var(--card-ratio);
  border: 1px solid var(--card-edge);
  border-radius: 8px;
  color: var(--card-ink);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 34%),
    linear-gradient(180deg, var(--card), #f4f7fb);
  box-shadow:
    0 0.34rem 0.66rem rgba(5, 17, 17, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.62),
    inset 0 -0.35rem 0 rgba(53, 70, 96, 0.045);
  user-select: none;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease, opacity 140ms ease;
}
.card.red { color: var(--red); }
.card.black { color: var(--black); }

/* Trump cards: warm gold face and edge, so "diamonds are trump" is visible. */
.card.trump {
  border: 2px solid var(--gold-deep);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 34%),
    linear-gradient(180deg, #fff8e2, #f7e3a6);
}

.card-face {
  height: 100%;
  display: grid;
  grid-template-rows: 20cqw 1fr 20cqw;
  padding: 6cqw;
}
.corner {
  display: grid;
  gap: 1.6cqw;
  justify-items: center;
  justify-self: start;
  align-self: start;
  line-height: 0.95;
  font-weight: 900;
  font-size: 18cqw;
  width: 20cqw;
}
.corner.bottom { justify-self: end; align-self: end; transform: rotate(180deg); }
.suit-main {
  place-self: center;
  font-family: var(--suit-font);
  font-size: 43cqw;
  opacity: 0.94;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  line-height: 1;
}
.suit-main.face {
  font-family: var(--ui-font);
  font-weight: 900;
  font-size: 36cqw;
  display: flex;
  align-items: baseline;
}
.suit-main.face .sym { font-size: 24cqw; }

.card .pts {
  position: absolute;
  top: 5cqw;
  right: 5cqw;
  display: grid;
  place-items: center;
  width: 25cqw;
  height: 25cqw;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1b8, var(--gold) 60%, var(--gold-deep));
  color: #3a2a00;
  font-weight: 900;
  font-size: 13cqw;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.card .trump-band {
  position: absolute;
  left: 5cqw;
  bottom: 6cqw;
  padding: 1cqw 3cqw;
  border-radius: 3cqw;
  background: var(--gold-deep);
  color: #fff;
  font-size: 9.5cqw;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.card .trump-band b { font-size: 11cqw; }

.card-tag {
  position: absolute;
  left: 50%;
  top: -0.65rem;
  transform: translateX(-50%);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: #fff;
  background: #333;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  z-index: 2;
}
.card-tag + .card-tag { top: auto; bottom: -0.65rem; }
.card-tag.partner { background: var(--partner); }
.card-tag.wins { background: #2f8f5b; }
.card-tag.win { background: var(--gold); color: #1b242d; }
.card-tag.led { background: #355a73; top: auto; bottom: -0.65rem; }
.card-tag.new { background: #2f8f5b; }
.card-tag.bury { background: var(--copper); top: auto; bottom: -0.65rem; }

.card.partner-card { box-shadow: 0 0 0 3px var(--partner), 0 0.4rem 0.8rem rgba(0, 0, 0, 0.3); }
.card.back { background: var(--card-back); border-color: rgba(255, 242, 199, 0.3); }
.card.placeholder {
  display: grid;
  place-items: center;
  background: rgba(3, 24, 20, 0.2);
  border: 1px dashed rgba(255, 242, 199, 0.25);
  box-shadow: none;
  color: var(--gold);
  font-size: 1.6rem;
}

/* Hand interaction states */
.hand .card.playable { cursor: pointer; }
.hand .card.playable:hover { transform: translateY(-0.4rem); }
.hand .card.selected { transform: translateY(-1rem); box-shadow: 0 0 0 3px var(--gold), 0 0.8rem 1.4rem rgba(0, 0, 0, 0.4); }
.hand .card.bury-sel { transform: translateY(-1rem); box-shadow: 0 0 0 3px var(--copper), 0 0.8rem 1.4rem rgba(0, 0, 0, 0.4); }
.hand .card.blocked { filter: grayscale(0.7) brightness(0.72); cursor: help; }

/* ---------- home & lobby ---------- */

.home, .lobby {
  max-width: 46rem;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  display: grid;
  gap: 1rem;
}
.logo {
  margin: 1.5rem 0 0;
  font-size: clamp(2.4rem, 9vw, 3.6rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.logo span { color: var(--gold); }
.logo.small { font-size: 1.8rem; margin: 0; }
.tagline { margin: -0.5rem 0 0.5rem; color: var(--muted); }
.home-form { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem; }
.home-form label { flex: 1 1 14rem; display: grid; gap: 0.35rem; font-weight: 650; }
.home-form label.check { flex-basis: 100%; display: block; font-weight: 500; font-size: 0.92rem; }
.home-form label.check input { accent-color: var(--gold); margin-right: 0.35rem; }
input[type="text"], input:not([type]) {
  height: 2.6rem;
  padding: 0 0.75rem;
  border: 1px solid rgba(255, 242, 199, 0.28);
  border-radius: 7px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.3);
}
.center-msg { padding: 4rem 1rem; text-align: center; font-size: 1.1rem; }

.lobby-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.invite { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.code { font-size: 1.2rem; letter-spacing: 0.12em; color: var(--gold); }
.seat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.seat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.8rem;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}
.seat-num {
  display: grid; place-items: center;
  width: 1.7rem; height: 1.7rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 800;
}
.row-actions { margin-left: auto; display: flex; gap: 0.4rem; }
.opt-group h3 { margin: 0.9rem 0 0.4rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.opts { display: grid; gap: 0.45rem; }
.opts.row { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.opt {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.1rem 0.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.18);
}
.opt input { grid-row: span 2; margin-top: 0.2rem; accent-color: var(--gold); }
.opt span { color: var(--muted); font-size: 0.86rem; }
.opt.on { border-color: var(--gold); background: rgba(230, 187, 85, 0.12); }
.lobby-start { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem; }


.meter-wrap { padding: 0.55rem 0.8rem 0.6rem; border-radius: 9px; border: 1px solid var(--panel-border); background: var(--panel); }
.meter {
  position: relative;
  display: flex;
  height: 1.05rem;
  margin: 1.1rem 0 0.4rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
.meter .seg { height: 100%; transition: width 400ms ease; }
.meter .seg.picker { background: linear-gradient(180deg, #ffe08a, var(--gold-deep)); border-radius: 999px 0 0 999px; }
.meter .seg.unknown { background: repeating-linear-gradient(45deg, #8a8f96 0 4px, #6f747a 4px 8px); }
.meter .seg.def { background: linear-gradient(180deg, #8fd0ff, #2f7fbf); border-radius: 0 999px 999px 0; }
.meter .tick { position: absolute; top: -0.25rem; bottom: -0.25rem; width: 2px; background: rgba(255, 255, 255, 0.55); }
.meter .tick.main { width: 3px; background: #fff; }
.meter .tick span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: 0.68rem; font-weight: 800; white-space: nowrap; color: var(--muted); }
.meter .tick.main span { color: var(--ink); }
.meter-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; font-size: 0.85rem; }
.sw { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 3px; margin-right: 0.3rem; vertical-align: -0.05rem; }
.sw.picker { background: var(--gold); }
.sw.unknown { background: #7d8288; }
.sw.def { background: #4f9fdc; }
.meter-notes { margin-top: 0.25rem; font-size: 0.82rem; line-height: 1.4; }

.trick { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; }
.slot { display: grid; justify-items: center; gap: 0.5rem; }
.slot .card { --w: var(--trick-w); }
.slot.winner .card { box-shadow: 0 0 0 3px var(--gold), 0 0 1.3rem rgba(230, 187, 85, 0.5); }
.slot.turn .card.placeholder { border-color: var(--gold); animation: glow-gold 1.6s ease-in-out infinite; }
@keyframes glow-gold { 50% { box-shadow: 0 0 1rem rgba(230, 187, 85, 0.5); } }
.slot-name { font-size: 0.78rem; font-weight: 700; max-width: var(--trick-w); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.card.in-trick { animation: drop-in 220ms ease-out; }
@keyframes drop-in { from { transform: translateY(-0.8rem) scale(0.96); opacity: 0; } }
.rungs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.1rem; flex: 1; }
.rung { display: inline-flex; flex-direction: column; align-items: center; transition: opacity 200ms ease; }
.rung .chip { font-size: 0.82rem; padding: 0.05em 0.25em; }
.rung.gone { opacity: 0.28; }
.rung.gone .chip { text-decoration: line-through; }
.rung.mine .chip { box-shadow: 0 0 0 2px var(--good); }
.rung.called .chip { box-shadow: 0 0 0 2px var(--partner); }
.rung small { font-size: 0.62rem; color: var(--muted); }
.gt { color: var(--muted); font-style: normal; font-size: 0.75rem; }
.ladder-left { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.fail-order b { font-weight: 900; }
.pts-legend { display: inline-flex; flex-wrap: wrap; gap: 0.15rem 0.5rem; align-items: center; }
.pts-legend .coin { margin-left: 0.15rem; }

.warn { color: #ffd38a; font-size: 0.88rem; margin-top: 0.2rem; }
.warn-inline { color: #ffd38a; font-weight: 700; }
.call-opts { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.call-opt {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.75rem;
  text-align: left;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.25);
}
.call-opt:hover { border-color: var(--gold); background: rgba(230, 187, 85, 0.12); }
.call-opt.rec { border-color: rgba(127, 224, 166, 0.6); }
.call-opt.alone { border-style: dashed; }
.call-opt small { color: var(--muted); }


/* ---------- overlay / modals ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.55);
  overflow-y: auto;
}
.overlay[hidden] { display: none; }
.modal {
  position: relative;
  width: min(40rem, 100%);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1.2rem 1.3rem;
  border: 1px solid rgba(230, 187, 85, 0.38);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent 34%),
    linear-gradient(145deg, rgba(230, 187, 85, 0.16), rgba(188, 31, 60, 0.06)),
    rgba(9, 25, 26, 0.98);
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.45);
  line-height: 1.45;
}
.modal h2 { margin: 0 2rem 0.6rem 0; font-size: 1.45rem; }
.modal h3 { margin: 1.1rem 0 0.3rem; font-size: 1rem; color: var(--gold); }
.modal p { margin: 0.45rem 0; }
.modal .close { position: absolute; top: 0.8rem; right: 0.8rem; }
.modal .trick { margin: 0.6rem 0; }
.modal-actions { display: flex; justify-content: center; margin-top: 1rem; }
.big-num { font-size: 1.25em; color: var(--gold); }
.meter.final { margin: 1.4rem 0 0.6rem; }
.score-table, .rules-table { width: 100%; border-collapse: collapse; margin: 0.6rem 0; font-size: 0.92rem; }
.score-table th, .score-table td, .rules-table th, .rules-table td { padding: 0.35rem 0.45rem; border-bottom: 1px solid rgba(255, 255, 255, 0.1); text-align: left; }
.score-table th, .rules-table th { color: var(--muted); font-weight: 700; font-size: 0.8rem; }
.score-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.score-table tr.me td { background: rgba(230, 187, 85, 0.1); }
.score-table.wide td.what { font-size: 0.85rem; }
.score-table tfoot td { border-top: 2px solid rgba(255, 255, 255, 0.25); }
.delta { font-weight: 800; font-variant-numeric: tabular-nums; }
.delta.pos { color: var(--good); }
.delta.neg { color: var(--bad); }
.scoring-help summary { cursor: pointer; color: var(--gold); font-weight: 700; margin-top: 0.6rem; }
.rules-ladder { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.menu-list { display: grid; gap: 0.5rem; }
.modal-actions { flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.game-over { margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid rgba(255, 255, 255, 0.15); }
.game-over h2 { color: var(--gold); }
.standings { margin: 0.5rem 0; padding-left: 1.4rem; display: grid; gap: 0.25rem; }
.standings li { display: flex; justify-content: space-between; max-width: 18rem; }
.standings li.top { font-weight: 800; color: var(--gold); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 2000;
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.75rem 1rem;
  border: 1px solid rgba(230, 187, 85, 0.45);
  border-radius: 8px;
  color: var(--ink);
  background: linear-gradient(145deg, rgba(230, 187, 85, 0.16), rgba(255, 255, 255, 0.035)), rgba(9, 27, 27, 0.97);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 0.75rem);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  line-height: 1.4;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }


/* =====================================================================
   Full-screen game layout. #app scrolls for the lobby; the game is fixed
   to the viewport and sized with container units so nothing scrolls.
   ===================================================================== */

html, body { height: 100%; }
#app { height: 100%; overflow-y: auto; }

/* Forced portrait: when a phone turns sideways, counter-rotate the page so
   it stays put relative to the device (set by applyRotation in app.js). */
html[data-rot="-90"] body,
html[data-rot="90"] body {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vh;
  height: 100vw;
  overflow: hidden;
  transform-origin: 0 0;
}
html[data-rot="-90"] body { transform: translateY(100vh) rotate(-90deg); }
html[data-rot="90"] body { transform: translateX(100vw) rotate(90deg); }

.game {
  position: fixed;
  inset: 0;
  container-type: size;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.75rem;
  padding: 0 0.75rem;
  background: rgba(0, 0, 0, 0.28);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  min-width: 0;
}
.topbar .spacer { flex: 1; }
.brand { font-weight: 900; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand span { color: var(--gold); }
.code-tag { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.code-tag b { color: var(--gold); letter-spacing: 0.06em; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 2rem;
  min-width: 2rem;
  justify-content: center;
  padding: 0 0.6rem;
  border-radius: 7px;
  border: 1px solid rgba(196, 224, 241, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-weight: 650;
  font-size: 0.82rem;
}
.icon-btn:hover:not(:disabled) { border-color: rgba(196, 224, 241, 0.5); background: rgba(255, 255, 255, 0.12); }
.glyph { font-style: normal; font-size: 1rem; line-height: 1; font-family: var(--suit-font); }
.standing-chip {
  height: 1.8rem;
  padding: 0 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(230, 187, 85, 0.45);
  background: rgba(230, 187, 85, 0.12);
  color: var(--ink);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* ---------- seat plates ---------- */
.plate {
  position: relative;
  display: grid;
  gap: 2px;
  min-width: 7.5rem;
  max-width: 12rem;
  padding: 0.4rem 0.65rem 0.4rem 0.8rem;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 0.8rem;
  transition: box-shadow 160ms ease, border-color 160ms ease;
}
.plate::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45rem;
  bottom: 0.45rem;
  width: 4px;
  border-radius: 0 3px 3px 0;
  background: rgba(255, 255, 255, 0.18);
}
.plate.side-picker::before { background: var(--gold); }
.plate.side-def::before { background: var(--defender); }
.plate.side-unknown::before { background: #7d8288; }
.plate.side-picker { background: linear-gradient(90deg, rgba(230, 187, 85, 0.16), transparent 70%), var(--panel); }
.plate.side-def { background: linear-gradient(90deg, rgba(90, 169, 230, 0.14), transparent 70%), var(--panel); }
.plate.turn { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(230, 187, 85, 0.5), 0 0 1.2rem rgba(230, 187, 85, 0.35); }
.plate-name { font-weight: 800; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plate-tags { display: flex; flex-wrap: wrap; gap: 3px; }
.plate-tags:empty { display: none; }
.plate-stats { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.76rem; min-height: 1.1rem; }
.plate-stats:empty { display: none; }
.plate.compact { min-width: 0; max-width: none; padding: 0.3rem 0.4rem 0.3rem 0.6rem; font-size: 0.72rem; }
.plate.compact .plate-name { font-size: 0.8rem; }
.tag {
  display: inline-block;
  padding: 0 0.35rem;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 800;
  line-height: 1.05rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.14);
  white-space: nowrap;
}
.tag.dealer { background: #e9eef5; color: #1b242d; }
.tag.picker { background: var(--gold); color: #1b242d; }
.tag.partner { background: var(--partner); color: #fff; }
.tag.partner.secret { background: transparent; border: 1.5px dashed var(--partner); color: #d5c2ff; line-height: 0.85rem; }
.tag.bot { background: #355a73; }
.tag.off { background: #6b2533; }

/* ---------- desk table ---------- */
.table { position: relative; min-height: 0; min-width: 0; }
.table.desk { container-type: size; --tw: min(17cqh, 8cqw); }
.table .oval {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 3%;
  bottom: 2%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.05);
  background: radial-gradient(ellipse at 50% 45%, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.12));
  box-shadow: inset 0 0 4rem rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.table.desk > .plate { position: absolute; transform: translate(-50%, -50%); }
.spot-at { position: absolute; transform: translate(-50%, -50%); }
.table .card, .table .spot { --w: var(--tw); }
.spot { width: var(--w); aspect-ratio: 1 / 1.5; border-radius: 8px; border: 1.5px dashed rgba(255, 242, 199, 0.22); }
.spot.turn { border-color: var(--gold); animation: glow-gold 1.6s ease-in-out infinite; }
.card.winner { box-shadow: 0 0 0 3px var(--gold), 0 0 1.3rem rgba(230, 187, 85, 0.55); }
.showing-prev .card.in-trick { opacity: 0.6; filter: saturate(0.7); animation: none; }
.caption {
  position: absolute;
  left: 50%;
  bottom: 1.5%;
  transform: translateX(-50%);
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 0.85rem;
  white-space: nowrap;
}
.caption:empty { display: none; }
.prev-pill {
  display: inline-block;
  padding: 0 0.45rem;
  margin-right: 0.2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.blind { display: flex; gap: 0.5rem; }
.blind .card { --w: calc(var(--tw) * 0.85); }

/* Corner panels: standings (left) and hand status (right). */
.corner-panel {
  position: absolute;
  top: 0.6rem;
  width: clamp(11rem, 17cqw, 15.5rem);
  max-height: calc(100% - 1.2rem);
  overflow-y: auto;
  display: grid;
  gap: 0.55rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 0.85rem;
  line-height: 1.35;
}
.standings-panel { left: 0.6rem; }
.status-panel { right: 0.6rem; }
.corner-panel h4 {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.2rem;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}
.corner-panel h4 span { color: var(--muted); font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 0.72rem; }
.corner-panel p { margin: 0; }
.status-panel section + section { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 0.5rem; }
.big-name { font-weight: 800; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.partner-card-big { margin: 0.15rem 0; }
.chip.xl { font-size: 1.7rem; padding: 0.08em 0.4em; border-radius: 7px; }
.partner-sec .who { color: var(--muted); font-weight: 700; }
.partner-sec.secret {
  margin: 0 -0.4rem;
  padding: 0.45rem 0.4rem;
  border-radius: 8px;
  border: 1.5px solid var(--partner);
  background: rgba(155, 108, 240, 0.18);
  animation: glow 2.4s ease-in-out infinite;
}
.partner-sec.secret + section { border-top: 0; }
.partner-sec.secret .who { color: #e2d4ff; }
.partner-sec.revealed .who { color: var(--ink); }
@keyframes glow { 50% { box-shadow: 0 0 1.2rem rgba(155, 108, 240, 0.45); } }
.status-panel .leaster h4 { color: var(--defender); }
.prow { display: grid; grid-template-columns: 3.6rem 1fr 1.8rem; align-items: center; gap: 0.4rem; font-size: 0.78rem; }
.prow .pbar { margin: 0; }
.prow b { text-align: right; }
.picker-line { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.picker-line h4 { margin: 0; }
.prow b { font-variant-numeric: tabular-nums; }
.gold { color: var(--gold); }
.blue { color: #8fd0ff; }
.pbar { position: relative; height: 0.5rem; margin: 0.15rem 0 0.35rem; border-radius: 999px; background: rgba(0, 0, 0, 0.4); }
.pbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; transition: width 400ms ease; }
.pbar i.p { background: linear-gradient(180deg, #ffe08a, var(--gold-deep)); }
.pbar i.d { background: linear-gradient(180deg, #8fd0ff, #2f7fbf); }
.pbar b { position: absolute; top: -2px; bottom: -2px; width: 1px; background: rgba(255, 255, 255, 0.35); }
.pbar b.m { width: 2px; background: #fff; }
.pnote { margin-top: 0.3rem !important; font-size: 0.74rem; line-height: 1.3; }
.status-panel .points { display: grid; gap: 0.3rem; }
.standings-panel ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.1rem; }
.standings-panel li {
  display: grid;
  grid-template-columns: 1.1rem minmax(0, 1fr) auto;
  gap: 0.35rem;
  align-items: baseline;
  padding: 0.12rem 0.35rem;
  border-radius: 5px;
}
.standings-panel li.me { background: rgba(230, 187, 85, 0.14); }
.standings-panel .place { color: var(--muted); font-weight: 800; font-size: 0.75rem; }
.standings-panel .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.standings-panel li.lead .nm::after { content: " ♛"; color: var(--gold); }
.standings-panel .sc { font-weight: 800; font-variant-numeric: tabular-nums; }
.sc.pos { color: var(--good); }
.sc.neg { color: var(--bad); }
.link { background: none; border: 0; padding: 0; color: var(--gold); font: inherit; font-size: 0.78rem; font-weight: 700; text-decoration: underline; cursor: pointer; justify-self: start; }

/* ---------- phone table ---------- */
.table.phone { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 0.35rem; padding: 0.4rem 0.4rem 0; }
.opp-row { display: grid; grid-template-columns: repeat(var(--k), minmax(0, 1fr)); gap: 0.3rem; }
.trick-zone {
  container-type: size;
  --tw: min(calc(100cqw / var(--k) - 0.7rem), 27cqh);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  justify-items: center;
  align-content: start;
  gap: 0.25rem;
  min-height: 0;
}
.opp-spots { width: 100%; display: grid; grid-template-columns: repeat(var(--k), minmax(0, 1fr)); justify-items: center; padding-top: 0.75rem; }
.me-spot { padding-top: 0.5rem; }
.trick-zone .caption { position: static; transform: none; align-self: end; margin-bottom: 0.2rem; font-size: 0.78rem; }
.blind-wrap { padding-top: 2rem; }
.status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.45rem;
  padding: 0.35rem 0.6rem;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 0.8rem;
}
.status-row .lbl { font-size: 0.6rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.status-row .who { color: var(--muted); font-weight: 700; }
.status-row.secret { border-color: var(--partner); background: rgba(155, 108, 240, 0.2); }
.status-row.secret .who { color: #e2d4ff; }
.status-row.leaster { border-color: var(--defender); }
.mini-race { display: inline-flex; align-items: center; gap: 0.3rem; margin-left: auto; font-weight: 800; font-size: 0.78rem; }
.mini-race .pbar { width: 4.5rem; margin: 0; }

/* ---------- action strip ---------- */
.action {
  display: flex;
  align-items: center;
  gap: 0.6rem 1rem;
  margin: 0.35rem 0.75rem 0;
  padding: 0.5rem 0.8rem;
  min-height: 3rem;
  max-height: 38cqh;
  overflow-y: auto;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
}
.action.active {
  border-color: rgba(230, 187, 85, 0.6);
  background: linear-gradient(145deg, rgba(230, 187, 85, 0.15), rgba(255, 255, 255, 0.03)), rgba(9, 27, 27, 0.94);
}
.act-body { flex: 1; min-width: 0; }
.act-text { line-height: 1.4; font-size: 0.92rem; }
.act-text .tip { color: #e9dfc2; }
.act-text.waiting { color: var(--muted); }
.act-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }
.me-line { flex: 0 0 auto; }
.me-line .plate { min-width: 9rem; }
.action.phone { flex-wrap: wrap; margin: 0.35rem 0.4rem 0; padding: 0.45rem 0.55rem; }
.action.phone .act-body { flex-basis: 100%; }
.action.phone .act-buttons { margin-left: auto; }
.action.phone .me-line { order: -1; flex-basis: 100%; }
.action.phone .me-line .plate { display: flex; align-items: center; gap: 0.5rem; }
.call-opts { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }
.call-opt { padding: 0.35rem 0.6rem; gap: 0.5rem; font-weight: 700; font-size: 0.85rem; }

/* The verbose-tips sheep and its speech bubble. */
.sheep-say { display: flex; align-items: flex-start; gap: 0.55rem; }
.sheep {
  flex: 0 0 auto;
  width: 4.4rem;
  height: 4.4rem;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4));
  animation: sheep-bob 3.2s ease-in-out infinite;
  transform-origin: 50% 90%;
}
@keyframes sheep-bob { 50% { transform: rotate(-4deg) translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .sheep, .spot.turn, .partner-sec.secret { animation: none; } }
.bubble {
  position: relative;
  min-width: 0;
  padding: 0.55rem 0.8rem 0.45rem;
  border-radius: 14px;
  background: #fffdf6;
  color: #1d2422;
  font-size: 0.88rem;
  line-height: 1.42;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.bubble::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 1.3rem;
  border: 9px solid transparent;
  border-left: 0;
  border-right-color: #fffdf6;
}
.bubble b { color: #0f1513; }
.bubble .muted { color: #5d6461; }
.bubble .good { color: #1f7a45; }
.bubble .warn-inline { color: #a14b00; }
.bubble-foot { margin-top: 0.3rem; font-size: 0.7rem; color: #6a706d; }
.bubble-foot .link { color: #8a5a00; font-size: 0.7rem; }
.action.phone .sheep { width: 3.2rem; height: 3.2rem; }
.action.phone .bubble { font-size: 0.82rem; }

/* ---------- hand ---------- */
.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-width: 0;
  overflow: visible;
  padding: 1.15rem 0.6rem 0.5rem;
  min-height: 0;
}
.game.desk .hand { height: clamp(8rem, 25cqh, 16rem); }
.game.phone .hand { height: clamp(6.5rem, 20cqh, 11rem); padding-left: 0.3rem; padding-right: 0.3rem; }
.hand .card { --w: var(--hand-w, 5rem); }
.hand.watching { align-items: center; color: var(--muted); }

/* ---------- trump-order drawer ---------- */
.overlay:has(.modal.drawer) { place-items: stretch end; padding: 0; }
.modal.drawer { width: min(21rem, 100%); max-height: none; height: 100%; border-radius: 10px 0 0 10px; }
.ladder-list { list-style: none; margin: 0.5rem 0; padding: 0; display: grid; gap: 0.2rem; }
.ladder-list li { display: grid; grid-template-columns: 1.6rem auto 1fr; align-items: center; gap: 0.5rem; }
.ladder-list .num { color: var(--muted); font-size: 0.75rem; font-weight: 800; text-align: right; }
.ladder-list .note { color: var(--muted); font-size: 0.75rem; }
.ladder-list li.gone .chip { opacity: 0.35; text-decoration: line-through; }
.ladder-list li.mine .chip { box-shadow: 0 0 0 2px var(--good); }
.ladder-list li.called .chip { box-shadow: 0 0 0 2px var(--partner); }

/* ---------- tips picker (join forms) and menu ---------- */
.tips-pick { flex-basis: 100%; display: grid; grid-template-columns: 1fr; gap: 0.4rem; margin: 0; padding: 0; border: 0; }
@media (min-width: 600px) { .tips-pick { grid-template-columns: repeat(3, 1fr); } }
.tips-pick legend { font-weight: 650; margin-bottom: 0.35rem; padding: 0; }
.tips-pick label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 0.4rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
  font-weight: 500;
}
.tips-pick label.on { border-color: var(--gold); background: rgba(230, 187, 85, 0.12); }
.tips-pick input { grid-row: span 2; accent-color: var(--gold); }
.tips-pick span { color: var(--muted); font-size: 0.8rem; }
.tips-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
.standings { list-style: none; padding: 0; }
.modal .standings li { display: flex; justify-content: space-between; max-width: 18rem; }
.modal .standings li.me { color: var(--gold); font-weight: 800; }
