/* Trilliant. A plain dark table, flat ivory cards, a little brass for controls.
   The cut gems are the only saturated colour on the page. */

:root {
  --velvet-950: #120d0b;
  --velvet-900: #1a1310;
  --velvet-800: #231a15;
  --velvet-700: #2d221b;
  --velvet-600: #3a2c23;
  --velvet-500: #4b3a2e;
  --ivory: #f3ebdc;
  --ivory-2: #e6dac4;
  --ivory-3: #d5c6ab;
  --ink: #2a211c;
  --ink-soft: #66574b;
  --brass: #c9a35a;
  --brass-hi: #e9c97f;
  --brass-lo: #8c6c34;
  --text: #f0e7d7;
  --text-mute: #b9a893;
  --text-faint: #8a7a69;
  --line: rgba(240, 231, 215, 0.1);
  --line-brass: rgba(201, 163, 90, 0.32);
  --ok: #7fc79a;
  --warn: #e7a35c;

  --band-white: #d9dfe8; --ink-white: #2a2f3a;
  --band-blue: #1f4ea9; --ink-blue: #eef3ff;
  --band-green: #0f774e; --ink-green: #effaf4;
  --band-red: #a8243a; --ink-red: #fff0f2;
  --band-black: #2a2830; --ink-black: #f1eff5;
  --band-gold: #b8891f; --ink-gold: #fff8e3;

  --font-display: 'IM Fell English', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-ui: 'Schibsted Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;

  --radius: 14px;
  --cw: clamp(72px, min((100vw - 480px) / 6.9, (100vh - 370px) / 4.3), 128px);
  --nw: calc(var(--cw) * 0.84);
  --tw: calc(var(--cw) * 0.56);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font: 400 15px/1.45 var(--font-ui);
  background: #1c1613;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }
#trilliant-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shared bits ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line-brass);
  background: transparent; color: var(--text);
  font-weight: 600; font-size: 14px; letter-spacing: 0.01em; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover:not(:disabled) { border-color: var(--brass); background: rgba(201, 163, 90, 0.08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn--primary { color: #241809; border-color: transparent; background: #d4b06a; }
.btn--primary:hover:not(:disabled) { background: #e0bf7c; border-color: transparent; }
.btn--small { min-height: 30px; padding: 0 12px; font-size: 13px; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-mute); }
.btn--ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line); background: transparent; }
/* Leaving: red so it can't be mistaken for anything else. */
.btn--danger { color: #f19a8f; border-color: rgba(233, 115, 99, 0.5); background: transparent; }
.btn--danger:hover:not(:disabled) { color: #ffb4aa; border-color: #e97363; background: rgba(233, 115, 99, 0.1); }
.btn--danger-solid { color: #fff4f1; border-color: transparent; background: #c2443a; }
.btn--danger-solid:hover:not(:disabled) { background: #d4544a; border-color: transparent; }

.field {
  width: 100%; min-height: 44px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line-brass);
  background: rgba(10, 7, 5, 0.45); color: var(--text);
  font-size: 16px;
}
.field::placeholder { color: var(--text-faint); }
.field:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(201, 163, 90, 0.18); }
.label { display: block; margin: 0 0 6px; font-size: 13px; color: var(--text-mute); }

.panel {
  border-radius: var(--radius);
  background: #261e19;
  border: 1px solid var(--line);
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.dot.is-on { background: var(--ok); box-shadow: 0 0 0 3px rgba(127, 199, 154, 0.16); }

.gem { display: block; flex: none; }
.gem--lift { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45)); }

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

.home {
  min-height: 100dvh; display: grid; place-items: center;
  padding: 48px 20px 32px;
}
.home__inner { width: min(560px, 100%); text-align: center; }
.home__gems { display: flex; justify-content: center; align-items: flex-end; gap: clamp(10px, 3vw, 22px); margin-bottom: 26px; }
.home__gems .gem { width: clamp(40px, 9vw, 60px); height: clamp(40px, 9vw, 60px); animation: settle 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.home__gems .gem:nth-child(2) { animation-delay: 0.06s; } .home__gems .gem:nth-child(3) { animation-delay: 0.12s; }
.home__gems .gem:nth-child(4) { animation-delay: 0.18s; } .home__gems .gem:nth-child(5) { animation-delay: 0.24s; }
.home__gems .gem:nth-child(6) { animation-delay: 0.3s; }
@keyframes settle { from { opacity: 0; transform: translateY(-14px) rotate(-8deg); } to { opacity: 1; transform: none; } }
.home__mark { font: 400 clamp(64px, 14vw, 104px)/0.9 var(--font-display); margin: 0; letter-spacing: -0.01em; color: var(--ivory); }
.home__mark em { color: var(--brass-hi); font-style: italic; }
.home__lede { margin: 16px auto 30px; max-width: 30em; color: var(--text-mute); font-size: 16px; }
.home__form { display: grid; gap: 14px; text-align: left; padding: 22px; }
.home__row { display: flex; gap: 10px; }
.home__row .field { flex: 1; }
.home__small { margin-top: 26px; font-size: 12.5px; color: var(--text-faint); }
.tables { margin-top: 22px; text-align: left; }
.tables__title { font: 700 17px var(--font-ui); margin: 0 0 8px; color: var(--ivory); }
.tables__row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.tables__row:first-of-type { border-top: 0; }
.tables__what { flex: 1; min-width: 0; }
.tables__what strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tables__what span { font-size: 12.5px; color: var(--text-faint); }

/* ---------- centred sheets (lobby, notices) ---------- */

.stage { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 28px 16px; }
.sheet { width: min(560px, 100%); min-width: 0; padding: 26px; }
.sheet__title { font: 700 28px/1.15 var(--font-ui); letter-spacing: -0.015em; margin: 0 0 8px; color: var(--ivory); }
.sheet__sub { margin: 0 0 20px; color: var(--text-mute); }
.sheet__actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 20px; }
.notice { text-align: center; }
.notice .sheet__actions { justify-content: center; }

.invite { display: flex; gap: 8px; align-items: stretch; margin: 0 0 22px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.setting--tight { margin-top: 10px; }
.setting__label { font-size: 14px; color: var(--text-mute); }
.setting__value { font-weight: 600; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); }
.segmented button { min-height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--text-mute); font-weight: 600; font-size: 13px; }
.segmented button:hover { color: var(--text); }
.segmented button.is-on { background: #d4b06a; color: #241809; }
.slider { display: flex; align-items: center; gap: 12px; }
.slider input[type=range] {
  -webkit-appearance: none; appearance: none; width: min(200px, 44vw); height: 6px; margin: 0; border-radius: 3px; cursor: pointer;
  background: linear-gradient(to right, #d4b06a var(--fill, 0%), rgba(240, 231, 215, 0.14) var(--fill, 0%));
}
.slider input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #e0bf7c; border: 3px solid #241809; box-shadow: 0 0 0 1px #d4b06a; }
.slider input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #e0bf7c; border: 3px solid #241809; box-shadow: 0 0 0 1px #d4b06a; }
.slider input[type=range]:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 6px; }
.slider__value { min-width: 2ch; font: 800 18px/1 var(--font-ui); font-variant-numeric: tabular-nums; text-align: right; color: var(--ivory); }
.invite__link {
  flex: 1; min-width: 0; display: flex; align-items: center; padding: 0 12px;
  border-radius: 10px; border: 1px dashed var(--line-brass); background: rgba(0, 0, 0, 0.22);
  font: 500 13px ui-monospace, 'SF Mono', Menlo, monospace; color: var(--text-mute);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

.seats { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.seat {
  display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 6px 8px 6px 16px;
  border-radius: 12px; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--line);
}
.seat--empty { border-style: dashed; color: var(--text-faint); }
.seat__name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat__tag { font-size: 12px; color: var(--text-mute); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.seat__you { color: var(--text-faint); font-weight: 500; }
.seat__off { font-size: 12px; font-weight: 600; color: var(--warn); }
.icon-btn { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-mute); }
.icon-btn:hover { color: var(--text); background: rgba(240, 231, 215, 0.08); }
.seat .rename { display: flex; gap: 8px; width: 100%; margin: 0; }
.seat .rename .field { min-height: 34px; }
.seat__wins { font: 800 15px var(--font-ui); color: var(--brass-hi); }
.rename .field { flex: 1; font-size: 15px; }

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

.lobby { width: min(520px, 100%); }
.lobby__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.lobby__head .sheet__title { margin: 0; }
.players { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.player { display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.player__name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player__meta { flex: 1; display: flex; justify-content: flex-end; gap: 10px; font-size: 12.5px; color: var(--text-mute); }
.player--empty { color: var(--text-faint); font-size: 14px; }
.avatar { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; margin-right: 6px; border-radius: 50%; background: rgba(240, 231, 215, 0.13); color: var(--ivory); font: 800 13px/1 var(--font-ui); }
.avatar--me { background: #d4b06a; color: #241809; }
.avatar.is-off { opacity: 0.45; }
.avatar--empty { background: transparent; border: 1.5px dashed rgba(240, 231, 215, 0.24); }
.player .rename { display: flex; gap: 8px; width: 100%; }
.player .rename .field { flex: 1; min-height: 34px; font-size: 15px; }
.settings { margin-top: 18px; display: grid; gap: 14px; }
.settings .setting { margin: 0; }
/* Reads as one more settings row: same label style on the left, a chevron where the controls sit. */
.more__toggle { display: flex; align-items: center; justify-content: space-between; min-height: 36px; font-size: 14px; color: var(--text-faint); cursor: pointer; list-style: none; border-radius: 6px; }
.more__toggle::-webkit-details-marker { display: none; }
.more__toggle::after { content: ''; width: 7px; height: 7px; margin: -3px 6px 0 0; border-right: 1.5px solid var(--text-faint); border-bottom: 1.5px solid var(--text-faint); transform: rotate(45deg); transition: transform 0.15s ease; }
.more[open] .more__toggle::after { margin-top: 4px; transform: rotate(-135deg); }
.more__toggle:hover, .more[open] .more__toggle { color: var(--text-mute); }
.more__toggle:hover::after { border-color: var(--text-mute); }
.more__body { display: grid; gap: 14px; margin-top: 8px; }
.setting__hint { display: block; font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.lobby__actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 24px; }
.lobby__note { margin: 14px 0 0; font-size: 12.5px; color: var(--text-faint); }

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

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(250px, 22vw, 330px);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px 14px;
  height: 100dvh;
  /* Past this the board has stopped growing; more width would only stretch the panels under it. */
  max-width: 1460px; margin-inline: auto;
  padding: 10px 14px 12px;
}
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; min-height: 44px; }
.topbar__mark { font: 400 26px/1 var(--font-display); color: var(--ivory); margin: 0; }
.topbar__status { flex: 1; min-width: 0; display: flex; justify-content: center; }
.topbar__tools { display: flex; align-items: center; gap: 8px; }
.topbar__sound { width: 34px; height: 34px; border: 1px solid var(--line); }
.topbar__sound:hover { border-color: var(--brass); }
.turnpill {
  display: inline-flex; align-items: center; gap: 10px; padding: 6px 16px; border-radius: 999px;
  min-width: 0; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); font-weight: 600; font-size: 14px;
}
.turnpill.is-mine { color: #241809; border-color: transparent; background: #d4b06a; }
.turnpill__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.turnpill__final { color: var(--warn); }
.turnpill__clock { font-variant-numeric: tabular-nums; font-weight: 700; opacity: 0.85; min-width: 2.6em; text-align: right; }
.turnpill.is-warn { border-color: rgba(233, 115, 99, 0.7); }
.turnpill.is-warn .turnpill__clock { color: #ff9d8f; opacity: 1; }
.turnpill.is-mine.is-warn { background: #e6a07a; }
.turnpill.is-mine.is-warn .turnpill__clock { color: #6b1308; }
.turnpill.is-mine .turnpill__final { color: #7a2a12; }

.main { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
/* Wraps the tray and your seat. Transparent to layout unless there is room to set them side by side. */
.dock { display: contents; }
.side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }

/* ---------- board ---------- */

.board {
  flex: 1; min-height: 0;
  display: grid; place-items: center;
  padding: 14px clamp(10px, 1.6vw, 22px);
  border-radius: 18px;
  background: #221b17;
  border: 1px solid var(--line);
}
.board__in { display: grid; grid-template-columns: auto auto auto; align-items: center; gap: clamp(10px, 1.6vw, 22px); }
.nobles { display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.rows { display: flex; flex-direction: column; gap: calc(var(--cw) * 0.09); }
.row { display: flex; gap: calc(var(--cw) * 0.09); }
.bank { display: flex; flex-direction: column; justify-content: center; gap: calc(var(--tw) * 0.2); }

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

.card {
  --band: var(--band-white); --band-ink: var(--ink-white);
  position: relative; flex: none;
  width: var(--cw); height: calc(var(--cw) * 1.36); padding: 0;
  border: 0; border-radius: calc(var(--cw) * 0.075);
  background: #f4eee3;
  color: var(--ink); text-align: left;
  display: grid; grid-template-rows: 29% 1fr;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card--white { --band: var(--band-white); --band-ink: var(--ink-white); }
.card--blue { --band: var(--band-blue); --band-ink: var(--ink-blue); }
.card--green { --band: var(--band-green); --band-ink: var(--ink-green); }
.card--red { --band: var(--band-red); --band-ink: var(--ink-red); }
.card--black { --band: var(--band-black); --band-ink: var(--ink-black); }
.card__band {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 calc(var(--cw) * 0.07);
  background: var(--band);
}
.card__pts { font: 800 calc(var(--cw) * 0.27)/1 var(--font-ui); color: var(--band-ink); font-variant-numeric: tabular-nums; }
.card__bonus { width: calc(var(--cw) * 0.3); height: calc(var(--cw) * 0.3); margin-left: auto; }
.card__body { position: relative; }
.card__cost { position: absolute; left: calc(var(--cw) * 0.07); bottom: calc(var(--cw) * 0.07); display: flex; flex-direction: column-reverse; gap: calc(var(--cw) * 0.025); margin: 0; padding: 0; list-style: none; }
.cost { display: flex; align-items: center; gap: calc(var(--cw) * 0.045); font: 800 calc(var(--cw) * 0.155)/1 var(--font-ui); font-variant-numeric: tabular-nums; color: var(--ink); }
.cost .gem { width: calc(var(--cw) * 0.18); height: calc(var(--cw) * 0.18); }
.cost.is-covered { color: #8f8373; }
.cost.is-covered .gem { opacity: 0.45; }

.card.is-clickable:hover { transform: translateY(-2px); }
@media (hover: hover) {
  .card.is-clickable:hover, .deck.is-clickable:hover { box-shadow: 0 0 0 1.5px rgba(255, 226, 150, 0.9), 0 0 16px rgba(255, 214, 110, 0.4); }
  .well.is-clickable:hover { box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.6), 0 0 0 1.5px rgba(255, 226, 150, 0.55), 0 0 14px rgba(255, 214, 110, 0.3); }
}
/* A saturated ring held off the card by a dark gap: a brass line flush against an ivory card disappears. */
.card.is-buyable { outline: max(2px, calc(var(--cw) * 0.025)) solid #ffcf3d; outline-offset: calc(var(--cw) * 0.016); }
/* Selected is the loudest state: a thicker ring than buyable, lifted, with a glow. */
.card.is-selected, .card.is-selected:hover, .deck.is-selected, .deck.is-selected:hover {
  transform: translateY(-4px);
  outline: max(3px, calc(var(--cw) * 0.035)) solid #ffcf3d; outline-offset: calc(var(--cw) * 0.016);
  box-shadow: 0 0 calc(var(--cw) * 0.2) rgba(255, 207, 61, 0.6), 0 10px 20px rgba(0, 0, 0, 0.45);
}
.card.is-new { animation: deal 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes deal { from { opacity: 0; transform: translateY(-14px) scale(0.96); } to { opacity: 1; transform: none; } }
.card.is-flash::after, .deck.is-flash::after, .well.is-flash::after, .seatcard.is-flash::after {
  content: ''; position: absolute; inset: -3px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 2px #9fd3ff, 0 0 20px rgba(159, 211, 255, 0.55);
  animation: flash 2.6s ease-out forwards;
}
@keyframes flash { 0%, 55% { opacity: 1; } 100% { opacity: 0; } }

.slot { width: var(--cw); height: calc(var(--cw) * 1.36); border-radius: calc(var(--cw) * 0.075); border: 1px dashed rgba(240, 231, 215, 0.12); flex: none; }

/* card sizes */
.card--mini { --cw: calc(var(--cw-base, 100px) * 0.62); }
.card--tiny { --cw: 40px; }

/* ---------- deck backs ---------- */

.deck {
  position: relative; flex: none;
  width: var(--cw); height: calc(var(--cw) * 1.36); padding: 0;
  border-radius: calc(var(--cw) * 0.075);
  border: 1px solid rgba(201, 163, 90, 0.45);
  background: #33271f;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--brass-hi);
  transition: transform 0.15s ease;
}
.deck__numeral { font: 400 calc(var(--cw) * 0.44)/1 var(--font-display); letter-spacing: 0.04em; }
.deck__count { font: 600 calc(var(--cw) * 0.11)/1 var(--font-ui); color: var(--text-mute); }
.deck.is-clickable:hover { transform: translateY(-2px); border-color: var(--brass); }
.deck.is-empty { opacity: 0.35; }

/* ---------- nobles ---------- */

.noble {
  position: relative; flex: none;
  width: var(--nw); height: var(--nw); padding: calc(var(--nw) * 0.08);
  border-radius: calc(var(--nw) * 0.1);
  background: #e4d8c2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  color: var(--ink);
  display: flex; flex-direction: column; justify-content: space-between;
  border: 0; text-align: left;
}
.noble__pts { font: 800 calc(var(--nw) * 0.26)/1 var(--font-ui); }
.noble__req { display: flex; gap: calc(var(--nw) * 0.05); margin: 0; padding: 0; list-style: none; }
.noble.is-choice { cursor: pointer; }
.noble.is-choice:hover { transform: translateY(-2px); box-shadow: 0 0 0 3px var(--brass-hi), 0 10px 20px rgba(0, 0, 0, 0.45); }

/* a card-shaped chip: "cards of this colour" (bonuses, noble requirements) */
.chip {
  --band: var(--band-white); --band-ink: var(--ink-white);
  display: inline-grid; place-items: center;
  width: 1.55em; height: 2.05em; border-radius: 0.28em;
  background: var(--band); color: var(--band-ink);
  font: 800 1em/1 var(--font-ui); font-variant-numeric: tabular-nums;
}
.chip--white { --band: var(--band-white); --band-ink: var(--ink-white); box-shadow: inset 0 0 0 1px rgba(40, 50, 70, 0.25); }
.chip--blue { --band: var(--band-blue); --band-ink: var(--ink-blue); }
.chip--green { --band: var(--band-green); --band-ink: var(--ink-green); }
.chip--red { --band: var(--band-red); --band-ink: var(--ink-red); }
.chip--black { --band: var(--band-black); --band-ink: var(--ink-black); }
.chip.is-zero { opacity: 0.28; }
.noble__req .chip { font-size: calc(var(--nw) * 0.14); }

/* ---------- bank ---------- */

.well {
  position: relative; flex: none;
  width: var(--tw); height: var(--tw); padding: 0; border: 0;
  border-radius: 50%;
  background: #17110e;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.6);
  display: grid; place-items: center;
  transition: transform 0.12s ease;
}
.well .gem { width: 74%; height: 74%; transition: transform 0.15s ease; }
.well__count {
  position: absolute; right: -5px; bottom: -3px;
  min-width: 1.6em; height: 1.6em; padding: 0 0.35em; border-radius: 0.8em;
  display: grid; place-items: center;
  background: var(--ivory); color: var(--ink);
  font: 800 calc(var(--tw) * 0.24)/1 var(--font-ui); font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
}
.well.is-clickable:hover .gem { transform: translateY(-3px) scale(1.04); }
.well.is-clickable:active .gem { transform: translateY(1px) scale(0.94); }
.well.is-empty .gem { opacity: 0.16; filter: grayscale(1); }
.well.is-empty .well__count { background: var(--velvet-500); color: var(--text-faint); }
.well.is-picked { box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.6), 0 0 0 2px var(--brass-hi); }
.well.is-picked .gem, .well.is-picked:hover .gem { transform: scale(1.1); }
.well--gold { margin-bottom: calc(var(--tw) * 0.14); }

/* ---------- tray ---------- */

.tray {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  min-height: 64px; padding: 9px 14px;
  border-radius: var(--radius);
  background: rgba(10, 7, 5, 0.34);
  border: 1px solid var(--line);
}
.tray.is-mine { border-color: rgba(201, 163, 90, 0.55); }
.tray.is-mine.is-fresh { animation: yourturn 1.4s ease-out; }
@keyframes yourturn { 0% { box-shadow: 0 0 0 0 rgba(233, 201, 127, 0.7); } 100% { box-shadow: 0 0 0 14px rgba(233, 201, 127, 0); } }
.tray__text { flex: 1; min-width: 220px; }
.tray__title { font: 700 17px/1.25 var(--font-ui); color: var(--ivory); }
.tray__hint { font-size: 13.5px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray__hint .gem { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; margin: 0 1px; }
.tray__hint strong { color: var(--text); font-weight: 600; }
.tray__hint.is-error { color: var(--warn); }
.tray__picks { display: flex; gap: 14px; align-items: center; padding: 5px 7px 0 0; }
.tray__picks .gem { width: 30px; height: 30px; }
.pick { position: relative; flex: none; width: 46px; height: 46px; padding: 0; border: 0; background: transparent; }
.tray__picks .pick .gem { width: 100%; height: 100%; }
.pick__x { position: absolute; top: -5px; right: -7px; width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%; background: #17110e; border: 1px solid rgba(240, 231, 215, 0.35); color: var(--text); }
.pick__x svg { width: 9px; height: 9px; stroke-width: 3; }
.pick:hover:not(:disabled) .pick__x { background: var(--ivory); border-color: var(--ivory); color: var(--ink); }
.tray__buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.pay { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pay__item { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pay__item .gem { width: 18px; height: 18px; }

/* ---------- player panels ---------- */

.seatcard { position: relative; padding: 12px 14px; }
.seatcard.is-turn { border-color: rgba(201, 163, 90, 0.55); }
.seatcard__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.seatcard__name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seatcard__turn { font-size: 11.5px; font-weight: 700; color: #2b1d0e; background: var(--brass-hi); border-radius: 999px; padding: 2px 8px; }
.seatcard__score { display: flex; align-items: baseline; gap: 4px; }
.seatcard__score b { font: 800 24px/1 var(--font-ui); color: var(--ivory); font-variant-numeric: tabular-nums; }
.seatcard__score span { font-size: 12px; color: var(--text-faint); }

.holdings { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.hold { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.hold .chip { font-size: 14px; }
.hold__gem { position: relative; width: 30px; height: 30px; }
.hold__gem .gem { width: 30px; height: 30px; }
.hold__gem b {
  position: absolute; right: -6px; bottom: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  display: grid; place-items: center; background: var(--ivory); color: var(--ink);
  font: 800 12px/1 var(--font-ui); font-variant-numeric: tabular-nums; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.hold.is-zero .hold__gem { opacity: 0.3; }
.hold__gem.is-picked { outline: 2px solid var(--brass-hi); outline-offset: 3px; border-radius: 50%; }
.hold__gem.is-clickable { cursor: pointer; }
.holdings__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 12.5px; color: var(--text-mute); }
.holdings__foot b { color: var(--text); font-variant-numeric: tabular-nums; }
.holdings__foot .is-full { color: var(--warn); }

.reserved { display: flex; gap: 8px; align-items: flex-end; }
.reserved__label { font-size: 12px; color: var(--text-faint); margin-bottom: 4px; }
.reserved .card, .reserved .deck, .reserved .slot { --cw: 62px; }
.reserved .deck__count { display: none; }

/* your own seat, under the board */
.me { display: flex; gap: 28px; align-items: flex-start; justify-content: space-between; padding: 12px 16px; }
.me__main { width: min(100%, 390px); }
.me .holdings__foot { justify-content: flex-start; gap: 18px; }
.me__reserve { display: flex; flex-direction: column; }
.me .reserved .card, .me .reserved .deck, .me .reserved .slot { --cw: clamp(54px, 4.4vw, 64px); }

/* ---------- side column ---------- */

.opps { display: flex; flex-direction: column; gap: 10px; flex: none; max-height: 72%; overflow-x: hidden; overflow-y: auto; padding: 4px; margin: -4px; scrollbar-width: thin; scrollbar-color: var(--velvet-500) transparent; }
.opp .reserved { margin-top: 10px; }
.opp .reserved .card, .opp .reserved .deck, .opp .reserved .slot { --cw: 46px; }

.feed { flex: 1; min-height: 160px; display: flex; flex-direction: column; overflow: hidden; }
.feed__tabs { display: flex; gap: 4px; padding: 8px 8px 0; }
.feed__tab { flex: 1; min-height: 32px; border: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--text-mute); font-weight: 600; font-size: 13px; }
.feed__tab.is-on { background: rgba(0, 0, 0, 0.25); color: var(--text); }
.feed__tab .badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 6px; border-radius: 9px; background: var(--brass); color: #2b1d0e; font-size: 11px; font-weight: 800; }
.feed__body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px; background: rgba(0, 0, 0, 0.25); scrollbar-width: thin; scrollbar-color: var(--velvet-500) transparent; }
.log { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; }
.log__item { line-height: 1.45; color: var(--text-mute); }
.log__item strong { color: var(--text); font-weight: 600; }
.log__item .gem { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; margin: 0 1px; }
.log__item .chip { font-size: 10px; }
.log__item.is-key { color: var(--brass-hi); }
.log__item .card--tiny { --cw: 22px; box-shadow: none; }
.chat { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.chat__msg strong { color: var(--brass-hi); font-weight: 600; margin-right: 6px; }
.chat__msg.is-system { color: var(--text-faint); font-size: 12.5px; font-style: italic; }
.chat__msg span { word-break: break-word; }
.chat__form { display: flex; gap: 6px; padding: 8px; background: rgba(0, 0, 0, 0.25); border-top: 1px solid var(--line); }
.chat__form .field { min-height: 36px; font-size: 14px; }
.empty { color: var(--text-faint); font-size: 13px; font-style: italic; }

/* ---------- overlays & banners ---------- */

.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(8, 5, 4, 0.66); animation: fade 0.2s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.overlay .sheet { max-height: calc(100dvh - 40px); overflow: auto; }
.choices { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.choices .noble { --nw: 104px; }

.results { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.result { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); }
.result.is-winner { border-color: rgba(233, 201, 127, 0.6); background: rgba(201, 163, 90, 0.1); }
.result__place { font: 800 20px/1 var(--font-ui); color: var(--brass-hi); text-align: center; }
.result__name { font-weight: 700; }
.result__meta { font-size: 12.5px; color: var(--text-mute); }
.result__pts { font: 800 26px/1 var(--font-ui); color: var(--ivory); font-variant-numeric: tabular-nums; }
.tally { margin-top: 14px; text-align: center; color: var(--text-mute); font-size: 14px; }
.tally b { color: var(--text); }

.banner {
  position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 999px;
  background: #3a2418; border: 1px solid rgba(231, 163, 92, 0.6); color: #ffd9b0; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60;
  padding: 10px 16px; border-radius: 12px; background: var(--ivory); color: var(--ink); font-weight: 600; font-size: 14px;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.45); animation: fade 0.2s ease both;
}

.spinner { width: 34px; height: 34px; margin: 0 auto 16px; }
.spinner .gem { width: 34px; height: 34px; animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Desktop: the board is a size container, so cards scale to whatever room
   the tray and your seat leave and can never spill out of the frame. In a
   tall, narrow board (a half-width window) the nobles move above the cards,
   which leaves more width for bigger cards. */
@media (min-width: 861px) {
  /* The moves and chat sit on top as a short panel; opponents follow straight after it. */
  .side .opps { order: 2; }
  .side .feed { flex: 0 1 38%; }
  .main { container: main / inline-size; }
  @container main (min-width: 940px) {
    .dock { display: grid; grid-template-columns: minmax(0, 1fr) minmax(max-content, 1fr); gap: 10px; align-items: stretch; }
    .dock .tray { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "text text" "picks buttons"; align-content: space-between; align-items: end; gap: 8px 12px; padding: 12px 14px; }
    .dock .tray__text { grid-area: text; min-width: 0; align-self: start; }
    .dock .tray__picks { grid-area: picks; }
    .dock .tray__buttons { grid-area: buttons; justify-content: flex-end; }
    .dock .tray__hint { white-space: normal; }
    .dock .me__main { width: 340px; }
  }
  .board { container: board / size; }
  .board__in {
    --cw: clamp(52px, min((100cqw - 110px) / 6.75, (100cqh - 34px) / 4.3), 134px);
    --nw: calc(var(--cw) * 0.84);
    --tw: calc(var(--cw) * 0.56);
  }
  @container board (aspect-ratio < 1.3) {
    .board__in {
      grid-template-columns: auto auto;
      --cw: clamp(52px, min((100cqw - 90px) / 5.95, (100cqh - 60px) / 5.2), 134px);
    }
    .nobles { grid-column: 1 / -1; flex-direction: row; justify-content: center; }
  }
}

/* ---------- mid widths: side column folds under ---------- */

@media (max-width: 860px) {
  :root { --cw: clamp(64px, (100vw - 130px) / 6.9, 116px); }
  .opp .holdings, .opp .holdings__foot { max-width: 400px; }
  .game { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; height: auto; min-height: 100dvh; }
  .side { display: contents; }
  .opps { order: -1; grid-row: 2; flex-direction: row; max-height: none; overflow-x: auto; overflow-y: hidden; }
  .opps .opp { flex: 1 0 280px; }
  .main { grid-row: 3; }
  .feed { grid-row: 4; min-height: 280px; max-height: 420px; }
  .board { flex: none; }
}

/* ---------- phones ---------- */

@media (max-width: 720px) {
  :root { --cw: min(calc((100vw - 64px) / 5.25), 92px); --nw: calc(var(--cw) * 0.95); --tw: calc(var(--cw) * 0.74); }
  body { font-size: 14px; }
  .game { padding: 8px 8px 16px; gap: 8px; }
  .topbar { gap: 8px; }
  .topbar__mark { font-size: 22px; }
  .turnpill { padding: 5px 12px; font-size: 13px; }
  .board { padding: 10px 6px; }
  .board__in { grid-template-columns: 1fr; justify-items: center; gap: 12px; }
  .nobles { flex-direction: row; justify-content: center; flex-wrap: wrap; gap: 6px; order: 0; }
  .rows { order: 1; }
  .bank { order: 2; flex-direction: row; gap: 8px; }
  .well--gold { margin: 0 6px 0 0; }
  .me { flex-direction: column; gap: 12px; }
  .me__main { width: 100%; }
  .me .holdings__foot { gap: 14px; flex-wrap: wrap; }
  .tray { position: sticky; bottom: 8px; z-index: 20; background: rgba(28, 20, 16, 0.96); backdrop-filter: blur(6px); }
  .tray__text { min-width: 0; flex-basis: 100%; }
  .tray__hint { white-space: normal; }
  .pick { width: 32px; height: 32px; }
  .tray__picks { gap: 10px; padding-right: 4px; }
  .pick__x { top: -6px; right: -7px; width: 17px; height: 17px; }
    .opps .opp { flex: 1 0 86%; }
  .sheet { padding: 20px; }
  .sheet__title { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
