:root {
  --bg: #0d0f14;
  --bg2: #141822;
  --panel: #1a1f2c;
  --panel2: #222838;
  --line: #2c3346;
  --ink: #e8eaf0;
  --muted: #8b93a7;
  --gold: #d9b36a;
  --gold2: #f0cd84;
  --accent: #6d7fd6;
  --green: #5cb88a;
  --red: #d96a6a;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
  --card-r: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 70% -10%, #1b2030, var(--bg)) fixed;
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
.field {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: #0f131c; color: var(--ink); outline: none;
}
.field:focus { border-color: var(--accent); }
.btn {
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--ink); transition: .15s;
}
.btn:hover { border-color: var(--gold); color: var(--gold2); }
.btn-primary { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #2a2110; border: none; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.07); color: #2a2110; }

/* ===================== LOBBY — arcane preparation table ===================== */
body.lobby {
  --parch: #ece3cf; --parch-dim: #a99f87; --au: #d9b36a; --au2: #f3d590; --void: #08070f;
  --w: #f3ecd6; --u: #5b8dd9; --b: #9a93c4; --r: #d8584b; --g: #5aa961;
  overflow-x: clip; color: var(--parch); font-family: "Spectral", Georgia, serif; background: var(--void);
}
body.lobby .lb-atmos { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(120% 80% at 50% -12%, #241d3f 0%, #15112a 36%, #0b0917 66%, var(--void) 100%); }
body.lobby .lb-atmos::before { content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(40% 30% at 50% -2%, rgba(224,178,98,.15), transparent 70%),
    radial-gradient(60% 50% at 50% 118%, rgba(91,141,217,.10), transparent 70%); }
body.lobby .lb-atmos::after { content: ""; position: absolute; inset: 0; opacity: .5;
  background-image:
    radial-gradient(1.3px 1.3px at 16% 20%, rgba(255,255,255,.6), transparent),
    radial-gradient(1.2px 1.2px at 78% 14%, rgba(243,213,144,.6), transparent),
    radial-gradient(1.1px 1.1px at 64% 78%, rgba(255,255,255,.5), transparent),
    radial-gradient(1.2px 1.2px at 30% 70%, rgba(255,255,255,.45), transparent),
    radial-gradient(1.4px 1.4px at 90% 60%, rgba(243,213,144,.5), transparent); }
body.lobby::after { content: ""; position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

/* the page is a column: header pinned up top, console centered in the rest */
.lobby { display: flex; flex-direction: column; min-height: 100dvh; }

/* header bar */
.lb-top { position: relative; z-index: 2; width: min(980px, 100%); margin: 0 auto;
  padding: 26px 22px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lb-brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.lb-glyph { font-size: 30px; line-height: 1; color: var(--au2);
  text-shadow: 0 0 18px rgba(243,213,144,.5); transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.lb-brand:hover .lb-glyph { transform: rotate(-14deg); }
.lb-word { font-family: "Cinzel", serif; font-weight: 700; font-size: 22px; letter-spacing: .1em;
  background: linear-gradient(176deg, #fffaf0, var(--au2) 60%, #c79a4c);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.lb-foot { position: relative; z-index: 2; text-align: center; padding: 14px 22px 26px;
  color: var(--parch-dim); font-family: "Cinzel", serif; font-size: 11px; letter-spacing: .12em; opacity: .8; }
.lb-ver-btn { font: inherit; letter-spacing: inherit; color: var(--au2); background: none; border: none;
  cursor: pointer; padding: 2px 4px; border-radius: 6px; transition: .2s; }
.lb-ver-btn:hover { color: #fff7e6; text-shadow: 0 0 12px rgba(243,213,144,.5); }
/* What's-new nudge: a tiny "Click to see what's new!" bubble above the version,
   shown only when there's an unseen release. Clicking it opens the changelog. */
.lb-ver-wrap { position: relative; display: inline-block; }
.ver-nudge {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 8px;
  background: #1c1810; border: 1px solid rgba(217,179,106,.55); color: var(--au2, #f3d590);
  font-family: "Cinzel", serif; font-size: 11px; letter-spacing: .05em; text-transform: none;
  padding: 6px 8px 6px 11px; border-radius: 9px; z-index: 5;
  box-shadow: 0 8px 22px -6px rgba(0,0,0,.7), 0 0 16px rgba(243,213,144,.16);
  animation: nudge-fade .35s ease both, nudge-bob 2.8s ease-in-out infinite; }
.ver-nudge::after {   /* downward tail pointing at the version */
  content: ""; position: absolute; top: 100%; left: 50%; width: 9px; height: 9px; background: #1c1810;
  border-right: 1px solid rgba(217,179,106,.55); border-bottom: 1px solid rgba(217,179,106,.55);
  transform: translate(-50%, -50%) rotate(45deg); }
.ver-nudge-text { font: inherit; letter-spacing: inherit; color: inherit; background: none; border: none;
  cursor: pointer; padding: 0; }
.ver-nudge-text:hover { color: #fff7e6; }
.ver-nudge-x { background: none; border: none; color: var(--parch-dim, #b9a87f); cursor: pointer;
  font-size: 10px; line-height: 1; padding: 1px 3px; border-radius: 4px; transition: color .15s; }
.ver-nudge-x:hover { color: #fff; }
@keyframes nudge-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nudge-bob { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ver-nudge { animation: nudge-fade .25s ease both; } }

/* changelog modal */
.auth-card.changelog-card { width: min(680px, 94vw); max-height: 84vh; display: flex; flex-direction: column; }
.changelog-card h3 { margin: 0 0 12px; }
.changelog-body { overflow-y: auto; padding-right: 12px; color: var(--parch); text-align: left;
  font-family: "Spectral", serif; font-size: 14px; line-height: 1.55;
  scrollbar-width: thin; scrollbar-color: rgba(217,179,106,.4) transparent; }
.changelog-body::-webkit-scrollbar { width: 9px; }
.changelog-body::-webkit-scrollbar-track { background: transparent; }
.changelog-body::-webkit-scrollbar-thumb { background: rgba(217,179,106,.32); border-radius: 8px;
  border: 2px solid transparent; background-clip: padding-box; }
.changelog-body::-webkit-scrollbar-thumb:hover { background: rgba(217,179,106,.55); background-clip: padding-box; }
.changelog-body h2 { font-family: "Cinzel", serif; font-size: 15px; color: var(--au); letter-spacing: .04em;
  margin: 0 0 10px; }
.changelog-body h3 { font-family: "Cinzel", serif; font-size: 15px; color: var(--au2); margin: 18px 0 4px;
  padding-top: 12px; border-top: 1px solid rgba(217,179,106,.16); }
.changelog-body h3:first-of-type { border-top: none; padding-top: 0; }
.changelog-body h4 { font-family: "Cinzel", serif; font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--parch-dim); margin: 12px 0 5px; }
.changelog-body ul { margin: 0 0 6px; padding-left: 20px; }
.changelog-body li { margin-bottom: 5px; }
.changelog-body code { font-family: ui-monospace, monospace; font-size: .88em; background: rgba(243,213,144,.1);
  border: 1px solid rgba(217,179,106,.2); border-radius: 4px; padding: 0 4px; color: var(--au2); }
.changelog-body strong { color: #fbeed0; }
.ver-beta { display: inline-block; margin-left: 4px; font-family: "Cinzel", serif; font-weight: 700;
  font-size: 8.5px; letter-spacing: .14em; padding: 1px 6px; border-radius: 6px; text-transform: uppercase;
  color: #f3d590; border: 1px solid rgba(243,213,144,.45); background: rgba(243,213,144,.1); opacity: 1; }

.account-bar { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.acct-hint, .acct-who { color: var(--parch-dim); } .acct-who strong { color: var(--au2); }
.acct-btn { background: rgba(243,213,144,.05); border: 1px solid rgba(217,179,106,.32); color: var(--au2);
  border-radius: 8px; padding: 6px 13px; font-family: "Cinzel", serif; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; cursor: pointer; transition: .2s; }
.acct-btn:hover { border-color: var(--au2); background: rgba(243,213,144,.12); }

/* two-column console */
.lb-main { position: relative; z-index: 2; flex: 1; width: min(980px, 100%); margin: 0 auto; padding: 10px 22px 44px;
  display: grid; grid-template-columns: 1.06fr .94fr; gap: 20px; align-items: center; align-content: center; }

.lb-card { position: relative; padding: 26px 26px 28px; border-radius: 16px;
  border: 1px solid rgba(217,179,106,.18);
  background: linear-gradient(168deg, rgba(36,30,58,.72), rgba(13,11,26,.72));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 24px 60px -34px rgba(0,0,0,.85); }
.lb-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.lb-step { flex-shrink: 0; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
  font-family: "Cinzel", serif; font-weight: 700; font-size: 13px; color: var(--au2);
  border: 1px solid rgba(217,179,106,.4);
  background: radial-gradient(circle at 50% 30%, rgba(243,213,144,.16), rgba(243,213,144,.02)); }
.lb-card-head h2 { margin: 0; font-family: "Cinzel", serif; font-weight: 600; font-size: 17px;
  letter-spacing: .04em; color: #fbeed0; }

.lb-field { margin-bottom: 16px; }
.lb-label { display: block; font-family: "Cinzel", serif; font-size: 10.5px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--au); margin-bottom: 7px; }
body.lobby .field { width: 100%; padding: 11px 13px; border-radius: 9px; border: 1px solid rgba(217,179,106,.2);
  background: rgba(8,7,15,.6); color: var(--parch); font-family: "Spectral", serif; font-size: 14.5px;
  outline: none; transition: border-color .2s, box-shadow .2s; }
body.lobby .field::placeholder { color: #6a6378; }
body.lobby .field:focus { border-color: var(--au); box-shadow: 0 0 0 3px rgba(217,179,106,.14); }
body.lobby .row { display: flex; gap: 10px; }
body.lobby .row .field { flex: 1; }

body.lobby .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 9px; cursor: pointer; border: 1px solid rgba(217,179,106,.34);
  background: rgba(243,213,144,.05); color: var(--au2); font-family: "Cinzel", serif; font-size: 12px;
  letter-spacing: .1em; text-transform: uppercase;
  transition: transform .2s, border-color .2s, background .2s, box-shadow .2s, filter .2s; }
body.lobby .btn:hover { border-color: var(--au2); background: rgba(243,213,144,.12); transform: translateY(-1px); }
body.lobby .btn-primary { color: #2a1d08; border: 1px solid var(--au2);
  background: linear-gradient(180deg, #f6dca0, var(--au) 92%);
  box-shadow: 0 8px 24px -10px rgba(217,179,106,.6), inset 0 1px 0 rgba(255,255,255,.45); }
body.lobby .btn-primary:hover { transform: translateY(-2px); color: #2a1d08;
  background: linear-gradient(180deg, #fffaf0, #f6dca0 92%);
  box-shadow: 0 14px 34px -12px rgba(231,190,110,.75), inset 0 1px 0 rgba(255,255,255,.5); }

/* deck status chip */
.deck-status { margin-top: 14px; font-size: 14px; line-height: 1.5; min-height: 2px; }
.deck-status:empty::before { content: "No deck loaded yet — import one above to bring it to the table.";
  color: #6a6378; font-style: italic; font-size: 13px; }
.deck-status.loading { color: var(--parch-dim); font-style: italic; }
.deck-status.error { color: #e58a7f; }
.deck-status.ok { padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(217,179,106,.25);
  background: rgba(243,213,144,.05); }
.deck-name { color: #fbeed0; } .deck-status.ok .deck-name strong { color: var(--au2); }
.deck-meta { color: var(--parch-dim); font-size: 13px; margin-top: 3px; }
.deck-warn { color: #e58a7f; font-size: 12.5px; margin-top: 6px; }
.deck-hint { color: var(--parch-dim); font-size: 12.5px; margin-top: 8px; }
.deck-hint a, .deck-status a { color: var(--au2); }
.deck-actions { display: flex; gap: 8px; margin-top: 11px; }
.deck-act { padding: 6px 13px; border-radius: 8px; border: 1px solid rgba(217,179,106,.3);
  background: rgba(243,213,144,.06); color: var(--parch, #e8e0cf); font-size: 12.5px; cursor: pointer; transition: .15s; }
.deck-act:hover { background: rgba(243,213,144,.14); color: var(--au2); border-color: rgba(217,179,106,.55); }

/* deck viewer modal */
.deck-modal { position: fixed; inset: 0; z-index: 9100; display: grid; place-items: center; padding: 24px;
  background: rgba(6,5,12,.82); backdrop-filter: blur(4px); }
.deck-modal.hidden { display: none; }
.deck-modal-card { position: relative; width: min(900px, 94vw); max-height: 88vh; display: flex; flex-direction: column;
  padding: 26px 26px 20px; border-radius: 16px; border: 1px solid rgba(217,179,106,.4);
  background: linear-gradient(168deg, rgba(34,28,54,.97), rgba(13,11,26,.98));
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.85); }
.deck-modal-card h3 { margin: 0 4px 2px 0; font-family: "Cinzel", serif; font-weight: 600; font-size: 22px; color: var(--au2);
  max-width: calc(100% - 30px); }
.deck-modal-meta { color: var(--parch-dim); font-size: 13px; margin: 0 0 14px; }
.deck-modal-body { overflow-y: auto; padding-right: 6px; }
.dv-section { margin-bottom: 16px; }
.dv-head { margin: 0 0 8px; font-family: "Cinzel", serif; font-size: 14px; font-weight: 600; color: #fbeed0;
  border-bottom: 1px solid rgba(217,179,106,.18); padding-bottom: 5px; }
.dv-head span { color: var(--parch-dim); font-weight: 400; font-family: "Spectral", serif; }
.dv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 9px; }
.dv-card { position: relative; aspect-ratio: 5 / 7; border-radius: 7px; background-size: cover; background-position: center;
  background-color: rgba(8,7,15,.6); border: 1px solid rgba(217,179,106,.18);
  display: flex; align-items: center; justify-content: center; text-align: center; overflow: hidden; }
.dv-noart { padding: 6px; }
.dv-name { font-size: 11px; color: var(--parch, #e8e0cf); line-height: 1.25; }
.dv-qty { position: absolute; bottom: 4px; right: 4px; background: rgba(8,7,15,.85); color: var(--au2);
  font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; border: 1px solid rgba(217,179,106,.35); }
.dv-card { cursor: zoom-in; }
.dv-preview { z-index: 9300; width: 250px; border-color: rgba(217,179,106,.45); }
@media (max-width: 760px) { .dv-grid { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); } }

/* saved decks */
.deck-library { margin-top: 18px; border-top: 1px solid rgba(217,179,106,.16); padding-top: 16px; }
.lib-head { font-family: "Cinzel", serif; font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--au); margin-bottom: 10px; }
.lib-hint { opacity: .7; }
.lib-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.lib-empty { color: var(--parch-dim); font-size: 13px; font-style: italic; }
.lib-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 13px; border-radius: 9px;
  border: 1px solid rgba(217,179,106,.16); background: rgba(8,7,15,.45); transition: border-color .2s; }
.lib-row:hover { border-color: rgba(243,213,144,.4); }
.lib-name { flex: 1; font-size: 14px; color: var(--parch); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-use { background: linear-gradient(180deg, #f6dca0, var(--au)); color: #2a1d08; border: none; border-radius: 7px;
  padding: 5px 14px; font-family: "Cinzel", serif; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.lib-use:hover { filter: brightness(1.06); }
.lib-del { background: rgba(216,88,75,.08); border: 1px solid rgba(216,88,75,.35); color: #d6796f;
  border-radius: 7px; width: 28px; height: 28px; font-size: 13px; cursor: pointer; transition: .2s; flex-shrink: 0; }
.lib-del:hover { border-color: var(--r); color: #fff; background: rgba(216,88,75,.85); }

/* pod selector + play actions */
.pod-size { display: flex; align-items: center; gap: 14px; }
.seg { display: inline-flex; border: 1px solid rgba(217,179,106,.28); border-radius: 9px; overflow: hidden;
  background: rgba(8,7,15,.5); }
.seg-btn { background: none; color: var(--parch-dim); border: none; padding: 9px 20px; font-size: 15px;
  font-family: "Cinzel", serif; cursor: pointer; border-right: 1px solid rgba(217,179,106,.2); transition: .18s; }
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { color: var(--au2); }
.seg-btn.active { background: linear-gradient(180deg, var(--au2), var(--au)); color: #2a1d08; font-weight: 700; }
.pod-hint { font-size: 12px; color: var(--parch-dim); font-style: italic; }

.lb-seat-intro { color: var(--parch-dim); font-size: 13.5px; line-height: 1.55; margin: 0 0 18px; }
.lb-seat-actions { display: flex; flex-direction: column; gap: 12px; }
.lb-bigbtn { width: 100%; padding: 15px; font-size: 13px; }
.lb-modal-go { width: 100%; margin-top: 20px; padding: 13px; font-size: 12.5px; }

/* loading veil shown while a table is conjured or joined */
.lb-loading { position: fixed; inset: 0; z-index: 9500; display: grid; place-items: center;
  background: rgba(6,5,12,.92); animation: veil-fade .3s ease forwards; }
.lb-loading.hidden { display: none; }
.lb-loading-inner { display: flex; flex-direction: column; align-items: center; gap: 16px;
  animation: veil-rise .55s cubic-bezier(.2,.75,.25,1) both; }
@keyframes veil-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes veil-rise { from { opacity: 0; transform: translateY(34px); } to { opacity: 1; transform: none; } }

/* pop-in for the create / join table modals */
#create-modal, #join-modal { animation: modal-veil .22s ease forwards; }
#create-modal .auth-card, #join-modal .auth-card {
  animation: modal-pop .34s cubic-bezier(.2,.8,.3,1.12) both; }
@keyframes modal-veil { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(18px) scale(.93); }
  to { opacity: 1; transform: none; } }

.lb-loading-glyph { font-size: 52px; line-height: 1; color: var(--au2);
  text-shadow: 0 0 28px rgba(243,213,144,.6); animation: pulse 1.6s ease-in-out infinite; }
.lb-loading-ring { width: 30px; height: 30px; border: 3px solid rgba(217,179,106,.22);
  border-top-color: var(--au2); border-radius: 50%; animation: sp .8s linear infinite; }
.lb-loading p { margin: 0; font-family: "Cinzel", serif; letter-spacing: .14em; text-transform: uppercase;
  font-size: 12px; color: var(--au); }

/* arcane flavor lines (loading veil, lobby, roll-off) */
.lb-loading .lb-loading-flavor { margin-top: 6px; font-family: "Spectral", serif; font-style: italic;
  text-transform: none; letter-spacing: .02em; font-size: 12.5px; color: var(--parch-dim); min-height: 16px; }
.flavor-line { margin: 16px 0 0; font-family: "Spectral", serif; font-style: italic; font-size: 13px;
  color: var(--muted); min-height: 17px; }
.flavor-in { animation: flavor-fade .5s ease; }
@keyframes flavor-fade { from { opacity: 0; } to { opacity: 1; } }
.code-field { text-transform: uppercase; letter-spacing: 6px; text-align: center;
  font-family: "Cinzel", serif; font-size: 18px; }
.lb-note { margin: 18px 0 0; color: var(--parch-dim); font-size: 12.5px; line-height: 1.5; font-style: italic; }

/* auth modal */
.auth-modal { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center;
  background: rgba(6,5,12,.8); backdrop-filter: blur(4px); }
.auth-card { position: relative; width: min(390px, 92vw); padding: 30px 28px 24px; border-radius: 16px;
  border: 1px solid rgba(217,179,106,.4);
  background: linear-gradient(168deg, rgba(34,28,54,.97), rgba(13,11,26,.98));
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.85); }
.auth-card h3 { margin: 0 0 6px; font-family: "Cinzel", serif; font-weight: 600; font-size: 21px; color: var(--au2); }
body.lobby .hint { color: var(--parch-dim); font-size: 13px; line-height: 1.5; margin: 0; }
.auth-x { position: absolute; top: 14px; right: 16px; background: none; border: none; color: var(--parch-dim);
  font-size: 18px; cursor: pointer; transition: .2s; }
.auth-x:hover { color: var(--au2); }
.auth-form { display: flex; flex-direction: column; gap: 11px; margin-top: 14px; }
.auth-error { color: #e58a7f; font-size: 13px; min-height: 4px; }
.auth-actions { display: flex; gap: 10px; align-items: center; }
.auth-actions .btn-primary { flex: 1; }

@media (max-width: 760px) { .lb-main { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
  body.lobby *, body.lobby *::before, body.lobby *::after { animation: none !important; }
  body.lobby .reveal { opacity: 1; transform: none; }
}

/* ===================== LANDING — "arcane planar gateway" ===================== */
body.landing {
  --parch: #ece3cf;        /* warm parchment text */
  --parch-dim: #a99f87;    /* muted parchment */
  --au: #d9b36a;           /* gold */
  --au2: #f3d590;          /* bright gold */
  --void: #08070f;
  --w: #f3ecd6; --u: #5b8dd9; --b: #9a93c4; --r: #d8584b; --g: #5aa961; /* WUBRG */
  /* `clip` (unlike `hidden`) tames horizontal overflow WITHOUT turning the body
     into a scroll container — which is what was leaving phantom space + a floated
     footer at the bottom. No min-height: the fixed atmosphere covers the viewport. */
  overflow-x: clip;
  color: var(--parch);
  font-family: "Spectral", Georgia, serif;
  background: var(--void);
}
/* layered atmosphere (fixed, so it always fills the viewport): void gradient,
   mana-glow bloom, sparse stars, fine grain */
body.landing .ld-atmos { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(120% 85% at 50% -10%, #2a2147 0%, #16122b 34%, #0b0917 64%, var(--void) 100%); }
body.landing .ld-atmos::before {            /* warm bloom behind the sigil + cool rim light */
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(46% 38% at 50% 30%, rgba(224,178,98,.20), rgba(224,178,98,0) 70%),
    radial-gradient(70% 50% at 50% 120%, rgba(91,141,217,.12), transparent 70%);
}
/* the starfield is a live canvas (static/js/stars.js): slow drift, per-star
   twinkle, and stars brighten as the cursor approaches them */
body.landing #stars { position: absolute; inset: 0; width: 100%; height: 100%; }
body.landing::after {                        /* grain overlay */
  content: ""; position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.ld-wrap { position: relative; z-index: 2; max-width: 880px; margin: 0 auto;
  padding: 7vh 22px 7vh; text-align: center; }

/* --- sigil + glyph --- */
.sigil-wrap { position: relative; width: min(340px, 78vw); aspect-ratio: 1; margin: 0 auto 6px; }
.sigil { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.sigil .anchor { fill: none; stroke: none; }
.sigil circle, .sigil path { fill: none; vector-effect: non-scaling-stroke; }
.sigil .r-thin { stroke: rgba(217,179,106,.28); stroke-width: 1; }
.sigil .r-dot  { stroke: rgba(243,213,144,.5); stroke-width: 3; stroke-dasharray: 1.5 9; stroke-linecap: round; }
.sigil .r-dash { stroke: rgba(217,179,106,.34); stroke-width: 1.5; stroke-dasharray: 26 12; }
.sigil .penta     { stroke: rgba(217,179,106,.16); stroke-width: 1; }
.sigil .pentagram { stroke: rgba(243,213,144,.32); stroke-width: 1; stroke-linejoin: round; }
.sigil .spin-cw  { transform-box: fill-box; transform-origin: center; animation: spin 64s linear infinite; }
.sigil .spin-ccw { transform-box: fill-box; transform-origin: center; animation: spin 92s linear infinite reverse; }
.sigil .pip { animation: pulse 3.6s ease-in-out infinite; }
.sigil .pip-w { fill: var(--w); filter: drop-shadow(0 0 6px rgba(243,236,214,.9)); }
.sigil .pip-u { fill: var(--u); filter: drop-shadow(0 0 6px rgba(91,141,217,.9)); animation-delay: .4s; }
.sigil .pip-b { fill: #3b3752; stroke: var(--b); stroke-width: 2; filter: drop-shadow(0 0 6px rgba(154,147,196,.8)); animation-delay: .8s; }
.sigil .pip-r { fill: var(--r); filter: drop-shadow(0 0 6px rgba(216,88,75,.9)); animation-delay: 1.2s; }
.sigil .pip-g { fill: var(--g); filter: drop-shadow(0 0 6px rgba(90,169,97,.9)); animation-delay: 1.6s; }

.sigil-glyph { position: absolute; inset: 0; display: grid; place-items: center;
  font-size: clamp(80px, 22vw, 120px); line-height: 1; color: var(--au2);
  text-shadow: 0 0 24px rgba(243,213,144,.55), 0 0 60px rgba(224,178,98,.35);
  animation: breathe 4.5s ease-in-out infinite; }

/* --- type --- */
.ld-eyebrow { font-family: "Cinzel", serif; font-weight: 600; letter-spacing: .42em;
  text-transform: uppercase; font-size: 11.5px; color: var(--au); margin: 0 0 10px;
  padding-left: .42em; opacity: .9; }
.ld-title { font-family: "Cinzel", serif; font-weight: 900; letter-spacing: .06em;
  font-size: clamp(52px, 12vw, 104px); line-height: .96; margin: 0;
  background: linear-gradient(176deg, #fffaf0 8%, var(--au2) 52%, #b98a3e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 26px rgba(217,179,106,.25)); }
.ld-tag { font-size: clamp(16px, 2.1vw, 19px); line-height: 1.62; color: var(--parch);
  max-width: 540px; margin: 20px auto 0; font-weight: 300; }
.ld-tag em { font-style: italic; color: var(--au2); }

/* --- buttons --- */
.ld-cta { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 34px; }
.ld-btn { display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
  font-family: "Cinzel", serif; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  font-size: 14px; padding: 14px 30px; border-radius: 4px; position: relative;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s, background .25s, color .25s; }
.ld-btn svg { width: 16px; height: 16px; }
.ld-btn-play { color: #2a1d08; border: 1px solid var(--au2);
  background: linear-gradient(180deg, #f6dca0, var(--au) 92%);
  box-shadow: 0 0 0 1px rgba(243,213,144,.25), 0 10px 30px -8px rgba(217,179,106,.6),
              inset 0 1px 0 rgba(255,255,255,.5); }
.ld-btn-play svg { fill: #2a1d08; }
.ld-btn-play:hover { transform: translateY(-3px);
  box-shadow: 0 0 0 1px rgba(243,213,144,.45), 0 18px 44px -10px rgba(231,190,110,.8),
              inset 0 1px 0 rgba(255,255,255,.6); }
.ld-btn-ghost { color: var(--au2); border: 1px solid rgba(217,179,106,.4);
  background: rgba(243,213,144,.04); }
.ld-btn-ghost svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ld-btn-ghost:hover { transform: translateY(-3px); color: #fff7e6;
  border-color: var(--au2); background: rgba(243,213,144,.1);
  box-shadow: 0 10px 30px -12px rgba(217,179,106,.5); }

/* --- filigree divider --- */
.ld-rule { display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 58px auto 30px; max-width: 460px; color: var(--au); }
.ld-rule span { height: 1px; width: 130px;
  background: linear-gradient(90deg, transparent, rgba(217,179,106,.5)); }
.ld-rule span:last-child { background: linear-gradient(90deg, rgba(217,179,106,.5), transparent); }
.ld-rule i { font-style: normal; font-size: 10px; color: var(--au2); filter: drop-shadow(0 0 6px rgba(243,213,144,.6)); }

/* --- feature tablets --- */
.ld-features { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 720px; margin: 0 auto; }
.feat { display: flex; gap: 15px; align-items: flex-start; text-align: left;
  padding: 20px; border-radius: 12px; border: 1px solid rgba(217,179,106,.16);
  background: linear-gradient(168deg, rgba(38,33,60,.66), rgba(15,12,28,.66));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 16px 40px -24px rgba(0,0,0,.8);
  transition: transform .3s cubic-bezier(.2,.8,.2,1), border-color .3s, box-shadow .3s; }
.feat:hover { transform: translateY(-4px); border-color: rgba(243,213,144,.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 24px 50px -22px rgba(217,179,106,.32); }
.feat-ic { flex-shrink: 0; width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid rgba(217,179,106,.34);
  background: radial-gradient(circle at 50% 30%, rgba(243,213,144,.16), rgba(243,213,144,.02));
  box-shadow: inset 0 0 12px rgba(243,213,144,.12); }
.feat-ic svg { width: 22px; height: 22px; fill: none; stroke: var(--au2); stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; }
.feat h3 { margin: 2px 0 5px; font-family: "Cinzel", serif; font-weight: 600; font-size: 16px;
  letter-spacing: .02em; color: #fbeed0; }
.feat p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--parch-dim); font-weight: 300; }

.ld-foot { margin-top: 48px; color: var(--parch-dim); font-size: 14px; font-style: italic; }
.ld-foot a { color: var(--au2); text-decoration: none; font-style: normal; }
.ld-foot a:hover { text-shadow: 0 0 12px rgba(243,213,144,.5); }
.ld-ver { display: block; margin-top: 10px; font-family: "Cinzel", serif; font-style: normal;
  font-size: 11px; letter-spacing: .14em; color: var(--parch-dim); opacity: .6; }

/* --- motion --- */
.reveal { opacity: 0; transform: translateY(22px); animation: rise .9s cubic-bezier(.2,.75,.25,1) forwards;
  animation-delay: var(--d, 0ms); }
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%,100% { text-shadow: 0 0 24px rgba(243,213,144,.5), 0 0 60px rgba(224,178,98,.3); }
  50% { text-shadow: 0 0 34px rgba(243,213,144,.8), 0 0 90px rgba(224,178,98,.5); } }
@keyframes pulse { 0%,100% { opacity: .65; } 50% { opacity: 1; } }

@media (max-width: 600px) {
  .ld-features { grid-template-columns: 1fr; }
  .ld-rule span { width: 80px; }
  .ld-cta .ld-btn { padding: 13px 26px; }
}
@media (prefers-reduced-motion: reduce) {
  body.landing *, body.landing *::before, body.landing *::after { animation: none !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ===================== TABLE ===================== */
body.table { overflow: hidden; }
.table-wrap { height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 8px 14px;
  background: var(--bg2); border-bottom: 1px solid var(--line); }
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; }
.tb-mid { flex: 1; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.home { font-size: 22px; text-decoration: none; }
.code { color: var(--muted); } .code strong { color: var(--gold2); letter-spacing: 2px; }
.pill { background: var(--panel2); border: 1px solid var(--line); border-radius: 20px; padding: 3px 12px; font-size: 13px; color: var(--muted); }
.pill.active { color: #2a2110; background: linear-gradient(180deg, var(--gold2), var(--gold)); border: none; font-weight: 600; }
.pill.clock { font-variant-numeric: tabular-nums; letter-spacing: .5px; color: var(--gold2);
  box-sizing: border-box; min-width: 66px; text-align: center; }
.pill.clock::before { content: "⏳ "; filter: grayscale(.2); }
/* the clock reads as bare gilded text — no chip, a touch larger than the pills */
body.table .pill.clock { background: none; border: none; padding: 2px 4px; font-size: 15px; }
.tool { padding: 7px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 13px; }
.tool:hover { border-color: var(--gold); color: var(--gold2); }
.tool.muted { opacity: .5; }
.tool.judge { background: linear-gradient(180deg, #2a3350, #20283e); border-color: #3a4566; color: var(--gold2); }
.conn { font-size: 12px; color: var(--muted); }
.conn.ok { color: var(--green); } .conn.bad { color: var(--red); }

.layout { flex: 1; display: flex; min-height: 0; position: relative; }
/* The Chronicle sidebar is an absolute overlay on the right, so the board stays
   full-width and every row centres on the page; the hand's fan (JS layoutHand)
   stops short of the panel so a big hand never tucks under it. */
.board { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.seat { flex: 1; display: flex; position: relative; min-height: 0; }

/* Opponents sit across the top; the viewer is always anchored at the bottom. */
.opponents { flex: 1; display: flex; min-height: 0; border-bottom: 2px solid var(--line); }
.opponents .seat.opp { flex: 1 1 0; flex-direction: column; min-width: 0;
  border-right: 1px solid var(--line); background: linear-gradient(180deg, rgba(217,106,106,.05), transparent); }
.opponents .seat.opp:last-child { border-right: none; }
/* Opponent rail is a compact horizontal strip above their battlefield. */
.opponents .seat.opp .seat-rail { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
  gap: 10px 14px; border-right: none; border-bottom: 1px solid var(--line); padding: 6px 10px; }
.opponents .seat.opp .nameplate { flex-direction: row; align-items: center; gap: 10px; }
.opponents .seat.opp .zones { flex-direction: row; flex-wrap: wrap; gap: 5px; }
.opponents .seat.opp .life { font-size: 15px; }
.seat.opp.active-seat { background: linear-gradient(180deg, rgba(217,179,106,.12), transparent); }
.seat.opp.active-seat .pname { color: var(--gold2); }
.seat .pname.dead, .seat.dead .pname { color: var(--muted); text-decoration: line-through; }
.pname.turn { text-shadow: 0 0 10px rgba(217,179,106,.5); }
.lifeval.zero, .life b.zero { color: var(--red); }

.seat.you { flex-direction: column; background: linear-gradient(0deg, rgba(109,127,214,.06), transparent); }

.seat-rail { width: 132px; flex-shrink: 0; padding: 8px; display: flex; flex-direction: column; gap: 8px;
  background: rgba(0,0,0,.18); border-right: 1px solid var(--line); }
.seat.you .seat-rail { flex-direction: row; width: auto; border-right: none; border-top: 1px solid var(--line);
  align-items: center; gap: 14px; padding: 6px 12px; }
.nameplate { display: flex; flex-direction: column; gap: 3px; }
.seat.you .nameplate { flex-direction: row; align-items: center; gap: 14px; }
.pname { font-weight: 600; color: var(--gold2); font-size: 14px; }
.life { display: inline-flex; align-items: center; gap: 6px; font-size: 18px; }
.life b { min-width: 26px; text-align: center; }
.lifebtn { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; padding: 0; line-height: 1;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; font-size: 17px; font-weight: 600; }
.lifebtn:hover { border-color: var(--gold); }
.counters { font-size: 11px; color: var(--muted); }
.zones { display: flex; flex-direction: column; gap: 6px; }
.seat.you .zones { flex-direction: row; }
.zone-chip { font-size: 11.5px; color: var(--muted); padding: 6px 8px; border: 1px dashed var(--line); border-radius: 7px;
  display: flex; justify-content: space-between; gap: 6px; cursor: pointer; background: rgba(0,0,0,.2); white-space: nowrap; }
.zone-chip:hover { border-color: var(--gold); color: var(--gold2); }
.zone-chip b { color: var(--ink); }

.battlefield { flex: 1; position: relative; overflow: hidden; min-width: 0; cursor: zoom-in;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,.035) 1px, transparent 0); background-size: 28px 28px; }
.seat.focused .battlefield, .board.focus-opp .seat.opp.focused .battlefield { cursor: zoom-out; }
/* Opponents' boards always mirror positions ("across the table"): a card the
   opponent places top-left shows bottom-right to you. The card *content* rides
   that 180° (upside-down) only when the viewer opts in via Settings →
   "Rotate opponents' cards 180°" (body.flip-opp); otherwise each card is
   counter-rotated so it reads upright while the board stays mirrored. */
.seat.opp .battlefield { transform: rotate(180deg); }

.hand { height: 122px; flex-shrink: 0; display: flex; justify-content: center; align-items: flex-end;
  padding: 4px 12px 0; background: rgba(0,0,0,.28); border-top: 1px solid var(--line); position: relative; }

/* cards */
.card {
  position: absolute; width: 78px; height: 109px; border-radius: var(--card-r);
  background-size: cover; background-position: center; background-color: #20283c;
  box-shadow: 0 2px 6px rgba(0,0,0,.5); border: 1px solid rgba(0,0,0,.5);
  touch-action: none; user-select: none; transition: transform .12s, box-shadow .12s;
  cursor: grab; color: #cfd6e6; font-size: 9px; padding: 4px; overflow: hidden; line-height: 1.1;
  z-index: var(--cardz, 0);   /* stack order = zone-list order, set per render */
}
.card:hover { box-shadow: 0 4px 16px rgba(217,179,106,.45); z-index: 500; }
.card.tapped { transform: rotate(90deg); }
.card.noart { display: flex; align-items: center; text-align: center; justify-content: center;
  background: linear-gradient(160deg, #2a3247, #1a2030); border: 1px solid var(--line); }
/* Your own face-down card: keep the art at proper size but greyscale it. */
.card.facedown { filter: grayscale(1) brightness(0.66); }
/* Opponent's face-down card (no art): show a generic card back + glyph. */
.card.facedown.noart { filter: none; background: linear-gradient(135deg, #2a2336, #18141f); }
.card.facedown.noart::after { content: "🜲"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; opacity: .5; pointer-events: none; }
.card .cardname { pointer-events: none; padding: 2px; }
/* counter badges (top-right, stacked) */
.card .cnts { position: absolute; top: 2px; right: 2px; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; pointer-events: none; }
.card .cb { font-weight: 700; font-size: 9px; line-height: 1.3; border-radius: 5px; padding: 0 4px; box-shadow: 0 1px 2px rgba(0,0,0,.6); white-space: nowrap; }
.card .cb.plus { background: var(--green); color: #06170f; }
.card .cb.minus { background: var(--red); color: #2a0f0f; }
.card .cb.named { background: #c9b275; color: #211a07; }
/* effective power/toughness (bottom-right, where MTG prints P/T) */
.card .pt { position: absolute; right: 2px; bottom: 2px; background: #11161f; color: #fff; border: 1px solid var(--gold);
  font-weight: 700; font-size: 11px; border-radius: 5px; padding: 0 4px; pointer-events: none; }
/* keyword chips (bottom-left strip) */
.card .kw { position: absolute; left: 2px; bottom: 2px; display: flex; flex-wrap: wrap; gap: 2px; max-width: 58%; pointer-events: none; }
.card .kwc { background: rgba(12,16,24,.85); color: var(--gold2); font-size: 8px; font-weight: 600; line-height: 1.4;
  border: 1px solid rgba(217,179,106,.4); border-radius: 4px; padding: 0 3px; }
.card .kwc.more { color: var(--muted); border-color: var(--line); }
/* "This permanent has a triggered ability" marker — top-right corner. */
.card .trig { position: absolute; top: 2px; right: 2px; z-index: 6; pointer-events: none;
  font-size: 10px; line-height: 1; padding: 2px 3px; border-radius: 5px;
  background: rgba(12,16,24,.82); border: 1px solid rgba(240,205,132,.55);
  filter: drop-shadow(0 0 3px rgba(240,205,132,.5)); }
/* Trigger reminders set to Off hides the board glyph too. */
body.trig-off .card .trig { display: none; }
.card.ghost { position: fixed; pointer-events: none; transform: translate(-50%, -50%); z-index: 9999; opacity: .9; }

.hand .card { position: relative; width: 84px; height: 117px; margin: 0 var(--gap, -14px); bottom: 0;
  transition: transform .14s, margin .14s; transform-origin: bottom center; }
.hand .card:hover { transform: translateY(-22px) scale(1.08); margin: 0 6px; z-index: 60; }
.hand .card.drawn { animation: card-draw .42s cubic-bezier(.2,.8,.3,1) both; }
@keyframes card-draw { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
/* A card materialising onto the battlefield: fade in with a brief arcane bloom
   that settles to the card's resting shadow. Uses opacity + box-shadow only, so it
   never fights a tapped/flipped card's transform. */
.card.placed { animation: card-place .4s cubic-bezier(.2,.8,.3,1); }
@keyframes card-place {
  0%   { opacity: 0; box-shadow: 0 0 22px 5px rgba(243,213,144,.7); }
  55%  { opacity: 1; }
  100% { opacity: 1; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
}
@media (prefers-reduced-motion: reduce) { .card.placed { animation: none; } }
/* Counter-rotate opponent cards back to upright (board stays mirrored) unless
   the viewer turned ON "Rotate opponents' cards 180°". 270° = the counter-flip
   plus a tapped card's own 90°. */
body:not(.flip-opp) .seat.opp .battlefield .card { transform: rotate(180deg); }
body:not(.flip-opp) .seat.opp .battlefield .card.tapped { transform: rotate(270deg); }

/* ---- Land shelf (set-spot placement) ----------------------------------- */
/* A fanned flow-row pinned to each board's bottom edge. Lands auto-route here;
   the shelf rides the board's 180° mirror, so each player's lands sit at their
   own back edge (nearest them) with creatures forward — the table convention.
   Always present (even empty) as a discoverable, comfortably-sized drop target. */
.land-lane {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; min-height: 104px;
  display: flex; justify-content: center; align-items: flex-end;
  padding: 0 14px 8px; pointer-events: none;
}
/* A faint lip so the row reads as its own band without boxing it in. */
.land-lane::before {
  content: ""; position: absolute; left: 8%; right: 8%; bottom: 3px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(217,179,106,.30), transparent);
}
/* While a land is held, outline the shelf so it's clear where it'll drop.
   Hidden until body.drag-land; only your own shelf lights up. */
.land-lane::after {
  content: ""; position: absolute; inset: 6px 12px 7px; border-radius: 11px;
  border: 1px dotted transparent; pointer-events: none;
  transition: border-color .16s ease, background-color .16s ease;
}
body.drag-land .seat.you .land-lane::after {
  border-color: rgba(217,179,106,.34); background: rgba(217,179,106,.035);
}
.land-lane .card {
  pointer-events: auto; position: relative; width: 72px; height: 100px; bottom: 0;
  margin: 0 var(--lane-gap, -18px); transform-origin: center;
  transition: transform .14s, margin .14s;
}
/* Spread the fan on hover so a buried land lifts clear and stays clickable
   (your own board only — opponents' shelf cards keep their mirror counter-flip). */
.seat.you .land-lane .card:hover { transform: translateY(-16px) scale(1.07); margin: 0 5px; z-index: 60; }
.seat.you .land-lane .card.tapped { transform: rotate(90deg); }
.seat.you .land-lane .card.tapped:hover { transform: translateY(-10px) rotate(90deg) scale(1.04); margin: 0 5px; z-index: 60; }
@media (max-width: 820px) {
  .land-lane { min-height: 88px; }
  .land-lane .card { width: 60px; height: 84px; }
}

.card-preview { position: fixed; display: none; width: 230px; border-radius: 12px; z-index: 9000;
  box-shadow: 0 12px 40px rgba(0,0,0,.7); pointer-events: none; border: 1px solid var(--line);
  animation: preview-in .13s ease; }
/* replays each time the preview flips from display:none to block (a new card) */
@keyframes preview-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .card-preview { animation: none; } }

/* context menu */
.ctx { position: fixed; z-index: 9500; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; box-shadow: var(--shadow); min-width: 168px; }
.ctx button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; border-radius: 6px;
  background: transparent; color: var(--ink); font-size: 13px; }
.ctx button:hover { background: var(--accent); color: #fff; }
.ctx button.danger { color: #e58a7f; }
.ctx button.danger:hover { background: rgba(216,88,75,.85); color: #fff; }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 2px; }

/* turn toast */
.toast { position: fixed; top: 66px; left: 50%; z-index: 9700;
  padding: 10px 24px; border-radius: 999px; white-space: nowrap;
  background: linear-gradient(168deg, rgba(34,28,54,.98), rgba(13,11,26,.98));
  border: 1px solid rgba(217,179,106,.5); color: var(--gold2, #f3d590);
  font-family: "Cinzel", serif; font-size: 15px; letter-spacing: .04em;
  box-shadow: 0 14px 40px -10px rgba(0,0,0,.8), 0 0 26px rgba(243,213,144,.16);
  opacity: 0; pointer-events: none; transform: translate(-50%, -14px);
  transition: opacity .45s ease, transform .45s ease; }
.toast.show { animation: toast-in .35s ease forwards; }
@keyframes toast-in {
  0%   { opacity: 0; transform: translate(-50%, -14px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .toast.show { animation: none; opacity: 1; transform: translate(-50%, 0); }
}

/* Fullscreen turn announcement */
.turn-banner { position: fixed; inset: 0; z-index: 9600; display: grid; place-items: center;
  pointer-events: none; opacity: 0; }
.turn-banner::before { content: ""; position: absolute; inset: 0;
  background: radial-gradient(80% 60% at 50% 50%, rgba(8,7,15,.62), rgba(8,7,15,.30) 55%, transparent 80%); }
.turn-banner .tb-inner { position: relative; text-align: center; padding: 0 24px; }
.turn-banner .tb-who { font-family: "Cinzel", serif; font-weight: 700; line-height: 1.05;
  font-size: clamp(38px, 8vw, 92px); letter-spacing: .03em;
  background: linear-gradient(176deg, #fffaf0, #f3d590 58%, #c79a4c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 30px rgba(243,213,144,.45)); }
.turn-banner.mine .tb-who { filter: drop-shadow(0 4px 34px rgba(243,213,144,.7)); }
.turn-banner .tb-turn { margin-top: 14px; font-family: "Cinzel", serif; font-weight: 600;
  font-size: clamp(13px, 2vw, 22px); letter-spacing: .42em; text-transform: uppercase;
  color: var(--gold2, #f3d590); opacity: .9; }
.turn-banner.show { animation: turn-banner 2.2s cubic-bezier(.2,.7,.25,1) forwards; }
.turn-banner.show .tb-inner { animation: turn-banner-in 2.2s cubic-bezier(.16,.8,.3,1) forwards; }
@keyframes turn-banner {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  78%  { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes turn-banner-in {
  0%   { transform: translateY(26px) scale(.86); }
  16%  { transform: translateY(0) scale(1); }
  78%  { transform: translateY(0) scale(1); }
  100% { transform: translateY(-14px) scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  .turn-banner.show { animation: none; opacity: 1; }
  .turn-banner.show .tb-inner { animation: none; transform: none; }
}

/* P/T modifier popover */
.ptmod { position: fixed; z-index: 9600; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; box-shadow: var(--shadow); min-width: 150px; }
.ptmod.hidden { display: none; }
.ptmod-head { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .65; margin-bottom: 7px; }
.ptmod-row { display: flex; align-items: center; gap: 7px; margin: 4px 0; }
.ptmod-row > span { width: 48px; font-size: 13px; opacity: .85; }
.ptmod-b { width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--ink); font-size: 16px; line-height: 1; cursor: pointer; }
.ptmod-b:hover { background: var(--accent); color: #fff; }
.ptmod-v { flex: 1; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; }
.ptmod-clear { display: block; width: 100%; margin-top: 8px; padding: 5px; border: 1px solid var(--line);
  border-radius: 6px; background: transparent; color: var(--ink); font-size: 12px; cursor: pointer; }
.ptmod-clear:hover { background: var(--line); }

/* counters popover (shares the .ptmod box styling) */
.counters { min-width: 186px; }
.ctr-quick { display: flex; gap: 6px; margin-bottom: 9px; }
.ctr-q { flex: 1; padding: 6px 0; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--ink); font-size: 13px; cursor: pointer; }
.ctr-q:hover { background: var(--accent); color: #fff; }
.ctr-list { display: flex; flex-direction: column; gap: 4px; }
.ctr-empty { font-size: 12px; opacity: .55; padding: 1px 0 3px; }
.ctr-row { display: flex; align-items: center; gap: 7px; }
.ctr-k { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctr-n { width: 22px; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; }
.ctr-add { display: flex; gap: 6px; margin-top: 9px; }
.ctr-name { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--ink); font-size: 13px; }
.ctr-addb { padding: 5px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: transparent; color: var(--ink); font-size: 12px; cursor: pointer; }
.ctr-addb:hover { background: var(--line); }

/* sidebar */
/* Floats over the right edge of the board (absolute, out of flow) so opening
   it no longer squeezes the play area — it slides in on top instead. */
.sidebar { position: absolute; top: 0; right: 0; bottom: 0; z-index: 120;
  width: 320px; border-left: 1px solid var(--line); background: var(--bg2);
  display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.45); }
.side-tabs { display: flex; border-bottom: 1px solid var(--line); }
.stab { flex: 1; padding: 10px; background: transparent; border: none; color: var(--muted); border-bottom: 2px solid transparent; position: relative; }
.stab.active { color: var(--gold2); border-bottom-color: var(--gold); }
.stab.ding::after { content: ""; position: absolute; top: 8px; right: 18px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.side-body { flex: 1; min-height: 0; position: relative; }
.tabpane { position: absolute; inset: 0; display: none; flex-direction: column; }
.tabpane.active { display: flex; }

.log { list-style: none; margin: 0; padding: 10px; flex: 1; overflow-y: auto; font-size: 13px; }
.logline { padding: 3px 0; color: var(--muted); }
.logline .lw { color: var(--gold); font-weight: 600; }
.logline.mine .lw { color: var(--accent); }
.chat { padding: 8px; border-top: 1px solid var(--line); }

.judge-feed { flex: 1; overflow-y: auto; padding: 12px; }
.judge-empty { color: var(--muted); font-size: 13px; }
.judge-thinking { color: var(--gold2); font-size: 13px; display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.ruling { margin-bottom: 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.rq { background: var(--panel2); padding: 8px 10px; font-size: 13px; color: var(--muted); }
.rq b { color: var(--ink); }
.ra { padding: 10px 12px; font-size: 13.5px; }
.ra h4 { margin: 10px 0 4px; color: var(--gold2); font-size: 13px; }
.ra code { background: #0f131c; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.ra strong { color: var(--gold2); }
.judge-form { padding: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.judge-form textarea { resize: none; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 8000; }
.modal-card { width: min(900px, 92vw); max-height: 86vh; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; color: var(--gold2); }
.x { background: transparent; border: none; color: var(--muted); font-size: 18px; }

/* settings modal */
.modal-card.settings-card { width: min(440px, 94vw); }
.modal-card.confirm-card { width: min(420px, 92vw); }
.confirm-body { margin: 0; padding: 18px 20px 6px; color: var(--ink); font-size: 14.5px; line-height: 1.55; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; }
.confirm-actions .btn { min-width: 96px; }
.prompt-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
#prompt-input { width: 100%; }
.settings-body { padding: 4px 4px 8px; display: flex; flex-direction: column; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 14px 18px; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: none; }
.setting-label { display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; color: var(--parch); }
.setting-label small { color: var(--muted); font-size: 11px; }
.switch { position: relative; flex: none; width: 46px; height: 26px; padding: 0; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,.06); cursor: pointer; transition: background .2s, border-color .2s; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #c9cad6; transition: transform .2s, background .2s; }
.switch[aria-checked="true"] { background: linear-gradient(180deg, var(--gold2), var(--gold)); border-color: transparent; }
.switch[aria-checked="true"] .knob { transform: translateX(20px); background: #2a2110; }
.pref-seg { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.pref-seg button { background: transparent; border: none; border-left: 1px solid var(--line); color: var(--muted);
  font-family: inherit; font-size: 12px; padding: 6px 12px; cursor: pointer; transition: background .15s, color .15s; }
.pref-seg button:first-child { border-left: none; }
.pref-seg button:hover { color: var(--parch); }
.pref-seg button.active { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #2a2110; font-weight: 600; }
.pref-range { flex: none; width: 150px; accent-color: var(--gold); cursor: pointer; }
.setting-row.disabled { opacity: .4; pointer-events: none; }
.setting-row.col { flex-direction: column; align-items: stretch; gap: 12px; }
.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.mat-sw { position: relative; height: 50px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer;
  overflow: hidden; padding: 0; background-image: var(--pm); background-size: cover; background-position: center;
  display: flex; align-items: flex-end; transition: transform .12s, border-color .12s; }
.mat-sw:hover { transform: translateY(-2px); border-color: var(--gold); }
.mat-sw.sel { border-color: var(--gold2); box-shadow: 0 0 0 2px var(--gold); }
.mat-name { width: 100%; font-size: 10.5px; color: #f3f1ea; text-align: center; padding: 2px 0 3px;
  background: linear-gradient(0deg, rgba(8,9,13,.82), transparent); }
.mat-custom { display: flex; gap: 8px; }
.mat-custom .field { flex: 1; }
.mat-custom .field.bad { border-color: var(--red); }

/* token creator */
.modal-card.token-card { width: min(680px, 94vw); }
.token-tabs { display: flex; border-bottom: 1px solid var(--line); }
.ttab { flex: 1; padding: 9px 6px; background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); font-family: inherit; font-size: 12.5px; cursor: pointer; transition: color .15s; }
.ttab:hover { color: var(--parch); }
.ttab.active { color: var(--gold2); border-bottom-color: var(--gold); }
.token-body { min-height: 240px; max-height: 52vh; overflow-y: auto; }
.tokenpane { display: none; padding: 12px; }
.tokenpane.active { display: block; }
.token-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.ttoken { position: relative; aspect-ratio: 63/88; border-radius: 8px; background-size: cover; background-position: center;
  background-color: #1a2030; border: 1px solid var(--line); cursor: pointer; transition: .12s;
  display: flex; align-items: center; justify-content: center; text-align: center; }
.ttoken:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(217,179,106,.4); }
.ttoken.sel { border-color: var(--gold2); box-shadow: 0 0 0 2px var(--gold), 0 6px 18px rgba(217,179,106,.5); }
.ttoken.noart span { color: var(--parch); font-size: 11px; padding: 6px; line-height: 1.25; }
.ttoken-pt { position: absolute; right: 3px; bottom: 3px; background: #11161f; color: #fff; border: 1px solid var(--gold);
  border-radius: 5px; font-size: 10px; font-weight: 700; padding: 0 4px; }
.token-empty { color: var(--muted); font-size: 13px; padding: 16px 6px; text-align: center; }
#token-search-input { margin-bottom: 12px; }
.token-custom { display: flex; flex-direction: column; gap: 12px; }
.token-custom label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.token-custom .tc-row { display: flex; gap: 12px; }
.token-custom .tc-row label { flex: 1; }
.token-hint { color: var(--muted); font-size: 11.5px; margin: 0; }
.token-foot { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.token-sel { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-sel.has { color: var(--gold2); }
.token-count { flex: none; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.token-count input { width: 56px; padding: 7px 8px; border-radius: 7px; border: 1px solid var(--line);
  background: #0f131c; color: var(--ink); }

.modal-grid { padding: 14px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.mcard { aspect-ratio: 63/88; border-radius: 8px; background-size: cover; background-position: center; background-color: #1a2030;
  cursor: pointer; border: 1px solid var(--line); transition: .12s; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 11px; padding: 6px; }
.mcard:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(217,179,106,.4); }
.mcard.noart { color: var(--muted); }

/* scry */
.scry-hint { margin: 0; padding: 10px 16px 0; color: var(--muted); font-size: 13px; }
.scry-hint strong { color: var(--gold2); }
.scry-card { position: relative; }
.scry-card .scry-badge { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(20,10,14,.82); color: var(--red); border: 1px solid var(--red); border-radius: 7px;
  padding: 3px 8px; font-size: 11px; font-weight: 600; opacity: 0; pointer-events: none; }
.scry-card.to-bottom { outline: 2px solid var(--red); outline-offset: 1px; filter: brightness(.55); }
.scry-card.to-bottom .scry-badge { opacity: 1; }
.scry-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--line); }
.scry-count { color: var(--muted); font-size: 13px; }

/* explore */
.explore-body { padding: 14px 16px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.explore-card { width: 180px; aspect-ratio: 63/88; border-radius: 10px; background-size: cover; background-position: center;
  background-color: #1a2030; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 10px; color: var(--muted); }
.explore-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Draw button glow at the start of your turn */
.tool.glow { border-color: var(--gold); color: #2a2110;
  background: linear-gradient(180deg, var(--gold2), var(--gold)); font-weight: 600;
  animation: drawpulse 1.7s ease-in-out infinite; }
@keyframes drawpulse {
  0%   { transform: translateY(0);    box-shadow: 0 0 0 0 rgba(217,179,106,0); }
  12%  { transform: translateY(-6px); box-shadow: 0 0 14px 3px rgba(217,179,106,.75); }
  24%  { transform: translateY(0); }
  36%  { transform: translateY(-3px); }
  48%  { transform: translateY(0); box-shadow: 0 0 6px 1px rgba(217,179,106,.4); }
  100% { transform: translateY(0); box-shadow: 0 0 0 0 rgba(217,179,106,0); }
}
@media (prefers-reduced-motion: reduce) {
  .tool.glow { animation: none; transform: none; box-shadow: 0 0 12px 2px rgba(217,179,106,.6); }
}

/* Action cue: a trigger reminder that needs a manual follow-up glows the button
   that does it (Actions ▾ / Draw / life + / the matching Actions item). A soft
   pulsing halo — deliberately calmer than the solid-gold draw-owed .glow so the
   two never read the same. */
.cue { animation: cue-pulse 1.5s ease-in-out infinite; }
.tool.cue, body.table .tool.cue, #ctx button.cue, .lifebtn.cue {
  border-color: var(--gold); color: var(--gold2); }
@keyframes cue-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(243,213,144,0); }
  50%      { box-shadow: 0 0 13px 2px rgba(243,213,144,.6); }
}
@media (prefers-reduced-motion: reduce) {
  .cue { animation: none; box-shadow: 0 0 11px 2px rgba(243,213,144,.55); }
}

/* concede / disabled tool / danger */
.tool.danger { border-color: #5a2a2a; color: #e69a9a; }
.tool.danger:hover { border-color: var(--red); color: #ffb3b3; background: #2a1818; }
.tool:disabled { opacity: .4; cursor: not-allowed; }
.tool:disabled:hover { border-color: var(--line); color: var(--ink); }
.btn-danger { background: linear-gradient(180deg, #d96a6a, #b34a4a); color: #2a0f0f; border: none; font-weight: 600; }
.btn-danger:hover { filter: brightness(1.08); color: #2a0f0f; }

/* defeat prompts */
.deaths { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 7500;
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.death-row { display: flex; align-items: center; gap: 12px; background: #2a1622; border: 1px solid #5a2a3a;
  padding: 8px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; }

/* defeat fanfare — skull burst + red vignette over the eliminated seat */
.board .seat { position: relative; }
.defeat-fx { position: absolute; inset: 0; z-index: 60; pointer-events: none; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: radial-gradient(circle at center, rgba(150,26,38,.4), rgba(6,5,12,.62) 72%);
  animation: defeat-flash 2.4s ease forwards; }
.defeat-skull { font-size: clamp(48px, 9vw, 96px); line-height: 1;
  filter: drop-shadow(0 0 26px rgba(216,88,75,.8));
  animation: defeat-skull 2.4s cubic-bezier(.18,.7,.3,1) forwards; }
.defeat-word { font-family: "Cinzel", serif; font-size: clamp(15px, 2.2vw, 24px); font-weight: 700;
  letter-spacing: .2em; text-transform: uppercase; color: #f3c9bd; text-shadow: 0 0 20px rgba(216,88,75,.85);
  animation: defeat-word 2.4s ease forwards; }
@keyframes defeat-flash { 0% { opacity: 0; } 10% { opacity: 1; } 72% { opacity: 1; } 100% { opacity: 0; } }
@keyframes defeat-skull {
  0%   { transform: scale(.2) rotate(-14deg); opacity: 0; }
  16%  { transform: scale(1.18) rotate(5deg); opacity: 1; }
  32%  { transform: scale(1) rotate(0); }
  72%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.45); opacity: 0; }
}
@keyframes defeat-word {
  0%, 12% { opacity: 0; transform: translateY(10px); }
  28% { opacity: 1; transform: translateY(0); }
  72% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .defeat-fx, .defeat-skull, .defeat-word { animation-duration: .01s; animation-iteration-count: 1; }
}

/* emotes / reactions — picker popover + floating glyph over a seat */
.emote-bar { position: fixed; z-index: 9500; display: flex; flex-wrap: wrap; gap: 4px;
  width: min(232px, 86vw); padding: 8px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); }
.emote-opt { width: 34px; height: 34px; padding: 0; border: 1px solid transparent; border-radius: 8px;
  background: transparent; font-size: 20px; line-height: 1; cursor: pointer; transition: .12s; }
.emote-opt:hover { background: var(--panel); border-color: var(--gold); transform: scale(1.15); }
.emote-pop { position: absolute; bottom: 30%; transform: translateX(-50%); z-index: 70;
  pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  animation: emote-float 2.4s cubic-bezier(.2,.7,.3,1) forwards; }
.emote-glyph { font-size: clamp(40px, 7vw, 72px); line-height: 1;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,.6)); }
.emote-who { font-family: "Cinzel", serif; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  color: var(--gold2); background: rgba(12,14,20,.78); border: 1px solid var(--line);
  padding: 1px 9px; border-radius: 999px; }
@keyframes emote-float {
  0%   { opacity: 0; transform: translateX(-50%) translateY(14px) scale(.4); }
  14%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.15); }
  28%  { transform: translateX(-50%) translateY(-6px) scale(1); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-86px) scale(.92); }
}
@media (prefers-reduced-motion: reduce) {
  .emote-pop { animation-duration: 1.4s; }
}

/* trigger reminders — stacked advisory toasts, bottom-right above the hand */
.trig-stack { position: fixed; right: 14px; bottom: 96px; z-index: 9400;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none; max-width: min(340px, 88vw); }
.trig-toast { pointer-events: auto; cursor: pointer; display: flex; gap: 9px; align-items: flex-start;
  width: 320px; max-width: 88vw; padding: 9px 10px; background: var(--panel2);
  border: 1px solid rgba(240,205,132,.4); border-left: 3px solid var(--gold2);
  border-radius: 10px; box-shadow: var(--shadow);
  animation: trig-in .22s cubic-bezier(.2,.7,.3,1) both; }
.trig-toast.out { animation: trig-out .22s ease forwards; }
.tt-ico { font-size: 15px; line-height: 1.2; filter: drop-shadow(0 0 4px rgba(240,205,132,.6)); }
.tt-body { flex: 1; min-width: 0; }
.tt-name { font-family: "Cinzel", serif; font-weight: 600; font-size: 12.5px; color: var(--gold2); }
.tt-text { font-size: 11.5px; line-height: 1.35; color: var(--ink); margin-top: 1px; }
.tt-x { flex: none; background: none; border: none; color: var(--muted); font-size: 13px;
  line-height: 1; cursor: pointer; padding: 1px 2px; }
.tt-x:hover { color: var(--ink); }
@keyframes trig-in  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes trig-out { to { opacity: 0; transform: translateX(20px); } }

/* Anchored variant — floats above (or below) the triggering permanent. */
.trig-pop { position: fixed; z-index: 9450; width: 264px; max-width: 80vw;
  animation: trig-pop-in .18s cubic-bezier(.2,.7,.3,1) both; }
.trig-pop.out { animation: trig-pop-out .2s ease forwards; }
.trig-pop::after { content: ""; position: absolute; left: var(--caret, 50%); transform: translateX(-50%);
  width: 0; height: 0; border: 7px solid transparent; }
.trig-pop:not(.below)::after { top: 100%; border-top-color: var(--gold2); }   /* caret points down */
.trig-pop.below::after       { bottom: 100%; border-bottom-color: var(--gold2); } /* caret points up */
@keyframes trig-pop-in  { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes trig-pop-out { to { opacity: 0; transform: translateY(4px) scale(.97); } }

/* waiting room overlay */
.waiting { position: fixed; inset: 0; background: rgba(8,9,13,.9); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 8600; }
.wait-card { width: min(420px, 92vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 30px 28px 24px; text-align: center; box-shadow: var(--shadow); }
.wait-glyph { font-size: 44px; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.wait-card h2 { margin: 8px 0 4px; font-size: 22px; color: var(--gold2); }
.wait-sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.wait-code { font-size: 38px; font-weight: 700; letter-spacing: 8px; color: #fff;
  background: #0f131c; border: 1px solid var(--line); border-radius: 10px; padding: 10px 0; margin-bottom: 8px; }
.wait-seated { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.wait-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* pre-game lobby seat list */
.wait-seats { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 18px; text-align: left; }
.wseat { display: flex; align-items: center; gap: 10px; padding: 9px 13px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(8,7,15,.4); font-size: 14px; }
.wseat.you { border-color: rgba(217,179,106,.5); background: rgba(243,213,144,.07); }
.wseat.empty { opacity: .55; }
.wdot { width: 9px; height: 9px; border-radius: 50%; background: #4a4658; flex-shrink: 0; }
.wdot.on { background: #5aa961; box-shadow: 0 0 8px rgba(90,169,97,.7); }
.wname { flex: 1; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wbadge { font-size: 11px; font-family: "Cinzel", serif; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
.wbadge.ok { color: #8fe0a0; border-color: rgba(90,169,97,.5); background: rgba(90,169,97,.12); }
.wbadge.wait { font-style: italic; text-transform: none; letter-spacing: 0; }

/* first-player roll-off overlay */
.rolloff { position: fixed; inset: 0; background: rgba(8,9,13,.92); backdrop-filter: blur(5px);
  display: grid; place-items: center; z-index: 8650; }
.rolloff.hidden { display: none; }
.ro-card { width: min(440px, 92vw); background: var(--panel); border: 1px solid var(--gold);
  border-radius: 18px; padding: 26px 28px 24px; text-align: center;
  box-shadow: 0 22px 70px rgba(0,0,0,.78), inset 0 1px 0 rgba(255,255,255,.05);
  animation: ro-rise .4s cubic-bezier(.2,.8,.3,1) both; }
@keyframes ro-rise { from { opacity: 0; transform: translateY(20px) scale(.96); } to { opacity: 1; transform: none; } }
.ro-stage { height: 168px; display: grid; place-items: center; margin: 2px 0 6px; }
.ro-stage canvas { display: block; margin: 0 auto; }
.ro-stage.flat { font-size: 92px; line-height: 1; filter: drop-shadow(0 8px 22px rgba(243,213,144,.35));
  animation: ro-bob 2.4s ease-in-out infinite; }
@keyframes ro-bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
/* pre-roll countdown card */
.cd-card { width: min(360px, 90vw); }
.cd-label { font-family: "Cinzel", serif; color: var(--gold2); letter-spacing: .18em; text-transform: uppercase;
  font-size: 12px; margin: 2px 0 2px; opacity: .85; }
.cd-num { font-family: "Cinzel", serif; font-weight: 800; font-size: 108px; line-height: 1; color: var(--gold2);
  text-shadow: 0 0 30px rgba(243,213,144,.55), 0 4px 18px rgba(0,0,0,.6); margin: 8px 0 12px;
  animation: cd-pop .85s cubic-bezier(.2,.8,.3,1); }
@keyframes cd-pop { 0% { transform: scale(1.5); opacity: 0; } 50% { transform: scale(1); opacity: 1; } }
.ro-card h2 { margin: 4px 0 6px; font-family: "Cinzel", serif; font-size: 23px; color: var(--gold2); letter-spacing: .02em; }
.ro-sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; min-height: 18px; }
.ro-rolls { display: flex; flex-direction: column; gap: 7px; margin: 0 0 18px; }
.ro-rolls:empty { margin: 0; }
.ro-roll { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: rgba(8,7,15,.45); font-size: 14px; }
.ro-roll.out { opacity: .4; }
.ro-roll.win { border-color: var(--gold); background: rgba(243,213,144,.1); }
.ro-rname { font-family: "Cinzel", serif; color: var(--ink); }
.ro-rval { color: var(--muted); } .ro-rval b { color: var(--gold2); }
.ro-actions { display: flex; gap: 10px; justify-content: center; }
.ro-actions:empty { display: none; }

/* game-over overlay */
.gameover { position: fixed; inset: 0; background: rgba(8,9,13,.82); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 8500; }
.go-card { width: min(460px, 92vw); background: var(--panel); border: 1px solid var(--gold);
  border-radius: 16px; padding: 28px 28px 22px; text-align: center; box-shadow: 0 16px 60px rgba(0,0,0,.7); }
.go-glyph { font-size: 48px; }
.go-card h2 { margin: 6px 0 4px; font-size: 26px;
  background: linear-gradient(180deg, #fff, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.go-summary { color: var(--muted); margin-bottom: 14px; }
.go-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 14px; }
.go-table th { color: var(--muted); font-weight: 500; font-size: 12px; padding: 4px 6px; text-align: center; }
.go-table th:first-child { text-align: left; }
.go-table td { padding: 7px 6px; border-top: 1px solid var(--line); text-align: center; }
.go-table td:first-child { text-align: left; font-weight: 600; }
.go-table tr.win td { color: var(--gold2); }
.go-table tr.lose td { color: var(--muted); }
.go-actions { display: flex; gap: 10px; justify-content: center; }

.hidden { display: none !important; }

@media (max-width: 820px) {
  .sidebar { width: 260px; }
  .tb-mid { display: none; }
  .card { width: 64px; height: 90px; }
}

/* ===================== TABLE — arcane reskin (layered over the above) ===================== */
body.table {
  /* shift the cool default palette to the gold-on-void arcane scheme */
  --bg: #0b0917; --bg2: #100c20; --panel: #191328; --panel2: #14102a;
  --line: rgba(217,179,106,.18); --ink: #ece3cf; --muted: #a99f87; --accent: #5b8dd9;
  --shadow: 0 14px 44px rgba(0,0,0,.62);
  font-family: "Spectral", Georgia, serif;
  background: radial-gradient(135% 100% at 50% -22%, #241d3f 0%, #15112a 32%, #0b0917 62%, #07060e 100%) fixed;
}
/* tiny card text stays crisp */
body.table .card, body.table .card .cardname { font-family: ui-sans-serif, system-ui, "Segoe UI", sans-serif; }

/* topbar = arcane command bar */
body.table .topbar { background: linear-gradient(180deg, rgba(20,15,38,.94), rgba(11,9,23,.92));
  border-bottom: 1px solid rgba(217,179,106,.24); }
body.table .home { color: var(--gold2); text-shadow: 0 0 14px rgba(243,213,144,.5);
  transition: transform .35s cubic-bezier(.2,.8,.2,1); }
body.table .home:hover { transform: rotate(-14deg); }
body.table .code strong { font-family: "Cinzel", serif; color: var(--gold2); letter-spacing: .2em; }
body.table .pill { font-family: "Cinzel", serif; font-size: 11px; letter-spacing: .06em;
  border-color: rgba(217,179,106,.26); background: rgba(8,7,15,.5); }
body.table .pill.active { color: #2a1d08; font-weight: 700; border-color: transparent;
  background: linear-gradient(180deg, var(--gold2), var(--gold));
  box-shadow: 0 0 14px rgba(243,213,144,.45); }

/* tools */
body.table .tool { font-family: "Cinzel", serif; font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  border-radius: 8px; border: 1px solid rgba(217,179,106,.28); background: rgba(243,213,144,.045); color: var(--ink);
  transition: transform .15s, border-color .18s, background .18s, color .18s; }
body.table .tool:hover { border-color: var(--gold2); color: var(--gold2); background: rgba(243,213,144,.11); transform: translateY(-1px); }
body.table .tool.judge { background: linear-gradient(180deg, rgba(91,141,217,.2), rgba(40,48,76,.34));
  border-color: rgba(120,150,220,.45); color: #d3e2ff; }
body.table .tool.judge:hover { border-color: #9ab4ff; color: #eef4ff; }
body.table .tool.danger { background: rgba(216,88,75,.08); border-color: rgba(216,88,75,.4); color: #e9a59c; }
body.table .tool.danger:hover { border-color: var(--red); color: #ffc2ba; background: rgba(216,88,75,.16); }
/* the start-of-turn Draw reminder stays a solid gold token (the drawpulse glow rides on top) */
body.table .tool.glow { color: #2a1d08; font-weight: 700; border-color: var(--gold2);
  background: linear-gradient(180deg, var(--gold2), var(--gold)); }
body.table .tool.glow:hover { color: #2a1d08; background: linear-gradient(180deg, #f8e2ac, var(--gold)); }
body.table .tool:disabled:hover { transform: none; border-color: rgba(217,179,106,.28);
  color: var(--ink); background: rgba(243,213,144,.045); }

/* seats, nameplates, battlefield */
body.table .opponents { border-bottom: 2px solid rgba(217,179,106,.22); }
body.table .seat.you { background: linear-gradient(0deg, rgba(91,141,217,.07), transparent 58%); }
body.table .opponents .seat.opp { background: linear-gradient(180deg, rgba(216,88,75,.055), transparent 58%); }
body.table .seat.opp.active-seat { background: linear-gradient(180deg, rgba(243,213,144,.14), transparent 60%); }
body.table .pname { font-family: "Cinzel", serif; color: var(--gold2); letter-spacing: .03em; }
body.table .life b, body.table .lifeval { font-family: "Cinzel", serif; }
body.table .lifebtn { background: rgba(243,213,144,.05); border-color: rgba(217,179,106,.3); color: var(--gold2); }
body.table .lifebtn:hover { border-color: var(--gold2); background: rgba(243,213,144,.14); }
body.table .battlefield {
  background-image:
    radial-gradient(62% 62% at 50% 50%, rgba(243,213,144,.045), transparent 72%),
    radial-gradient(circle at 1px 1px, rgba(243,213,144,.05) 1px, transparent 0);
  background-size: auto, 30px 30px; }
body.table .seat.active-seat .battlefield { box-shadow: inset 0 0 90px rgba(243,213,144,.08); }

/* ----- table playmats ----- */
/* Each theme defines a --pm background, consumed by both the battlefield and the
   settings swatches so there's a single definition per theme. */
.pm-arcane    { --pm: radial-gradient(62% 62% at 50% 45%, rgba(243,213,144,.07), transparent 72%), linear-gradient(160deg,#1b2030,#12151f); }
.pm-plains    { --pm: radial-gradient(62% 62% at 50% 40%, rgba(247,236,200,.12), transparent 72%), linear-gradient(160deg,#2b291f,#1b1a14); }
.pm-island    { --pm: radial-gradient(62% 62% at 50% 40%, rgba(120,180,240,.16), transparent 72%), linear-gradient(160deg,#13202f,#0e1722); }
.pm-swamp     { --pm: radial-gradient(62% 62% at 50% 40%, rgba(160,120,190,.14), transparent 72%), linear-gradient(160deg,#1c1626,#110d18); }
.pm-mountain  { --pm: radial-gradient(62% 62% at 50% 40%, rgba(232,120,86,.15), transparent 72%), linear-gradient(160deg,#2a1512,#1a0f0d); }
.pm-forest    { --pm: radial-gradient(62% 62% at 50% 40%, rgba(120,200,130,.13), transparent 72%), linear-gradient(160deg,#15251a,#0e1812); }
.pm-celestial { --pm: radial-gradient(62% 62% at 50% 38%, rgba(150,165,245,.16), transparent 72%), linear-gradient(160deg,#171a2e,#0f1020); }
.pm-sunset    { --pm: radial-gradient(70% 60% at 50% 42%, rgba(245,160,110,.16), transparent 72%), linear-gradient(160deg,#2a1a1f,#171016); }
.pm-void      { --pm: radial-gradient(62% 62% at 50% 42%, rgba(90,205,195,.12), transparent 72%), linear-gradient(160deg,#0f1d1f,#0a1214); }
body.table .battlefield[class*="pm-"] {
  background-image: var(--pm), radial-gradient(circle at 1px 1px, rgba(255,255,255,.05) 1px, transparent 0);
  background-size: auto, 30px 30px; }
/* Custom image playmat: darken the edges so cards stay readable over any art. */
body.table .battlefield.mat-img { box-shadow: inset 0 0 200px rgba(0,0,0,.5); }

/* zone chips */
body.table .zone-chip { border-style: solid; border-color: rgba(217,179,106,.2); background: rgba(8,7,15,.42);
  font-family: "Cinzel", serif; font-size: 10px; letter-spacing: .03em; }
body.table .zone-chip:hover { border-color: var(--gold2); color: var(--gold2); }
body.table .zone-chip b { font-family: "Spectral", serif; color: var(--ink); }

/* hand tray */
body.table .hand { background: linear-gradient(0deg, rgba(8,7,15,.6), rgba(8,7,15,.15));
  border-top: 1px solid rgba(217,179,106,.22); }

/* sidebar */
body.table .sidebar { background: linear-gradient(180deg, rgba(18,13,34,.92), rgba(11,9,23,.94));
  border-left: 1px solid rgba(217,179,106,.18); }
body.table .stab { font-family: "Cinzel", serif; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; }
body.table .logline .lw { font-family: "Cinzel", serif; font-size: 11.5px; }

/* buttons inside the table (overlays, judge) */
body.table .btn { font-family: "Cinzel", serif; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid rgba(217,179,106,.34); background: rgba(243,213,144,.05); color: var(--gold2); border-radius: 9px; }
body.table .btn:hover { border-color: var(--gold2); background: rgba(243,213,144,.12); color: var(--gold2); }
body.table .btn-primary { color: #2a1d08; border: 1px solid var(--gold2);
  background: linear-gradient(180deg, #f6dca0, var(--gold) 92%); }
body.table .btn-primary:hover { color: #2a1d08; filter: brightness(1.03);
  background: linear-gradient(180deg, #fff6e2, var(--gold2) 92%); }
/* keep solid-colour variants on-brand on hover (the generic .btn:hover above
   sets a gold tint that would otherwise wash them out) */
body.table .btn-danger:hover { color: #2a0f0f; filter: brightness(1.06);
  background: linear-gradient(180deg, #e07a7a, #b34a4a); border-color: transparent; }
body.table .btn:disabled { opacity: .6; cursor: default; filter: none; transform: none; }

/* overlays + modals + context menu */
body.table .modal { background: rgba(6,5,12,.72); backdrop-filter: blur(3px); }
body.table .modal-card, body.table .wait-card, body.table .go-card, body.table .ctx, body.table .ptmod {
  background: linear-gradient(168deg, rgba(34,28,54,.97), rgba(13,11,26,.98));
  border: 1px solid rgba(217,179,106,.4); }
body.table .ptmod-head { font-family: "Cinzel", serif; color: var(--gold2); }
body.table .ptmod-b, body.table .ptmod-clear { background: rgba(8,7,15,.6); border-color: rgba(217,179,106,.3); }
body.table .ptmod-b:hover, body.table .ptmod-clear:hover { background: rgba(243,213,144,.14); color: var(--gold2); }
body.table .ctr-q, body.table .ctr-name, body.table .ctr-addb { background: rgba(8,7,15,.6); border-color: rgba(217,179,106,.3); }
body.table .ctr-q:hover, body.table .ctr-addb:hover { background: rgba(243,213,144,.14); color: var(--gold2); }
body.table .ctr-name:focus { outline: none; border-color: rgba(217,179,106,.6); }
body.table .modal-head h3, body.table .wait-card h2, body.table .go-card h2 { font-family: "Cinzel", serif; }
body.table .wait-glyph, body.table .go-glyph { text-shadow: 0 0 30px rgba(243,213,144,.4); }
body.table .wait-code { font-family: "Cinzel", serif; background: rgba(8,7,15,.7);
  border-color: rgba(217,179,106,.3); color: var(--gold2); letter-spacing: .2em; }
body.table .ctx button { font-family: "Spectral", serif; }
body.table .ctx button:hover { background: rgba(243,213,144,.12); color: var(--gold2); }
body.table .ruling { border-color: rgba(217,179,106,.22); }
body.table .judge-thinking { color: var(--gold2); }

/* per-turn play controls on the "you" rail (Draw / Actions / Pass turn) */
.play-controls { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---- screen real-estate QoL: collapsible sidebar + focus-a-board ---- */
.sidebar { transition: transform .3s ease; }
body.side-collapsed .sidebar { transform: translateX(100%); box-shadow: none; }
/* Log pull-tab: a vertical handle on the panel's left edge, centred top-to-bottom.
   It's a child of the panel, so it rides the slide and lands at the screen's right
   edge when the log is hidden — the side-to-side mirror of the hand grab-handle. */
.side-handle {
  position: absolute; left: -17px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 66px; padding: 0; margin: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1; color: #cbd3e6;
  background: rgba(22, 18, 38, .97);
  border: 1px solid var(--line); border-right: none;
  border-radius: 8px 0 0 8px; cursor: pointer; z-index: 6;
  box-shadow: -3px 0 10px rgba(0, 0, 0, .3);
  transition: background .15s ease, color .15s ease;
}
.side-handle:hover { background: rgba(40, 33, 66, .99); color: #fff; }
/* icon-only topbar buttons: larger glyph, same chip footprint */
.icon-tool { font-size: 17px; line-height: 1; padding: 3px 9px; }

/* Collapse your bottom strip (rail + hand). max-height animates to 0 (its open
   value = the exact content height, measured by JS into --strip-h, so there's
   no dead-time at the start); the battlefield (flex:1) expands to fill and the
   handle glides down with it. */
.bottom-strip {
  flex-shrink: 0; overflow: hidden;
  max-height: var(--strip-h, 260px);
  transition: max-height .34s cubic-bezier(.4, 0, .2, 1), opacity .26s ease;
}
body.bottom-collapsed .bottom-strip { max-height: 0; opacity: 0; }
/* Grab-handle: a flex item between the battlefield and the bottom strip, so it
   sits on the bar's top edge when open; when the strip is hidden the battlefield
   pushes it to the screen edge as a pull-up tab. No JS positioning needed. */
.hand-handle {
  align-self: center; flex-shrink: 0;
  width: 58px; height: 17px; padding: 0; margin: 0 0 -1px; /* overlap the bar's top border */
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1; color: #cbd3e6;
  background: rgba(22, 18, 38, .97);
  border: 1px solid var(--line); border-bottom: none;
  border-radius: 8px 8px 0 0; cursor: pointer; position: relative; z-index: 5;
  box-shadow: 0 -3px 10px rgba(0, 0, 0, .3);
  transition: background .15s ease, color .15s ease;
}
.hand-handle:hover { background: rgba(40, 33, 66, .99); color: #fff; }
#side-toggle.ding::after { content: ""; position: absolute; top: 7px; right: 4px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--red); box-shadow: 0 0 6px rgba(229,72,77,.85); }

.pname { cursor: pointer; }
.pname:hover { text-shadow: 0 0 10px rgba(243,213,144,.65); }
.seat.focused .pname::before { content: "◆ "; font-size: 9px; vertical-align: 2px; color: var(--gold2); }

/* The spotlight animates flex-grow only (basis stays 0), so cards keep their
   percentage positions and drag/drop math is untouched in every state. */
.board .opponents, .board .seat.you, .opponents .seat.opp { transition: flex-grow .35s ease; }
/* spotlight an opponent: the top row + the focused panel grow; the rest become strips */
.board.focus-opp .opponents { flex-grow: 2.6; }
.board.focus-opp .seat.you { flex-grow: .85; }
.board.focus-opp .opponents .seat.opp { flex-grow: .22; }
.board.focus-opp .opponents .seat.opp .zones { display: none; }
.board.focus-opp .opponents .seat.opp.focused { flex-grow: 1; }
.board.focus-opp .opponents .seat.opp.focused .zones { display: flex; }
/* spotlight your own board: opponents shrink to slim strips (name + life stay visible) */
.board.focus-you .opponents { flex-grow: .3; }
.board.focus-you .seat.you { flex-grow: 2; }
.board.focus-you .opponents .seat.opp .zones { display: none; }
/* gold rim on whichever board is spotlighted */
.seat.opp.focused, .seat.you.focused { box-shadow: inset 0 0 0 1px rgba(243,213,144,.3), inset 0 0 70px rgba(243,213,144,.05); }

/* Persistent staging marker (only rendered when MTG_ENV_LABEL is set). Pinned
   bottom-left, click-through, above the UI so it's unmistakable you're on dev. */
.env-badge {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 9999;
  pointer-events: none;
  padding: 3px 9px;
  font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
  color: #ffd9a8;
  background: rgba(120, 40, 20, .82);
  border: 1px solid rgba(255, 150, 90, .55);
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  user-select: none;
}

/* "Exile until this leaves" — board targeting mode + linkage badges. */
body.targeting .card { cursor: crosshair; }
body.targeting .card:not(.in-hand) {
  outline: 1px dashed rgba(243, 213, 144, .8);
  outline-offset: 1px;
}
.target-hint {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%);
  z-index: 9998; pointer-events: none;
  padding: 7px 14px; border-radius: 8px;
  font: 600 13px/1.2 system-ui, sans-serif; color: #ffe9c4;
  background: rgba(40, 22, 12, .92); border: 1px solid rgba(243, 213, 144, .5);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .5);
}
.target-hint.hidden { display: none; }
/* ⊘ badge on a source that is exiling something (top-left, opposite ⚡). */
.card .exiling {
  position: absolute; top: 2px; left: 2px; z-index: 6; pointer-events: none;
  font-size: 10px; font-weight: 700; line-height: 1; padding: 2px 3px;
  border-radius: 5px; color: #ffd9a8;
  background: rgba(120, 40, 20, .85); border: 1px solid rgba(255, 150, 90, .6);
}
/* "exiled by X" label in the exile zone viewer. */
.mcard .exiled-by {
  position: absolute; left: 3px; bottom: 3px; right: 3px; z-index: 6;
  pointer-events: none; text-align: center;
  font-size: 10px; font-weight: 700; line-height: 1.2; padding: 2px 3px;
  border-radius: 5px; color: #ffd9a8;
  background: rgba(120, 40, 20, .82); border: 1px solid rgba(255, 150, 90, .55);
}

/* ---- Squared-off controls on the game table (less rounded → more "Magic").
   Scoped to body.table so the lobby and the cards themselves are untouched. ---- */
body.table .tool,
body.table .pill,
body.table .lifebtn,
body.table .zone-chip,
body.table .btn,
body.table .ctx button,
body.table .ptmod-b,
body.table .ctr-q,
body.table .ctr-name,
body.table .ctr-addb,
body.table .pref-seg,
body.table .seg,
body.table .token-count input {
  border-radius: 2px;
}
body.table .hand-handle { border-radius: 2px 2px 0 0; }
body.table .side-handle { border-radius: 2px 0 0 2px; border-color: rgba(217,179,106,.3);
  color: var(--gold2); background: rgba(20,15,38,.97); }
body.table .side-handle:hover { background: rgba(40,33,66,.99); color: #fff; }

/* ============================================================================
   GRIMOIRE THEME — "Illuminated Grimoire" table skin (dev). Evolves the arcane
   theme: indigo starfield, gold filigree fields, medallion life, sigil zones,
   a rune divider, and a drop-cap chronicle. Built to hold up at 2–4 players.
   ========================================================================== */
body.table{
  --gold:#d9b36a; --gold2:#f4e0a8; --gold-lo:#9a7836; --crimson:#b6464e; --pale:#cfe0ff;
  font-family:"EB Garamond",Georgia,serif;
  background:
    radial-gradient(1.3px 1.3px at 12% 16%, rgba(255,255,255,.55), transparent),
    radial-gradient(1.2px 1.2px at 73% 9%, rgba(203,182,255,.5), transparent),
    radial-gradient(1.5px 1.5px at 41% 34%, rgba(255,255,255,.4), transparent),
    radial-gradient(1.1px 1.1px at 88% 28%, rgba(217,179,106,.55), transparent),
    radial-gradient(1.2px 1.2px at 24% 62%, rgba(255,255,255,.4), transparent),
    radial-gradient(1.1px 1.1px at 63% 73%, rgba(255,255,255,.35), transparent),
    radial-gradient(1.4px 1.4px at 92% 64%, rgba(203,182,255,.45), transparent),
    radial-gradient(1.1px 1.1px at 8% 84%, rgba(217,179,106,.4), transparent),
    radial-gradient(1.2px 1.2px at 52% 92%, rgba(255,255,255,.3), transparent),
    radial-gradient(1.1px 1.1px at 34% 8%, rgba(255,255,255,.3), transparent),
    radial-gradient(135% 100% at 50% -22%, #221a40 0%, #15112a 32%, #0b0917 62%, #06050d 100%) fixed;
}

/* gilded topbar with a glowing rule */
body.table .topbar{ position:relative; background:linear-gradient(180deg,rgba(23,18,50,.96),rgba(11,9,23,.94)); border-bottom:1px solid rgba(217,179,106,.3); }
body.table .topbar::after{ content:""; position:absolute; left:0; right:0; bottom:-1px; height:2px;
  background:linear-gradient(90deg,transparent,var(--gold-lo) 12%,var(--gold) 50%,var(--gold-lo) 88%,transparent); box-shadow:0 0 10px rgba(217,179,106,.4); }
body.table .code strong{ background:linear-gradient(180deg,var(--gold2),var(--gold) 60%,var(--gold-lo)); -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent; }

/* gold-gradient player names */
body.table .pname{ font-family:"Cinzel",serif; font-weight:600; letter-spacing:.08em;
  background:linear-gradient(180deg,var(--gold2),var(--gold) 60%,var(--gold-lo)); -webkit-background-clip:text; background-clip:text; -webkit-text-fill-color:transparent; }
body.table .pname.dead,body.table .seat.dead .pname{ -webkit-text-fill-color:var(--muted); background:none; text-decoration:line-through; }
body.table .seat.active-seat .pname,body.table .pname.turn{ filter:drop-shadow(0 0 8px rgba(243,213,144,.6)); }

/* life as a gilded medallion */
body.table .life{ gap:7px; }
body.table .life b,body.table .life .lifeval{ position:relative; font-family:"Cinzel",serif; font-weight:700; font-size:22px;
  width:56px; height:56px; min-width:56px; border-radius:50%; display:inline-grid; place-items:center; color:var(--gold2);
  background:radial-gradient(circle at 50% 34%,#271d4e,#0f0b24); border:2px solid var(--gold-lo);
  box-shadow:0 0 18px rgba(217,179,106,.2),inset 0 0 16px #000a,inset 0 1px 0 rgba(255,255,255,.08);
  text-shadow:0 0 11px rgba(217,179,106,.5); }
body.table .life b::before,body.table .life .lifeval::before{ content:""; position:absolute; inset:4px; border-radius:50%;
  border:1px solid rgba(217,179,106,.42); box-shadow:inset 0 0 7px rgba(0,0,0,.5); }
body.table .opponents .life b,body.table .opponents .life .lifeval{ width:46px; height:46px; min-width:46px; font-size:18px; }
body.table .life b.zero,body.table .lifeval.zero{ color:#ff8a8a; border-color:var(--crimson); text-shadow:0 0 9px rgba(182,70,78,.6); }
body.table .lifebtn{ border-radius:50%; background:#14102f; border:1px solid rgba(217,179,106,.35); color:var(--gold2); }
body.table .lifebtn:hover{ border-color:var(--gold2); background:rgba(243,213,144,.12); }

/* sigil zone tiles: gold sigil over a prominent count over a tiny label */
body.table .zone-chip{ display:flex; flex-direction:column; align-items:center; justify-content:center; gap:0;
  min-width:52px; padding:5px 9px 4px; line-height:1; cursor:pointer;
  border:1px solid rgba(217,179,106,.24); background:rgba(10,8,24,.42); border-radius:3px; box-shadow:inset 0 0 9px #0006; }
body.table .zone-chip::before{ font-family:"Spectral",serif; color:var(--gold); opacity:.82; font-size:12px; margin-bottom:2px;
  text-shadow:0 0 6px rgba(217,179,106,.4); }
body.table .zone-chip[data-zone="library"]::before{ content:"\25A4"; }
body.table .zone-chip[data-zone="graveyard"]::before{ content:"\2020"; }
body.table .zone-chip[data-zone="exile"]::before{ content:"\2726"; }
body.table .zone-chip[data-zone="command"]::before{ content:"\2756"; }
body.table .zone-chip[data-zone="hand"]::before{ content:"\2736"; }
body.table .zone-chip b{ font-family:"Cinzel",serif; font-weight:700; font-size:16px; color:var(--gold2); text-shadow:0 0 8px rgba(217,179,106,.3); }
body.table .zone-chip .zname{ font-family:"Cinzel",serif; font-size:8px; letter-spacing:.16em; text-transform:uppercase; color:var(--muted); margin-top:2px; }
body.table .zone-chip:hover{ border-color:var(--gold2); box-shadow:inset 0 0 9px #0006,0 0 9px rgba(217,179,106,.22); }
body.table .zone-chip:hover b, body.table .zone-chip:hover .zname{ color:var(--gold2); }
/* opponents: tighter tiles so 2–3 of them still fit comfortably */
body.table .opponents .zone-chip{ min-width:44px; padding:3px 6px; }
body.table .opponents .zone-chip b{ font-size:14px; }
/* The counters popover sets .counters{min-width:186px}; that same class is the
   in-rail counters indicator, so it was reserving 186px of empty space and
   shoving the zone tiles far from the life counter. Don't reserve it in the rail. */
body.table .nameplate .counters{ min-width:0; }
/* Life·piles (left) and play controls (right) are a HUD floating over the
   battlefield's bottom corners — out of flow, so the battlefield reclaims the band
   that used to sit empty between them. They hover just above the hand strip
   (--strip-h is the JS-measured strip height) and slide to the floor when the hand
   is collapsed. */
.seat.you .rail-left, .seat.you .play-controls{ position:absolute; z-index:50; margin:0;
  bottom:calc(var(--strip-h, 150px) + 8px); transition:bottom .3s ease; }
.seat.you .rail-left{ left:16px; }
.seat.you .play-controls{ right:16px; }
body.bottom-collapsed .seat.you .rail-left, body.bottom-collapsed .seat.you .play-controls{ bottom:12px; }
body.table .seat.you .rail-left{ display:flex; align-items:center; gap:11px; min-width:0;
  background:rgba(9,7,20,.66); border:1px solid rgba(217,179,106,.22); border-radius:4px; padding:5px 10px;
  backdrop-filter:blur(3px); box-shadow:0 4px 16px rgba(0,0,0,.4); }
body.table .seat.you .play-controls{ background:rgba(9,7,20,.66); border:1px solid rgba(217,179,106,.22);
  border-radius:4px; padding:5px 8px; backdrop-filter:blur(3px); box-shadow:0 4px 16px rgba(0,0,0,.4); }
body.table .seat.you .nameplate{ gap:11px; }
body.table .seat.you .zones{ gap:7px; }
/* the hand owns its own full-width row; min-width:0 stops a crowded hand from
   widening it (default flex min-width is min-content) so JS can fan it to fit. */
body.table .seat.you .seat-rail{ justify-content:center; }
body.table .seat.you .hand{ flex:1 1 100%; min-width:0; }

/* arcane battlefield + gold filigree frame */
body.table .battlefield{
  background-image:
    radial-gradient(120% 120% at 50% 50%, rgba(54,40,96,.34), transparent 66%),
    radial-gradient(circle at 1px 1px, rgba(243,213,144,.05) 1px, transparent 0);
  background-size:auto, 30px 30px; }
body.table .battlefield::before{ content:""; position:absolute; inset:6px; z-index:0; pointer-events:none;
  border:1px solid rgba(217,179,106,.22); border-radius:3px; box-shadow:inset 0 0 44px rgba(217,179,106,.045);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cpath d='M11 1 L13 9 L21 11 L13 13 L11 21 L9 13 L1 11 L9 9 Z' fill='%23d9b36a' fill-opacity='0.5'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cpath d='M11 1 L13 9 L21 11 L13 13 L11 21 L9 13 L1 11 L9 9 Z' fill='%23d9b36a' fill-opacity='0.5'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cpath d='M11 1 L13 9 L21 11 L13 13 L11 21 L9 13 L1 11 L9 9 Z' fill='%23d9b36a' fill-opacity='0.5'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cpath d='M11 1 L13 9 L21 11 L13 13 L11 21 L9 13 L1 11 L9 9 Z' fill='%23d9b36a' fill-opacity='0.5'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:5px 5px,calc(100% - 5px) 5px,5px calc(100% - 5px),calc(100% - 5px) calc(100% - 5px); }
body.table .seat.active-seat .battlefield::before{ border-color:rgba(217,179,106,.4); box-shadow:inset 0 0 60px rgba(217,179,106,.09); }
body.table .seat.active-seat .battlefield{ box-shadow:inset 0 0 90px rgba(217,179,106,.07); }

/* colour-identity tint: each half lit by its deck's dominant colour (JS sets
   tint-{w,u,b,r,g}); skipped when a custom playmat is chosen so playmats win. */
body.table .battlefield[class*="tint-"]:not([class*="pm-"]){ background-size:auto,30px 30px; }
body.table .battlefield.tint-w:not([class*="pm-"]){ background-image:radial-gradient(120% 120% at 50% 50%,rgba(228,210,152,.2),transparent 64%),radial-gradient(circle at 1px 1px,rgba(243,213,144,.05) 1px,transparent 0); }
body.table .battlefield.tint-u:not([class*="pm-"]){ background-image:radial-gradient(120% 120% at 50% 50%,rgba(74,124,202,.23),transparent 64%),radial-gradient(circle at 1px 1px,rgba(243,213,144,.05) 1px,transparent 0); }
body.table .battlefield.tint-b:not([class*="pm-"]){ background-image:radial-gradient(120% 120% at 50% 50%,rgba(134,94,176,.22),transparent 64%),radial-gradient(circle at 1px 1px,rgba(243,213,144,.05) 1px,transparent 0); }
body.table .battlefield.tint-r:not([class*="pm-"]){ background-image:radial-gradient(120% 120% at 50% 50%,rgba(188,72,80,.26),transparent 64%),radial-gradient(circle at 1px 1px,rgba(243,213,144,.05) 1px,transparent 0); }
body.table .battlefield.tint-g:not([class*="pm-"]){ background-image:radial-gradient(120% 120% at 50% 50%,rgba(86,160,106,.23),transparent 64%),radial-gradient(circle at 1px 1px,rgba(243,213,144,.05) 1px,transparent 0); }

/* rune divider between the opponents and you */
body.table .opponents{ border-bottom:1px solid rgba(217,179,106,.32); position:relative;
  box-shadow:0 1px 0 rgba(217,179,106,.1); }
body.table .opponents::after{ content:"⟡ ◆ ⟡"; position:absolute; left:50%; bottom:-10px; transform:translateX(-50%); z-index:8;
  font-family:"Cinzel",serif; font-size:11px; letter-spacing:.42em; color:var(--gold); padding:1px 14px 0;
  background:radial-gradient(closest-side,#0b0917 60%,transparent); text-shadow:0 0 10px rgba(217,179,106,.55); }

/* hand on a glowing shelf — card size is user-tunable (Settings → Hand card size)
   via --hand-card-w; the shelf height tracks it so cards never clip. */
body.table .hand{ height:calc(var(--hand-card-w,96px) * 1.396 + 8px); background:linear-gradient(0deg,rgba(8,7,21,.7),rgba(8,7,21,.12)); border-top:1px solid rgba(217,179,106,.28); position:relative; }
body.table .hand .card{ width:var(--hand-card-w,96px); height:calc(var(--hand-card-w,96px) * 1.396); margin:0 var(--gap, -15px); }
body.table .hand .card:hover{ transform:translateY(-26px) scale(1.06); margin:0 7px; }
body.table .hand::before{ content:""; position:absolute; left:24%; right:24%; top:-1px; height:2px;
  background:linear-gradient(90deg,transparent,rgba(217,179,106,.6),transparent); box-shadow:0 0 14px rgba(217,179,106,.4); }

/* play controls read as gilded primary actions */
body.table .play-controls .tool{ border-color:rgba(217,179,106,.45); background:linear-gradient(180deg,rgba(243,213,144,.12),rgba(243,213,144,.04)); color:var(--gold2); }
body.table .play-controls .tool:hover{ border-color:var(--gold2); background:rgba(243,213,144,.18); }
/* The "you haven't drawn yet" nudge: the glow must out-rank the faint fill above
   (same specificity, defined later) so Draw turns solid gold when a draw is owed. */
body.table .play-controls .tool.glow{ color:#2a1d08; font-weight:700; border-color:var(--gold2);
  background:linear-gradient(180deg,var(--gold2),var(--gold)); }
body.table .play-controls .tool.glow:hover{ color:#2a1d08; background:linear-gradient(180deg,#f8e2ac,var(--gold)); }
/* divider between the turn actions (Draw·Actions·Pass) and the undo/redo pair */
.play-controls .pc-sep{ align-self:stretch; width:1px; margin:3px 3px; background:rgba(217,179,106,.32); }

/* ---- phase bar + priority (Arena-style turn structure) ---- */
.phasebar { display: flex; align-items: center; gap: 1px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.phase-step { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px;
  border: 1px solid transparent; border-radius: 13px; background: none; color: var(--muted);
  font-family: "Cinzel", serif; font-size: 11px; letter-spacing: .3px; line-height: 1.1;
  white-space: nowrap; transition: color .12s, border-color .12s, background .12s, box-shadow .12s; }
.phase-step.done { color: #5a6072; }
.phase-step.cur { color: #2a2110; font-weight: 600;
  background: linear-gradient(180deg, var(--gold2), var(--gold));
  box-shadow: 0 0 10px rgba(217,179,106,.4); }
/* a flagged stop wears a small accent dot before its label */
.phase-step.stopped::before { content: "•"; color: var(--accent); font-size: 15px; line-height: 0; margin-right: -1px; }
.phase-step.cur.stopped::before { color: #5a3d0e; }
.phase-step:not(.clickable) { cursor: default; }
.phase-step.clickable { cursor: pointer; }
.phase-step.clickable:hover { color: var(--gold2); border-color: var(--line); }
.phase-sep { width: 1px; height: 12px; margin: 0 4px; background: rgba(217,179,106,.22); }

/* Pass ▸ lights up while you actually hold priority. */
.tool.prio-btn.prio { border-color: var(--gold); color: #2a2110; font-weight: 600;
  background: linear-gradient(180deg, var(--gold2), var(--gold));
  box-shadow: 0 0 12px rgba(217,179,106,.5); animation: cue-pulse 1.6s ease-in-out infinite; }

/* Priority-stop chips in Settings. */
.stops-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.stop-chip { padding: 5px 10px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); color: var(--muted); font-size: 12px; transition: .12s; }
.stop-chip:hover { border-color: var(--gold); color: var(--gold2); }
.stop-chip.on { border-color: var(--accent); color: #cdd6ff; background: rgba(109,127,214,.16); }
.stop-chip.on::before { content: "✓ "; color: var(--accent); }

@media (prefers-reduced-motion: reduce) { .tool.prio-btn.prio { animation: none; } }

/* ---- combat helper ---- */
.combat-bar { position: fixed; left: 50%; top: 52px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 12px; max-width: min(92vw, 780px);
  padding: 8px 14px; border-radius: 12px; border: 1px solid var(--red);
  background: linear-gradient(180deg, rgba(42,16,16,.97), rgba(24,11,11,.97));
  box-shadow: 0 10px 34px rgba(0,0,0,.5); }
.combat-bar .cb-stage { font-size: 18px; }
.combat-bar .cb-msg { flex: 1; min-width: 0; color: var(--ink); font-size: 13.5px; }
.combat-bar .cb-actions { display: flex; gap: 8px; }
.combat-bar .btn { padding: 6px 12px; }

body.combat .battlefield .card { cursor: pointer; }
.card.atk { outline: 2px solid var(--red); outline-offset: 1px; box-shadow: 0 0 14px rgba(217,106,106,.55); }
.card.blocking { outline: 2px solid var(--accent); outline-offset: 1px; box-shadow: 0 0 14px rgba(109,127,214,.5); }
.card.armed { outline: 2px dashed var(--gold2); outline-offset: 1px; box-shadow: 0 0 16px rgba(240,205,132,.6); }
.card.cdead { filter: grayscale(.5) brightness(.68); }
.card.cdead::after { content: "✗"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 30px; color: rgba(255,92,92,.92); text-shadow: 0 1px 4px #000; pointer-events: none; }
.cbadge { position: absolute; top: -7px; left: -7px; z-index: 6; min-width: 18px; height: 18px;
  padding: 0 4px; border-radius: 9px; background: var(--red); color: #2a0f0f; font-size: 11px;
  font-weight: 700; line-height: 18px; text-align: center; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.card.blocking > .cbadge { background: var(--accent); color: #0f1330; }

.combat-card { max-width: 540px; }
.combat-summary { margin: 6px 0; }
.cs-lines { list-style: none; margin: 0 0 10px; padding: 0; }
.cs-lines li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; line-height: 1.4; }
.cs-pt { color: var(--gold2); font-variant-numeric: tabular-nums; }
.cs-kw { color: var(--accent); font-size: 11.5px; }
.cs-x { color: var(--red); font-weight: 700; }
.cs-totals { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0; }
.cs-life { font-weight: 600; font-size: 14px; }
.cs-life.dn { color: var(--red); } .cs-life.up { color: var(--green); }
.cs-deaths { color: var(--muted); font-size: 13px; }
.combat-note { color: var(--muted); font-size: 11.5px; margin: 2px 0 10px; line-height: 1.4; }

@media (max-width: 820px) { .combat-bar { top: auto; bottom: 92px; } }

/* chronicle sidebar */
body.table .sidebar{ background:linear-gradient(180deg,rgba(21,16,49,.95),rgba(11,9,23,.96)); border-left:1px solid rgba(217,179,106,.28); }
body.table .sidebar::before{ content:""; position:absolute; left:0; top:0; bottom:0; width:2px; z-index:2;
  background:linear-gradient(180deg,transparent,var(--gold-lo),var(--gold),var(--gold-lo),transparent); box-shadow:0 0 10px rgba(217,179,106,.4); }
body.table .stab.active{ color:var(--gold2); border-bottom-color:var(--gold); text-shadow:0 0 8px rgba(243,213,144,.4); }
body.table .log{ font-family:"EB Garamond",serif; font-size:14.5px; line-height:1.65; }
body.table .log .logline:first-child::first-letter{ font-family:"Pirata One",serif; font-size:30px; line-height:.7; float:left; padding:3px 8px 0 0; color:var(--gold);
  -webkit-text-fill-color:var(--gold); text-shadow:0 0 10px rgba(217,179,106,.4); }
