/* Skull King — styles */

:root {
  --bg-1: #101a2e;
  --bg-2: #070c16;
  --ink: #edf2fa;
  --dim: #97a7bf;
  --panel: #16223a;
  --panel-2: #1e2e4e;
  --line: rgba(255, 255, 255, 0.11);
  --gold: #f2b950;
  --gold-dim: rgba(242, 185, 80, 0.16);
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  /* suits */
  --s-green: #2fae5f;
  --s-green-2: #1e7f42;
  --s-yellow: #e0a52e;
  --s-yellow-2: #b57e14;
  --s-purple: #8f63ee;
  --s-purple-2: #6a3fc4;
  --s-black: #2b3242;
  --s-black-2: #171c28;
  /* specials */
  --k-pirate: #c4403f;
  --k-pirate-2: #8f2626;
  --k-escape: #dfe6ee;
  --k-escape-2: #b7c2cf;
  --k-sk: #0c0c12;
  --k-mermaid: #12a5a0;
  --k-mermaid-2: #0a7472;
  --k-tigress: #e07726;
  --k-tigress-2: #aa4f12;
  --k-loot: #c9a13b;
  --k-loot-2: #8e6c1a;
  --k-kraken: #5a3fa0;
  --k-kraken-2: #33215f;
  --k-whale: #3c6fb2;
  --k-whale-2: #23477a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Avenir Next', Avenir, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  background: var(--bg-2);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* The backdrop is pinned to the screen. Painted on the body it would be one
   screen tall and start over below that, and the lobby and the table on a
   phone are longer than a screen. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1100px 700px at 50% -10%, rgba(242, 185, 80, 0.1), transparent 60%),
    radial-gradient(900px 600px at 88% 110%, rgba(18, 165, 160, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
}

a {
  color: var(--gold);
}

.hidden {
  display: none !important;
}

/* 6 and 9 read alike upside-down — underline them wherever values render */
.u69 {
  text-decoration: underline;
  text-underline-offset: 0.13em;
  text-decoration-thickness: 0.09em;
}

/* ---------------------------------------------------------------- screens */

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#screen-home,
#screen-lobby {
  justify-content: center;
  padding: 24px;
  gap: 14px;
}

.back-home {
  position: fixed;
  top: 14px;
  left: 16px;
  color: var(--dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  z-index: 5;
}

.back-home:hover {
  color: var(--ink);
}

/* ---------------------------------------------------------------- home */

.logo {
  margin: 0;
  font-size: clamp(36px, 8vw, 60px);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.55);
}

.logo .skull {
  color: var(--gold);
  margin: 0 0.12em;
  display: inline-block;
  animation: bob 2.6s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-5px) rotate(4deg); }
}

.tagline {
  margin: 0 0 10px;
  color: var(--dim);
  text-align: center;
  max-width: 46em;
  line-height: 1.6;
}

.field {
  width: min(340px, 86vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 17px;
  padding: 13px 16px;
  outline: none;
}

.field:focus {
  border-color: rgba(242, 185, 80, 0.55);
}

.field::placeholder {
  color: #64748c;
}

.btn {
  border-radius: var(--radius);
  padding: 13px 22px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease;
  box-shadow: var(--shadow);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled {
  filter: grayscale(0.55) brightness(0.65);
  cursor: default;
}

.btn.primary {
  background: linear-gradient(180deg, #ffd479, #e09a24);
  color: #402a08;
  width: min(340px, 86vw);
}

.btn.secondary {
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--dim);
  font-weight: 600;
  padding: 9px 16px;
  font-size: 14px;
}

.join-row {
  display: flex;
  gap: 10px;
  width: min(340px, 86vw);
}

.join-row .field {
  flex: 1;
  width: auto;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.divider {
  color: #64748c;
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(340px, 86vw);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

#home-status {
  min-height: 22px;
  color: var(--dim);
  text-align: center;
  max-width: 36em;
}

#home-status.error {
  color: #ff9c9c;
}

.small-print {
  color: #64748c;
  font-size: 12.5px;
  text-align: center;
  max-width: 46em;
  line-height: 1.55;
}

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

.lobby-panel {
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 28px;
  width: min(430px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.lobby-label {
  color: var(--dim);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#lobby-code {
  font-size: 46px;
  font-weight: 900;
  letter-spacing: 0.32em;
  margin-right: -0.32em;
  color: var(--gold);
  text-shadow: 0 4px 18px rgba(242, 185, 80, 0.25);
  user-select: all;
}

.copy-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

#lobby-players {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 40dvh;
  overflow-y: auto;
}

.seat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}

.seat-row.empty {
  opacity: 0.4;
  border-style: dashed;
}

.seat-name {
  font-weight: 700;
}

.seat-name.dim {
  color: var(--dim);
  font-weight: 500;
}

.chip {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--dim);
}

.chip.you {
  background: var(--gold-dim);
  color: var(--gold);
}

.chip.bot {
  background: rgba(18, 165, 160, 0.24);
  color: #7fe0dc;
}

.kick {
  margin-left: auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--dim);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  flex: none;
}

.kick:hover {
  background: rgba(229, 72, 77, 0.32);
  color: #ffb4b4;
}

/* Two lines reserved, not one. The hint rewrites itself as the table fills
   ("Share the code or link — or add a bot" becoming "4 aboard — ten rounds"),
   and the long one wraps: every button below it moved down the moment somebody
   joined. It is the only thing on this screen whose height depends on content. */
#lobby-hint {
  color: var(--dim);
  font-size: 14px;
  text-align: center;
  line-height: 1.5; min-height: 3em;
}

#scoring-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
}

.scoring-pick {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--dim);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.scoring-pick.on {
  background: var(--gold-dim);
  border-color: rgba(242, 185, 80, 0.6);
  color: var(--gold);
}

.scoring-pick:disabled {
  cursor: default;
}

#scoring-blurb {
  color: var(--dim);
  font-size: 13px;
  text-align: center;
  max-width: 34em;
  line-height: 1.5;
  min-height: 18px;
}

#scoring-chip {
  font-weight: 800;
  letter-spacing: 0.03em;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--dim);
}

.av {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  flex: none;
  color: #101418;
}

.av.empty {
  background: rgba(255, 255, 255, 0.07);
  color: var(--dim);
}

.av.bot {
  background: #1d3d54;
  color: #9fe8e4;
  font-size: 17px;
}

.av.s0 { background: #f2b950; }
.av.s1 { background: #58b7ff; }
.av.s2 { background: #3ddc84; }
.av.s3 { background: #ff5d8f; }
.av.s4 { background: #b98aff; }
.av.s5 { background: #63e0dc; }
.av.s6 { background: #ff9c5e; }
.av.s7 { background: #d3e15c; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  flex-wrap: wrap;
  min-height: 50px;
}

#room-chip,
#round-chip {
  font-weight: 800;
  letter-spacing: 0.08em;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--dim);
}

#round-chip {
  color: var(--gold);
}

.topbar .spacer {
  flex: 1;
}

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

#table {
  width: min(1040px, 100%);
  padding: 4px 14px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.seat {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 11px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.seat.turn {
  border-color: rgba(242, 185, 80, 0.65);
  box-shadow: 0 0 0 1px rgba(242, 185, 80, 0.4), 0 0 18px rgba(242, 185, 80, 0.16);
}

.seat.me {
  background: rgba(242, 185, 80, 0.06);
}

.seat.offline {
  opacity: 0.55;
}

.seat.won-pulse {
  animation: wonpulse 1s ease;
}

@keyframes wonpulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.7); }
  100% { box-shadow: 0 0 0 16px rgba(61, 220, 132, 0); }
}

.seat-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.seat-head .av {
  width: 26px;
  height: 26px;
  font-size: 12px;
}

.seat-head .nm {
  font-weight: 800;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-score {
  margin-left: auto;
  font-weight: 800;
  font-size: 13px;
  color: var(--gold);
  white-space: nowrap;
}

.seat-bid {
  display: flex;
  gap: 5px;
  align-items: center;
  min-height: 44px;
  flex-wrap: wrap;
}

.bidchip {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--dim);
}

.bidchip.locked {
  background: var(--gold-dim);
  color: var(--gold);
}

.bidchip.good {
  background: rgba(61, 220, 132, 0.16);
  color: #7fe8ac;
}

.bidchip.over {
  background: rgba(229, 72, 77, 0.16);
  color: #ff9c9c;
}

.seat-note {
  color: var(--dim);
  font-size: 11.5px;
  font-style: italic;
  min-height: 15px;
  line-height: 1.35;
}

/* ---------------------------------------------------------------- trick area */

#middle {
  width: min(1040px, 100%);
  padding: 8px 14px 0;
}

#trick {
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  min-height: 128px;
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.18);
}

#trick .trick-label {
  color: var(--dim);
  font-size: 13px;
  font-weight: 700;
  margin-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 90px;
}

#trick .suitchip {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  align-self: flex-start;
}

.tplay {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.tplay .who {
  font-size: 11px;
  font-weight: 700;
  color: var(--dim);
  max-width: 74px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tplay.winner .who {
  color: #7fe8ac;
}

.tplay.winner .card {
  outline: 2px solid rgba(61, 220, 132, 0.8);
}

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

.card {
  width: 62px;
  height: 88px;
  border-radius: 9px;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.5);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  flex: none;
}

.card.mini {
  width: 52px;
  height: 74px;
}

.card .cv {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}

.card.mini .cv {
  font-size: 21px;
}

.card .cbonus {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.03em;
  background: rgba(0, 0, 0, 0.45);
  color: var(--gold);
  border: 1px solid rgba(242, 185, 80, 0.55);
  border-radius: 999px;
  padding: 1px 7px;
  text-shadow: none;
}

.card.mini .cbonus {
  font-size: 9px;
  padding: 0 5px;
  bottom: 3px;
}

.card .cn {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
  text-align: center;
  line-height: 1.15;
  padding: 0 3px;
}

.card.green { background: linear-gradient(180deg, var(--s-green), var(--s-green-2)); }
.card.yellow { background: linear-gradient(180deg, var(--s-yellow), var(--s-yellow-2)); }
.card.purple { background: linear-gradient(180deg, var(--s-purple), var(--s-purple-2)); }
.card.black { background: linear-gradient(180deg, var(--s-black), var(--s-black-2)); border-color: rgba(242, 185, 80, 0.4); }
.card.pirate { background: linear-gradient(180deg, var(--k-pirate), var(--k-pirate-2)); }
.card.escape { background: linear-gradient(180deg, var(--k-escape), var(--k-escape-2)); color: #2a3442; text-shadow: none; }
.card.sk { background: linear-gradient(180deg, #23232e, var(--k-sk)); border-color: var(--gold); color: var(--gold); }
.card.mermaid { background: linear-gradient(180deg, var(--k-mermaid), var(--k-mermaid-2)); }
.card.tigress { background: linear-gradient(180deg, var(--k-tigress), var(--k-tigress-2)); }
.card.loot { background: linear-gradient(180deg, var(--k-loot), var(--k-loot-2)); }
.card.kraken { background: linear-gradient(180deg, var(--k-kraken), var(--k-kraken-2)); }
.card.whale { background: linear-gradient(180deg, var(--k-whale), var(--k-whale-2)); }

.card .ck {
  font-size: 24px;
  line-height: 1;
}

.card.mini .ck {
  font-size: 20px;
}

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

#hand {
  width: min(1040px, 100%);
  padding: 10px 14px 0;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  min-height: 106px;
  align-items: flex-end;
}

/* stationary hit target; only the inner card face lifts (anti-flicker) */
.hcard {
  padding: 0;
  position: relative;
  cursor: pointer;
  flex: none;
}

.hcard .card {
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.hcard:hover:not(:disabled) .card,
.hcard:focus-visible .card {
  transform: translateY(-7px);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.5);
}

.hcard.sel .card {
  transform: translateY(-10px);
  outline: 3px solid var(--gold);
}

.hcard:disabled {
  cursor: default;
}

.hcard.illegal .card {
  filter: grayscale(0.7) brightness(0.55);
}

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

#action-bar {
  width: min(1040px, 100%);
  padding: 10px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 84px;
}

.abar-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.abar-label {
  color: var(--dim);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}

.abar-label b {
  color: var(--ink);
}

.pick {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 15px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  min-width: 44px;
}

.pick:hover:not(:disabled) {
  border-color: rgba(242, 185, 80, 0.6);
}

.pick.on {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold);
}

.pick:disabled {
  opacity: 0.35;
  cursor: default;
}

.pick.go {
  background: linear-gradient(180deg, #ffd479, #e09a24);
  color: #402a08;
  border: 0;
}

.pick.escape-go {
  background: linear-gradient(180deg, var(--k-escape), var(--k-escape-2));
  color: #2a3442;
  border: 0;
}

.pick.pirate-go {
  background: linear-gradient(180deg, var(--k-pirate), var(--k-pirate-2));
  color: #fff;
  border: 0;
}

/* ---------------------------------------------------------------- feed */

#feed {
  position: fixed;
  right: 12px;
  top: 58px;
  width: 300px;
  max-height: min(300px, 34dvh);
  overflow-y: auto;
  background: rgba(7, 11, 19, 0.88);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--dim);
  z-index: 6;
}

.feed-line {
  padding: 2px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}

.feed-line:last-child {
  border-bottom: 0;
}

/* ---------------------------------------------------------------- chat */

#chat {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 7;
}

#chat-panel {
  width: 300px;
  height: 340px;
  max-height: 46dvh;
  background: rgba(9, 13, 21, 0.96);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.chat-head {
  padding: 9px 13px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
}

#chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chat-msg {
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}

.chat-time {
  color: #5a6a80;
  font-size: 11px;
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}

.chat-name {
  font-weight: 800;
  margin-right: 6px;
}

.chat-name.s0 { color: #f2b950; }
.chat-name.s1 { color: #58b7ff; }
.chat-name.s2 { color: #3ddc84; }
.chat-name.s3 { color: #ff5d8f; }
.chat-name.s4 { color: #b98aff; }
.chat-name.s5 { color: #63e0dc; }
.chat-name.s6 { color: #ff9c5e; }
.chat-name.s7 { color: #d3e15c; }

.chat-msg.mine .chat-text {
  color: #ffe9c4;
}

#chat-form {
  display: flex;
  border-top: 1px solid var(--line);
}

#chat-input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--ink);
  font-size: 14px;
  padding: 11px 12px;
}

.chat-send {
  padding: 0 14px;
  color: var(--gold);
  cursor: pointer;
  font-size: 16px;
}

#chat-toggle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  position: relative;
}

#chat-unread {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

#chat-peek {
  max-width: 300px;
  background: rgba(9, 13, 21, 0.96);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
}

#chat-peek .chat-text {
  color: var(--dim);
}

.chat-bubble {
  position: absolute;
  top: -8px;
  left: 10px;
  transform: translateY(-100%);
  background: #fff;
  color: #1c2634;
  border-radius: 12px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 600;
  max-width: 240px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  z-index: 8;
  pointer-events: none;
  word-break: break-word;
}

.chat-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 16px;
  border: 6px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
}

/* ---------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 12, 0.74);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 18px;
}

.panel {
  background: linear-gradient(180deg, #1b2942, #111b2e);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 26px;
  width: min(440px, 94vw);
  max-height: 88dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow);
  text-align: center;
}

.panel.wide {
  width: min(680px, 94vw);
  text-align: left;
  align-items: stretch;
}

.panel h2 {
  margin: 0;
  font-size: 24px;
}

.rules {
  margin: 0;
  padding-left: 20px;
  color: var(--dim);
  line-height: 1.6;
  font-size: 14.5px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rules b,
.rules i {
  color: var(--ink);
}

.credit {
  color: #64748c;
  font-size: 12.5px;
  line-height: 1.55;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* round-end score table */

#re-table {
  overflow-x: auto;
}

#re-table table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
}

#re-table th,
#re-table td {
  padding: 6px 9px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  white-space: nowrap;
}

#re-table th {
  color: var(--dim);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

#re-table td.nm {
  text-align: left;
  font-weight: 700;
}

#re-table .pos {
  color: #7fe8ac;
  font-weight: 800;
}

#re-table .neg {
  color: #ff9c9c;
  font-weight: 800;
}

#re-table .tot {
  color: var(--gold);
  font-weight: 800;
}

#re-wait,
#go-wait {
  color: var(--dim);
  font-size: 13.5px;
}

#go-rank {
  margin: 0;
  padding: 0;
  list-style: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}

.rank-row.me {
  border-color: rgba(242, 185, 80, 0.5);
}

.rank-pos {
  font-weight: 900;
  font-size: 16px;
  width: 22px;
  text-align: center;
  color: var(--dim);
}

.rank-name {
  font-weight: 700;
  flex: 1;
  text-align: left;
}

.rank-score {
  font-weight: 800;
  color: var(--gold);
}

/* ---------------------------------------------------------------- toasts, flash */

#toasts {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: rgba(12, 17, 27, 0.95);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.toast.gone {
  opacity: 0;
  transform: translateY(-8px);
}

.flash {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(24px, 5.4vw, 40px);
  font-weight: 900;
  letter-spacing: 0.04em;
  padding: 14px 34px;
  border-radius: 18px;
  background: rgba(8, 12, 20, 0.94);
  border: 2px solid var(--gold);
  color: var(--gold);
  z-index: 25;
  animation: flashpop 1.7s ease forwards;
  text-align: center;
  pointer-events: none;
}

.flash.bad {
  border-color: #ff5d5d;
  color: #ff9c9c;
}

.flash.plain {
  border-color: var(--line);
  color: var(--ink);
}

@keyframes flashpop {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  12% { transform: translate(-50%, -50%) scale(1.06); opacity: 1; }
  22% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 26;
  overflow: hidden;
}

#confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(-10px) rotate(0); opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(105dvh) rotate(660deg); opacity: 0; }
}

/* ---------------------------------------------------------------- layout: desktop gutter */

@media (min-width: 1000px) {
  #screen-game {
    /* keep the docked log + chat column clear of the play area */
    padding-right: 320px;
  }
}

/* ---------------------------------------------------------------- narrow screens
   (keep this block at the END of the file: it must win the cascade) */

@media (max-width: 999px) {
  #feed {
    position: static;
    width: auto;
    margin: 8px 14px;
    max-height: 150px;
    order: 9;
  }

  #screen-game {
    padding-bottom: 90px;
  }

  #chat {
    bottom: 10px;
    right: 10px;
  }

  #chat-panel {
    width: min(300px, calc(100vw - 20px));
  }

  .card {
    width: 52px;
    height: 76px;
  }

  .card .cv {
    font-size: 21px;
  }

  .card.mini {
    width: 44px;
    height: 62px;
  }
}

/* Disconnect banner: the table stalls until the player returns or the host
   resolves it (neutral tones so it reads on any of our palettes) */
#dc-banner { display: none; }
#dc-banner.on { display: flex; flex-direction: column; gap: 6px; margin: 10px auto 2px; max-width: 620px; padding: 0 10px; }
#dc-banner .dc-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; background: rgba(255, 92, 92, 0.14); border: 1px solid rgba(255, 92, 92, 0.55); border-radius: 10px; padding: 7px 12px; font-size: 13px; line-height: 1.35; }
#dc-banner .dc-row.covered { background: rgba(127, 127, 127, 0.12); border-color: rgba(127, 127, 127, 0.45); }
#dc-banner .dc-btn { border: 1px solid rgba(127, 127, 127, 0.55); background: rgba(127, 127, 127, 0.16); color: inherit; border-radius: 8px; padding: 4px 10px; font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
#dc-banner .dc-btn:hover { background: rgba(127, 127, 127, 0.28); }

/* Observers: watch chip, lobby note, and the shadow-a-player bar */
#watch-chip { display: none; }
#watch-chip.on { display: inline-block; margin-left: 8px; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(127, 127, 127, 0.16); border: 1px solid rgba(127, 127, 127, 0.4); vertical-align: middle; }
#lobby-watch { display: none; }
#lobby-watch.on { display: block; margin: 6px auto 0; font-size: 12.5px; opacity: 0.85; text-align: center; }
#ob-bar { display: none; }
#ob-bar.on { display: flex; flex-direction: column; gap: 6px; margin: 10px auto 2px; max-width: 620px; padding: 0 10px; }
#ob-bar .ob-row { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; background: rgba(120, 160, 255, 0.12); border: 1px solid rgba(120, 160, 255, 0.5); border-radius: 10px; padding: 7px 12px; font-size: 13px; line-height: 1.35; }
#ob-bar .ob-switch { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
#ob-bar .ob-btn { border: 1px solid rgba(127, 127, 127, 0.55); background: rgba(127, 127, 127, 0.16); color: inherit; border-radius: 8px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
#ob-bar .ob-btn:hover { background: rgba(127, 127, 127, 0.28); }
#ob-bar .ob-btn.on { background: rgba(120, 160, 255, 0.3); border-color: rgba(120, 160, 255, 0.75); cursor: default; }

/* Seat claiming / resigning */
#ob-bar .ob-btn.claim { background: rgba(120, 230, 160, 0.18); border-color: rgba(120, 230, 160, 0.6); }
#ob-bar .ob-btn.claim:hover { background: rgba(120, 230, 160, 0.3); }
#lobby-watch button { margin-left: 8px; border: 1px solid rgba(120, 230, 160, 0.6); background: rgba(120, 230, 160, 0.18); color: inherit; border-radius: 8px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
#lobby-watch button:hover { background: rgba(120, 230, 160, 0.3); }

/* Rectangular table: players face each other top/bottom; played cards land
   in a slot on each player's table-facing side */
.prow { display: flex; justify-content: center; align-items: stretch; gap: 12px; flex-wrap: wrap; width: min(1040px, 100%); padding: 2px 14px; }
.pcell { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 150px; }
.pcell .seat { width: 100%; }
.pslot { min-height: 84px; display: flex; align-items: center; justify-content: center; }
.pslot.empty { border: 2px dashed rgba(127, 127, 127, 0.3); border-radius: 9px; width: 52px; height: 74px; box-sizing: border-box; }
.pslot .slot-hint { font-size: 10.5px; color: var(--dim); text-align: center; padding: 2px; }
#middle { min-height: 40px; }
#middle { min-height: 0; }
#trick { min-height: 100px; }
#trick { padding: 6px 12px; }

/* Announcements must survive any browser width: wrap instead of clipping */
.flash { max-width: min(92vw, 780px); width: max-content; white-space: normal; overflow-wrap: break-word; text-align: center; box-sizing: border-box; }

/* Your side of the table reads centered, like everything above it — but a
   centred flex row that overflows spills equally off BOTH ends, and the left
   spill cannot be scrolled back to: scrollLeft is already 0 there. `safe`
   drops the centring exactly when that would happen, so a hand wider than the
   phone starts at its first card instead of hiding it. */
#hand { justify-content: safe center; }
#action-bar { align-items: center; }
#action-bar .abar-row { justify-content: center; }
#action-bar { align-self: center; margin-left: auto; margin-right: auto; }

/* Game table-talk: the same bubbles as chat, tinted as the game speaking */
.chat-bubble.say { border: 1px solid rgba(255, 205, 110, 0.75); background: rgba(66, 52, 22, 0.96); color: #ffe9c4; font-weight: 600; }

/* Top-row players speak toward the table: bubbles hang below their seat */
.chat-bubble { max-width: min(240px, 60vw); }
.chat-bubble.below { top: auto; bottom: -8px; transform: translateY(100%); }
.chat-bubble.below::after { bottom: auto; top: -6px; border-top-color: transparent; border-bottom-color: #fff; }
.chat-bubble.say::after { border-top-color: rgba(66, 52, 22, 0.96); }
.chat-bubble.say.below::after { border-top-color: transparent; border-bottom-color: rgba(66, 52, 22, 0.96); }

/* Bubbles on a fixed overlay: flicker-free, unclippable, above the seats */
#bubble-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; }
#bubble-layer .bubble-stack { position: absolute; display: flex; flex-direction: column; gap: 4px; transform: translate(-50%, calc(-100% - 10px)); }
#bubble-layer .chat-bubble { position: relative; left: auto; top: auto; bottom: auto; right: auto; margin: 0; transform: none; }
#bubble-layer .chat-bubble::after { display: none; }
#bubble-layer .chat-bubble:last-child::after { display: block; left: 50%; right: auto; bottom: -12px; top: auto; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fff; }
#bubble-layer .chat-bubble.say:last-child::after { border-top-color: rgba(66, 52, 22, 0.96); }
/* headroom for table talk above the top row; fixed seat footprints */
#row-top { margin-top: 84px; }
.pcell { width: 168px; min-width: 168px; }
.pcell .seat { min-height: 104px; }
.seat-note { min-height: 15px; }
.prow .pcell { flex: 0 0 168px; }

/* ================================================================ 7 Wonders */

#cities { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; padding: 8px; }
#me { padding: 0 8px 8px; }

.city { background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.09); border-radius: 12px; padding: 8px; font-size: 12px; }
.city.mine { border-color: rgba(224,179,82,.45); background: rgba(224,179,82,.07); }
.city-head { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.city-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.nb { background: rgba(127,180,216,.22); color: #bcdcf0; }
.chip.ready { background: rgba(127,192,138,.25); color: #b7e6c1; }
.chip.off { background: rgba(200,106,106,.2); color: #e9b6b6; }
.chip.team.t0 { background: rgba(127,180,216,.22); color: #bcdcf0; }
.chip.team.t1 { background: rgba(224,179,82,.22); color: #f0d9a4; }

.city-stat { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 5px; }
.coin-chip { background: #e0b352; color: #2a1e0c; border-radius: 9px; padding: 0 6px; font-weight: 800; }
.shield-chip { background: rgba(200,106,106,.22); color: #f0c0c0; border-radius: 9px; padding: 0 6px; }
.tok-chip { background: rgba(255,255,255,.1); border-radius: 9px; padding: 0 6px; }
.debt-chip { background: rgba(120,0,0,.4); color: #ffb4b4; border-radius: 9px; padding: 0 6px; }

.city-wonder { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.w-name { color: #e0b352; font-weight: 600; }
.w-pips { display: inline-flex; gap: 3px; }
.pip { width: 9px; height: 9px; border-radius: 2px; background: rgba(255,255,255,.16); display: inline-block; }
.pip.on { background: #e0b352; }

.city-cards { display: flex; flex-wrap: wrap; gap: 4px; }
.stack { position: relative; display: flex; align-items: center; gap: 3px; padding: 1px 5px; border-radius: 7px;
         font-size: 10px; line-height: 1.5; max-width: 100%; }
.stack-n { font-weight: 800; }
.stack-card { opacity: .78; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 8em; }
.stack.brown  { background: rgba(140, 94, 58, .5); }
.stack.grey   { background: rgba(150, 150, 155, .38); }
.stack.blue   { background: rgba(80, 130, 200, .42); }
.stack.yellow { background: rgba(210, 170, 60, .38); color: #2a1e0c; }
.stack.red    { background: rgba(190, 70, 70, .45); }
.stack.green  { background: rgba(80, 160, 100, .42); }
.stack.purple { background: rgba(150, 100, 190, .42); }
.stack.black  { background: rgba(40, 40, 46, .75); }
.stack.white  { background: rgba(232, 224, 206, .82); color: #2a2318; }

/* resource letters, coloured so a cost reads as a shape */
.res { display: inline-flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.res-chip { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 3px;
            font-size: 10px; font-weight: 800; color: #16100a; }
.res-choice { display: inline-flex; align-items: center; gap: 1px; padding: 0 2px;
              border: 1px dashed rgba(255,255,255,.3); border-radius: 4px; }
.res-slash { opacity: .5; font-size: 9px; }
.r-wood { background: #8c5e3a; color: #f6ecdf; }
.r-stone { background: #9aa0a6; }
.r-clay { background: #c07a45; }
.r-ore { background: #55606e; color: #eaf0f6; }
.r-glass { background: #7fc8e8; }
.r-papyrus { background: #e8e0c0; }
.r-textile { background: #c79ad8; }

/* the hand */
#hand { display: flex; gap: 8px; padding: 8px; overflow-x: auto; align-items: stretch; }
.hand-note { color: #9fb4aa; padding: 10px; }

/* Testing knobs: the step prompt, and a bot's hand turned face up. Both are
   deliberately plain — they are scaffolding, not part of the game. */
#step {
  align-self: center; margin: 2px auto 0; padding: 5px 12px;
  border: 1px dashed rgba(224, 179, 82, .5); border-radius: 999px;
  color: #e0b352; font-size: 12px; cursor: pointer;
}
.city-peek {
  margin-top: 3px; font-size: 10.5px; line-height: 1.4;
  color: #8fa89c; font-style: italic; overflow-wrap: anywhere;
}
.hand-card { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }
.swcard { border-radius: 10px; padding: 7px; border: 1px solid rgba(255,255,255,.13);
          background: rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 4px; min-height: 96px; }
.swcard .sw-name { font-weight: 700; font-size: 13px; }
.swcard .sw-gist { font-size: 11px; color: #cfe3d5; line-height: 1.35; }
.swcard .sw-cost { margin-top: auto; display: flex; gap: 4px; align-items: center; }
.sw-free { font-size: 10px; color: #7fc08a; }
.swcard.brown  { border-left: 4px solid #8c5e3a; }
.swcard.grey   { border-left: 4px solid #9aa0a6; }
.swcard.blue   { border-left: 4px solid #5082c8; }
.swcard.yellow { border-left: 4px solid #d2aa3c; }
.swcard.red    { border-left: 4px solid #be4646; }
.swcard.green  { border-left: 4px solid #50a064; }
.swcard.purple { border-left: 4px solid #9664be; }
.swcard.black  { border-left: 4px solid #2a2a30; }
/* Leaders are white cards with a different back; on a dark table the tell is
   the pale edge and a warmer face than any Age card has. */
.swcard.white  { border-left: 4px solid #e8e0ce; background: rgba(232, 224, 206, .10); }
/* the "take nothing" face at the end of the discard pile: a card-shaped
   absence, so it lines up with the real ones without pretending to be one */
.swcard.ghost  { border-left: 4px dashed rgba(255,255,255,.22); background: none; color: #8fa89c; }
.swcard.white .sw-name { color: #f2ead8; }

.edition { font-size: 12.5px; color: #9fb4aa; border-left: 3px solid rgba(224,179,82,.5); padding-left: 10px; }
.lead-chip { background: rgba(232,224,206,.16); color: #efe6d2; border-radius: 6px; padding: 0 5px; }
.act-leaders .lead-name { color: #efe6d2; border-bottom: 1px dotted rgba(239,230,210,.45); cursor: help; }

.card-acts { display: flex; flex-direction: column; gap: 3px; }
.btn.tiny { font-size: 11px; padding: 3px 6px; border-radius: 7px; }
.btn.tiny.go { background: #2f7a4a; }
.btn.tiny.sell { background: rgba(255,255,255,.08); }
/* the once-an-Age free build: a third way to build, so it reads as a sibling
   of Build rather than of Sell */
.btn.tiny.free { background: #2f6a7a; }
.btn.tiny:disabled { opacity: .38; cursor: not-allowed; }

#waiting { padding: 2px 10px; color: #e0b352; font-size: 13px; min-height: 18px; }
.act-note { color: #9fb4aa; font-size: 12px; display: inline-flex; gap: 5px; align-items: center; flex-wrap: wrap; }

/* lobby pickers */
#exp-picker, #side-picker { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pick { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); color: inherit;
        border-radius: 9px; padding: 5px 10px; cursor: pointer; font: inherit; font-size: 13px; }
.pick.on { background: rgba(224,179,82,.22); border-color: #e0b352; color: #f0d9a4; }
.pick:disabled { cursor: default; opacity: .75; }
#exp-blurb, #side-blurb { font-size: 12px; color: #9fb4aa; margin: 4px 0 2px; line-height: 1.5; }

/* end-of-age and final tables */
.ae-row, .go-row { display: grid; gap: 8px; align-items: baseline; padding: 3px 4px; border-radius: 6px; font-size: 13px; }
.ae-row { grid-template-columns: 1fr 70px 70px 70px; }
/* Eight columns in the base game, up to eleven with Leaders, Cities and
   somebody in debt. The numbers give up width before the names do, so a long
   scoresheet narrows rather than truncating whose it is. */
.go-row {
  grid-template-columns: minmax(58px, 1fr) repeat(var(--go-cols, 8), minmax(28px, 52px));
  gap: 6px; font-variant-numeric: tabular-nums;
}
#gameover .panel.wide { width: min(760px, 94vw); }
.ae-row.head, .go-row.head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #6f9a80; }
.go-row.win { background: rgba(224,179,82,.14); }
.go-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.go-total { font-weight: 800; color: #e0b352; }
.ae-row .up { color: #6fcf7f; }
.ae-row .down { color: #e07a6a; }
/* Ten columns do not fit on a phone, and squeezing them squeezes the names to
   nothing. So below 700px the scoresheet stops being a table: one block per
   player, their name and total on top, the breakdown wrapping underneath with
   each figure wearing the label the header row used to give it. */
@media (max-width: 700px) {
  #go-table { display: flex; flex-direction: column; gap: 6px; }
  .go-row.head { display: none; }
  .go-row {
    display: flex; flex-wrap: wrap; gap: 3px 9px; align-items: baseline;
    padding: 7px 9px; background: rgba(255, 255, 255, .045); font-size: 12px;
  }
  .go-row .go-name { order: 0; flex: 1 1 auto; font-weight: 700; font-size: 14px; }
  .go-row .go-total { order: 1; margin-left: auto; font-size: 16px; }
  .go-row span[data-k] { order: 2; }
  .go-row span[data-k]::before {
    content: attr(data-k) " ";
    font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
    color: #6f9a80; margin-right: 1px;
  }
  .go-row .go-total::before { color: inherit; opacity: .6; }
}
.diplo-chip { background: rgba(127,180,216,.25); color: #cfe8f7; border-radius: 9px; padding: 0 6px; }
.chip.mate { background: rgba(127,192,138,.28); color: #c7ecd0; }
.stack.black { color: #d9d9e2; }

/* The lobby's two conditional buttons take turns in the same slot, so they hold
   one height between them — an emoji in one label made its line box 2px taller
   than the other's and everything below twitched as they swapped. */
#btn-add-bot, #btn-start { min-height: 42px; line-height: 1.2; }

/* ---------------------------------------------------------------- phones
   (keep this block at the END of the file: it must win the cascade)

   Every screen here was drawn for a desktop window and then left to stack when
   the window narrowed, so on a 375x667 phone the important half of each one
   sat below the fold. Nothing below changes the design; it is the same layout
   at phone scale. */
/* The home and lobby screens tighten on a short window as well as a narrow
   one, because a phone held sideways has 375px of height and the same problem. */
@media (max-width: 640px), (max-height: 520px) {
  #screen-home,
  #screen-lobby { padding: 14px; gap: 9px; }
  /* the Collection pill is fixed at the top left, so the screen has to start
     below it rather than behind it */
  #screen-home { padding-top: 52px; }

  .tagline { font-size: 13.5px; line-height: 1.5; margin-bottom: 0; }
  /* 16px is the floor: anything smaller and iOS zooms the page on focus */
  .field { font-size: 16px; padding: 11px 14px; }
  .btn { padding: 11px 18px; font-size: 16px; }
  .btn.ghost { padding: 8px 14px; font-size: 13.5px; }
  .divider { font-size: 12px; }
  #home-status { min-height: 18px; font-size: 13px; }
  .small-print { font-size: 11.5px; line-height: 1.45; }

  .lobby-panel { padding: 14px 12px; gap: 8px; border-radius: 18px; }
  .lobby-label { font-size: 11px; }
  #lobby-code { font-size: 28px; }
  /* Every seat is listed, filled or not, so a full room was taller than the
     phone and the rest of the lobby sat below the fold. Two columns puts the
     whole table on screen instead of behind a scrollbar. */
  #lobby-players { display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
    max-height: none; overflow: visible; margin-top: 0; }
  .seat-row { gap: 7px; padding: 6px 8px; min-width: 0; }
  .seat-row .av { width: 24px; height: 24px; font-size: 11px; }
  .seat-name { font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chip { font-size: 9px; padding: 1px 5px; letter-spacing: 0; }
  /* the avatar is already a bot's, so the chip repeating it only costs the
     name the room it needs in half a column */
  .seat-row .chip.bot { display: none; }
  .kick { width: 20px; height: 20px; font-size: 10px; }
  #lobby-hint { font-size: 12.5px; }
}

/* The table below is a narrow-screen layout, not a short-screen one: a wide
   window that happens to be short still wants the desktop table. */
@media (max-width: 640px) {
  /* One line. A wrapped topbar costs three of them, and the gear and log
     buttons already claim the right-hand 100px. */
  .topbar { flex-wrap: nowrap; gap: 6px; padding: 8px 10px; min-height: 0; }
  .topbar .btn.ghost { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
  /* nothing may reach under those two buttons, so when the bar runs out of
     room the chips give up width and the buttons keep theirs */
  .topbar > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .btn { flex: none; }

  #feed { max-height: 74px; margin: 5px 8px; font-size: 11px; }
  /* Room for the chat button and no more. A 46px button 10px off the bottom
     needs 56 of reserve and was getting 44, so its top twelve pixels sat on the
     log; here it is the same size as the gear and the log toggle in the other
     corner, and the reserve actually covers it. */
  #chat-toggle { width: 38px; height: 38px; font-size: 17px; }
  #screen-game { padding-bottom: 52px; }

  /* two pickers and two blurbs before the Start button: eight players filled
     the lobby past the fold, and these are the least of it */
  #exp-picker, #side-picker { gap: 5px; }
  .pick { padding: 4px 9px; font-size: 12px; }
  #exp-blurb, #side-blurb { font-size: 11.5px; line-height: 1.4; margin: 2px 0 0; }

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

  /* Cities wanted 210px each, so a phone showed one per row and eight players
     ran the board four screens deep. Two per row, and the wonder and its
     stacks sized to that width. */
  /* these blocks size to their contents on a centring column, so a grid told
     to fit two columns was still handed one column's worth of width */
  #cities, #me, #hand, #action-bar, #waiting { width: 100%; }
  #cities { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 6px; padding: 6px 8px; }
  .city { padding: 6px 7px; font-size: 11px; border-radius: 10px; }
  .city-head { gap: 5px; margin-bottom: 3px; }
  .city .av { width: 20px; height: 20px; font-size: 10px; }
  .city-name { font-size: 12px; }
  .city-stat { gap: 4px; margin-bottom: 3px; }
  .city-wonder { gap: 4px; margin-bottom: 3px; }
  .pip { width: 7px; height: 7px; }
  .stack { font-size: 9.5px; padding: 0 4px; }
  .stack-card { max-width: 5.5em; }
  .res-chip { width: 13px; height: 13px; font-size: 9px; }
  #me { padding: 0 8px 6px; }

  /* The hand is a row that scrolls — it says so two hundred lines further up,
     but the earlier rule's flex-wrap survived into it, so seven cards stacked
     into a 720px column instead. */
  #hand { flex-wrap: nowrap; min-height: 0; padding: 6px 8px; gap: 6px;
    scrollbar-width: none; }
  #hand::-webkit-scrollbar { display: none; }
  .hand-card { min-width: 138px; gap: 4px; }
  .swcard { min-height: 0; padding: 6px; gap: 3px; }
  .swcard .sw-name { font-size: 12px; }
  .swcard .sw-gist { font-size: 10px; line-height: 1.3; }
  .btn.tiny { font-size: 10.5px; padding: 2px 5px; }
  .card-acts { gap: 2px; }

  /* the age, the turn and which way the hands are passing are three chips
     that do not fit beside a room code and two buttons. The age and turn are
     one chip; which way it passes is drawn on every card row anyway. */
  #age-chip, #turn-chip, #pass-chip { font-size: 10px; padding: 3px 6px; white-space: nowrap; }
  #pass-chip { display: none; }
  #room-chip { font-size: 10px; padding: 3px 6px; letter-spacing: .03em; }
  .topbar .btn.ghost { padding: 5px 8px; font-size: 11px; }

  #waiting { min-height: 0; font-size: 12px; padding: 2px 8px; }
  #action-bar { min-height: 0; padding: 6px 8px 8px; gap: 6px; }
  .act-note { font-size: 11px; }
}
