/* Kitchen table: stitched neoprene playmats on a walnut table.
   Ownership is encoded by mat dye per seat; brass marks what can be acted
   on right now. Two or four seats, placed by position classes. */
:root {
  color-scheme: dark;
  --table: #1a140f;
  --table-grain: #231a13;
  --ink: rgb(236 228 206 / 0.42);
  --paper: #efe8d8;
  --paper-dim: #b9b0a0;
  --brass: #e3b451;
  --brass-deep: #9c7426;
  --good: #8fd6a2;
  --bad: #ff8f80;
  /* Largest battlefield card; each row shrinks it to fit its mat (see .row). */
  --card-max: clamp(62px, min(10vw, 18vh), 200px);
  --card-w: var(--card-max);
  --hand-w: clamp(96px, min(9.6vw, 19vh), 170px);
  --card-r: calc(var(--card-w) * 0.055);
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --noise: 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='160' height='160' filter='url(%23n)' opacity='.09'/%3E%3C/svg%3E");
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--paper);
  background: var(--table);
  -webkit-font-smoothing: antialiased;
}

/* Seat dyes (mat) and inks (labels). */
.seat-you { --felt: #24365c; --seat-ink: #8fb3ff; --die-fill: #1d2b4a; }
.seat-opponent, .seat-across { --felt: #4d2533; --seat-ink: #ff9fae; --die-fill: #3a1824; }
.seat-left { --felt: #23443a; --seat-ink: #92dcb4; --die-fill: #17332b; }
.seat-right { --felt: #4a3a1c; --seat-ink: #f0c987; --die-fill: #382a12; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background:
    repeating-linear-gradient(92deg, transparent 0 38px, rgb(0 0 0 / 0.08) 38px 40px, transparent 40px 97px),
    radial-gradient(120% 90% at 50% 50%, var(--table-grain), var(--table));
}
::selection { background: var(--brass); color: #1a140f; }
* { scrollbar-color: var(--brass-deep) transparent; scrollbar-width: thin; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }
button { font: inherit; color: inherit; }

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

.table {
  height: 100vh;
  display: grid;
  gap: 4px;
  padding: 40px 14px 0;
}
/* Both mats get the same height: each holds three rows. */
.table.seats-2 {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "center" "bottom" "hand";
}
/* Four seats at the corners of a square; the centre band holds the shared game. */
.table.seats-4 {
  --card-max: clamp(46px, min(6.5vw, 13vh), 140px);
  --card-w: var(--card-max);
  --hand-w: clamp(86px, min(8.4vw, 17vh), 150px);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  grid-template-areas:
    "tl tr"
    "center center"
    "bl br"
    "hand hand";
  column-gap: 10px;
}
.mat.pos-top { grid-area: top; }
.mat.pos-bottom { grid-area: bottom; }
.mat.pos-tl { grid-area: tl; }
.mat.pos-tr { grid-area: tr; }
.mat.pos-bl { grid-area: bl; }
.mat.pos-br { grid-area: br; }
.centerline { grid-area: center; }
.hand-area { grid-area: hand; }

.mat { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.mat.side-top { justify-content: flex-end; }

.mat-surface {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 92px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 22px;
  background:
    radial-gradient(90% 120% at 50% 0%, rgb(255 255 255 / 0.07), transparent 60%),
    var(--noise),
    var(--felt);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.05) inset, 0 10px 28px rgb(0 0 0 / 0.45), 0 2px 4px rgb(0 0 0 / 0.4);
  transition: box-shadow 200ms var(--ease-out);
}
/* Stitched rim: the detail that makes a playmat read as a playmat. */
.mat-surface::before {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1.5px dashed rgb(255 255 255 / 0.16);
  border-radius: 16px;
  pointer-events: none;
}
.table.seats-4 .mat-surface { grid-template-columns: 80px minmax(0, 1fr) 64px; padding: 10px 12px; gap: 8px; }
/* Right-hand corners mirror the layout so every seat faces the middle of the table. */
.table.seats-4 .mat.pos-tr .mat-surface, .table.seats-4 .mat.pos-br .mat-surface {
  grid-template-columns: 64px minmax(0, 1fr) 80px;
}
.table.seats-4 .mat.pos-tr .seat, .table.seats-4 .mat.pos-br .seat { order: 3; }
.table.seats-4 .mat.pos-tr .zones, .table.seats-4 .mat.pos-br .zones { order: 1; }
.table.seats-4 .mat.pos-tr .field, .table.seats-4 .mat.pos-br .field { order: 2; }

.mat.active .mat-surface { box-shadow: 0 0 0 1px rgb(227 180 81 / 0.35), 0 10px 28px rgb(0 0 0 / 0.45); }
.mat.targetable .mat-surface, .mat.drop-target .mat-surface { box-shadow: 0 0 0 2px rgb(227 180 81 / 0.7), 0 10px 28px rgb(0 0 0 / 0.45); }
.mat.aimed .mat-surface, .mat.drop-hover .mat-surface {
  box-shadow: 0 0 0 3px var(--brass), 0 0 26px rgb(227 180 81 / 0.4), 0 10px 28px rgb(0 0 0 / 0.45);
}
.mat.out .mat-surface { filter: grayscale(0.85) brightness(0.55); }
.mat.out::after {
  content: 'Left the game';
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.7);
  font-weight: 700;
}

/* The field is a size container: its rows size their cards from its height
   and width. --filled/--empty (rows with and without cards) and each row's
   --row-n (card widths across) are set by app.js. */
.field {
  --filled: 3;
  --empty: 0;
  container-type: size;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 0;
  height: 100%;
}
/* Three rows (creatures, enchantments + artifacts, lands), each centred. A card
   is 88/63 ≈ 1.397 times as tall as it is wide. An empty row is a 30px strip
   with its printed name; the rows with cards split the rest of the height
   (minus the two 4px gaps and 8px of padding and border each), and a row never
   gets wider than the field, so it stays on one line. */
.row {
  --row-n: 1;
  --card-w: min(
    var(--card-max),
    calc(((100cqh - 8px - var(--empty) * 30px) / var(--filled) - 8px) / 1.397),
    calc((100cqw - 12px) / var(--row-n) - 6px)
  );
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: calc(var(--card-w) * 1.397 + 6px);
  padding: 3px;
  border-radius: 12px;
}
/* Printed zone outlines, like the ink on a real mat. */
.row.lands { border: 1px dashed var(--ink); }
.row.support { border: 1px dotted var(--ink); }
.row:empty { min-height: 30px; }
.row:empty::before { color: var(--ink); font-size: 12px; text-align: center; }
.row.lands:empty::before { content: 'Lands'; }
.row.main:empty::before { content: 'Creatures'; }
.row.support:empty::before { content: 'Enchantments and artifacts'; }

/* Face-down hand of every seat that isn't acting. It overlays the mat's outer
   edge (the table margin above the top mat, the hand area below the bottom
   one) instead of taking height from the mat, so the battlefield gets it. */
.backs {
  /* The hidden hand keeps its size; a larger battlefield doesn't make it taller. */
  --card-w: min(var(--card-max), 110px);
  position: absolute;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  height: calc(var(--card-w) * 0.5);
  overflow: visible;
  pointer-events: none;
}
.mat.side-top .backs { bottom: calc(100% - var(--card-w) * 0.2); }
/* With four seats the corner mats sit under the toolbar's buttons: there the
   hidden hand keeps its own band in the mat, as before. */
.table.seats-4 .mat.side-top .backs,
.table.seats-4 .mat.side-bottom .backs { position: static; padding: 0; justify-content: center; z-index: auto; }
/* Below the bottom mat the acting hand's fan is centred, so this hidden hand
   sits at the left, under the seat panel, above the fan's layer. */
.mat.side-bottom .backs {
  top: calc(100% - var(--card-w) * 0.2);
  justify-content: flex-start;
  padding-left: calc(var(--card-w) * 0.4);
  z-index: 6;
}
.backs .card {
  width: calc(var(--card-w) * 0.66);
  margin-inline: calc(var(--card-w) * -0.14);
  --rot: calc(var(--fan) * -3deg);
  --lift: calc(var(--card-w) * -0.18 - var(--fan) * var(--fan) * 1.5px);
}
.mat.side-bottom .backs .card { --rot: calc(var(--fan) * 3deg); --lift: calc(var(--card-w) * 0.12 + var(--fan) * var(--fan) * 1.5px); }

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

.card {
  --lift: 0px;
  --rot: 0deg;
  --scale: 1;
  /* Corner radius from this card's own width. */
  --card-r: calc(var(--card-w) * 0.055);
  position: relative;
  flex: 0 0 auto;
  width: var(--card-w);
  aspect-ratio: 63 / 88;
  padding: 0;
  border: 0;
  border-radius: var(--card-r);
  background: #0e0c0a;
  cursor: default;
  transform: translateY(var(--lift)) rotate(var(--rot)) scale(var(--scale));
  transition-property: transform, box-shadow, opacity, filter, margin;
  transition-duration: 200ms;
  transition-timing-function: var(--ease-out);
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.5), 0 4px 10px rgb(0 0 0 / 0.35);
}
.card .face {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--card-r);
  object-fit: cover;
  outline: 1px solid rgb(255 255 255 / 0.1);
  outline-offset: -1px;
  user-select: none;
  -webkit-user-drag: none;
}
.card .face.typed {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 6px;
  background: linear-gradient(#3a332a, #221d17);
  font-size: 11px;
  text-align: left;
}
.card .face.typed span { color: var(--paper-dim); font-size: 10px; }

.card.tapped { --rot: 90deg; margin-inline: calc(var(--card-w) * 0.2); filter: brightness(0.82); }
.card.field.side-bottom.attacking { --lift: -16px; }
.card.field.side-top.attacking { --lift: 16px; }
.card.attacking { box-shadow: 0 0 0 2px #f08a4b, 0 10px 22px rgb(0 0 0 / 0.55); }
.card.blocking { box-shadow: 0 0 0 2px #7fc8e6, 0 6px 16px rgb(0 0 0 / 0.5); }

.card.actionable { cursor: pointer; box-shadow: 0 0 0 2px var(--brass), 0 0 14px rgb(227 180 81 / 0.35), 0 4px 10px rgb(0 0 0 / 0.4); }
/* Mana-only sources stay quiet: a thin brass edge, not a glow, so real choices stand out. */
.card.actionable.mana-only { box-shadow: 0 0 0 1px rgb(227 180 81 / 0.55), 0 4px 10px rgb(0 0 0 / 0.35); }
.card.actionable:hover { --scale: 1.05; }
.card.draggable { cursor: grab; touch-action: none; }
.card.selectable { cursor: pointer; box-shadow: 0 0 0 2px var(--brass), 0 0 18px rgb(227 180 81 / 0.5); }
.card.selectable:hover { --scale: 1.06; }
.card.chosen { box-shadow: 0 0 0 3px var(--brass), 0 0 0 6px rgb(227 180 81 / 0.3), 0 8px 18px rgb(0 0 0 / 0.5); }
/* A chosen creature steps toward the centre line, like pushing it forward on a real table. */
.card.field.side-bottom.chosen { --lift: -14px; }
.card.field.side-top.chosen { --lift: 14px; }
.card.source { box-shadow: 0 0 0 3px #8fb3ff, 0 8px 18px rgb(0 0 0 / 0.5); }
.card.muted { opacity: 0.42; filter: saturate(0.5); }
.card:active { --scale: 0.96; }

.card .pt {
  position: absolute;
  right: -5px;
  bottom: -6px;
  padding: 1px 5px;
  border-radius: 6px;
  background: #f1ead9;
  color: #1c1712;
  font-weight: 700;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.5);
}
.table.seats-4 .card .pt { font-size: 10px; }
/* Each number against the printed card: green above it, red below it. */
.card .pt .up { color: #137a35; }
.card .pt .down { color: #c4231a; }
.card .badges {
  position: absolute;
  left: -4px;
  top: -6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  pointer-events: none;
  z-index: 2;
}
/* A tapped card turns 90°; its badges turn back so they stay readable. */
.card.tapped .badges { top: 100%; left: -6px; transform: rotate(-90deg); transform-origin: top left; }
.badge {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  background: #2b241c;
  color: var(--paper);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.6);
}
.badge.counter { background: #2f5a3a; }
.badge.sick { background: #3c3550; color: #d9cffd; }
.badge.blocks { background: #1f4b5c; color: #c9eefc; }
.badge.attacks { background: #6b3a19; color: #ffd9b8; }

/* Feedback for what just changed: answers the action, then settles. */
.card.entered { animation: card-enter 420ms var(--ease-out); }
.card.hit { animation: card-hit 380ms ease-out; }
.card.pumped .pt { animation: pt-pop 520ms var(--ease-out); }
/* Uses the individual translate/scale properties so it composes with the
   card's own transform (tapped rotation, lift) instead of replacing it. */
@keyframes card-enter { from { opacity: 0; translate: 0 18px; scale: 0.92; } }
@keyframes card-hit {
  0%, 100% { translate: 0; }
  25% { translate: -4px 0; filter: brightness(1.6) saturate(1.4); }
  60% { translate: 3px 0; }
}
@keyframes pt-pop { 40% { transform: scale(1.35); } }

.card.back {
  display: inline-block;
  background:
    radial-gradient(circle at 50% 50%, #c79b4a 0 9%, transparent 10%),
    radial-gradient(circle at 50% 50%, transparent 0 22%, rgb(199 155 74 / 0.5) 23% 25%, transparent 26%),
    repeating-linear-gradient(45deg, rgb(0 0 0 / 0.18) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #5b3b24, #2c1c12);
  outline: 2px solid #1a110b;
  outline-offset: -5px;
}

/* ------------------------------------------------------------ the acting hand */

.hand-area {
  position: relative;
  display: grid;
  justify-items: center;
  /* The fan overlaps the bottom mat's edge; hovered cards rise above it. */
  height: calc(var(--hand-w) * 0.8);
  margin-top: -12px;
  z-index: 5;
  pointer-events: none;
}
.hand-label {
  position: absolute;
  top: -20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--seat-ink, var(--paper-dim));
}
.hand { display: flex; justify-content: center; align-items: flex-start; }
.hand > * { pointer-events: auto; }
.hand .card {
  --card-r: calc(var(--hand-w) * 0.055);
  width: var(--hand-w);
  margin-inline: calc(var(--hand-w) * -0.17);
  transform-origin: 50% 120%;
  --rot: calc(var(--fan) * 3.2deg);
  --lift: calc(var(--fan) * var(--fan) * 2.2px);
  box-shadow: 0 -2px 10px rgb(0 0 0 / 0.45);
}
.hand .card:hover, .hand .card:focus-visible {
  --lift: calc(var(--hand-w) * -0.42);
  --rot: 0deg;
  --scale: 1.12;
  z-index: 60 !important;
}
.hand .card.actionable { box-shadow: 0 0 0 2px var(--brass), 0 0 16px rgb(227 180 81 / 0.45); }
.hand-empty { color: var(--paper-dim); font-size: 13px; margin-top: 30px; pointer-events: none; }

/* ------------------------------------------------------------ drag & drop */

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 70;
  width: var(--hand-w);
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms var(--ease-out);
}
.drag-ghost.show { opacity: 1; }
.drag-ghost img, .ghost-text {
  display: block;
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 24px 44px rgb(0 0 0 / 0.7);
  outline: 1px solid rgb(255 255 255 / 0.1);
}
.ghost-text { padding: 14px 8px; background: #2a2119; font-weight: 700; }
/* ------------------------------------------------------------ target arrows */
.target-layer {
  position: fixed;
  inset: 0;
  z-index: 41;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}
.target-arrow path {
  fill: none;
  stroke: #ff8a4c;
  stroke-width: 5;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.75));
  /* Drawn from the card toward the target once. */
  stroke-dasharray: 100;
  animation: target-draw 420ms var(--ease-out) both;
}
.target-layer marker path { fill: #ff8a4c; }
/* Combat: red for attacks, blue for blocks, same draw-in as target arrows. */
.attack-arrow path, .block-arrow path {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.75));
  stroke-dasharray: 100;
  animation: target-draw 380ms var(--ease-out) both;
}
.attack-arrow path { stroke: #ff4d3d; }
.block-arrow path { stroke: #5fbfff; }
.target-layer .settled path { animation: none; }
.target-layer .attack-head path { fill: #ff4d3d; }
.target-layer .block-head path { fill: #5fbfff; }
.target-count circle { fill: #1b130d; stroke: #ff8a4c; stroke-width: 2.5; }
.target-count text { fill: #ffd2b0; font: 800 12px ui-sans-serif, system-ui, sans-serif; }
.target-count { animation: target-count-in 300ms 300ms var(--ease-out) both; }
@keyframes target-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes target-count-in { from { opacity: 0; } }
.card.targeted { box-shadow: 0 0 0 3px #ff8a4c, 0 0 22px rgb(255 138 76 / 0.6); }
.seat.targeted { box-shadow: 0 0 0 3px #ff8a4c, 0 0 22px rgb(255 138 76 / 0.5); }

/* ------------------------------------------------------------ damage missile */
.missile {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 67;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform;
}
.missile.core {
  background: radial-gradient(circle, #fffbe6 0%, #ffd36b 35%, #ff7a2a 70%, rgb(255 80 20 / 0) 100%);
  box-shadow: 0 0 14px 6px rgb(255 140 50 / 0.85), 0 0 30px 12px rgb(255 80 20 / 0.45);
}
.missile.spark {
  background: radial-gradient(circle, #ffe2a0 0%, #ff8a3a 60%, rgb(255 80 20 / 0) 100%);
  box-shadow: 0 0 8px 3px rgb(255 120 40 / 0.6);
  opacity: 0.75;
}
.impact {
  position: fixed;
  z-index: 67;
  width: 90px;
  height: 90px;
  margin: -45px 0 0 -45px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, #fff6d0 0%, rgb(255 170 70 / 0.9) 25%, rgb(255 90 30 / 0.5) 50%, rgb(255 60 20 / 0) 72%);
  animation: impact-burst 520ms var(--ease-out) forwards;
}
.impact::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgb(255 190 100 / 0.9);
  animation: impact-ring 520ms var(--ease-out) forwards;
}
@keyframes impact-burst {
  0% { transform: scale(0.25); opacity: 1; }
  60% { opacity: 0.85; }
  100% { transform: scale(1.4); opacity: 0; }
}
@keyframes impact-ring {
  0% { transform: scale(0.3); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

/* ------------------------------------------------------------ burning spell */
.burn {
  position: fixed;
  z-index: 66;
  pointer-events: none;
  border-radius: 12px;
  /* Opaque top, clear bottom; sliding the mask up eats the card from below. */
  mask-image: linear-gradient(to bottom, #000 0%, #000 45%, transparent 55%, transparent 100%);
  mask-size: 100% 220%;
  mask-repeat: no-repeat;
  mask-position: 0 0%;
}
.burn img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.burn-edge {
  position: absolute;
  left: -6%;
  width: 112%;
  height: 16%;
  translate: 0 -50%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, #fff3c4 0%, #ffb347 30%, rgb(255 90 30 / 0.75) 55%, transparent 75%);
  mix-blend-mode: screen;
  filter: blur(2px);
}
.ember {
  position: absolute;
  bottom: 6%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ffc46b;
  box-shadow: 0 0 6px 2px rgb(255 140 50 / 0.8);
  opacity: 0;
  animation: ember-rise 700ms ease-out both;
}
@keyframes ember-rise {
  0% { opacity: 0; transform: translate(0, 0) scale(1); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--drift), -140px) scale(0.3); }
}

/* A card copy flying between zones; the real card is hidden until it lands. */
.flight {
  position: fixed;
  z-index: 65;
  border-radius: 7px;
  object-fit: cover;
  pointer-events: none;
  will-change: transform;
  outline: 1px solid rgb(255 255 255 / 0.1);
}
.card.drag-source { opacity: 0.35; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }
body.dragging .preview { display: none; }
body.drag-play .mat-surface { box-shadow: 0 0 0 1px rgb(227 180 81 / 0.25), 0 10px 28px rgb(0 0 0 / 0.45); }
body.drag-play.drop-ok .drag-ghost img { box-shadow: 0 0 0 3px var(--brass), 0 24px 44px rgb(0 0 0 / 0.7); }
.card.drop-target { box-shadow: 0 0 0 2px var(--brass), 0 0 18px rgb(227 180 81 / 0.5); }
.card.drop-hover { --scale: 1.1; box-shadow: 0 0 0 3px var(--brass), 0 0 26px rgb(227 180 81 / 0.7); }
.arrow-layer {
  position: fixed;
  inset: 0;
  z-index: 69;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  opacity: 0;
}
.arrow-layer.show { opacity: 1; }
.arrow-layer line { stroke: var(--brass); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 2 12; filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.7)); }
.arrow-layer marker path { fill: var(--brass); }

/* ------------------------------------------------------------ seat */

.seat {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: 14px;
  transition: box-shadow 200ms var(--ease-out), background-color 200ms var(--ease-out);
}
.seat.priority { background: rgb(227 180 81 / 0.08); box-shadow: 0 0 0 1px rgb(227 180 81 / 0.5); }
.seat.selectable { cursor: pointer; box-shadow: 0 0 0 2px var(--brass), 0 0 18px rgb(227 180 81 / 0.45); }
.seat.chosen { box-shadow: 0 0 0 3px var(--brass); }
.die { position: relative; width: 66px; height: 66px; display: grid; place-items: center; }
.table.seats-4 .die { width: 54px; height: 54px; }
.die svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.d20-shell { fill: var(--die-fill); stroke: var(--seat-ink); stroke-width: 2.5; stroke-linejoin: round; }
.d20-facet { fill: rgb(255 255 255 / 0.06); stroke: rgb(255 255 255 / 0.22); stroke-width: 1.2; }
.d20-edge { stroke: rgb(255 255 255 / 0.16); stroke-width: 1; fill: none; }
.die-value {
  position: relative;
  margin-top: 8px;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 3px rgb(0 0 0 / 0.6);
}
.table.seats-4 .die-value { font-size: 18px; margin-top: 6px; }
.die.down { animation: die-roll 520ms var(--ease-out); }
.die.down .die-value { color: var(--bad); }
.die.up .die-value { color: var(--good); }
@keyframes die-roll { 30% { transform: rotate(-14deg) scale(1.12); } 70% { transform: rotate(6deg); } }
.life-float {
  position: absolute;
  top: -6px;
  right: -10px;
  font-weight: 800;
  font-size: 18px;
  animation: float-up 1100ms var(--ease-out) forwards;
  pointer-events: none;
}
.life-float.down { color: var(--bad); }
.life-float.up { color: var(--good); }
@keyframes float-up { from { opacity: 1; transform: translateY(6px); } to { opacity: 0; transform: translateY(-26px); } }
.seat-name { font-weight: 700; font-size: 14px; color: var(--seat-ink); }
.seat-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.tag { font-size: 10px; padding: 1px 7px; border-radius: 999px; border: 1px solid rgb(255 255 255 / 0.25); color: var(--paper-dim); }
.tag.priority { border-color: var(--brass); color: var(--brass); }
.tag.attacked { border-color: #f08a4b; color: #ffcfae; }
.tag.out { border-color: var(--bad); color: var(--bad); }
.tag.ai { border-color: #a9cdf5; color: #a9cdf5; }
.tag.energy { border-color: #e9c54a; color: #ffe38a; }
.pool { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.pip {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 800; color: #14110d;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.6);
}
.pip.W { background: #f3ecd0; } .pip.U { background: #8fc2ec; } .pip.B { background: #a99aa8; }
.pip.R { background: #ee8a68; } .pip.G { background: #8ccf98; } .pip.C { background: #c9c4bc; }
/* Restricted mana (Powerstone): a dashed ring marks "artifact spells only". */
.pip.restricted { outline: 2px dashed #6fb8e0; outline-offset: 1px; }

/* ------------------------------------------------------------ zones */

.zones { display: grid; gap: 8px; justify-items: center; justify-content: center; }
.zone {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 5px;
  border: 1px dashed var(--ink);
  border-radius: 10px;
  background: none;
}
button.zone { cursor: pointer; }
button.zone:hover { border-color: var(--brass); }
/* Something in this graveyard or exile can be played now: click to open it. */
.zone.playable {
  position: relative;
  border: 2px solid #a9cdf5;
  box-shadow: 0 0 14px rgb(169 205 245 / 0.55);
  animation: playable-pulse 1.6s ease-in-out infinite;
}
.playable-badge {
  position: absolute;
  left: 50%;
  bottom: -9px;
  translate: -50% 0;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 800;
  color: #10202e;
  background: #a9cdf5;
  z-index: 2;
}
@keyframes playable-pulse {
  50% { box-shadow: 0 0 4px rgb(169 205 245 / 0.25); }
}
@media (prefers-reduced-motion: reduce) {
  .zone.playable { animation: none; }
}
.zone-label { font-size: 10px; color: var(--ink); }
/* Capped so a large battlefield card size doesn't overflow the zones column. */
.pile { position: relative; display: grid; place-items: center; width: calc(min(var(--card-w), 124px) * 0.52); aspect-ratio: 63 / 88; }
.pile .pile-card { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 5px; box-shadow: 2px 2px 0 #120d09, 4px 4px 0 #0c0806; }
.pile img.pile-card { object-fit: cover; }
.pile .count {
  position: relative;
  min-width: 24px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.72);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* Command zone (Commander): commanders face up, castable like a hand card. */
/* With a command zone the piles sit side by side and the command zone spans
   below them, so the zones column gets wider instead of taller. */
.mat.has-command .mat-surface { grid-template-columns: 104px minmax(0, 1fr) 124px; }
.table.seats-4 .mat.has-command .mat-surface { grid-template-columns: 80px minmax(0, 1fr) 100px; }
.table.seats-4 .mat.has-command.pos-tr .mat-surface,
.table.seats-4 .mat.has-command.pos-br .mat-surface { grid-template-columns: 100px minmax(0, 1fr) 80px; }
.mat.has-command .zones { grid-template-columns: auto auto; gap: 6px; }
.mat.has-command .zone { padding: 4px; }
.zone.command {
  grid-column: 1 / -1;
  order: 3;
  border-style: solid;
  border-color: rgb(227 180 81 / 0.45);
  background: rgb(227 180 81 / 0.06);
}
.zone.command .zone-label { color: var(--brass); }
.command-cards { display: flex; gap: 4px; }
.card.command { --card-w: calc(min(var(--card-max), 124px) * 0.56); }
.card.command.actionable:hover { --scale: 1.08; }
.card.command .tax {
  position: absolute;
  right: -4px;
  bottom: -4px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  color: #1b150e;
  background: var(--brass);
}
.zone-empty { font-size: 10px; color: var(--ink); padding: 6px 2px; }
/* A commander anywhere on the table wears a small crown. */
.card .cmdr-mark {
  position: absolute;
  top: -6px;
  left: 50%;
  translate: -50% 0;
  font-size: 12px;
  line-height: 1;
  color: var(--brass);
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.9);
  pointer-events: none;
}
.cmdr-damage { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
/* Equipment and the creature it's attached to. */
.badge.equip { background: #3e4f63; }
.tag.cmdr { border-color: rgb(227 180 81 / 0.6); color: #f2d38a; }
.tag.cmdr.danger { border-color: var(--bad); color: var(--bad); font-weight: 700; }

/* ------------------------------------------------------------ centre line */

/* Phases left, commands in the middle, combat summary right. The right edge
   stays free because the spotlight floats over it while a card is in use. */
.centerline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "phases command middle";
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 4px;
}
.phases { grid-area: phases; }
.command { grid-area: command; }
.middle { grid-area: middle; }
.table.seats-4 .phases { flex-wrap: nowrap; }
.table.seats-4 .phase { padding: 4px 7px; font-size: 11px; }
.phases { display: flex; gap: 2px; margin: 0; padding: 0; list-style: none; flex-wrap: wrap; }
.phase {
  display: grid;
  white-space: nowrap;
  padding: 5px 9px;
  border-radius: 8px;
  color: rgb(239 232 216 / 0.45);
  font-size: 12px;
  font-weight: 600;
  transition: background-color 200ms var(--ease-out), color 200ms var(--ease-out);
}
.phase.done { color: rgb(239 232 216 / 0.7); }
.phase.current { background: var(--brass); color: #1b150e; box-shadow: 0 3px 10px rgb(0 0 0 / 0.4); }
.phase-step { font-size: 10px; font-weight: 500; }

.middle { display: grid; gap: 6px; justify-items: center; min-width: 0; }
/* ------------------------------------------------------------ spotlight
   The card in use floats over the right edge of the table, large, the way a
   played card is held up for everyone to read. It never takes board space
   and never catches clicks. */
.spotlight {
  position: fixed;
  right: 22px;
  top: 50%;
  z-index: 42;
  display: none;
  width: min(270px, 24vw);
  pointer-events: none;
  transform: translateY(-50%);
}
.spotlight.show { display: grid; gap: 10px; justify-items: center; }
.spotlight.enter .spot-lead { animation: spot-in 380ms var(--ease-out); }
@keyframes spot-in {
  from { opacity: 0; transform: translateX(40px) rotate(4deg) scale(0.9); filter: blur(3px); }
}
.spot-lead { margin: 0; display: grid; gap: 8px; justify-items: center; width: 100%; }
.spot-image {
  display: block;
  width: 100%;
  border-radius: 14px;
  outline: 1px solid rgb(255 255 255 / 0.1);
  box-shadow: 0 0 0 3px var(--seat-ink, var(--brass)), 0 26px 50px rgb(0 0 0 / 0.75);
}
.spot-text { padding: 16px; border-radius: 14px; background: #241d16; box-shadow: 0 26px 50px rgb(0 0 0 / 0.75); }
.spot-text p { margin: 6px 0 0; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.spot-lead figcaption {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 14px;
  border-radius: 12px;
  background: rgb(20 15 11 / 0.9);
  box-shadow: 0 8px 20px rgb(0 0 0 / 0.5);
  text-align: center;
  font-size: 12px;
  color: var(--paper-dim);
}
.spot-lead figcaption strong { font-size: 15px; color: var(--paper); }
.spot-who { color: var(--seat-ink); }
.spot-targets { color: var(--brass); font-weight: 700; }
.spot-label { font-size: 11px; color: var(--paper-dim); justify-self: start; }
.spot-queue { display: grid; gap: 6px; width: 100%; margin: 0; padding: 0; list-style: none; }
.spot-queue li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 10px;
  background: rgb(20 15 11 / 0.88);
  font-size: 12px;
}
.spot-thumb { width: 38px; aspect-ratio: 63 / 88; border-radius: 4px; object-fit: cover; box-shadow: 0 0 0 1px var(--seat-ink); }
.combat { display: grid; gap: 3px; justify-items: center; }
.combat-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px; font-size: 12px; align-items: baseline; }
.combat-line > * { white-space: nowrap; }
.combat-line .versus { color: #f0a070; }

.command { display: grid; gap: 6px; justify-items: center; min-width: 0; }
.prompt { display: grid; gap: 6px; justify-items: center; text-align: center; }
.prompt-text { margin: 0; font-size: 13px; color: var(--paper); text-wrap: pretty; max-width: 52ch; }
.prompt-error { margin: 0; font-size: 12px; color: var(--bad); }
.prompt-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.x-input { font-size: 13px; }
.x-input input { width: 64px; margin-left: 6px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--brass-deep); background: #0f0c09; color: var(--paper); }
.damage-title { font-size: 12px; color: var(--paper-dim); }
.damage-order { margin: 0; padding-left: 18px; font-size: 12px; text-align: left; }
.damage-order li { display: flex; gap: 8px; align-items: center; }
.controls { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.acting { font-size: 12px; margin-right: 4px; color: var(--seat-ink, var(--paper-dim)); }
.control, .chip, .tool, .action-list button, .tabs button, .menu button {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition-property: transform, background-color, box-shadow;
  transition-duration: 140ms;
  transition-timing-function: var(--ease-out);
}
.control:active:not(:disabled), .chip:active, .tool:active:not(:disabled) { transform: scale(0.96); }
.control { min-height: 40px; padding: 8px 14px; font-weight: 600; background: rgb(255 255 255 / 0.08); }
.control:hover:not(:disabled) { background: rgb(255 255 255 / 0.14); }
.control.primary {
  min-height: 46px;
  padding: 10px 22px;
  font-size: 16px;
  font-weight: 800;
  color: #1b150e;
  background: linear-gradient(#f0c766, var(--brass));
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.4) inset, 0 6px 16px rgb(0 0 0 / 0.45);
}
.control.primary:hover:not(:disabled) { background: linear-gradient(#f6d27c, #e8bc5d); }
.control:disabled, .tool:disabled { opacity: 0.45; cursor: not-allowed; }
.chip { padding: 4px 10px; background: rgb(255 255 255 / 0.1); font-size: 12px; }
.chip:hover, .chip.on { background: rgb(227 180 81 / 0.3); }
.chip.on { box-shadow: 0 0 0 1px var(--brass); }

/* ------------------------------------------------------------ toolbar */

.toolbar {
  position: fixed;
  top: 8px;
  left: 14px;
  z-index: 45;
  display: flex;
  gap: 8px;
  align-items: center;
}
.tool-group { display: flex; gap: 2px; padding: 2px; border-radius: 12px; background: rgb(0 0 0 / 0.45); }
.tool { padding: 6px 12px; background: rgb(0 0 0 / 0.55); font-size: 13px; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-group .tool { background: none; }
.tool:hover:not(:disabled) { background: rgb(227 180 81 / 0.22); }
.tool.current { color: var(--brass); }
.tool-info { font-size: 12px; color: var(--paper-dim); padding: 4px 8px; border-radius: 8px; background: rgb(0 0 0 / 0.4); }

/* ------------------------------------------------------------ new game dialog */

.new-game {
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid rgb(227 180 81 / 0.35);
  border-radius: 16px;
  color: var(--paper);
  background: var(--noise), linear-gradient(#2a2017, #1c150f);
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.6);
}
.new-game::backdrop { background: rgb(8 6 4 / 0.7); }
.new-game[open] { animation: dialog-in 200ms var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.new-game form { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px; }
.new-game h2 { margin: 0; font-size: 20px; letter-spacing: 0.02em; }
.ng-options { display: flex; flex-wrap: wrap; align-items: end; gap: 14px 22px; }
.ng-segment { display: flex; flex-wrap: wrap; gap: 2px; margin: 0; padding: 0; border: 0; min-inline-size: 0; }
.ng-segment legend { float: left; width: 100%; margin-bottom: 4px; padding: 0; font-size: 12px; color: var(--paper-dim); }
.ng-segment label { position: relative; padding: 7px 12px; border-radius: 8px; font-size: 14px; white-space: nowrap; cursor: pointer; background: rgb(0 0 0 / 0.4); }
.ng-segment input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ng-segment label:has(input:checked) { color: #1b150e; font-weight: 700; background: var(--brass); }
.ng-segment label:has(input:focus-visible) { outline: 2px solid var(--paper); outline-offset: 1px; }
.ng-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--paper-dim); }
.ng-field input, .ng-seat select, .ng-seat textarea {
  padding: 7px 9px;
  border: 1px solid rgb(255 255 255 / 0.16);
  border-radius: 8px;
  color: var(--paper);
  font: inherit;
  font-size: 14px;
  background: rgb(0 0 0 / 0.35);
}
.ng-field input { width: 14ch; }
/* ------------------------------------------------------------ legal notice */
/* Fan Content Policy notice: small, in the bottom-right corner (the hand fan is centred, the other hands' backs sit bottom-left). */
.legal {
  position: fixed;
  right: 10px;
  bottom: 4px;
  z-index: 1;
  max-width: min(250px, 22vw);
  text-align: right;
  font-size: 9px;
  line-height: 1.35;
  color: rgb(236 224 200 / 0.45);
}
.legal a { color: inherit; }
.legal:hover { color: rgb(236 224 200 / 0.85); }

/* ------------------------------------------------------------ zone viewer */
/* Graveyards and exile shown as cards over the table; not modal, so a card
   played from it can still pick its targets on the table. */
.zone-view {
  position: fixed;
  left: 50%;
  /* Over the top half, clear of the centre line's buttons. */
  top: 48px;
  translate: -50% 0;
  /* Above the toolbar (45); below the card preview (47) and menus (50). */
  z-index: 46;
  width: min(940px, calc(100vw - 32px));
  max-height: calc(50vh - 60px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px 16px;
  border: 1px solid rgb(227 180 81 / 0.35);
  border-radius: 16px;
  color: var(--paper);
  background: var(--noise), linear-gradient(#2a2017, #1c150f);
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.65);
  animation: dialog-in 180ms var(--ease-out);
}
.zone-view[hidden] { display: none; }
.zv-head { display: flex; align-items: center; gap: 12px; }
.zv-head h2 { margin: 0; font-size: 17px; white-space: nowrap; }
.zv-tabs { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.zv-tab {
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--paper-dim);
  background: rgb(0 0 0 / 0.4);
  cursor: pointer;
}
.zv-tab[aria-selected="true"] { color: #1b150e; background: var(--brass); }
.zv-tab .zv-count { margin-left: 5px; opacity: 0.75; }
.zv-tab .zv-playable { margin-left: 5px; padding: 0 5px; border-radius: 999px; color: #10202e; background: #a9cdf5; }
.zv-close {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: var(--paper);
  background: rgb(0 0 0 / 0.45);
  cursor: pointer;
}
.zv-close:hover { border-color: var(--brass); color: var(--brass); }
.zv-note { margin: 0; font-size: 12.5px; color: var(--paper-dim); }
.zv-note:empty { display: none; }
.zv-cards {
  --card-w: 128px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr));
  justify-items: center;
  gap: 14px 10px;
  overflow: auto;
  min-height: 120px;
  padding: 8px 4px 6px;
}
.zv-card { display: grid; justify-items: center; gap: 4px; }
.zv-card .card.zoneview { width: var(--card-w); }
/* Not playable now: dimmed, still previewable. */
.zv-card .card.zoneview:not(.actionable) { filter: brightness(0.72) saturate(0.85); }
.zv-card .card.zoneview.actionable { box-shadow: 0 0 0 2px var(--brass), 0 0 16px rgb(227 180 81 / 0.5); cursor: pointer; }
.zv-card .card.zoneview.actionable:hover { --scale: 1.05; }
.zv-caption { max-width: var(--card-w); font-size: 11px; line-height: 1.25; text-align: center; color: var(--paper-dim); }
.zv-caption.playable { color: #a9cdf5; font-weight: 700; }
.zv-empty { grid-column: 1 / -1; align-self: center; color: var(--paper-dim); font-size: 13px; }

/* Debug: add a card to a hand. */
.debug-tool { border: 1px dashed rgb(255 143 128 / 0.55); color: #ffb3a8; }
.debug-add { width: min(560px, calc(100vw - 32px)); }
.debug-tag { margin-left: 6px; padding: 2px 7px; border-radius: 999px; font-size: 11px; vertical-align: middle; color: #1b150e; background: #ff8f80; }
.debug-name { flex: 1; }
.debug-name input { width: 100%; }
#debug-player { padding: 7px 9px; border: 1px solid rgb(255 255 255 / 0.16); border-radius: 8px; color: var(--paper); font: inherit; font-size: 14px; background: rgb(0 0 0 / 0.35); }
#debug-player option { color: #1b150e; }
.ng-check { display: flex; align-items: center; gap: 6px; font-size: 14px; padding-bottom: 7px; }
.ng-seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; overflow: auto; min-height: 0; }
.ng-seat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  border-left: 4px solid var(--seat-ink, var(--brass));
  background: rgb(255 255 255 / 0.05);
}
.ng-seat-head { display: flex; align-items: center; gap: 10px; }
.ng-seat-name { min-width: 7ch; font-weight: 800; color: var(--seat-ink, var(--paper)); }
.ng-seat select { flex: 1; min-width: 0; }
/* Human or computer: a fixed width, the deck takes the rest. */
.ng-seat select.ng-who { flex: 0 0 auto; width: 15ch; }
.ng-seat select option { color: #1b150e; }
.ng-seat textarea { resize: vertical; min-height: 110px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.ng-about { margin: 0; font-size: 12.5px; color: var(--paper-dim); }
.ng-report { margin: 0; padding: 0; list-style: none; font-size: 12.5px; display: flex; flex-direction: column; gap: 2px; }
.ng-report .ok { color: var(--good); }
.ng-report .warn { color: #f2c97a; }
.ng-report .bad { color: var(--bad); font-weight: 600; }
.ng-error { margin: 0; color: var(--bad); font-size: 13px; }
.ng-error:empty { display: none; }
.ng-actions { display: flex; align-items: center; gap: 8px; }
.ng-spacer { flex: 1; }

/* ------------------------------------------------------------ overlays */

.preview {
  position: fixed;
  left: 18px;
  top: 50%;
  /* Above the zone viewer (46). */
  z-index: 47;
  width: min(300px, 26vw);
  transform: translateY(-50%) translateX(-12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms var(--ease-out), transform 160ms var(--ease-out);
}
.preview.show { opacity: 1; transform: translateY(-50%); }
.preview img { display: block; width: 100%; border-radius: 14px; box-shadow: 0 18px 40px rgb(0 0 0 / 0.65); outline: 1px solid rgb(255 255 255 / 0.1); }
.preview-text { display: grid; gap: 6px; padding: 14px; border-radius: 14px; background: #241d16; box-shadow: 0 18px 40px rgb(0 0 0 / 0.65); }
.preview-text em { color: var(--brass); font-style: normal; font-size: 13px; }
.preview-text p { margin: 0; white-space: pre-wrap; line-height: 1.45; font-size: 13px; }

.menu {
  position: fixed;
  z-index: 50;
  display: grid;
  gap: 4px;
  padding: 6px;
  border-radius: 12px;
  background: #2a2119;
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.6);
}
.menu button { padding: 8px 12px; background: none; text-align: left; font-size: 13px; }
.menu button:hover, .menu button:focus-visible { background: rgb(227 180 81 / 0.22); }

.turn-banner {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 60;
  display: grid;
  justify-items: center;
  padding: 18px 44px;
  border-radius: 18px;
  background: rgb(20 15 11 / 0.92);
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.6);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.94);
}
.turn-banner.show { animation: banner 1500ms var(--ease-out) forwards; }
.turn-banner strong { font-size: 30px; letter-spacing: -0.01em; color: var(--seat-ink, var(--paper)); }
.banner-turn { font-size: 13px; color: var(--paper-dim); }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.94); filter: blur(4px); }
  18%, 72% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
  100% { opacity: 0; transform: translate(-50%, -54%) scale(1); }
}

.toasts {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 55;
  display: grid;
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 14px;
  border-radius: 999px;
  background: #2a2119;
  box-shadow: 0 8px 20px rgb(0 0 0 / 0.5);
  font-size: 13px;
  animation: toast 2200ms var(--ease-out) forwards;
}
.toast span { color: var(--good); font-size: 12px; }
.toast.out span { color: var(--bad); }
/* A computer seat's move. */
.toast.ai strong { color: var(--seat-ink, #a9cdf5); }
.toast.ai span { color: var(--paper); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-6px); } 12%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

.drawer-toggle {
  position: fixed;
  top: 8px;
  right: 14px;
  z-index: 45;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.55);
  font-size: 13px;
  cursor: pointer;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 44;
  width: min(380px, 92vw);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 52px 14px 14px;
  background: #1f1812;
  box-shadow: -14px 0 40px rgb(0 0 0 / 0.55);
}
.drawer[hidden] { display: none; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs button { padding: 6px 10px; background: none; font-size: 13px; color: var(--paper-dim); }
.tabs button[aria-selected="true"] { background: rgb(227 180 81 / 0.2); color: var(--paper); }
.drawer-body { overflow: auto; }
.log { margin: 0; padding: 0; list-style: none; font-size: 12px; line-height: 1.5; color: var(--paper-dim); }
.log li { padding: 3px 0; border-bottom: 1px solid rgb(255 255 255 / 0.05); }
.log li:first-child { color: var(--paper); }
.drawer h3 { margin: 12px 0 6px; font-size: 13px; }
.grave-list { margin: 0; padding-left: 18px; font-size: 13px; }
.grave-list .empty { color: var(--paper-dim); list-style: none; margin-left: -18px; }
.drawer-note { margin: 0 0 8px; font-size: 12px; color: var(--paper-dim); }
.action-list { display: grid; gap: 6px; }
.action-list button { padding: 8px 10px; text-align: left; background: rgb(255 255 255 / 0.07); font-size: 13px; }
.action-list button:hover:not(:disabled) { background: rgb(227 180 81 / 0.22); }
.raw { margin: 0; font-size: 11px; white-space: pre-wrap; color: var(--paper-dim); }

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

@media (max-width: 960px) {
  :root { --card-max: clamp(40px, 10vw, 90px); --card-w: var(--card-max); --hand-w: clamp(56px, 12vw, 86px); }
  body { overflow: auto; }
  .table { height: auto; min-height: 100vh; }
  .table.seats-4 {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "tl" "tr" "center" "bl" "br" "hand";
  }
  .mat-surface { grid-template-columns: 72px minmax(0, 1fr) 60px; padding: 10px; gap: 8px; }
  .centerline { grid-template-columns: 1fr; grid-template-areas: "phases" "command" "middle"; justify-items: stretch; }
  .spotlight { width: min(190px, 42vw); top: auto; bottom: 12px; transform: none; }
  .command, .prompt { justify-items: stretch; text-align: left; }
  .controls, .prompt-row { justify-content: flex-start; }
  .preview { display: none; }
  .tool { max-width: 24ch; }
}

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