/* =====================================================================
   Sunder - fixed "ink and ember" theme.
   A duel recorded like a woodblock print: bone paper, iron ink, one
   vermillion accent, a little gold leaf on a night-indigo table. No glass,
   no neon, no gradients on the cards. The shared base.css is loaded (back
   chip + resets) but glass.css deliberately is not: this game keeps its own
   chrome (.c-bar, .c-btn, .c-modal and friends).
   ===================================================================== */

:root {
  --night-a: #1d2440;
  --night-b: #131829;
  --night-c: #0a0d17;
  --night-line: rgba(226, 214, 186, .055);

  --bone-hi: #f8f4e9;
  --bone: #efe8d8;
  --bone-lo: #dbd1b8;
  --bone-line: rgba(45, 50, 74, .26);

  --ink: #222840;
  --ink-soft: #5c6280;
  --ink-faint: rgba(34, 40, 64, .6);

  --iron: #3a4159;
  --iron-hi: #98a1b8;

  --ember: #d4462e;
  --ember-hi: #f2795a;
  --ember-lo: #8d2a19;

  --gold: #c9a227;
  --gold-hi: #eac95f;

  --font-body: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;

  /* Base scale: the width of one card in hand. Every other size on the table
     derives from it. It grows with viewport width (13.5vw) so the duel gets
     properly big on large screens, and the vh term caps it so the three tall
     bands (two rune plaques and the hand) plus the bar and the action footer
     still fit one screen height with no scrollbar on short windows. 124px is
     the "silly-big" ceiling. */
  --u: clamp(66px, min(13.5vw, calc((100vh - 215px) / 3.7)), 124px);
}

/* ---------- The night table ---------- */
/* The whole board is one screen: no page scrollbar, ever. The table itself is
   the only thing that may scroll (on very short windows) and its scrollbar is
   hidden, so the layout never shifts or gains a gutter. */
body.sr-page {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-color: var(--night-b);
  background-image:
    radial-gradient(120% 66% at 50% -14%, rgba(214, 190, 140, .11), transparent 60%),
    repeating-linear-gradient(90deg, var(--night-line) 0 1px, transparent 1px 30px),
    repeating-linear-gradient(0deg, var(--night-line) 0 1px, transparent 1px 30px),
    radial-gradient(86% 52% at 50% 46%, rgba(212, 70, 46, .07), transparent 70%),
    radial-gradient(92% 60% at 50% 118%, rgba(0, 0, 0, .5), transparent 72%),
    linear-gradient(178deg, var(--night-a), var(--night-b) 58%, var(--night-c));
  background-attachment: fixed;
}
body.sr-page *,
body.sr-page *::before,
body.sr-page *::after { box-sizing: border-box; }

/* Nightfall: the duel is over, the room goes colder. One fixed veil, faded in
   by a class on the page rather than repainting the body gradient. */
body.sr-page::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(78% 54% at 50% 44%, rgba(141, 42, 25, .1), transparent 72%),
    linear-gradient(180deg, rgba(4, 6, 14, .34), rgba(4, 6, 14, .62));
  opacity: 0;
  transition: opacity 1.4s ease;
}
body.sr-page.is-night::after { opacity: 1; }

.sr-app {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: none;
}
/* The body veil only reaches the felt, because the bone chrome is opaque. A
   second, shallower wash sits on top of the whole table so nightfall reads on the
   bar and the cards too. It stays under .sr-pop (z-index 8), so a number that
   just landed never dims, and the modals are page siblings above this element. */
.sr-app::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    radial-gradient(122% 92% at 50% 38%, transparent 54%, rgba(4, 6, 14, .5) 100%),
    linear-gradient(180deg, rgba(10, 14, 30, .14), rgba(6, 8, 18, .26));
  opacity: 0;
  transition: opacity 1.6s ease;
}
body.sr-page.is-night .sr-app::after { opacity: 1; }

/* ---------- Top bar: a strip of bone paper ---------- */
.c-bar {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 9px clamp(12px, 3vw, 26px) 10px;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bone-hi), var(--bone) 58%, var(--bone-lo));
  border-bottom: 1.5px solid rgba(24, 28, 46, .62);
  box-shadow: 0 7px 22px rgba(4, 6, 14, .5), inset 0 1px 0 rgba(255, 255, 255, .8);
}
/* A second ink rule under the first, like a printed masthead. */
.c-bar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 3px;
  height: 1px;
  background: rgba(34, 40, 64, .22);
  pointer-events: none;
}
.c-bar__brand { display: flex; align-items: center; gap: 9px; }
.c-bar__brand svg { display: block; }
.c-bar__title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(19px, 3vw, 27px);
  font-weight: 700;
  letter-spacing: .01em;
  color: #1c2138;
}
.c-bar__stats { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.stat { font-size: 13px; letter-spacing: .02em; color: var(--ink-soft); }
.stat b {
  font-family: var(--font-mono);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
/* The chronicle count reddens as the deck runs out, since an empty deck is
   when the duel stops being about cards. */
.stat b.is-thin { color: var(--ember-lo); }
.c-bar__controls { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* Buttons: bone tabs with a hard iron bottom edge. */
.c-btn {
  appearance: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .01em;
  padding: 7px 14px;
  border-radius: 3px;
  color: #232a44;
  background: linear-gradient(180deg, #fbf8ef, #e3dcc9);
  border: 1px solid rgba(40, 46, 70, .42);
  box-shadow: 0 2px 0 rgba(40, 46, 70, .26), 0 5px 12px rgba(4, 6, 14, .3);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .12s ease, filter .12s ease;
}
.c-btn:hover { filter: brightness(1.03); }
.c-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(40, 46, 70, .26); }
.c-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.c-btn:disabled { opacity: .48; cursor: default; transform: none; box-shadow: 0 1px 0 rgba(40, 46, 70, .2); }
.c-btn--primary {
  color: #fff2e6;
  background: linear-gradient(180deg, #d8512f, #a33119);
  border-color: #7c2412;
  box-shadow: 0 2px 0 #6e2010, 0 5px 14px rgba(120, 30, 12, .38);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .28);
}

/* ---------- The table ---------- */
.sr-table {
  width: min(97vw, 1180px);
  margin: 0 auto;
  padding: clamp(7px, 1.3vh, 14px) 0 clamp(8px, 1.4vh, 14px);
  flex: 1 1 auto;
  min-height: 0;
  /* Safety valve for very short windows: the table scrolls internally, with the
     scrollbar hidden, so the page itself never gains one. */
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1vh, 11px);
}
.sr-table::-webkit-scrollbar { width: 0; height: 0; }

/* ---------- A rank: crest beside rune slot ---------- */
.sr-rank {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: clamp(8px, 1.4vw, 16px);
  min-height: 0;
}
.sr-rank--them { flex-direction: row; }
.sr-rank--you { flex-direction: row; }

/* ---------- The crest: who is standing there ---------- */
.sr-crest {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 8px clamp(9px, 1.4vw, 15px) 9px;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(240, 232, 210, .07), rgba(6, 8, 16, .26));
  box-shadow: inset 0 0 0 1px rgba(232, 222, 196, .14);
  transition: box-shadow .14s ease, background .14s ease, transform .1s ease;
}
.sr-crest--you { box-shadow: inset 0 0 0 1px rgba(201, 162, 39, .3); }
.sr-crest--them { box-shadow: inset 0 0 0 1px rgba(212, 70, 46, .3); }
/* Whose turn it is: the rank is lifted out of the cloth and edged in gold leaf,
   so the eye lands on the active side without any motion on the table. */
.sr-crest.is-turn {
  background: linear-gradient(180deg, rgba(240, 232, 210, .13), rgba(6, 8, 16, .2));
  box-shadow: inset 0 0 0 1.5px rgba(201, 162, 39, .55), 0 6px 18px rgba(4, 6, 14, .45);
  transform: translateY(-2px);
}
/* A crest you can hit: the lifted-card target. Same trick as the plaque, the
   frame brightens rather than anything moving. */
.sr-crest.is-aim { cursor: pointer; }
.sr-crest.is-aim:hover,
.sr-crest.is-aim:focus-visible {
  background: linear-gradient(180deg, rgba(242, 121, 90, .16), rgba(6, 8, 16, .24));
  box-shadow: inset 0 0 0 2px rgba(242, 121, 90, .8), 0 0 18px rgba(212, 70, 46, .2);
  transform: translateY(-2px);
}
.sr-crest.is-hit { animation: srShake .34s ease-out both; }
@keyframes srShake {
  0% { transform: translateX(0); }
  22% { transform: translateX(-5px); }
  48% { transform: translateX(4px); }
  74% { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

.sr-crest__top { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.sr-crest__who {
  font-family: var(--font-serif);
  font-size: clamp(15px, 2.1vw, 21px);
  font-weight: 700;
  letter-spacing: .005em;
  color: #f4efe1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-crest--you .sr-crest__who { color: var(--gold-hi); }
.sr-crest--them .sr-crest__who { color: var(--ember-hi); }
.sr-crest__note {
  margin-left: auto;
  font-size: 12px;
  color: rgba(232, 222, 196, .5);
  white-space: nowrap;
}

/* Life: a printed number over a ruled track. The ticks are one life each. */
.sr-life { display: flex; align-items: center; gap: 9px; }
.sr-life__n {
  font-family: var(--font-mono);
  font-size: clamp(20px, 3.4vw, 32px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  color: #f7f2e4;
  font-variant-numeric: tabular-nums;
  min-width: 2.1ch;
  text-align: right;
}
.sr-life__n.is-low { color: var(--ember-hi); }
.sr-life__n.is-gain { animation: srGain .5s ease-out both; }
.sr-life__n.is-loss { animation: srLoss .5s ease-out both; }
@keyframes srGain { 0% { color: var(--gold-hi); transform: scale(1.2); } 100% { color: #f7f2e4; transform: none; } }
@keyframes srLoss { 0% { color: var(--ember); transform: scale(1.16); } 100% { color: #f7f2e4; transform: none; } }
.sr-bar {
  position: relative;
  flex: 1 1 auto;
  min-width: 40px;
  height: clamp(9px, 1.5vh, 14px);
  border-radius: 2px;
  background: rgba(6, 8, 16, .5);
  box-shadow: inset 0 0 0 1px rgba(232, 222, 196, .18);
  overflow: hidden;
}
.sr-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-hi));
  transition: width .3s ease;
}
.sr-crest--them .sr-bar i { background: linear-gradient(90deg, var(--ember-lo), var(--ember)); }
/* One tick per point of life, printed over the fill. The count comes from the
   crest (--life), so the second rank's longer bar still rules correctly. */
.sr-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, rgba(6, 8, 16, .5) 0 1px,
    transparent 1px calc(100% / var(--life, 20)));
  pointer-events: none;
}

.sr-chips { display: flex; flex-wrap: wrap; gap: 5px; min-height: 20px; }
.sr-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px 1px 5px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  color: #e8e0cc;
  background: rgba(232, 222, 196, .08);
  box-shadow: inset 0 0 0 1px rgba(232, 222, 196, .2);
}
.sr-chip b { font-family: var(--font-mono); font-size: 12.5px; }
.sr-chip svg { width: 11px; height: 11px; display: block; }
.sr-chip--ward { color: #f2e4bd; background: rgba(201, 162, 39, .16); box-shadow: inset 0 0 0 1px rgba(201, 162, 39, .5); }
.sr-chip--weak { color: #f3c9bc; background: rgba(212, 70, 46, .14); box-shadow: inset 0 0 0 1px rgba(212, 70, 46, .45); }

/* A number that landed just now, shouted once over the crest. */
.sr-pop {
  position: absolute;
  left: 50%;
  top: 40%;
  z-index: 8;
  padding: 2px 10px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: clamp(16px, 2.6vw, 24px);
  font-weight: 700;
  line-height: 1.3;
  color: #fff4e8;
  background: rgba(141, 42, 25, .94);
  box-shadow: 0 3px 14px rgba(4, 6, 14, .55);
  pointer-events: none;
  animation: srRise .52s cubic-bezier(.2, .7, .3, 1) both;
}
.sr-pop.is-good { color: #221d0c; background: rgba(234, 201, 95, .96); }
.sr-pop.is-ward { color: #141a2c; background: rgba(201, 162, 39, .5); }
.sr-pop.is-quiet { font-size: clamp(11px, 1.7vw, 15px); background: rgba(40, 46, 70, .94); color: #dfe6f5; }
@keyframes srRise {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(.7); }
  24% { opacity: 1; transform: translate(-50%, -60%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -165%) scale(1); }
}

/* ---------- A rune plaque ---------- */
/* Waiting spells are the loudest thing on the table, and they are landscape
   plaques rather than cards, so a rune never reads as a card you could play. */
.sr-slot {
  position: relative;
  flex: 0 0 auto;
  width: calc(var(--u) * 1.72);
  display: flex;
  align-items: center;
}
.sr-empty {
  width: 100%;
  min-height: calc(var(--u) * .86);
  display: grid;
  place-items: center;
  padding: 6px 8px;
  border: 1px dashed rgba(232, 222, 196, .18);
  border-radius: 3px;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.35;
  color: rgba(232, 222, 196, .32);
}
.sr-empty.is-aim {
  cursor: pointer;
  border-color: rgba(201, 162, 39, .6);
  background: rgba(201, 162, 39, .07);
  color: rgba(242, 232, 210, .82);
}
.sr-empty.is-aim:hover { border-color: var(--gold-hi); background: rgba(201, 162, 39, .14); }

.sr-rune {
  position: relative;
  width: 100%;
  min-height: calc(var(--u) * .86);
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 6px 7px;
  border-radius: 3px;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bone-hi), var(--bone) 62%, var(--bone-lo));
  box-shadow:
    inset 0 0 0 1.5px rgba(34, 40, 64, .8),
    inset 0 0 0 3px rgba(212, 70, 46, .18),
    0 0 20px rgba(212, 70, 46, .28),
    0 4px 12px rgba(4, 6, 14, .48);
}
button.sr-rune { cursor: pointer; }
.sr-rune--you { box-shadow: inset 0 0 0 1.5px rgba(34, 40, 64, .8), 0 0 20px rgba(201, 162, 39, .3), 0 4px 12px rgba(4, 6, 14, .48); }
/* A rune about to land breathes. It is the only infinite motion on the table,
   so it is also the thing that tells you whose turn you are waiting on. */
.sr-rune.is-live { animation: srSmoulder 2.4s ease-in-out infinite; }
@keyframes srSmoulder {
  0%, 100% { box-shadow: inset 0 0 0 1.5px rgba(34, 40, 64, .8), inset 0 0 0 3px rgba(212, 70, 46, .16), 0 0 14px rgba(212, 70, 46, .2), 0 4px 12px rgba(4, 6, 14, .48); }
  50% { box-shadow: inset 0 0 0 1.5px rgba(34, 40, 64, .8), inset 0 0 0 3px rgba(212, 70, 46, .4), 0 0 26px rgba(212, 70, 46, .44), 0 4px 12px rgba(4, 6, 14, .48); }
}
/* Cuttable: the plaque you have a blade for. Framed in gold, and it lifts.
   The frame has to be an animation, not a plain box-shadow: .is-live breathes
   on that same property, and a running animation always beats a declaration. */
.sr-rune.is-cuttable {
  box-shadow: inset 0 0 0 2px var(--gold-hi), 0 0 22px rgba(201, 162, 39, .4), 0 4px 12px rgba(4, 6, 14, .5);
  animation: srGold 1.9s ease-in-out infinite;
}
@keyframes srGold {
  0%, 100% { box-shadow: inset 0 0 0 2px var(--gold-hi), inset 0 0 0 4px rgba(201, 162, 39, .22), 0 0 14px rgba(201, 162, 39, .3), 0 4px 12px rgba(4, 6, 14, .5); }
  50% { box-shadow: inset 0 0 0 2.5px #f4e2ab, inset 0 0 0 5px rgba(234, 201, 95, .3), 0 0 28px rgba(201, 162, 39, .55), 0 4px 12px rgba(4, 6, 14, .5); }
}
/* The "N to cut" block is the affordance: it goes gold and solid so the number
   you have to beat reads as a button, not as a caption. */
.sr-rune.is-cuttable .sr-rune__p {
  border-left-color: rgba(120, 90, 12, .6);
  color: #4a3808;
}
.sr-rune.is-cuttable .sr-rune__p b { color: #4a3808; }
.sr-rune.is-cuttable .sr-rune__p span { color: rgba(74, 56, 8, .8); }
button.sr-rune.is-cuttable:hover,
button.sr-rune.is-cuttable:focus-visible { transform: translateY(-3px); }
.sr-rune__mark {
  flex: 0 0 auto;
  width: calc(var(--u) * .46);
  display: grid;
  place-items: center;
  color: var(--ember);
}
.sr-rune__mark svg { width: 100%; height: auto; display: block; }
.sr-rune__txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sr-rune__name {
  font-family: var(--font-serif);
  font-size: clamp(12px, 1.5vw, 15px);
  font-weight: 700;
  line-height: 1.1;
  color: #1c2138;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sr-rune__t { font-size: clamp(9.5px, 1.1vw, 11.5px); line-height: 1.28; color: var(--ink); }
.sr-rune__t b { color: var(--ember-lo); }
.sr-rune__c { font-size: clamp(9px, 1vw, 11px); line-height: 1.25; color: var(--ink-faint); font-style: italic; }
.sr-rune__p {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-left: 5px;
  border-left: 1px solid var(--bone-line);
  color: var(--ink);
}
.sr-rune__p b { font-family: var(--font-mono); font-size: clamp(17px, 2.6vw, 26px); font-weight: 700; line-height: 1; }
.sr-rune__p span { font-size: 8.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); text-align: center; line-height: 1.15; }

/* Lands: the plaque flares and slides off the table. */
@keyframes srFlare {
  0% { opacity: 1; transform: none; filter: none; }
  30% { opacity: 1; transform: scale(1.06); filter: brightness(1.5); }
  100% { opacity: 0; transform: translateY(-18px) scale(.96); }
}
.sr-rune.is-land { animation: srFlare .44s ease-in forwards; }
/* Cut: a bright line sweeps across, then the plaque falls. Deliberately short,
   because the next render repaints the slot. */
@keyframes srSweep {
  0% { transform: translateX(-104%) rotate(-14deg); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateX(104%) rotate(-14deg); opacity: 0; }
}
.sr-rune__slash {
  position: absolute;
  left: 0; right: 0; top: 46%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #fff8e8 40%, var(--gold-hi) 60%, transparent);
  box-shadow: 0 0 12px rgba(234, 201, 95, .9);
  pointer-events: none;
  animation: srSweep .3s ease-out both;
}
@keyframes srFall {
  0% { transform: none; opacity: 1; }
  100% { transform: translateY(20px) rotate(-5deg); opacity: 0; }
}
.sr-rune.is-cut { animation: srFall .4s ease-in forwards; }

/* ---------- The rail: chronicle, turn, dusk ---------- */
.sr-rail {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(240, 232, 210, .05), rgba(6, 8, 16, .2));
  box-shadow: inset 0 0 0 1px rgba(232, 222, 196, .1);
  font-size: 12px;
  color: rgba(232, 222, 196, .62);
}
.sr-rail__k {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(232, 222, 196, .4);
}
.sr-rail b { font-family: var(--font-mono); font-size: 13px; color: #f2ecdd; }
.sr-rail__d {
  margin-left: auto;
  font-family: var(--font-serif);
  font-size: 12.5px;
  font-style: italic;
  color: rgba(232, 222, 196, .46);
}
/* The deck stack, drawn as a small pile of card stock. */
.sr-deck {
  position: relative;
  flex: 0 0 auto;
  width: calc(var(--u) * .4);
  height: calc(var(--u) * .54);
  border-radius: 2px;
  background: linear-gradient(180deg, #2b3352, #1a2038);
  box-shadow: inset 0 0 0 1px rgba(232, 222, 196, .3), 2px 2px 0 rgba(232, 222, 196, .12), 4px 4px 0 rgba(232, 222, 196, .07);
}
.sr-deck::after {
  content: "";
  position: absolute;
  inset: 4px 5px;
  border-radius: 1px;
  background: radial-gradient(circle at 50% 42%, rgba(212, 70, 46, .8), rgba(212, 70, 46, 0) 62%);
  box-shadow: inset 0 0 0 1px rgba(201, 162, 39, .5);
}
.sr-dusk {
  flex: 0 0 auto;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #f6d3a0;
  background: rgba(212, 70, 46, .18);
  box-shadow: inset 0 0 0 1px rgba(242, 121, 90, .5);
  animation: srSmoulderDusk 2.8s ease-in-out infinite;
}
@keyframes srSmoulderDusk {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(242, 121, 90, .35); }
  50% { box-shadow: inset 0 0 0 1px rgba(242, 121, 90, .85), 0 0 12px rgba(212, 70, 46, .3); }
}

/* ---------- The hand: two-faced cards ---------- */
.sr-hand {
  --hg: clamp(5px, .8vw, 10px);
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  justify-content: center;
  gap: var(--hg);
  padding: 2px 0 calc(var(--u) * .14);
}
.sr-card {
  /* The width is the unit, never a share of the row: a percentage in here would
     also be substituted into the height calc below, where it resolves against an
     indefinite row height and collapses the card to a sliver. Above 1000px seven
     cards at the 124px cap plus gaps are 928px, so the row always fits; below it
     the hand turns into a swipe instead of shrinking. */
  --cw: var(--u);
  position: relative;
  flex: 0 0 auto;
  width: var(--cw);
  height: calc(var(--cw) * 1.44);
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1.5px solid rgba(24, 28, 46, .85);
  border-radius: 3px;
  overflow: hidden;
  font: inherit;
  text-align: center;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bone-hi), var(--bone) 62%, var(--bone-lo));
  box-shadow: 0 3px 0 rgba(6, 8, 16, .3), 0 8px 16px rgba(4, 6, 14, .46);
  cursor: pointer;
  transition: transform .14s cubic-bezier(.2, .8, .3, 1), box-shadow .14s ease, filter .14s ease;
}
/* A whisper of paper grain, so the bone is not a flat fill. */
.sr-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .4;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='44' height='44' filter='url(%23n)' opacity='.14'/%3E%3C/svg%3E");
}
.sr-card > * { position: relative; z-index: 1; }

.sr-card__name {
  flex: 0 0 auto;
  padding: 2px 3px 3px;
  font-family: var(--font-serif);
  font-size: calc(var(--cw) * .108);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .005em;
  color: #1c2138;
  border-bottom: 1px solid var(--bone-line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sr-card__split {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}
/* The fold: the seam is not vertical, it leans a couple of degrees like a
   sheet that has been creased in half. */
.sr-card__split::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 1.5px;
  margin-left: -.75px;
  background: rgba(34, 40, 64, .5);
  transform: rotate(2.4deg);
  z-index: 2;
  pointer-events: none;
}
.sr-side {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--cw) * .02);
  padding: 2px 1px;
}
.sr-side--blade { color: var(--iron); }
.sr-side--rune { color: var(--ember); background: rgba(212, 70, 46, .07); }
.sr-side svg { width: 52%; height: auto; display: block; }
.sr-num {
  font-family: var(--font-mono);
  font-size: calc(var(--cw) * .3);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.03em;
}
.sr-side--rune .sr-num { color: var(--ember-lo); }
.sr-side__k {
  font-size: calc(var(--cw) * .075);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--ink-faint);
  white-space: nowrap;
}

.sr-card__body {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 4px 4px;
  border-top: 1px solid var(--bone-line);
  background: rgba(255, 255, 255, .32);
}
.sr-card__body p {
  margin: 0;
  font-size: calc(var(--cw) * .088);
  line-height: 1.22;
  text-align: left;
  color: var(--ink);
}
.sr-card__body p b { color: var(--ember-lo); font-weight: 700; }
.sr-card__body p.is-cut { color: var(--ink-faint); font-style: italic; }

.sr-card:disabled { cursor: default; }
.sr-card.is-sorted { order: 0; }
button.sr-card:hover:not(:disabled),
button.sr-card:focus-visible {
  transform: translateY(-8px) rotate(-.7deg);
  filter: brightness(1.03);
  box-shadow: 0 4px 0 rgba(6, 8, 16, .28), 0 16px 26px rgba(4, 6, 14, .55);
  z-index: 5;
}
button.sr-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button.sr-card:active:not(:disabled) { transform: translateY(-3px); }
/* Lifted: gold-edged and held up off the table, so the card you have committed
   to is unmistakable while you choose which half of it to use. */
.sr-card.is-picked {
  transform: translateY(-13px) rotate(-1.2deg);
  z-index: 6;
  box-shadow:
    inset 0 0 0 2px rgba(234, 201, 95, .95),
    0 5px 0 rgba(6, 8, 16, .3),
    0 18px 30px rgba(4, 6, 14, .6);
}
/* A blade that is too small to answer the rune on the table: still playable,
   but the cut option is gone, so say so on the card. */
.sr-card.is-shorn { opacity: .96; }

/* ---------- Action bar ----------
   The Game Center back chip is fixed at the bottom-left of the viewport
   (base.css), so the bar keeps a wide left gutter: the status line then
   always starts clear of the chip instead of running under it. */
.sr-act {
  position: relative;
  flex: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 8px clamp(12px, 3vw, 24px) 10px clamp(150px, 17vw, 190px);
  color: #f2ecdd;
  background: linear-gradient(180deg, rgba(10, 13, 24, .86), rgba(6, 8, 16, .96));
  border-top: 1px solid rgba(232, 222, 196, .14);
  box-shadow: 0 -8px 24px rgba(4, 6, 14, .5);
}
.sr-act__status {
  flex: 1 1 16ch;
  margin: 0;
  min-width: 0;
  font-size: 13.5px;
  line-height: 1.4;
  color: rgba(240, 234, 216, .84);
}
.sr-act__status b { color: #fff3d8; font-weight: 700; }
.sr-act__status .is-hot { color: var(--ember-hi); }
.sr-act__status .is-cold { color: rgba(232, 222, 196, .5); }
.sr-act__moves { display: flex; flex-wrap: wrap; gap: 7px; margin-left: auto; }
.sr-mv {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 3px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  color: #232a44;
  background: linear-gradient(180deg, #fbf8ef, #e6dfcc);
  border: 1px solid rgba(40, 46, 70, .45);
  box-shadow: 0 2px 0 rgba(40, 46, 70, .3);
  cursor: pointer;
  transition: transform .07s ease, filter .12s ease, box-shadow .12s ease;
}
.sr-mv:hover { filter: brightness(1.04); transform: translateY(-1px); }
.sr-mv:active { transform: none; box-shadow: 0 1px 0 rgba(40, 46, 70, .3); }
.sr-mv:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sr-mv kbd {
  flex: 0 0 auto;
  padding: 0 4px;
  border-radius: 2px;
  border: 1px solid rgba(40, 46, 70, .35);
  background: rgba(255, 255, 255, .6);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.5;
}
.sr-mv span { display: block; }
.sr-mv b { font-family: var(--font-mono); font-size: 14px; }
.sr-mv--blade { border-color: rgba(40, 46, 70, .6); }
.sr-mv--blade b { color: var(--iron); }
.sr-mv--cut { color: #2a1e06; background: linear-gradient(180deg, #f6e2a8, #dfc268); border-color: rgba(120, 90, 12, .55); }
.sr-mv--cut b { color: #5b420a; }
.sr-mv--spell { color: #fff1e6; background: linear-gradient(180deg, #e0573a, #ac3319); border-color: rgba(96, 24, 10, .7); text-shadow: 0 1px 0 rgba(0, 0, 0, .22); }
.sr-mv--spell b { color: #ffe6b8; }
.sr-mv--spell kbd { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .3); color: #ffeccf; }
.sr-mv--back { color: rgba(240, 234, 216, .72); background: none; border-color: rgba(232, 222, 196, .26); box-shadow: none; font-size: 12.5px; }
/* Casting at your last point of life is a legal move, not a sane one, so it is
   printed as a warning rather than taken away. */
.sr-mv--spell.is-steep {
  background: none;
  border-style: dashed;
  border-color: rgba(242, 121, 90, .75);
  color: #f6b79e;
  text-shadow: none;
}
.sr-mv--spell.is-steep b { color: #ffd2a8; }
.sr-mv--spell.is-steep kbd { background: rgba(242, 121, 90, .16); border-color: rgba(242, 121, 90, .4); color: #ffd2a8; }

/* ---------- Modals (the overlay scrolls, never the card) ---------- */
.c-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.c-modal[hidden] { display: none; }
.c-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 14, .72);
  cursor: pointer;
}
.c-modal__panel {
  position: relative;
  z-index: 1;
  margin: auto;
  width: min(94vw, 560px);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bone-hi), var(--bone) 62%, var(--bone-lo));
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .8),
    0 0 0 1.5px rgba(24, 28, 46, .7),
    0 30px 70px rgba(4, 6, 14, .66);
  animation: srPlate .24s ease-out both;
}
@keyframes srPlate {
  0% { transform: translateY(12px) scale(.985); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
/* The inner rule that every sheet of this duel carries. */
.c-modal__panel::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(34, 40, 64, .2);
  pointer-events: none;
}
.sr-rules { width: min(94vw, 620px); }
#rulesModal { z-index: 62; }
.c-modal__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 10px;
  border-bottom: 1.5px solid rgba(34, 40, 64, .3);
}
.c-modal__head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 21px;
  letter-spacing: .005em;
  color: #1c2138;
}
.c-modal__x {
  margin-left: auto;
  position: relative;
  z-index: 2;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 2px;
  border: 1px solid rgba(40, 46, 70, .4);
  background: linear-gradient(180deg, #fbf8ef, #e6dfcc);
  color: #333a58;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.c-modal__x:hover { filter: brightness(1.04); }
.c-modal__x[hidden] { display: none; }
.c-modal__body { padding: 14px 22px 4px; font-size: 14.5px; line-height: 1.6; color: #2c3350; }
.c-modal__body b { color: #171d33; }
.c-modal__body kbd {
  padding: 0 4px;
  border-radius: 2px;
  border: 1px solid rgba(40, 46, 70, .38);
  background: rgba(255, 255, 255, .6);
  font-family: var(--font-mono);
  font-size: 11px;
}
.c-modal__lead { margin: 0 0 12px; font-size: 15px; }
.c-modal__note { margin: 13px 0 2px; font-size: 12.5px; line-height: 1.55; color: rgba(34, 40, 64, .72); }
.c-modal__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 15px;
}

/* The how-to list: four numbered steps. */
.sr-steps {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 7px;
}
.sr-steps li {
  counter-increment: step;
  position: relative;
  padding: 8px 11px 8px 44px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .46);
  box-shadow: inset 0 0 0 1px rgba(34, 40, 64, .18);
  font-size: 14px;
  line-height: 1.45;
}
.sr-steps li::before {
  content: counter(step);
  position: absolute;
  left: 10px;
  top: 9px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: #fff3e6;
  background: linear-gradient(180deg, #d8512f, #a33119);
}

/* ---------- Flow: rival picker, handover, result ---------- */
.sr-flow { width: min(94vw, 600px); }
.sr-picks { display: grid; gap: 7px; }
.sr-pick {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  border-radius: 2px;
  border: 1px solid rgba(40, 46, 70, .4);
  background: linear-gradient(180deg, #fbf8ef, #ebe4d0);
  box-shadow: 0 2px 0 rgba(40, 46, 70, .2);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: transform .07s ease, filter .12s ease;
}
.sr-pick:hover { filter: brightness(1.03); transform: translateY(-1px); }
.sr-pick:active { transform: none; }
.sr-pick:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sr-pick__mark { display: grid; place-items: center; width: 40px; height: 32px; color: var(--iron); }
.sr-pick__mark svg { width: 100%; height: auto; }
.sr-pick--ember .sr-pick__mark { color: var(--ember); }
.sr-pick__t { display: block; font-family: var(--font-serif); font-size: 16px; font-weight: 700; color: #1c2138; }
.sr-pick__d { display: block; font-size: 12.5px; line-height: 1.4; color: rgba(34, 40, 64, .72); }

/* The handover sheet, in hotseat: nothing of the table shows through it. */
.sr-hand-over { text-align: center; padding: 8px 4px 4px; }
.sr-hand-over h3 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 26px;
  color: #1c2138;
}
.sr-hand-over p { margin: 0 0 12px; font-size: 13.5px; color: rgba(34, 40, 64, .72); }

/* ---------- Result ---------- */
.sr-verdict { display: flex; align-items: baseline; gap: 12px; margin: 0 0 10px; }
.sr-verdict__num {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  color: #1c2138;
  font-variant-numeric: tabular-nums;
}
.sr-verdict__num small { font-size: 13px; font-weight: 600; color: rgba(34, 40, 64, .5); margin-left: 3px; }
.sr-verdict__who { font-size: 13px; color: rgba(34, 40, 64, .76); }
.sr-log { display: grid; gap: 3px; margin: 10px 0 2px; }
.sr-log__row {
  display: grid;
  /* label first and wide, then one column per duelist so the two totals line up
     under the names in the header row */
  grid-template-columns: 1fr 5ch 5ch;
  gap: 8px;
  align-items: baseline;
  font-size: 12.5px;
  padding: 3px 0;
  border-bottom: 1px dotted rgba(34, 40, 64, .26);
}
.sr-log__row span { color: rgba(34, 40, 64, .72); }
.sr-log__row b {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #1c2138;
  text-align: right;
}
.sr-log__row--head { border-bottom: 1.5px solid rgba(34, 40, 64, .45); padding-bottom: 1px; }
.sr-log__row--head b {
  font-family: var(--font-serif);
  font-size: 12.5px;
  font-weight: 700;
  color: rgba(34, 40, 64, .8);
}

/* ---------- Toast ---------- */
.c-toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  z-index: 70;
  transform: translateX(-50%);
  max-width: min(92vw, 460px);
  padding: 9px 16px;
  border-radius: 3px;
  font-size: 13.5px;
  line-height: 1.4;
  color: #f6efdd;
  background: rgba(12, 15, 28, .95);
  border: 1px solid rgba(232, 222, 196, .2);
  box-shadow: 0 10px 26px rgba(4, 6, 14, .6);
  animation: srToast .18s ease-out both;
}
.c-toast[hidden] { display: none; }
@keyframes srToast {
  0% { transform: translate(-50%, 6px); opacity: 0; }
  100% { transform: translate(-50%, 0); opacity: 1; }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 780px) {
  :root { --u: clamp(62px, 21vw, 104px); }
  .sr-table { width: 97vw; gap: 6px; }
  /* Below this width a crest and a plaque cannot share a row. The plaque drops
     under its own crest, and the two plaques stay on the same side of the
     table so the eye still reads them as a pair. */
  .sr-rank { flex-direction: column; gap: 5px; }
  .sr-slot { width: 100%; }
  .sr-rune { min-height: 0; }
  .sr-crest__note { font-size: 11px; }
  .sr-chip { font-size: 10.5px; padding: 1px 6px 1px 5px; }
  .c-bar { gap: 6px 10px; padding: 6px 10px 7px; }
  .c-bar__title { font-size: 19px; }
  .c-bar__stats { gap: 10px; }
  .stat { font-size: 12px; }
  .stat b { font-size: 13px; }
  .c-bar .c-btn { font-size: 12.5px; padding: 5px 10px; }
  .sr-rail { font-size: 11px; padding: 3px 8px; }
  .sr-rail__d { display: none; }
  .sr-act { padding: 8px 10px 9px 140px; row-gap: 6px; }
  .sr-act__status { font-size: 12.5px; }
  .sr-act__moves { width: 100%; margin-left: 0; }
  .sr-mv { flex: 1 1 auto; font-size: 12.5px; padding: 5px 8px; }
  .c-modal { padding: 10px; }
  .c-modal__body { padding: 10px 14px 2px; }
}

@media (max-width: 420px) {
  :root { --u: clamp(58px, 23vw, 92px); }
  .sr-card__body p { font-size: 8.6px; }
  .sr-side__k { display: none; }
}

/* A hand that will not fit becomes a swipe: one row tall instead of wrapping,
   with the faded edge as the hint that there is more that way. */
@media (max-width: 1000px) {
  .sr-hand {
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-top: 14px;
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 22px), transparent 100%);
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 22px), transparent 100%);
  }
  .sr-hand::-webkit-scrollbar { width: 0; height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .c-modal__panel,
  .c-toast,
  .sr-rune.is-live,
  .sr-rune.is-cuttable,
  .sr-dusk,
  .sr-rune.is-land,
  .sr-rune.is-cut,
  .sr-rune__slash,
  .sr-pop,
  .sr-crest.is-hit,
  .sr-life__n.is-gain,
  .sr-life__n.is-loss { animation: none; }
  .sr-card,
  .sr-bar i { transition: none; }
  /* A landed or cut rune still has to look answered with motion off. */
  .sr-rune.is-land { opacity: .2; }
  .sr-rune.is-cut { opacity: .2; transform: translateY(14px); }
  .sr-rune__slash { opacity: 1; transform: rotate(-14deg); }
  .sr-pop { opacity: 1; transform: translate(-50%, -60%); }
}
