/* Club Canasta. A Pogo-style card table: team boards left and right, piles in the middle,
   players across the top, your hand and big game buttons along the bottom. */
:root {
  --bg-1: #7480bd;
  --bg-2: #4d568f;
  --ink: #1e2233;
  --muted: #6a7088;
  --panel: #ffffff;
  --line: #dcd9ea;
  --us: #2e9d7f;
  --us-deep: #1f7a62;
  --us-board: #93d2c1;
  --them: #8b5fb6;
  --them-deep: #6c4593;
  --them-board: #c9acdf;
  --red: #d01f3c;
  --gold: #f2b632;
  --green: #3fae49;
  --pink: #e2457a;
  --blue: #2f9bd6;
  --card-w: 86px;
  --card-h: 122px;
  --card-step: 40px;
  --mini-w: 44px;
  --mini-h: 62px;
  --mini-step: 19px;
  --chunky: 0 4px 0 rgba(0, 0, 0, 0.28);
  font-family: "Nunito", "Trebuchet MS", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: linear-gradient(165deg, var(--bg-1), var(--bg-2)) fixed; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
input, select { font: inherit; padding: 9px 11px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: none; border-color: var(--blue); }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.15; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 22px; background: rgba(20, 24, 52, 0.55); color: #fff; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 900; font-size: 1.35rem; letter-spacing: 0.3px; display: flex; align-items: center; gap: 8px; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: #fff; color: var(--red); font-size: 1.1rem; box-shadow: var(--chunky); }
.nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; font-weight: 700; }
.nav a { color: #e9ecff; text-decoration: none; }
.nav a:hover { color: #fff; text-decoration: underline; }
.nav .me { color: #c9cff5; font-weight: 600; }
.link { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; }
main { max-width: 1320px; margin: 0 auto; padding: 18px; }
.loading { color: #fff; }

/* ---------------------------------------------------------------- game buttons */
.btn { border: 0; border-radius: 12px; padding: 10px 18px; background: var(--green); color: #fff; font-weight: 900; letter-spacing: 0.4px; box-shadow: var(--chunky); text-transform: uppercase; font-size: 0.95rem; transition: transform 0.05s, filter 0.1s; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28); }
.btn:disabled { background: #9a9cab !important; color: #e3e4ea; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18); }
.btn.blue { background: var(--blue); }
.btn.pink { background: var(--pink); }
.btn.gold { background: var(--gold); color: #3b2800; }
.btn.purple { background: var(--them); }
.btn.ghost { background: #eceaf6; color: var(--ink); text-transform: none; letter-spacing: 0; font-weight: 800; }
.btn.small { padding: 6px 12px; font-size: 0.82rem; border-radius: 10px; }
.btn.round { position: relative; width: 46px; height: 46px; padding: 0; display: inline-grid; place-items: center; font-size: 1.2rem; text-transform: none; }
.btn.round .badge-dot { position: absolute; top: -6px; right: -6px; margin: 0; }

/* ---------------------------------------------------------------- panels */
.panel { background: var(--panel); border-radius: 16px; padding: 18px; box-shadow: 0 10px 30px rgba(20, 24, 60, 0.18); }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.error-text { color: var(--red); min-height: 1.2em; font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: 3px; font-size: 0.76rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: #eceaf6; color: var(--ink); text-decoration: none; }
.pill.open { background: #fff1c7; }
.pill.bot { background: #e4e7f7; }
.pill.status-playing { background: #d7f2e3; }
.pill.locked { background: #f6e3cf; }
.pill.rule { background: #eef6ff; color: #23527a; }
.variant-note { margin: 0 0 12px; font-weight: 700; font-size: 0.9rem; }

/* ---------------------------------------------------------------- auth */
.auth { max-width: 440px; margin: 50px auto; }
.auth h1 { font-size: 2rem; }
.auth .tabs { display: flex; gap: 6px; margin: 16px 0; }
.auth .tabs button { flex: 1; padding: 10px; border: 2px solid var(--line); background: #fff; border-radius: 10px; font-weight: 800; }
.auth .tabs button.on { background: var(--us); color: #fff; border-color: var(--us); }
.auth form { display: grid; gap: 12px; }
.auth label { display: grid; gap: 4px; font-size: 0.9rem; font-weight: 700; color: var(--muted); }

/* ---------------------------------------------------------------- lobby */
.lobby { display: grid; grid-template-columns: 1fr 340px; gap: 18px; }
.lobby .main-col { display: grid; gap: 18px; align-content: start; }
.create .basics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.create details { border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.create summary { font-weight: 800; cursor: pointer; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 16px; margin-top: 12px; }
.field { display: grid; gap: 4px; font-size: 0.78rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.field select, .field input { width: 100%; min-width: 0; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--ink); font-size: 0.95rem; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.table-list { display: grid; gap: 10px; }
.table-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: #f7f6fc; border: 2px solid #efedf7; }
.table-item .name { font-weight: 900; font-size: 1.05rem; }
.table-item .meta, .table-item .seats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.side { display: grid; gap: 18px; align-content: start; }
.online { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-board { margin-bottom: 10px; }
.mini-board .mini-title { font-weight: 900; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.mini-board ol { margin: 4px 0 0; padding-left: 22px; }
.mini-board li { padding: 2px 0; font-weight: 700; }
.mini-board a { text-decoration: none; }
.small-note { font-size: 0.8rem; }
a.btn { display: inline-block; text-decoration: none; }

/* ---------------------------------------------------------------- chat */
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat .msgs { flex: 1; overflow-y: auto; font-size: 0.93rem; padding-right: 4px; min-height: 180px; max-height: 360px; }
.chat .msg { padding: 3px 0; overflow-wrap: anywhere; }
.chat .msg .who { font-weight: 800; text-decoration: none; }
.chat .msg.system { color: var(--muted); font-style: italic; }
.chat .msg .tools { visibility: hidden; margin-left: 6px; }
.chat .msg:hover .tools { visibility: visible; }
.chat .msg .tools button { font-size: 0.75rem; background: none; border: 0; color: var(--muted); text-decoration: underline; }
.chat form { display: flex; gap: 6px; margin-top: 8px; }
.chat input { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- cards */
.card { position: relative; width: var(--card-w); height: var(--card-h); border-radius: 9px; background: linear-gradient(180deg, #fff, #f6f4ee); border: 1.5px solid #c9c3b4; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); color: #1b1b1f; user-select: none; flex: none; overflow: hidden; }
.card .ix { position: absolute; top: 5px; left: 6px; display: grid; justify-items: center; line-height: 0.95; font-weight: 900; }
.card .ix .r { font-size: 1.55rem; letter-spacing: -1px; }
.card .ix .s { font-size: 1.25rem; }
.card .val { position: absolute; top: 64px; left: 5px; font-size: 0.66rem; font-weight: 900; color: #fff; padding: 1px 5px; border-radius: 6px; background: #8a6bc0; }
.card .val.v10 { background: #3b9b58; }
.card .val.v20 { background: #d6513a; }
.card .val.v50 { background: #c98d00; }
.card .pip { position: absolute; right: 7px; bottom: 4px; font-size: 2.6rem; line-height: 1; opacity: 0.9; }
.card.red { color: var(--red); }
.card.joker { background: linear-gradient(160deg, #fff 45%, #ffe7a3); }
.card.joker .ix .s { font-size: 0.7rem; letter-spacing: 0; }
.card.mini.joker .ix .s { font-size: 0.5rem; }
.card.joker .pip { color: #c98d00; }
.card.wild { border-color: #d9a520; }
.card.back { background: #3a4170 repeating-linear-gradient(45deg, #49528a 0 5px, #3a4170 5px 10px); border: 3px solid #fff; }
.card.mini { width: var(--mini-w); height: var(--mini-h); border-radius: 6px; border-width: 1px; }
.card.mini .ix { top: 3px; left: 4px; }
.card.mini .ix .r { font-size: 1rem; }
.card.mini .ix .s { font-size: 0.85rem; }
.card.mini .val, .card.mini .pip { display: none; }
.card.selectable { cursor: pointer; transition: transform 0.08s ease, box-shadow 0.08s; }
.card.selectable:hover { transform: translateY(-6px); }
.card.fresh { box-shadow: 0 0 0 3px #4fd1ff, 0 0 14px 2px rgba(79, 209, 255, 0.85); }
.card.arrive { animation: arrive 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes arrive { from { transform: translateY(-140px) scale(0.85) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }
.card.selected, .card.selected:hover { transform: translateY(-22px); box-shadow: 0 0 0 3px var(--gold), 0 8px 14px rgba(0, 0, 0, 0.35); }

/* ---------------------------------------------------------------- game screen */
.game { display: grid; gap: 14px; }
.game-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; color: #fff; }
.game-top h2 { margin: 0; font-size: 1.15rem; }
.game-top .rules { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.game-top .rules .pill { background: rgba(255, 255, 255, 0.18); color: #fff; }

.strip { display: grid; gap: 12px; padding-top: 10px; }
.strip.n4 { grid-template-columns: repeat(4, 1fr); }
.strip.n2 { grid-template-columns: repeat(2, minmax(0, 340px)); justify-content: center; }
.player { position: relative; display: grid; grid-template-columns: 54px 1fr; gap: 2px 10px; align-items: center; padding: 10px 12px; border-radius: 14px; color: #fff; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18); }
.player.us { background: linear-gradient(180deg, var(--us), var(--us-deep)); }
.player.them { background: linear-gradient(180deg, var(--them), var(--them-deep)); }
.player .avatar { grid-row: span 2; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 1.2rem; background: #fff; color: var(--ink); border: 3px solid rgba(255, 255, 255, 0.85); }
.player.us .avatar { color: var(--us-deep); }
.player.them .avatar { color: var(--them-deep); }
.player .team { font-size: 0.72rem; font-weight: 900; letter-spacing: 0.8px; opacity: 0.9; }
.player .pname { font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .pname small { font-weight: 700; opacity: 0.85; }
.player .fan { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; height: 34px; }
.player .fan .backs { display: flex; }
.player .fan .backs span { width: 16px; height: 30px; border-radius: 3px; background: #3a4170 repeating-linear-gradient(45deg, #49528a 0 3px, #3a4170 3px 6px); border: 1.5px solid #fff; margin-left: -9px; }
.player .fan .backs span:first-child { margin-left: 0; }
.player .fan .n { font-weight: 900; font-size: 0.85rem; }
.player .tag { position: absolute; top: -11px; right: 12px; padding: 2px 10px; border-radius: 8px; font-size: 0.75rem; font-weight: 900; letter-spacing: 0.6px; box-shadow: var(--chunky); }
.player .tag.turn { background: #f08a24; color: #fff; }
.player .tag.away { background: #50566f; color: #fff; }
.player .dealer { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #fff; color: var(--ink); font-size: 0.7rem; font-weight: 900; margin-left: 6px; }
.player.is-turn { outline: 3px solid #f08a24; outline-offset: 2px; }

.table-area { display: grid; grid-template-columns: minmax(0, 1fr) 250px minmax(0, 1fr); gap: 14px; align-items: stretch; }
.board { border-radius: 20px; padding: 0 12px 12px; min-height: 300px; display: flex; flex-direction: column; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.08); }
.board.us { background: var(--us-board); }
.board.them { background: var(--them-board); }
.board .bhead { display: flex; justify-content: space-between; align-items: center; margin: 0 -12px 10px; padding: 8px 14px; border-radius: 20px 20px 0 0; color: #fff; }
.board.us .bhead { background: var(--us); }
.board.them .bhead { background: var(--them); }
.board .bhead .who { font-weight: 900; font-size: 0.95rem; }
.board .bhead .who small { display: block; font-weight: 700; opacity: 0.85; font-size: 0.78rem; }
.board .bhead .score { font-weight: 900; font-size: 1.9rem; line-height: 1; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); }
.board .threes { display: flex; gap: 4px; margin-bottom: 8px; }
.board .melds { display: flex; flex-wrap: wrap; gap: 8px 10px; align-content: flex-start; align-items: center; flex: 1; }
.board .empty { flex: 1; display: grid; place-items: center; text-align: center; font-weight: 900; font-size: 1.1rem; color: rgba(30, 34, 51, 0.55); padding: 20px; }
.meldcol { display: flex; flex-direction: row; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 10px; background: rgba(255, 255, 255, 0.18); }
.meldcol .stack { display: flex; flex-direction: row; }
.meldcol .stack .card + .card { margin-left: calc(var(--mini-step) + 3px - var(--mini-w)); }
.meldcol .count { font-size: 0.72rem; font-weight: 900; padding: 1px 7px; border-radius: 6px; background: rgba(255, 255, 255, 0.75); }
.meldcol.canasta .stack .card:first-child { box-shadow: 0 0 0 3px #1d1d22, 0 2px 4px rgba(0, 0, 0, 0.3); }
.meldcol.canasta.natural .stack .card:first-child { box-shadow: 0 0 0 3px var(--red), 0 2px 4px rgba(0, 0, 0, 0.3); }
.meldcol.canasta.wild .stack .card:first-child { box-shadow: 0 0 0 3px var(--gold), 0 2px 4px rgba(0, 0, 0, 0.3); }
.meldcol.canasta .count { background: #1d1d22; color: #fff; }
.meldcol.canasta.natural .count { background: var(--red); }
.meldcol.canasta.wild .count { background: var(--gold); color: #3b2800; }
.meldcol.target { cursor: pointer; background: rgba(255, 255, 255, 0.45); outline: 2px dashed var(--us-deep); }
.meldcol.pending { outline: 2px dashed var(--us-deep); background: rgba(255, 255, 255, 0.4); }
.meldcol.pending .count { background: var(--us-deep); color: #fff; }

.center { display: grid; align-content: start; justify-items: center; gap: 14px; padding-top: 18px; }
.piles { display: flex; gap: 22px; align-items: flex-start; }
.pile { position: relative; display: grid; justify-items: center; gap: 8px; }
.pile .stackwrap { position: relative; width: var(--card-w); height: var(--card-h); }
.pile .stackwrap .card { position: absolute; top: 0; left: 0; }
.pile .stackwrap .card.peek { transform: translate(12px, 3px) rotate(6deg); }
.pile .stackwrap .card.deep { transform: translate(-3px, -3px); }
.pile .countpill { background: #ffe9d6; color: var(--ink); font-weight: 900; padding: 3px 12px; border-radius: 10px; box-shadow: var(--chunky); font-size: 0.85rem; }
.pile .slot { width: var(--card-w); height: var(--card-h); border-radius: 9px; border: 3px dashed rgba(255, 255, 255, 0.45); display: grid; place-items: center; color: rgba(255, 255, 255, 0.75); font-weight: 800; font-size: 0.8rem; }
.pile.clickable .stackwrap, .pile.clickable .slot { cursor: pointer; filter: drop-shadow(0 0 9px rgba(242, 182, 50, 1)); }
.pile .frozen { position: absolute; inset: 0; border-radius: 9px; background: rgba(120, 200, 255, 0.5); border: 3px solid #7fd0ff; display: grid; place-items: center; pointer-events: none; }
.pile .frozen span { transform: rotate(-62deg); color: #fff; font-weight: 900; letter-spacing: 1.5px; font-size: 0.95rem; text-shadow: 0 1px 2px #0b4d7a; }
.pile .stopped { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); background: #1d1d22; color: #fff; font-size: 0.68rem; font-weight: 900; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.center .badge { background: rgba(255, 255, 255, 0.2); color: #fff; font-weight: 800; padding: 3px 10px; border-radius: 8px; font-size: 0.8rem; }
.lastmove { color: #fff; font-weight: 700; text-align: center; font-size: 0.88rem; min-height: 2.4em; max-width: 240px; opacity: 0.95; }

.hand-area { display: grid; justify-items: center; gap: 4px; padding-top: 6px; }
.pending-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; background: rgba(255, 255, 255, 0.92); padding: 6px 12px; border-radius: 12px; font-weight: 800; }
.hand { display: flex; justify-content: center; padding: 28px 10px 0; max-width: 100%; }
.hand .card + .card { margin-left: calc(var(--card-step) - var(--card-w)); }
.hand .card.gap { margin-left: calc(var(--card-step) - var(--card-w) + 10px); }

.actionbar { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 4px 0 2px; }
.timer { background: #25b39a; color: #fff; font-weight: 900; padding: 10px 16px; border-radius: 12px; box-shadow: var(--chunky); font-variant-numeric: tabular-nums; min-width: 104px; text-align: center; }
.timer.low { background: #e0582c; }
.timer.off { background: #6c7090; }
.hint { color: #fff; font-weight: 700; text-align: center; font-size: 0.95rem; min-height: 1.3em; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.badge-dot { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 10px; background: var(--red); color: #fff; font-size: 0.72rem; margin-left: 6px; padding: 0 5px; }

/* canasta celebration */
.meldcol.celebrate { animation: celebrate 1.3s ease-out; }
@keyframes celebrate { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(242, 182, 50, 0.9); } 30% { transform: scale(1.18); box-shadow: 0 0 0 12px rgba(242, 182, 50, 0.45); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(242, 182, 50, 0); } }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 18; display: grid; place-items: center; }
#fx > * { grid-area: 1 / 1; }
.banner { font-size: clamp(2rem, 6vw, 3.4rem); font-weight: 900; color: #fff; padding: 14px 36px; border-radius: 22px; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3); border: 4px solid #fff; animation: banner 1.9s ease-out forwards; }
.banner.us { background: linear-gradient(180deg, var(--us), var(--us-deep)); }
.banner.them { background: linear-gradient(180deg, var(--them), var(--them-deep)); }
@keyframes banner { 0% { transform: scale(0.3) rotate(-8deg); opacity: 0; } 15% { transform: scale(1.12) rotate(2deg); opacity: 1; } 25% { transform: scale(1) rotate(0); } 80% { opacity: 1; } 100% { transform: translateY(-50px); opacity: 0; } }
.burst { position: relative; width: 0; height: 0; }
.burst span { position: absolute; left: -12px; top: -16px; font-size: 1.9rem; color: #fff; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35); animation: burst 1.4s ease-out forwards; }
.burst span.red { color: #ffd1d8; }
@keyframes burst { 0% { transform: translate(0, 0) scale(0.4); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(200deg); opacity: 0; } }

/* waiting room */
.waiting { display: grid; gap: 16px; }
.seat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.seat-card { border-radius: 16px; padding: 16px; color: #fff; display: grid; gap: 10px; justify-items: center; text-align: center; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18); }
.seat-card.us { background: linear-gradient(180deg, var(--us), var(--us-deep)); }
.seat-card.them { background: linear-gradient(180deg, var(--them), var(--them-deep)); }
.seat-card .avatar { width: 64px; height: 64px; border-radius: 50%; background: rgba(255, 255, 255, 0.95); display: grid; place-items: center; font-weight: 900; font-size: 1.4rem; color: var(--ink); }
.seat-card .avatar.empty { background: rgba(255, 255, 255, 0.25); color: #fff; }
.seat-card .who { font-weight: 900; font-size: 1.1rem; }
.seat-card .team { font-size: 0.75rem; font-weight: 900; letter-spacing: 0.8px; opacity: 0.9; }
.waiting .startbar { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; color: #fff; font-weight: 800; }

/* tournaments */
.pill.trophy { background: #fff0c2; color: #6a4b00; }
.pill.t-scheduled { background: #e2f1ff; }
.pill.t-running { background: #d7f2e3; }
.pill.t-cancelled { background: #f6dcdc; }
.schedule { margin-top: 14px; border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.schedule summary { font-weight: 800; cursor: pointer; }
.schedule .row { margin-top: 12px; }
.t-actions { margin: 12px 0; }
.bracket { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 260px); gap: 18px; overflow-x: auto; margin-top: 16px; padding-bottom: 6px; }
.round { display: flex; flex-direction: column; justify-content: space-around; gap: 12px; }
.round-title { font-weight: 900; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.5px; color: var(--muted); }
.match { border-radius: 12px; background: #f7f6fc; border: 2px solid #ebe8f5; padding: 8px 10px; }
.match .side { padding: 3px 0; font-weight: 700; }
.match .side + .side { border-top: 1px solid var(--line); }
.match .side.won { color: var(--us-deep); font-weight: 900; }
.match .side.won::after { content: " ✓"; }
.match .side.lost { color: #9a9cab; text-decoration: line-through; }
.match .mstatus { font-size: 0.8rem; color: var(--muted); margin-top: 4px; font-weight: 700; }
.match.st-playing { border-color: var(--green); }
.match.st-open { border-color: var(--gold); }

/* chat dock: lobby side panel, beside the seats while a table fills, a drawer during play */
.dock { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.dock-panel { height: 470px; display: flex; flex-direction: column; }
.dock .dock-tabs { margin-bottom: 8px; }
.dock .dock-tabs button { padding: 6px 10px; font-size: 0.85rem; display: inline-flex; align-items: center; }
.dock .dock-tabs .badge-dot { margin-left: 5px; }
.dock .dock-head { display: flex; gap: 10px; align-items: center; font-size: 0.92rem; }
.dock .dock-head:not(:empty) { margin-bottom: 6px; }
.dock .dock-msgs { flex: 1; overflow-y: auto; min-height: 120px; max-height: none; }
.dock .msg.mine .who { color: var(--us-deep); }
.dock-form { display: flex; gap: 6px; margin-top: 8px; }
.dock-form input { flex: 1; min-width: 0; }
.dm-new { margin: 0 0 10px; }
.dm-row { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; background: #f7f6fc; border: 2px solid #efedf7; border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; color: var(--ink); }
.dm-row .muted { margin-left: auto; font-size: 0.8rem; }
button.pill { border: 0; cursor: pointer; }
button.pill:hover { background: #dfe3fb; }
.table-wrap.waiting-mode { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.table-wrap.waiting-mode .drawer { position: static; transform: none; width: auto; height: 560px; border-radius: 16px; z-index: auto; box-shadow: 0 10px 30px rgba(20, 24, 60, 0.18); }
.table-wrap.waiting-mode .dclose { display: none; }
.drawer .dclose { align-self: flex-end; margin-bottom: 6px; }

/* drawer (chat + game log) */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); background: #fff; box-shadow: -10px 0 30px rgba(0, 0, 0, 0.25); z-index: 25; display: flex; flex-direction: column; padding: 14px; transform: translateX(105%); transition: transform 0.2s ease; }
.drawer.open { transform: none; }
.drawer .dhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drawer .chat { flex: 1; }
.drawer .chat .msgs { max-height: none; }
.log { overflow-y: auto; font-size: 0.88rem; display: grid; gap: 2px; align-content: start; flex: 1; }
.log .entry { padding: 3px 0; border-bottom: 1px solid #f0eef6; }

/* overlays */
.overlay { position: fixed; inset: 0; background: rgba(18, 20, 44, 0.55); display: grid; place-items: center; z-index: 20; padding: 16px; }
.overlay .panel { max-width: 720px; width: 100%; max-height: 90vh; overflow-y: auto; }
.overlay h2 { font-size: 1.6rem; }
.score-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.score-table th, .score-table td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.score-table th:first-child, .score-table td:first-child { text-align: left; }
.score-table th.us { color: var(--us-deep); }
.score-table th.them { color: var(--them-deep); }
.score-table tr.total td { font-weight: 900; border-top: 2px solid var(--ink); }
.reveal { display: grid; gap: 6px; margin-top: 10px; }
.reveal .row .card + .card { margin-left: -22px; }
.floating { position: fixed; right: 20px; bottom: 20px; z-index: 15; }

/* rankings, profile, rules */
.tabs-inline { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs-inline button { padding: 7px 14px; border: 2px solid var(--line); background: #fff; border-radius: 10px; font-weight: 800; }
.tabs-inline button.on { background: var(--us); color: #fff; border-color: var(--us); }
.ranks { width: 100%; border-collapse: collapse; }
.ranks th, .ranks td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.ranks td.num, .ranks th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rules-text { max-width: 820px; line-height: 1.55; }
.rules-text h2 { margin-top: 24px; }
.rules-text li { margin: 4px 0; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #23263b; color: #fff; padding: 11px 18px; border-radius: 12px; max-width: 90vw; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 30; font-weight: 700; }
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }

/* ---------------------------------------------------------------- smaller screens */
@media (max-width: 1100px) {
  .lobby { grid-template-columns: 1fr; }
  .table-wrap.waiting-mode { grid-template-columns: 1fr; }
  .table-wrap.waiting-mode .drawer { height: 420px; }
  .table-area { grid-template-columns: 1fr 1fr; }
  .center { grid-column: 1 / -1; grid-row: 1; padding-top: 0; }
}
@media (max-width: 700px) {
  :root { --card-w: 56px; --card-h: 80px; --card-step: 22px; --mini-w: 34px; --mini-h: 48px; --mini-step: 15px; }
  main { padding: 10px; }
  .strip.n4 { grid-template-columns: repeat(2, 1fr); }
  .player { grid-template-columns: 40px 1fr; padding: 8px; }
  .player .avatar { width: 40px; height: 40px; font-size: 0.95rem; }
  .player .fan { height: 24px; }
  .table-area { grid-template-columns: 1fr; }
  .board { min-height: 140px; }
  .board.them { order: 1; }
  .center { order: 2; grid-row: auto; }
  .board.us { order: 3; }
  .card .ix .r { font-size: 1.1rem; }
  .card .ix .s { font-size: 0.95rem; }
  .card .val { top: 42px; font-size: 0.58rem; }
  .card .pip { font-size: 1.7rem; }
  .btn { padding: 9px 12px; font-size: 0.85rem; }
}
