/* Lobby + room shell for the online-play page. Layered on top of site.css. */

.play-view {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.play-panel {
  background: var(--panel, #fbf7ef);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  padding: 1.5rem;
}

.play-panel h1 {
  margin-top: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.field span {
  font-size: 0.9rem;
  opacity: 0.8;
}

.field input {
  padding: 0.5rem;
  font: inherit;
}

.lobby-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.create-form,
.join-form {
  display: flex;
  gap: 0.5rem;
  flex: 1 1 280px;
}

.create-form input,
.join-form input {
  flex: 1;
  padding: 0.5rem;
  font: inherit;
}

.rooms-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.room-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.room-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.room-list .room-meta {
  opacity: 0.7;
  font-size: 0.9rem;
}

.room-buttons {
  display: flex;
  gap: 0.4rem;
}

.close-btn {
  color: #9c4a35;
  border-color: rgba(156, 74, 53, 0.4);
}

.status-line {
  min-height: 1.2em;
  opacity: 0.8;
  font-size: 0.9rem;
}

/* ── Room: a game client laid out like a table — large board, linked log/chat rail ────────────── */

.room {
  --r-panel: #fbf7ef;
  --r-surface: #f4edde;
  --r-bg: #e8e0d0;
  --r-ink: #2c2620;
  --r-ink-dim: #7c7160;
  --r-line: rgba(60, 48, 28, 0.16);
  --r-line-soft: rgba(60, 48, 28, 0.08);
  --r-gold: #9a7b3f;
  --r-gold-soft: rgba(154, 123, 63, 0.16);
  --r-reveal: #2563eb;
  --r-warn: #9c4a35;

  position: fixed;
  inset: 0;
  z-index: 50;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--r-bg);
  color: var(--r-ink);
}

/* Source order matters: this must follow the display:flex rule to win when [hidden] is present. */
.room[hidden] {
  display: none;
}

.room-topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.6rem 1.25rem;
  background: var(--r-panel);
  border-bottom: 1px solid var(--r-line);
}

.room-ident {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.room-ident .torii {
  color: var(--r-gold);
  font-size: 1.15rem;
}

.room-kicker {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
  color: var(--r-ink-dim);
}

.room .room-id {
  font-family: ui-monospace, "SFMono-Regular", monospace;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.seats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
}

.seats li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.7rem 0.15rem 0.25rem;
  border: 1px solid var(--r-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  font-size: 0.92rem;
}

/* The small presence avatar that leads each roster chip; a card crop fills the circle, else initials. */
.roster-avatar {
  display: grid;
  place-items: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: var(--r-gold);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
  flex-shrink: 0;
}

.seats .you {
  color: var(--r-gold);
  font-style: italic;
}

.room-actions {
  display: flex;
  gap: 0.5rem;
}

.room .btn {
  font: 500 0.92rem/1 "EB Garamond", serif;
  padding: 0.5rem 1rem;
  border: 1px solid var(--r-line);
  border-radius: 7px;
  background: #fff;
  color: var(--r-ink);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.room .btn:hover {
  border-color: var(--r-gold);
}

.room .btn:focus-visible {
  outline: 2px solid var(--r-gold-soft);
  outline-offset: 1px;
}

.room .btn-gold {
  background: var(--r-gold);
  border-color: var(--r-gold);
  color: #fff;
}

.room .btn-gold:hover {
  background: #876b34;
}

.room .btn-ghost {
  background: transparent;
}

.room .btn-ghost:hover {
  border-color: var(--r-warn);
  color: var(--r-warn);
}

.room-body {
  min-height: 0;
  display: grid;
  /* Rail starts narrow; the vertical resizer widens it (min 240px, board keeps >= 360px). */
  grid-template-columns: 1fr 8px 280px;
  background: var(--r-panel);
}

.rail-resizer {
  display: grid;
  place-items: center;
  cursor: col-resize;
  background: var(--r-panel);
  border-left: 1px solid var(--r-line);
}

.rail-resizer::before {
  content: "";
  width: 3px;
  height: 2.5rem;
  border-radius: 3px;
  background: var(--r-line);
}

.rail-resizer:hover::before,
.rail-resizer:focus-visible::before {
  background: var(--r-gold);
}

.rail-resizer:focus-visible {
  outline: 2px solid var(--r-gold-soft);
  outline-offset: -2px;
}

.board-stage {
  /* One card footprint, shared by every card and slot. Keep in sync with CARD_W/CARD_H in board.js,
     which clamps drags to the same size. */
  --card-w: 81px;
  --card-h: 115px;
  position: relative;
  min-width: 0;
  min-height: 0;
  /* The board is a drag surface, never a text one: stop a press-drag from selecting deck labels etc. */
  user-select: none;
  display: grid;
  /* Opponent zones, the shared battlefield, your zones. The single column is pinned to minmax(0, 1fr):
     an implicit `auto` column grows to max-content, so a full hand would balloon the seat-bar past the
     viewport and shove the rail off-screen instead of letting the hand strip scroll. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

/* While an attach is armed, the whole board is a target picker: a crosshair over every card and slot
   cues that the next click chooses the parent to attach to. */
.board-stage.attaching,
.board-stage.attaching .board-card,
.board-stage.attaching .zone-card,
.board-stage.attaching .province {
  cursor: crosshair;
}

.battlefield {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 100% at 50% 0%, #f7f0e2, var(--r-surface));
  box-shadow: inset 0 0 90px rgba(60, 48, 28, 0.05);
  overflow: hidden;
}

/* While dragging, stop clipping so a card can cross the board's edge into the hand strip below. */
.battlefield.is-dragging {
  overflow: visible;
}

/* The dragged card rides above the board and the seat bars, so it stays visible as it crosses in. */
.board-card.dragging {
  z-index: 15;
}

/* A faint gold midline divides the two players' halves of the table. */
.battlefield::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--r-gold-soft), transparent);
  pointer-events: none;
}

/* Fold each card's border into its --card-w × --card-h footprint so a card renders at exactly the
   declared size the board geometry maths (CARD_W/CARD_H in board.js) assume, and fits a fixed-height
   slot like the hand strip without spilling. */
.board-card,
.zone-card,
.pile,
.province {
  box-sizing: border-box;
}

.board-card {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  border: 1px solid rgba(60, 48, 28, 0.35);
  border-radius: 6px;
  background: #efe7d6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: box-shadow 0.12s;
}

.board-card:hover {
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.22);
}

.board-card:active {
  cursor: grabbing;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.3);
}

.board-card img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  pointer-events: none;
}

.board-card.bowed {
  transform: rotate(90deg);
}

.board-card.inverted {
  transform: rotate(180deg);
}

.board-card.bowed.inverted {
  transform: rotate(270deg);
}

.board-card.face-down {
  background: linear-gradient(135deg, #7a5a36, #5e421f);
  border-color: #46330f;
}

.board-card.face-down::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: radial-gradient(circle at 50% 50%, rgba(255, 240, 210, 0.1), transparent 48%);
}

/* Selection: a cyan ring + wash, distinct from the gold log-link .highlight flash. */
.board-card.selected {
  box-shadow:
    0 0 0 2px #2bb8c9,
    0 2px 10px rgba(0, 0, 0, 0.24);
  z-index: 6;
}

.board-card.selected::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: rgba(43, 184, 201, 0.18);
  pointer-events: none;
}

/* A player's note, drawn boldly across the bottom half of a face-up card so it's the first thing read
   (e.g. marking a unit dead) while the art above stays visible. pre-wrap shows the text as typed;
   word-break keeps a long word in. */
.card-note {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 3px;
  background: rgba(18, 12, 5, 0.58);
  color: #fdf6e6;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
  pointer-events: none;
  border-radius: 0 0 6px 6px;
}

/* Disclosure cues, shared by battlefield and zone cards. A shown card — one whose private state you've
   deliberately revealed to the opponent — wears a thick blue border, drawn inside its footprint so it
   never bleeds over neighbouring cards, and distinct from the cyan selection ring. A peeked card is one
   this viewer alone sees, through their own private peek: drawn face up but dimmed to read as provisional. */
.board-card.shown,
.zone-card.shown {
  outline: 5px solid var(--r-reveal);
  outline-offset: -5px;
}

.board-card.peeked,
.zone-card.peeked {
  /* Dim and mute the card with a filter rather than opacity: the element stays fully opaque, so a
     stack of peeked cards occludes properly instead of showing through to the cards beneath. */
  filter: brightness(0.62) saturate(0.6);
}

/* The drag-to-select rubber band, drawn in battlefield-local coordinates. */
.marquee {
  position: absolute;
  z-index: 8;
  border: 1px dashed #2bb8c9;
  background: rgba(43, 184, 201, 0.12);
  pointer-events: none;
}

.board-menu {
  position: absolute;
  z-index: 20;
  min-width: 9rem;
  margin: 0;
  padding: 0.3rem 0;
  list-style: none;
  background: var(--r-panel);
  color: var(--r-ink);
  border: 1px solid var(--r-line);
  border-radius: 7px;
  box-shadow: 0 8px 20px rgba(40, 30, 15, 0.22);
  font-size: 0.92rem;
}

.board-menu li {
  padding: 0.35rem 0.95rem;
  cursor: pointer;
}

.board-menu li:hover {
  background: var(--r-gold-soft);
}

/* The single underlined letter is the item's keyboard accelerator while the menu is open. */
.board-menu .menu-key {
  text-decoration: underline;
}

.board-menu li.menu-sep {
  margin: 0.3rem 0;
  padding: 0;
  border-top: 1px solid var(--r-line);
  cursor: default;
}

.board-menu li.menu-sep:hover {
  background: none;
}

/* ── Table layout: seat bars (avatar + honor + hand) frame the battlefield; each seat's decks,
   pre-game cards, and provinces sit on the battlefield itself, as on the desktop table. ──────────── */

.seat-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  /* Trimmed to offset the hand-strip's scrollbar headroom — keep the pair in sync so the row's height holds. */
  padding: 0.25rem 0.8rem;
  background: var(--r-panel);
  /* Reserve a full card plus padding so the hand row is its final height from the first render, not
     only after the first card lands — and so the empty hand is always a real drop target. */
  min-height: calc(var(--card-h) + 0.8rem);
}

.seat-bar.opponent {
  border-bottom: 1px solid var(--r-line);
}

.seat-bar.self {
  border-top: 1px solid var(--r-line);
}

.player-panel {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
  width: 11rem;
}

.player-panel.is-away {
  opacity: 0.5;
}

.avatar {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--r-gold);
  color: #fff;
  font-weight: 600;
}

.panel-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-name {
  font-family: "EB Garamond", serif;
  font-size: 1.2rem;
  color: var(--r-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-honor {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--r-gold);
}

.panel-honor::before {
  content: "Honor ";
  font-weight: 400;
  color: var(--r-ink-dim);
}

/* The local seat's honor is a click/scroll stepper; the opponent's only reports. */
.panel-honor.is-editable {
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
  padding: 0 0.2rem;
}

.panel-honor.is-editable:hover {
  background: var(--r-gold);
  color: #fff;
}

.panel-honor.read-only {
  cursor: default;
}

.hand-strip {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-width: 0;
  /* Fixed height (not min-height) so an empty and a full hand stay the same size. The headroom over one
     card hosts the horizontal scrollbar: cards pin to the top and the bar sits in the strip below them,
     so the card shows full height and never shifts when the bar appears. scrollbar-width: thin (Firefox)
     and the 6px ::-webkit-scrollbar (Chrome/Safari) keep that bar slim enough to fit the headroom; the
     seat-bar sheds matching padding so the hand's total footprint is unchanged. */
  height: calc(var(--card-h) + 0.75rem);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding: 0;
  border-radius: 6px;
  transition: box-shadow 0.12s, background 0.12s;
}

.hand-strip::-webkit-scrollbar {
  height: 6px;
}

/* A card dragged over the hand glows it as the drop target. */
.hand-strip.drop-active {
  background: var(--r-gold-soft);
  box-shadow: inset 0 0 0 2px var(--r-gold);
}

/* The empty slot an incoming card opens in the hand, reserving where it will land — a blank gap, like
   the one a within-hand reorder opens by sliding its own hidden source aside. */
.hand-gap {
  box-sizing: border-box; /* --card-w/h is the full footprint, matching a real card */
  flex: 0 0 auto;
  width: var(--card-w);
  height: var(--card-h);
  pointer-events: none;
}

.table {
  position: relative;
  min-height: 0;
}

/* A seat's decks (left), pre-game cards, provinces (centre), and discards/fate deck (right), laid
   across one edge of the battlefield. Gaps pass pointer events through to the cards beneath. */
.tableau {
  position: absolute;
  left: 1rem;
  right: 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  pointer-events: none;
}

.tableau.opponent {
  top: 0.6rem;
}

.tableau.self {
  bottom: 0.6rem;
}

.tableau-decks,
.pregame,
.provinces {
  display: flex;
  gap: 0.4rem;
  pointer-events: auto;
}

.pile,
.province {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
}

.pile {
  border: 1px solid var(--r-line);
  background: var(--r-surface);
  overflow: hidden;
  /* Own stacking context so the label can sit behind the pile's card/back (see .pile-label). */
  isolation: isolate;
}

.pile.is-back {
  background: linear-gradient(135deg, #7a5a36, #5e421f);
  border-color: #46330f;
}

.pile-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Drop out of hit-testing so grabbing a face-down deck top starts our pointer-drag (MOVE_DECK_TOP)
     instead of the browser's native image drag, which would hijack it. Mirrors .zone-card img. */
  pointer-events: none;
}

.province {
  border: 1px dashed var(--r-line);
  background: var(--r-line-soft);
}

.pile-label {
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.55rem;
  color: var(--r-ink-dim);
  /* Lowest in the pile: a card or back covers the label, which shows only on an empty zone. */
  z-index: -1;
}

.pile.is-back .pile-label {
  color: rgba(255, 240, 210, 0.7);
}

.pile-count {
  position: absolute;
  right: 3px;
  bottom: 2px;
  padding: 0 0.25rem;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.deck {
  cursor: pointer;
}

.deck:hover {
  box-shadow: 0 0 0 2px var(--r-gold-soft);
}

/* Zone cards (hand, provinces, pre-game, pile tops) are full-size, movable cards, identical in size
   and feel to battlefield cards. touch-action/user-select keep a drag from being hijacked as a
   scroll or text selection. */
.zone-card {
  position: relative;
  flex: 0 0 auto;
  width: var(--card-w);
  height: var(--card-h);
  border: 1px solid rgba(60, 48, 28, 0.35);
  border-radius: 6px;
  background: #efe7d6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.zone-card:active {
  cursor: grabbing;
}

.zone-card img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  pointer-events: none;
}

.zone-card.bowed {
  transform: rotate(90deg);
}

.zone-card.inverted {
  transform: rotate(180deg);
}

.zone-card.bowed.inverted {
  transform: rotate(270deg);
}

.zone-card.face-down {
  background: linear-gradient(135deg, #7a5a36, #5e421f);
  border-color: #46330f;
}

.rail {
  display: grid;
  grid-template-rows: 1fr 10px minmax(180px, 1fr);
  min-height: 0;
  background: var(--r-panel);
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.75rem 0.9rem;
}

.pane-title {
  margin: 0 0 0.5rem;
  font: 600 0.74rem/1 "EB Garamond", serif;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--r-gold);
}

.action-log,
.chat-log {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
}

.action-log li {
  padding: 0.22rem 0;
  font-size: 0.92rem;
  font-style: italic;
  color: var(--r-ink-dim);
  border-bottom: 1px solid var(--r-line-soft);
}

.log-card-link {
  color: var(--r-gold);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-style: normal;
}

.log-card-link:hover {
  color: var(--r-gold-soft);
}

.board-card.highlight {
  animation: board-card-flash 1.2s ease-out;
  z-index: 10;
}

@keyframes board-card-flash {
  0% {
    box-shadow:
      0 0 0 3px var(--r-gold),
      0 0 18px 6px var(--r-gold-soft);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.pane-empty {
  border-bottom: none !important;
  opacity: 0.75;
}

.chat-log li {
  padding: 0.22rem 0;
  font-size: 0.95rem;
}

.chat-sender {
  margin-right: 0.3rem;
  font-weight: 600;
  color: var(--r-gold);
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.chat-form input {
  flex: 1;
  padding: 0.5rem 0.6rem;
  font: inherit;
  border: 1px solid var(--r-line);
  border-radius: 6px;
  background: #fff;
}

.chat-form input:focus-visible {
  outline: none;
  border-color: var(--r-gold);
  box-shadow: 0 0 0 2px var(--r-gold-soft);
}

.rail-splitter {
  display: grid;
  place-items: center;
  cursor: row-resize;
  background: var(--r-panel);
  border-top: 1px solid var(--r-line);
  border-bottom: 1px solid var(--r-line);
}

.rail-splitter::before {
  content: "";
  width: 2.5rem;
  height: 3px;
  border-radius: 3px;
  background: var(--r-line);
}

.rail-splitter:hover::before,
.rail-splitter:focus-visible::before {
  background: var(--r-gold);
}

.rail-splitter:focus-visible {
  outline: 2px solid var(--r-gold-soft);
  outline-offset: -2px;
}

@media (max-width: 860px) {
  .room-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .rail-resizer {
    display: none;
  }

  .board-stage {
    min-height: 60vh;
  }

  .rail {
    border-left: none;
    border-top: 1px solid var(--r-line);
    grid-template-rows: 200px 10px 260px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .room .btn,
  .board-card {
    transition: none;
  }
}

/* ── Deck-search dialog: the owner's deck (top-first), filterable by title, with a small preview. ── */
.deck-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 22, 10, 0.45);
}

/* A card-sized preview floated next to a card on the board (board.js positions it). It's
   pointer-transparent so it never blocks play; the next key or pointer action dismisses it, fading
   out once `closing` is set — the listener removes it when that transition ends. */
.card-view {
  position: absolute;
  z-index: 60;
  /* Cap the width so the aspect-derived height (~1.42x) can never exceed the viewport; otherwise a
     full-size preview of a hand card is taller than the screen and hangs off the bottom even after
     board.js clamps it. 60dvh of width keeps the height around 85dvh, leaving room for the margin. */
  width: min(400px, 60dvh);
  aspect-ratio: 81 / 115;
  border-radius: 10px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  animation: card-view-in 0.12s ease-out;
  transition: opacity 0.14s ease;
}

.card-view.closing {
  opacity: 0;
}

@keyframes card-view-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
}

.deck-dialog {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: min(560px, 92vw);
  max-height: 80vh;
  padding: 0.9rem;
  background: var(--r-panel);
  color: var(--r-ink);
  border: 1px solid var(--r-line);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(40, 30, 15, 0.3);
}

.deck-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.deck-dialog-title {
  margin: 0;
  font-size: 1rem;
}

.deck-dialog-close {
  border: none;
  background: none;
  color: var(--r-ink-dim);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.deck-dialog-close:hover {
  color: var(--r-ink);
}

.deck-dialog-filter {
  width: 100%;
  padding: 0.4rem 0.6rem;
  font: inherit;
  border: 1px solid var(--r-line);
  border-radius: 5px;
}

.deck-dialog-body {
  display: flex;
  gap: 0.8rem;
  min-height: 0;
}

.deck-dialog-list {
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  border: 1px solid var(--r-line);
  border-radius: 5px;
}

.deck-dialog-name {
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--r-line-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.deck-dialog-name:hover {
  background: var(--r-gold-soft);
}

.deck-dialog-empty {
  padding: 0.6rem;
  color: var(--r-ink-dim);
  text-align: center;
}

.deck-dialog-name.selected {
  background: var(--r-gold-soft);
  box-shadow: inset 3px 0 0 var(--r-gold);
}

/* Rows of one's own pile can be dragged to reorder it; suppress text selection so a drag up or down
   doesn't highlight the card names it passes over. */
.deck-dialog-name.reorderable {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.deck-dialog-preview {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 150px;
}

.deck-dialog-preview-img {
  width: 150px;
  height: 210px;
  object-fit: contain;
  border-radius: 6px;
}

.deck-dialog-preview-img.is-empty {
  visibility: hidden;
}

.deck-dialog-deal {
  width: 100%;
  padding: 0.4rem;
  font: inherit;
  color: var(--r-ink);
  background: #fff;
  border: 1px solid var(--r-line);
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.12s;
}

.deck-dialog-deal:hover:not(:disabled) {
  border-color: var(--r-gold);
}

.deck-dialog-deal:disabled {
  opacity: 0.4;
  cursor: default;
}

.deck-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--r-line);
}

.deck-dialog-btn,
.deck-scope-btn {
  padding: 0.4rem 0.8rem;
  font: inherit;
  color: var(--r-ink);
  background: #fff;
  border: 1px solid var(--r-line);
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.12s;
}

.deck-dialog-btn:hover,
.deck-scope-btn:hover {
  border-color: var(--r-gold);
}

/* The deck-menu "Search…" chooser: a centered card asking for the top N or the whole deck. */
.deck-scope {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: min(320px, 90vw);
  padding: 0.9rem;
  background: var(--r-panel);
  color: var(--r-ink);
  border: 1px solid var(--r-line);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(40, 30, 15, 0.3);
}

.deck-scope-row {
  display: flex;
  gap: 0.5rem;
}

.deck-scope-row .deck-scope-btn {
  flex: 1 1 auto;
}

.deck-scope-input {
  width: 4rem;
  padding: 0.4rem 0.5rem;
  font: inherit;
  border: 1px solid var(--r-line);
  border-radius: 5px;
}

/* The "Calculate probabilities" popup reuses the deck-scope modal frame. */
.draw-odds-heading {
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.draw-odds-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.draw-odds-row > span {
  flex: 1 1 auto;
}

.draw-odds-result {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.note-dialog {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: min(320px, 90vw);
  padding: 0.9rem;
  background: var(--r-panel);
  color: var(--r-ink);
  border: 1px solid var(--r-line);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(40, 30, 15, 0.3);
}

.note-dialog-input {
  width: 100%;
  min-height: 4rem;
  resize: vertical;
  padding: 0.4rem 0.5rem;
  font: inherit;
  border: 1px solid var(--r-line);
  border-radius: 5px;
  background: var(--r-surface);
  color: var(--r-ink);
}

.token-dialog {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: min(640px, 94vw);
  max-height: 80vh;
  padding: 0.9rem;
  background: var(--r-panel);
  color: var(--r-ink);
  border: 1px solid var(--r-line);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(40, 30, 15, 0.3);
}

.token-search-input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font: inherit;
  border: 1px solid var(--r-line);
  border-radius: 5px;
  background: var(--r-surface);
  color: var(--r-ink);
}

.token-search-body {
  display: flex;
  flex: 1 1 auto;
  gap: 0.8rem;
  min-height: 0;
}

.token-search-list {
  flex: 1 1 auto;
  min-height: 12rem;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  border: 1px solid var(--r-line);
  border-radius: 5px;
}

.token-search-result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  border-bottom: 1px solid var(--r-line-soft);
  user-select: none;
}

.token-search-result:hover {
  background: var(--r-gold-soft);
}

.token-search-result.selected {
  background: var(--r-gold-soft);
  box-shadow: inset 3px 0 0 var(--r-gold);
}

.token-search-thumb {
  flex: 0 0 auto;
  width: 28px;
  height: 40px;
  object-fit: cover;
  border-radius: 3px;
}

.token-search-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-search-preview {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 200px;
}

.token-search-preview-img {
  width: 200px;
  height: 280px;
  object-fit: contain;
  border-radius: 6px;
}

.token-search-preview-img.is-empty {
  visibility: hidden;
}

.token-search-create {
  width: 100%;
  padding: 0.45rem;
  font: inherit;
  color: var(--r-ink);
  background: #fff;
  border: 1px solid var(--r-line);
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.12s;
}

.token-search-create:hover:not(:disabled) {
  border-color: var(--r-gold);
}

.token-search-create:disabled {
  opacity: 0.4;
  cursor: default;
}
