:root {
  --felt: #14593b;
  --felt-deep: #0a3323;
  --felt-dark: #072619;
  --cream: #fbf6e9;
  --ink: #1f2420;
  --gold: #e6b84c;
  --gold-deep: #b98a1e;
  --red: #c3281e;
  --muted: #b9cdbf;
  --line: rgba(255, 255, 255, 0.14);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --cw: 54px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.45 var(--sans);
  color: var(--cream);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.07), transparent 60%),
    radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-deep) 78%, var(--felt-dark) 100%) fixed;
  background-color: var(--felt-deep);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }

/* ---------- home, join, lobby ---------- */
.screen { min-height: 100dvh; }
#home, #join, #lobby { display: grid; place-items: center; padding: 20px 16px; }
.panel {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 24px 22px;
  background: rgba(5, 30, 20, 0.62);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.brand {
  font: 700 46px/1 var(--serif);
  letter-spacing: 0.01em;
  color: var(--gold);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  text-align: center;
}
.brand.small { font-size: 22px; text-decoration: none; text-align: left; }
.lede { color: var(--muted); text-align: center; text-wrap: balance; margin-bottom: 4px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span, .panel h2 { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
input, select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font-size: 16px;
  color: var(--ink);
  background: var(--cream);
  border: 1px solid transparent;
  border-radius: 10px;
}
input::placeholder { color: #8b8f86; }

.btn {
  min-height: 46px;
  padding: 10px 18px;
  font-weight: 600;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  transition: transform 0.08s, background 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary {
  color: #2a1f05;
  background: linear-gradient(#f3cd6c, var(--gold) 55%, #d6a437);
  border-color: var(--gold-deep);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(#f8d882, #ecc35c 55%, #dcab40); }
.btn:disabled { opacity: 0.42; box-shadow: none; }
.btn.wide { width: 100%; }
.link {
  align-self: center;
  padding: 6px 8px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
}
.link:hover { color: var(--cream); }

.joinrow { display: flex; gap: 8px; margin-top: 6px; padding-top: 16px; border-top: 1px solid var(--line); }
.joinrow input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 0.2em; }
.joinrow input::placeholder { letter-spacing: normal; text-transform: none; }
#recentlist { list-style: none; margin: 6px 0 0; padding: 0; }
#recentlist li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 14px; }
#recentlist a { color: var(--cream); font-weight: 600; letter-spacing: 0.04em; }

.sharebox { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: rgba(0, 0, 0, 0.25); border: 1px dashed rgba(230, 184, 76, 0.6); border-radius: 12px; }
#sharelink { font: 600 15px/1.3 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; word-break: break-all; text-align: center; user-select: all; -webkit-user-select: all; }
.sharebtns { display: flex; gap: 8px; }
.sharebtns .btn { flex: 1; }
.waiting { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); animation: pulse 1.4s ease-in-out infinite; }
.hint { font-size: 13px; color: var(--muted); text-align: center; }
.hint b { color: var(--cream); letter-spacing: 0.12em; }
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.7); } }

/* ---------- cards ---------- */
.card {
  position: relative;
  flex: none;
  display: inline-block;
  width: var(--cw);
  height: calc(var(--cw) * 1.42);
  font-size: calc(var(--cw) * 0.36);
  color: #1b1c22;
  background: linear-gradient(160deg, #fffdf6, #f4ecd8);
  border: 1px solid rgba(60, 45, 20, 0.45);
  border-radius: calc(var(--cw) * 0.12);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
.card.red { color: var(--red); }
.card .ix {
  position: absolute;
  top: 5%;
  left: 0;
  width: 46%;
  min-width: 1.15em;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.98;
}
.card .ix b { font: 700 1em/1 var(--serif); }
.card .ix b.ten { letter-spacing: -0.09em; margin-left: -0.06em; }
.card .ix i { font-style: normal; font-size: 0.86em; line-height: 1; }
.card .pip { position: absolute; right: 9%; bottom: 3%; font-size: 1.55em; line-height: 1; opacity: 0.92; }
.card.wild { box-shadow: inset 0 0 0 calc(var(--cw) * 0.045) rgba(230, 184, 76, 0.95), 0 1px 2px rgba(0, 0, 0, 0.35); }
.card.joker { color: #6a2c91; }
.card.joker .ix b { font-size: 0.95em; }
.card.joker .jk { position: absolute; left: 0; right: 0; bottom: 34%; text-align: center; font: 700 0.3em/1 var(--sans); letter-spacing: 0.1em; }
.card.joker .pip { font-size: 1.1em; right: 0; left: 0; bottom: 6%; text-align: center; }
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.13) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.13) 0 2px, transparent 2px 7px),
    linear-gradient(#8f1d22, #6d1218);
  border: calc(var(--cw) * 0.06) solid var(--cream);
  box-shadow: 0 0 0 1px rgba(60, 45, 20, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
}
.card.slot { background: none; border: 2px dashed rgba(255, 255, 255, 0.3); box-shadow: none; }

/* ---------- table layout ---------- */
#table { display: flex; flex-direction: column; height: 100dvh; min-height: 0; }
#bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  padding-top: max(6px, env(safe-area-inset-top));
  background: rgba(4, 24, 16, 0.75);
  border-bottom: 1px solid var(--line);
}
#bar nav { display: flex; gap: 6px; margin-left: auto; }
#scores { display: flex; align-items: center; gap: 8px; min-width: 0; }
.score {
  display: flex;
  flex-direction: column;
  min-width: 64px;
  max-width: 120px;
  padding: 3px 10px 4px;
  line-height: 1.15;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 9px;
  border-bottom: 3px solid transparent;
}
.score b { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score span { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score em { font-size: 10px; font-style: normal; color: #f0a58c; }
.score.turn { border-bottom-color: var(--gold); background: rgba(230, 184, 76, 0.16); }
.handno { font-size: 12px; color: var(--muted); white-space: nowrap; }
.icon {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 50%;
}
.icon:hover { background: rgba(255, 255, 255, 0.16); }
.icon.off { color: rgba(255, 255, 255, 0.55); }
.icon.off::after { content: ''; position: absolute; width: 60%; border-top: 2px solid var(--cream); transform: rotate(-45deg); }
#unread {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: #fff;
  background: var(--red);
  border-radius: 9px;
}

#board {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 8px;
}
.zone {
  padding: 8px 10px 10px;
  background: rgba(0, 0, 0, 0.17);
  border: 1px solid var(--line);
  border-radius: 14px;
}
#me.zone { flex: 1 0 auto; }
#opp.turn { border-color: rgba(230, 184, 76, 0.55); }
.who { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.name { font: 700 17px/1.2 var(--serif); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 2px 8px; font-size: 11.5px; font-weight: 600; white-space: nowrap; color: var(--muted); background: rgba(255, 255, 255, 0.08); border-radius: 20px; }
.chip.good { color: #1d3a12; background: #a9d98a; }
.chip.warn { color: #3b2a04; background: #efcf7f; }
.empty { display: block; padding: 10px 2px 4px; font-size: 13px; font-style: italic; color: rgba(255, 255, 255, 0.45); }

.backs { --cw: 17px; display: flex; flex-wrap: wrap; padding: 6px 0 0 9px; min-height: 30px; }
.backs .card { margin-left: -9px; }
.backs.shown { --cw: 32px; padding-left: 16px; row-gap: 4px; }
.backs.shown .card { margin-left: -16px; }

/* ---------- melds ---------- */
.melds { --cw: 36px; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 16px; padding-top: 10px; }
.meld {
  position: relative;
  display: inline-flex;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 6px;
}
.fan { display: inline-flex; padding-left: calc(var(--cw) * 0.56); }
.fan .card { margin-left: calc(var(--cw) * -0.56); }
.count {
  position: absolute;
  top: -7px;
  right: -9px;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--cream);
  background: #0a2a1c;
  border: 1px solid rgba(230, 184, 76, 0.7);
  border-radius: 10px;
}
.meld.red3 .card { box-shadow: 0 0 0 1.5px rgba(195, 40, 30, 0.75), 0 1px 2px rgba(0, 0, 0, 0.35); }
.meld.canasta { margin-right: 4px; }
.meld.canasta .stack { display: inline-flex; }
.meld.canasta .stack .card { box-shadow: 2px 2px 0 #e8dfc8, 2.5px 2.5px 0 #77694a, 4.5px 4.5px 0 #e8dfc8, 5px 5px 0 #77694a, 6px 7px 6px rgba(0, 0, 0, 0.4); }
.ribbon {
  position: absolute;
  left: -3px;
  right: -8px;
  bottom: 5px;
  padding: 2px 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  color: #fff;
  background: #2a2c35;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.natural .ribbon { background: var(--red); }
.meld.canasta .count { color: #2a1f05; background: var(--gold); border-color: var(--gold-deep); }
button.meld.target { outline: 2px dashed var(--gold); outline-offset: 4px; animation: glow 1.2s ease-in-out infinite; }
@keyframes glow { 50% { outline-color: rgba(230, 184, 76, 0.35); } }

/* ---------- stock, pile, status ---------- */
#mid { --cw: 58px; display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
.deck {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 5px;
  background: none;
  border: 2px solid transparent;
  border-radius: 12px;
}
.deck > span:first-child { display: inline-flex; }
#stock .card.back { box-shadow: 0 0 0 1px rgba(60, 45, 20, 0.45), 2px 2px 0 #5d0f14, 3px 3px 0 var(--cream), 5px 5px 0 #5d0f14, 6px 7px 8px rgba(0, 0, 0, 0.4); }
#stock.empty .card.back { visibility: hidden; }
#stock.empty { border: 2px dashed rgba(255, 255, 255, 0.25); }
#pile.thick #piletop .card { box-shadow: 2px 2px 0 #e8dfc8, 2.5px 2.5px 0 #77694a, 4.5px 4.5px 0 #e8dfc8, 5px 5px 0 #77694a, 6px 7px 8px rgba(0, 0, 0, 0.4); }
#pile.frozen { background: rgba(120, 200, 255, 0.16); border-color: rgba(150, 215, 255, 0.75); }
#pile.frozen .cap { color: #bfe6ff; }
.cap { font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.deck.live { border-color: rgba(230, 184, 76, 0.85); background: rgba(230, 184, 76, 0.12); }
.deck.live:hover { background: rgba(230, 184, 76, 0.22); }
#status { flex: 1; min-width: 0; }
#statusmain { font-weight: 700; font-size: 15px; line-height: 1.3; text-wrap: balance; }
#mid.turn #statusmain { color: #ffe39a; }
#statussub { margin-top: 4px; font-size: 13px; line-height: 1.35; color: var(--muted); }

/* ---------- hand and actions ---------- */
#dock {
  flex: none;
  background: linear-gradient(rgba(4, 24, 16, 0.8), rgba(3, 18, 12, 0.94));
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tray { --cw: 36px; margin: 8px 8px 0; padding: 8px 10px 10px; background: rgba(230, 184, 76, 0.1); border: 1px dashed rgba(230, 184, 76, 0.7); border-radius: 12px; }
.trayhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 13px; }
.trayhead b { color: #ffd98a; }
.trayhead.ok b { color: #b6e79a; }
.trayhead span { color: var(--muted); }
.trayrow { display: flex; flex-wrap: wrap; gap: 10px 16px; padding-top: 10px; }
.meld.staged .count { color: #fff; background: #7b2a22; border-color: #c96; font-size: 13px; }
.card.fromtop { box-shadow: 0 0 0 2px #7fc8ff, 0 1px 2px rgba(0, 0, 0, 0.35); }

#hand {
  --cw: clamp(46px, 13.2vw, 62px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 6px;
  max-height: 40dvh;
  overflow-y: auto;
  padding: 16px 8px 6px calc(8px + var(--cw) * 0.5);
}
#hand.many { --cw: clamp(40px, 11vw, 54px); }
#hand .card { margin-left: calc(var(--cw) * -0.5); cursor: pointer; transition: transform 0.1s; }
#hand .card.gap { margin-left: calc(var(--cw) * -0.3); }
#hand .card.sel { transform: translateY(-11px); box-shadow: 0 0 0 2.5px var(--gold), 0 8px 12px rgba(0, 0, 0, 0.45); }
#hand .card.new::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: #3f9ae0; }
#hand .empty { padding: 14px 0 18px; margin-left: calc(var(--cw) * -0.5); }
#actions { display: flex; gap: 8px; padding: 6px 10px 10px; max-width: 640px; margin: 0 auto; }
#actions .btn { flex: 1; min-width: 0; padding-inline: 8px; }
.wait { flex: 1; padding: 12px 0; text-align: center; color: var(--muted); font-weight: 600; }
.wait::after { content: '…'; animation: pulse 1.4s ease-in-out infinite; display: inline-block; }

/* ---------- side panel ---------- */
#side {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 92vw);
  display: flex;
  flex-direction: column;
  background: #082a1c;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  padding-bottom: env(safe-area-inset-bottom);
}
.sidehead { display: flex; align-items: center; gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.tabs { flex: 1; display: flex; gap: 4px; }
.tab { flex: 1; padding: 8px 4px; font-size: 14px; font-weight: 600; color: var(--muted); background: none; border: 0; border-bottom: 3px solid transparent; }
.tab.on { color: var(--cream); border-bottom-color: var(--gold); }
.pane { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px; }
#logpane p, #chatlist p { margin-bottom: 7px; font-size: 13.5px; line-height: 1.35; }
#logpane p.mine { color: var(--cream); }
#logpane p.theirs { color: #cfe0b0; }
p.note { color: var(--muted); font-style: italic; }
#chatpane { display: flex; flex-direction: column; padding: 0; }
#chatlist { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px; }
#chatlist p { max-width: 88%; width: fit-content; padding: 6px 10px; background: rgba(255, 255, 255, 0.09); border-radius: 12px; overflow-wrap: anywhere; }
#chatlist p.mine { margin-left: auto; background: rgba(230, 184, 76, 0.22); }
#chatlist p.note { background: none; padding: 0; }
#chatlist b { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
#chatform { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
#chatform input { flex: 1; min-width: 0; min-height: 42px; }
#chatform .btn { min-height: 42px; }
#scorepane table, .scoretable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
#scorepane th, #scorepane td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); }
#scorepane th:first-child, #scorepane td:first-child { text-align: left; }
#scorepane th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
#scorepane tr.total td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--gold); }
#scorepane .note { margin-top: 12px; font-size: 13px; }

/* ---------- banner, toast ---------- */
#banner { position: fixed; z-index: 60; top: 0; left: 0; right: 0; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); text-align: center; font-weight: 600; color: #fff; background: #a8321f; }
#toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  top: 62px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(92vw, 460px);
  padding: 10px 16px;
  font-size: 14.5px;
  font-weight: 500;
  text-align: center;
  color: var(--ink);
  background: var(--cream);
  border-left: 5px solid var(--gold-deep);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ---------- dialogs ---------- */
dialog {
  width: min(560px, calc(100vw - 20px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  color: var(--ink);
  background: var(--cream);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  color-scheme: light;
}
dialog::backdrop { background: rgba(2, 14, 9, 0.7); }
#resultbody, .rulesdoc { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 22px 20px 18px; }
dialog h2 { font: 700 26px/1.15 var(--serif); color: #14402c; padding-right: 36px; }
dialog h3 { margin-top: 10px; font: 700 18px/1.2 var(--serif); color: #14402c; }
dialog .sub { color: #5a6158; font-size: 14px; }
dialog .sub.center { text-align: center; }
dialog .link { color: #46614f; }
dialog .link:hover { color: #14402c; }
dialog .icon.close { position: sticky; top: 10px; align-self: flex-end; margin-bottom: -48px; z-index: 2; color: var(--ink); background: #ece4cf; border-color: #cfc5a8; }
.rulesdoc ul, .rulesdoc ol { margin: 0; padding-left: 22px; }
.rulesdoc li { margin-bottom: 5px; }
.rulesdoc table, .scoretable { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.rulesdoc th, .rulesdoc td, .scoretable th, .scoretable td { padding: 6px 8px; text-align: left; border-bottom: 1px solid #e0d6bb; }
.rulesdoc th, .scoretable th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: #5a6158; }
.scoretable { table-layout: fixed; font-variant-numeric: tabular-nums; }
.scoretable td:first-child, .scoretable th:first-child { width: 40%; }
.scoretable td:not(:first-child), .scoretable th:not(:first-child) { text-align: right; }
.scoretable th { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scoretable small { display: block; font-size: 11.5px; line-height: 1.2; color: #6b7168; }
.scoretable tr.sum td { font-weight: 700; border-top: 2px solid #14402c; }
.scoretable tr.total td { font-weight: 700; font-size: 17px; color: #14402c; border-bottom: 0; }
.leftover { --cw: 34px; display: flex; flex-wrap: wrap; row-gap: 4px; padding-left: 15px; }
.leftover .card { margin-left: -15px; }
dialog .btn.primary { margin-top: 6px; }

/* ---------- small phones ---------- */
@media (max-width: 480px) {
  #bar .brand { display: none; }
  .handno { display: none; }
  #mid { --cw: 52px; gap: 6px; padding: 2px 0; }
  .melds, #tray { --cw: 33px; }
  .melds { gap: 9px 14px; }
  #statusmain { font-size: 14px; }
  #statussub { font-size: 12.5px; }
}
@media (max-height: 640px) {
  #hand { max-height: 34dvh; }
}

/* ---------- tablets and up ---------- */
@media (min-width: 760px) {
  #board { gap: 12px; padding: 14px; }
  .zone { padding: 12px 16px 16px; }
  .melds { --cw: 42px; gap: 12px 20px; }
  #tray { --cw: 42px; max-width: 940px; margin-inline: auto; }
  #mid { --cw: 76px; gap: 20px; padding: 6px 12px; }
  #statusmain { font-size: 18px; }
  #statussub { font-size: 14.5px; }
  .backs { --cw: 22px; }
  .backs.shown { --cw: 42px; }
  #hand { --cw: 66px; padding-top: 20px; }
  #hand.many { --cw: 58px; }
  #hand .card.sel { transform: translateY(-14px); }
  .ribbon { font-size: 10px; bottom: 8px; }
  .count { min-width: 21px; height: 21px; font-size: 12px; }
  #actions { padding-bottom: 14px; }
}

/* ---------- desktop: the log, chat and scores sit beside the table ---------- */
@media (min-width: 1100px) {
  body.ingame { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
  body.ingame #side, body.ingame #side[hidden] { position: static; display: flex !important; width: auto; height: 100dvh; box-shadow: none; }
  #sidebtn, #sideclose { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
