:root {
  --bg: #14110e;
  --panel: rgba(32, 28, 24, 0.94);
  --border: rgba(180, 160, 120, 0.22);
  --text: #e8e0d4;
  --muted: #9a8f7e;
  --accent: #d4a84b;
  --accent-dim: rgba(212, 168, 75, 0.35);
  --danger: #c45c5c;
  --spell: #2ec4b6;
  --curse: #b03040;
  --ritual: #a56bff;
  --radius: 12px;
  --font-display: "Cinzel", serif;
  --font-body: "Cormorant Garamond", serif;
  /* Board uses Lab design size (300×420) scaled via --stone-scale */
  --stone-scale: 0.42;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}
.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(80, 60, 30, 0.35), transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(40, 30, 50, 0.28), transparent 45%),
    linear-gradient(180deg, #1c1814, #0e0c0a);
  pointer-events: none;
  z-index: 0;
}
.app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
#viewMatch {
  overflow: hidden;
}
.hidden { display: none !important; }
.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 14, 12, 0.9);
  flex-wrap: nowrap;
  flex-shrink: 0;
}
.match-top {
  padding: 0.25rem 0.5rem;
  gap: 0.55rem;
  flex-wrap: nowrap;
}
.match-top .brand {
  flex-shrink: 0;
  min-width: 0;
}
.match-top .tagline,
.match-top .tag {
  font-size: 0.72rem;
}
.match-top h1 {
  font-size: 0.9rem;
}
.brand { display: flex; gap: 0.65rem; align-items: center; }
.mark { color: var(--accent); font-size: 1.35rem; }
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
}
.tag { margin: 0; color: var(--muted); font-size: 0.9rem; font-style: italic; }
.top-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}
/* Compact life chips in the match top bar */
.life-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
}
.match-top .life-chip {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  background: rgba(12, 10, 8, 0.88);
  border: 1px solid var(--border);
  box-shadow: none;
  max-width: 100%;
}
.match-top .life-chip.you {
  border-color: rgba(212, 168, 75, 0.55);
}
.match-top .life-chip[data-seat="0"].you {
  border-color: rgba(229, 57, 53, 0.65);
}
.match-top .life-chip[data-seat="1"].you {
  border-color: rgba(30, 136, 229, 0.65);
}
.match-top .life-chip .life-name {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.08rem 0.2rem;
  min-width: 3.5rem;
  max-width: 6.5rem;
  width: auto;
  color: var(--text);
  flex: 0 1 auto;
}
.match-top .life-chip .life-name:hover,
.match-top .life-chip .life-name:focus {
  border-color: rgba(180, 160, 120, 0.35);
  outline: none;
  background: rgba(0, 0, 0, 0.25);
}
.match-top .life-chip .life-name:disabled {
  opacity: 0.85;
  cursor: default;
  border-color: transparent;
  background: transparent;
}
.match-top .life-chip .life-value {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  min-width: 1.4rem;
  text-align: center;
}
.match-top .life-chip .life-delta {
  width: 2rem;
  padding: 0.1rem 0.15rem;
  font-size: 0.7rem;
  margin: 0;
}
.match-top .life-btns {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
}
.match-top .life-chip .life-btn {
  padding: 0.1rem 0.32rem;
  min-width: 1.25rem;
  font-size: 0.72rem;
  line-height: 1.1;
  margin: 0;
}

.btn {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}
.btn:hover { border-color: rgba(200, 180, 140, 0.45); }
.btn.primary {
  border-color: rgba(212, 168, 75, 0.5);
  color: #f5e6c8;
  background: rgba(80, 55, 20, 0.45);
}
.btn.danger { border-color: rgba(180, 60, 60, 0.45); color: #f0c0c0; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

.lobby-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  padding: 0.85rem;
  overflow: auto;
}
@media (max-width: 1000px) {
  .lobby-grid { grid-template-columns: 1fr; }
}

/* Right column: multiplayer (templates UI commented out for now) */
.lobby-right-stack {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.lobby-right-stack > .panel {
  flex: 1 1 0;
  min-height: 0;
}
/* When only multiplayer is shown, fill the right column */
.lobby-right-stack > .panel-multiplayer:only-child {
  flex: 1 1 auto;
}
/* Game setup (middle lobby column) */
.panel-game-setup {
  min-height: 0;
}
.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.panel-head-row h2 {
  flex: 1 1 auto;
  min-width: 0;
}
.btn-setup-toggle {
  flex: 0 0 auto;
  padding: 0.28rem 0.5rem;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.panel-game-setup.hide-unused-setup .setup-unused-option {
  display: none !important;
}
.game-setup-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 0.65rem 0.75rem;
  scrollbar-width: thin;
}
.setup-market-save-actions {
  margin-top: 0.45rem;
}
.setup-set-status {
  margin: 0.35rem 0 0;
  min-height: 1.1em;
  font-size: 0.8rem;
}
.setup-set-status.is-error {
  color: #f0c0c0;
}
.setup-set-status.is-ok {
  color: #b8d4a8;
}
.setup-block-title {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0.15rem 0 0.45rem;
}
.setup-slider-row {
  display: grid;
  grid-template-columns: 1fr auto 1.75rem;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.4rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.setup-slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  min-width: 0;
}
.setup-val {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--text);
  text-align: right;
  min-width: 1.5rem;
}
.setup-check {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  margin: 0.35rem 0 0.45rem;
}
.setup-cost-sliders.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.setup-warn {
  margin: 0.25rem 0 0.35rem;
  padding: 0.35rem 0.45rem;
  font-size: 0.82rem;
  color: #f0c0c0;
  border: 1px solid rgba(180, 60, 60, 0.45);
  border-radius: 8px;
  background: rgba(80, 20, 20, 0.35);
}
.setup-gap {
  height: 1rem;
  border-top: 1px solid var(--border);
  margin: 0.65rem 0 0.85rem;
}
.setup-custom-hint {
  margin: 0 0 0.35rem;
  padding: 0;
}
.setup-trap-bag-check {
  display: flex;
  width: 100%;
  margin-top: 0.65rem;
  margin-bottom: 0.2rem;
}
.setup-trap-hint {
  display: block;
  width: 100%;
  margin: 0 0 0.35rem;
  padding: 0;
  font-size: 0.8rem;
}
.setup-market-piles {
  margin-top: 0.35rem;
}
.setup-market-piles.hidden {
  display: none !important;
}
.setup-pile-grid {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 14rem;
  overflow: auto;
  padding-right: 0.15rem;
}
.setup-pile-row {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}
.setup-pile-row span {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.setup-pile-row select {
  width: 100%;
  min-width: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.25rem 0.35rem;
  font-family: var(--font-body);
  font-size: 0.88rem;
}
.setup-market-list-actions {
  margin: 0.25rem 0 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.setup-market-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.25rem;
}
.setup-market-row {
  display: grid;
  grid-template-columns: auto 1fr 3.25rem;
  gap: 0.35rem;
  align-items: center;
  padding: 0.28rem 0.35rem;
  border-radius: 6px;
}
.setup-market-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
}
.setup-market-row.is-off {
  opacity: 0.45;
}
.setup-market-list.is-readonly input[type="number"],
.setup-market-list.is-readonly input[type="checkbox"] {
  pointer-events: none;
  opacity: 0.85;
}
.setup-market-list.is-readonly .setup-market-row input[type="checkbox"] {
  opacity: 0.5;
}
.setup-market-row:hover {
  background: rgba(255, 255, 255, 0.04);
}
.setup-market-name {
  font-size: 0.9rem;
  color: var(--text);
  cursor: help;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.setup-market-row input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.2rem 0.3rem;
  font-size: 0.88rem;
  text-align: center;
}
.btn-host-blocked {
  outline: 1px solid rgba(180, 60, 60, 0.55);
}
.rematch-modal-card {
  max-width: 22rem;
}
.rematch-modal-body {
  padding: 0.85rem 1rem 0.35rem;
}
.rematch-modal-text {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.4;
  color: var(--text);
}
.rematch-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.65rem 1rem 0.9rem;
}
.multiplayer-hint {
  margin: 0;
  padding-top: 0.15rem;
  padding-bottom: 0.35rem;
}
/* Multiplayer connection status (was accidentally hidden with .hidden) */
.net-status {
  margin: 0.35rem 0.85rem 0.85rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  line-height: 1.35;
  color: var(--accent);
  min-height: 1.5em;
  word-break: break-word;
}
.net-status.net-status-ok {
  border-color: rgba(80, 160, 100, 0.45);
  color: #9ed4a8;
}
.net-status.net-status-error {
  border-color: rgba(196, 92, 92, 0.55);
  color: #f0b0b0;
}
.turn-settings {
  margin: 0 0.85rem 0.85rem;
  padding: 0.45rem 0.55rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}
.turn-settings summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}
.turn-settings[open] summary {
  color: var(--accent);
  margin-bottom: 0.45rem;
}
.turn-settings-hint {
  margin: 0 0 0.5rem;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.35;
}
.turn-settings-sub {
  margin-top: 0.55rem;
  opacity: 0.9;
}
.turn-settings-hint a {
  color: var(--accent);
}
.turn-settings-hint code {
  font-size: 0.8em;
  color: var(--accent);
}
.turn-settings select {
  width: 100%;
  font: inherit;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
}
.turn-settings .field {
  margin-bottom: 0.4rem;
}
.turn-settings-actions {
  margin: 0.35rem 0 0.15rem;
}
.turn-settings-status {
  margin: 0.35rem 0 0;
  min-height: 1.1em;
}
.templates-actions {
  padding: 0 0.85rem 0.45rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  padding: 0.65rem 0.85rem 0.35rem;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.pad { padding: 0.35rem 0.85rem 0.85rem; }
.muted { color: var(--muted); }
.hint { font-size: 0.88rem; color: var(--muted); }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }
.gap { gap: 0.45rem; }
.grow { flex: 1; min-width: 0; }
.pad.row, .row.pad { padding: 0 0.85rem 0.65rem; }
.host-row {
  padding: 0 0.85rem 0.5rem;
  align-items: center;
}
.host-randomize-opt {
  margin-left: 0.15rem;
}
.join-row {
  padding: 0 0.85rem 0.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.85rem 0.65rem;
}
.field span {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
input[type="text"], select, textarea {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.4rem 0.55rem;
  font-family: var(--font-body);
  font-size: 1rem;
}
.inline-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-style: italic;
  padding: 0.1rem 0.2rem;
  min-width: 12rem;
}

.mini-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0.5rem 0.75rem;
  overflow: auto;
  flex: 1;
}
.mini-list li {
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.95rem;
}
.mini-list.selectable li { cursor: pointer; }
.mini-list.selectable li:hover { background: rgba(255, 255, 255, 0.04); }
.mini-list.selectable li.active {
  border-color: var(--border);
  background: rgba(212, 168, 75, 0.08);
}
.mini-list .sub { color: var(--muted); font-size: 0.82rem; }

/* Lobby: visual card collection (3-up, wheel scroll, no visible scrollbar) */
.panel-collection {
  min-height: 0;
}
.panel-collection .panel-head h2 {
  text-transform: none;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
}
.collection-filters {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  padding: 0.15rem 0.65rem 0.4rem;
  align-items: center;
}
.collection-filter-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.collection-filter-opt input {
  accent-color: var(--accent);
  width: 0.9rem;
  height: 0.9rem;
  margin: 0;
  cursor: pointer;
}
.collection-filter-opt span {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.collection-search-wrap {
  flex-shrink: 0;
  padding: 0 0.55rem 0.45rem;
}
.collection-search {
  width: 100%;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.35rem 0.55rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.collection-search::placeholder {
  color: var(--muted);
  opacity: 0.85;
}
.collection-search:focus {
  outline: none;
  border-color: rgba(212, 168, 75, 0.45);
}
.card-collection-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  padding: 0.35rem 0.5rem 0.75rem;
  overflow-x: hidden;
  overflow-y: auto;
  align-content: start;
  /* Hide scrollbars; mouse-wheel / trackpad still scroll */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.card-collection-grid::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
.lobby-card-cell {
  min-width: 0;
  width: 100%;
  aspect-ratio: 300 / 420;
  position: relative;
  border-radius: 6px;
}
.lobby-card-cell .stone-scale-wrap {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  cursor: default;
}
.lobby-card-cell .stone-card {
  transform-origin: top left;
  pointer-events: none;
  cursor: default;
}
.lobby-card-cell .stone-card.pt-stone {
  cursor: default;
}
.card-collection-empty {
  grid-column: 1 / -1;
  padding: 1rem 0.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Boards */
.editor-layout, .match-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 0.65rem;
  padding: 0.65rem;
}
.editor-layout {
  grid-template-columns: 260px 1fr;
}
/* ===== MATCH: board snug left · chat far right (zone coords unchanged) ===== */
.match-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  grid-template-columns: 1fr min(260px, 28vw);
  gap: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
}
/* Pre-play (lobby / countdown): keep chat width; hide board; show centered copy */
.match-layout.match-waiting .match-table .board,
.match-layout.match-waiting .match-table .attack-overlay,
.match-layout.match-waiting .match-table .draft-market,
.match-layout.match-waiting .log-drawer {
  display: none !important;
}
.match-layout.match-waiting .match-table {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 6, 0.55);
}
.match-waiting-msg {
  display: none;
  max-width: 32rem;
  padding: 1.25rem 1.5rem;
  text-align: center;
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.45;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.match-layout.match-waiting .match-waiting-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
}
.match-waiting-msg .wait-line1 {
  display: block;
  font-family: var(--font-display);
  font-size: 1.55rem;
  color: var(--text);
  letter-spacing: 0.04em;
}
.match-waiting-msg .wait-line2 {
  display: block;
  font-size: 1.2rem;
  color: var(--accent);
}
.match-waiting-msg strong {
  color: var(--accent);
  font-weight: 600;
}
/* Draft: market faces + bags column (market / Draft) */
.match-layout.match-draft .match-table .board,
.match-layout.match-draft .match-table .attack-overlay,
.match-layout.match-draft .match-table .match-waiting-msg,
.match-layout.match-draft .log-drawer {
  display: none !important;
}
.draft-market {
  display: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  box-sizing: border-box;
  padding: clamp(0.45rem, 1.2vw, 1rem);
  flex-direction: column;
  gap: 0.45rem;
  background: rgba(10, 8, 6, 0.35);
}
.match-layout.match-draft .draft-market {
  display: flex;
}
.draft-status {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem 1.1rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
  text-align: center;
}
.draft-status strong {
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 600;
}
.draft-totals {
  opacity: 0.9;
}
.draft-curse-hint {
  color: var(--curse);
  font-style: italic;
}
.draft-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(100px, 18%);
  gap: clamp(0.45rem, 1.2vw, 1rem);
}
.draft-grid {
  min-width: 0;
  min-height: 0;
  display: grid;
  /* columns/rows set dynamically in JS from market face count */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: clamp(0.4rem, 1vw, 0.9rem);
}
.draft-market-cell {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-radius: 10px;
  cursor: pointer;
  transition: box-shadow 0.12s ease, outline-color 0.12s ease;
  outline: 2px solid transparent;
}
.draft-market-cell.is-selected {
  outline-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212, 168, 75, 0.35), 0 8px 24px rgba(0, 0, 0, 0.45);
}
.draft-market-cell.is-locked {
  cursor: default;
  opacity: 0.72;
}
.draft-market-cell .stone-scale-wrap.draft-card-wrap {
  flex-shrink: 0;
  pointer-events: none;
}
.draft-market-cell .stone-scale-wrap.draft-card-wrap .stone-card {
  transform-origin: top left;
  pointer-events: none;
}
.draft-bags {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.55rem;
  align-items: center;
  justify-items: center;
}
/* Market bag + Draft only (no trap deck) */
.draft-bags.draft-bags-market-only {
  grid-template-rows: minmax(0, 1fr) auto;
}
.draft-bag-slot {
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  position: relative;
  border-radius: 10px;
}
.draft-bag-curse {
  cursor: pointer;
}
.draft-bag-curse:hover .draft-bag-face,
.draft-bag-curse.is-active .draft-bag-face {
  filter: brightness(1.12);
}
.draft-bag-curse.is-active {
  outline: 2px solid rgba(176, 48, 64, 0.75);
  box-shadow: 0 0 0 3px rgba(176, 48, 64, 0.25);
}
.draft-bag-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}
.draft-confirm-btn {
  width: min(100%, 9rem);
  padding: 0.55rem 0.85rem;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.draft-confirm-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.draft-observer {
  flex: 0 0 auto;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  padding-bottom: 0.15rem;
}
.draft-curse-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 0.25rem 0 0.15rem;
}
.draft-curse-actions .btn {
  min-width: 8rem;
  padding: 0.55rem 1.4rem;
  font-size: 1.05rem;
}
/* Soften life HUD until full play */
#viewMatch.match-waiting .life-bar,
#viewMatch.match-draft .life-bar {
  opacity: 0.55;
}
#viewMatch.match-waiting .life-bar .life-btns,
#viewMatch.match-waiting .life-bar .life-delta,
#viewMatch.match-draft .life-bar .life-btns,
#viewMatch.match-draft .life-bar .life-delta {
  pointer-events: none;
  opacity: 0.4;
}
.match-table {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  grid-row: 1;
  grid-column: 1;
  /* No side preview rail — board can use the full table width */
  --preview-rail: 0px;
}
.match-layout > .log-drawer {
  grid-row: 2;
  grid-column: 1 / -1;
}
.board {
  position: relative;
  min-height: 0;
  border-radius: 0;
  border: none;
  overflow: hidden;
}
/* Editor: scrollable viewport + fixed design canvas (same size as match shell) */
.editor-viewport {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  position: relative !important;
  overflow: auto !important;
  min-height: 0;
  height: 100%;
  width: 100%;
  min-width: 0;
  background: #0c0b0a;
  /* room to scroll the 1400×900 canvas */
  -webkit-overflow-scrolling: touch;
  user-select: none;
}
.editor-canvas {
  position: relative;
  flex-shrink: 0;
  margin: 28px 12px 12px;
  box-sizing: border-box;
  border: 1px solid rgba(180, 160, 120, 0.28);
  border-radius: 6px;
  background:
    linear-gradient(rgba(180, 160, 120, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180, 160, 120, 0.08) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 40%, #1a3d2a 0%, transparent 55%),
    linear-gradient(180deg, #1a1612, #12100e);
  background-size: 50px 50px, 50px 50px, auto, auto;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45);
  /* Design coords are px on this element */
  touch-action: none;
}
.editor-hint {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 5;
  margin: 0;
  padding: 6px 8px;
  font-size: 0.8rem;
  color: var(--muted);
  pointer-events: none;
  text-align: center;
  background: linear-gradient(180deg, rgba(12, 11, 10, 0.95), rgba(12, 11, 10, 0.65));
}
.editor-hint-on-felt {
  color: rgba(220, 210, 190, 0.75);
  text-shadow: 0 1px 2px #000;
}
/* Free-form editor slots — always absolute on the design canvas */
.editor-canvas > .slot.editor-slot {
  position: absolute !important;
  z-index: 3;
  box-sizing: border-box;
  min-width: 72px !important;
  min-height: 96px !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0;
  cursor: grab;
  border: 1px solid rgba(180, 160, 120, 0.55);
  background: rgba(0, 0, 0, 0.58);
  border-radius: 8px;
  padding: 0.3rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  overflow: visible;
  flex: none !important;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  touch-action: none;
  user-select: none;
  transition: none !important;
}
.editor-canvas > .slot.editor-slot.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim), 0 8px 20px rgba(0, 0, 0, 0.5);
  z-index: 8;
}
.editor-canvas > .slot.editor-slot.dragging {
  cursor: grabbing;
  z-index: 50 !important;
  opacity: 0.97;
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent-dim),
    0 16px 36px rgba(0, 0, 0, 0.6);
  background: rgba(40, 34, 28, 0.95);
}
.editor-canvas > .slot.editor-market {
  border-color: rgba(46, 196, 182, 0.55);
  background: rgba(8, 40, 36, 0.55);
}
.editor-canvas > .slot .resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  border-right: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  cursor: se-resize;
  opacity: 0.9;
  z-index: 6;
  touch-action: none;
}
.editor-canvas > .slot .resize-handle:hover {
  opacity: 1;
}
.editor-layout {
  grid-template-columns: 260px 1fr;
  min-height: 0;
  flex: 1;
}
.play-board {
  overflow: hidden !important;
  height: 100%;
  min-height: 0;
  width: 100%;
}
.abs-play-board {
  display: flex;
  align-items: center;
  /* Snug left — do not re-center (preserves your zone layout visually) */
  justify-content: flex-start;
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, #1b4d34 0%, #0d2418 50%, #0a120e 100%);
  padding: 4px;
}
.abs-fit-host {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: flex-start; /* board shifts left */
}
.abs-shell {
  position: relative;
  flex-shrink: 0;
  transform-origin: left center; /* scale from left edge */
}
.abs-play-board .abs-slot {
  position: absolute !important;
  left: auto; /* set inline */
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  /* Inset is handled by card fit math — no extra CSS padding (was inflating bottom gap) */
  padding: 0 !important;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;
  --label: 0px;
  /* For empty-zone title font sizing (cqi) */
  container-type: size;
  container-name: zone;
}
.abs-play-board .abs-slot.market-cell,
.abs-play-board .abs-slot.editor-market {
  border-color: rgba(46, 196, 182, 0.5);
  background: rgba(8, 40, 36, 0.4);
}
.abs-play-board .abs-slot > .slot-label {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden;
}
.abs-play-board .abs-slot .slot-body {
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Big power readout over middle-row Legends (on the card face) */
.stone-scale-wrap.has-field-power {
  position: relative !important;
  overflow: visible !important;
}
.field-power-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 12;
  min-width: 1.15em;
  padding: 0.08em 0.22em;
  box-sizing: border-box;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1;
  text-align: center;
  color: #fff8ee;
  letter-spacing: 0.02em;
  /* Solid black border box + hard black outline on the digits */
  border: 3px solid #000;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  -webkit-text-stroke: 2.5px #000;
  paint-order: stroke fill;
  text-shadow:
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000;
  pointer-events: none;
  user-select: none;
}
.abs-play-board .abs-slot.hand-cell {
  border-color: rgba(180, 160, 120, 0.35);
  overflow: visible !important;
  min-height: 0 !important;
}
.abs-play-board .abs-slot.hand-cell.is-you {
  border-color: rgba(212, 168, 75, 0.55);
}
.abs-play-board .abs-slot.hand-cell .slot-body {
  overflow: visible;
}
.abs-play-board .stack-pile {
  width: var(--cw);
  height: var(--ch);
}

/*
 * Geometry tuned for LARGER cards:
 *  - Market is 2×3 on the LEFT (not a 7th full-width row)
 *  - Only 6 rows tall → much more vertical budget for --cw
 *  - Cols: market(2) + field(5) + deck/GY(1) = 8
 */
.legends-duel-board {
  --cw: 120px;
  --ch: 168px;
  --gap: 5px;
  --label: 13px;
  --zone-h: calc(var(--ch) + var(--label));
  --stone-scale: calc(var(--cw) / 300);
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, #1b4d34 0%, #0d2418 50%, #0a120e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden !important;
  padding: 4px;
}
.duel-shell {
  /* 8 cols × 6 rows */
  display: grid;
  grid-template-columns: repeat(8, var(--cw));
  grid-template-rows: repeat(6, var(--zone-h));
  gap: var(--gap);
  width: max-content;
  height: max-content;
}

/* Row 1 — opponent hand + ritual + deck + discard */
.db-hand-opp { grid-column: 1 / 6; grid-row: 1; }
.db-pile-opp-ritual { grid-column: 6; grid-row: 1; }
.db-pile-opp-deck { grid-column: 7; grid-row: 1; }
.db-pile-opp-disc { grid-column: 8; grid-row: 1; }

/*
 * Rows 2–4: temple LEFT — market 2×3 + bag column; field 5 cols; purgatory RIGHT
 * Market: cols 1–2 | Bags: col 3 (market bag row2, curse row3; Worship between in JS)
 * Field r0–r2: cols 4–8 | Purgatory: col 8 row 5 (right strip below field middle)
 */
.db-m-0 { grid-column: 1; grid-row: 2; }
.db-m-1 { grid-column: 2; grid-row: 2; }
.db-m-2 { grid-column: 1; grid-row: 3; }
.db-m-3 { grid-column: 2; grid-row: 3; }
.db-m-4 { grid-column: 1; grid-row: 4; }
.db-m-5 { grid-column: 2; grid-row: 4; }

.db-util-bag { grid-column: 3; grid-row: 2; }
.db-util-curse { grid-column: 3; grid-row: 3; }

.db-f-0-0 { grid-column: 4; grid-row: 2; }
.db-f-0-1 { grid-column: 5; grid-row: 2; }
.db-f-0-2 { grid-column: 6; grid-row: 2; }
.db-f-0-3 { grid-column: 7; grid-row: 2; }
.db-f-0-4 { grid-column: 8; grid-row: 2; }

.db-f-1-0 { grid-column: 4; grid-row: 3; }
.db-f-1-1 { grid-column: 5; grid-row: 3; }
.db-f-1-2 { grid-column: 6; grid-row: 3; }
.db-f-1-3 { grid-column: 7; grid-row: 3; }
.db-f-1-4 { grid-column: 8; grid-row: 3; }

.db-f-2-0 { grid-column: 4; grid-row: 4; }
.db-f-2-1 { grid-column: 5; grid-row: 4; }
.db-f-2-2 { grid-column: 6; grid-row: 4; }
.db-f-2-3 { grid-column: 7; grid-row: 4; }
.db-f-2-4 { grid-column: 8; grid-row: 4; }

/* Row 5 — field back row (face-down); purgatory on far right of this strip */
.db-f-3-0 { grid-column: 4; grid-row: 5; }
.db-f-3-1 { grid-column: 5; grid-row: 5; }
.db-f-3-2 { grid-column: 6; grid-row: 5; }
.db-f-3-3 { grid-column: 7; grid-row: 5; }
.db-f-3-4 { grid-column: 8; grid-row: 5; }
.db-util-purg { grid-column: 8; grid-row: 5; }

/* Row 6 — you */
.db-hand-me { grid-column: 1 / 6; grid-row: 6; }
.db-pile-me-ritual { grid-column: 6; grid-row: 6; }
.db-pile-me-deck { grid-column: 7; grid-row: 6; }
.db-pile-me-disc { grid-column: 8; grid-row: 6; }

/* Zones */
.grid-slot {
  position: relative !important;
  left: auto !important;
  top: auto !important;
  width: var(--cw) !important;
  height: var(--zone-h) !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0;
  padding: 1px !important;
  overflow: visible;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.grid-slot.slot-fd {
  background: rgba(0, 0, 0, 0.38);
  border-color: rgba(180, 160, 120, 0.2);
}
.grid-slot.market-cell {
  border-color: rgba(46, 196, 182, 0.45);
  background: rgba(8, 40, 36, 0.45);
}
.grid-slot .slot-label {
  font-size: 0.5rem;
  line-height: var(--label);
  height: var(--label);
  padding: 0;
  margin: 0;
  width: 100%;
  text-align: center;
  color: rgba(220, 210, 190, 0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grid-slot .slot-body {
  width: var(--cw);
  height: var(--ch);
  flex: 0 0 var(--ch);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0;
  margin: 0;
}

/* Hands: full table width, side-by-side (no overlap) */
.grid-slot.hand-cell {
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  height: var(--zone-h) !important;
  border-color: rgba(180, 160, 120, 0.25);
  background: rgba(0, 0, 0, 0.3);
}
.grid-slot.hand-cell.is-you {
  border-color: rgba(212, 168, 75, 0.5);
  box-shadow: inset 0 0 0 1px rgba(212, 168, 75, 0.15);
}
.grid-slot.hand-cell.is-active-seat {
  border-color: rgba(46, 196, 182, 0.75);
  box-shadow: inset 0 0 0 1px rgba(46, 196, 182, 0.25), 0 0 12px rgba(46, 196, 182, 0.2);
}
.hand-row-active {
  outline: 1px dashed rgba(46, 196, 182, 0.45);
  outline-offset: 2px;
  border-radius: 4px;
}
.active-seat-bar {
  display: inline-flex;
  gap: 0.2rem;
  align-items: center;
}
.active-seat-bar.hidden {
  display: none !important;
}
.active-seat-bar .seat-btn {
  min-width: 2.2rem;
  padding: 0.35rem 0.5rem;
}
.hand-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0 2px;
  /* Clip only horizontal overflow after pack; never chop card tops */
  overflow-x: auto;
  overflow-y: visible;
  gap: 6px;
  box-sizing: border-box;
}
.hand-row .stone-scale-wrap {
  flex: 0 0 auto;
  margin: 0 !important;
  overflow: visible;
}
.hand-row .stone-scale-wrap .stone-card {
  transform-origin: top left;
}
/* Opponent hand: face-down backs + count badge */
.slot-hand .slot-body,
.hand-cell .slot-body {
  position: relative;
}
.hand-count {
  position: absolute;
  top: 2px;
  right: 4px;
  z-index: 8;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.88);
  border: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 0.65rem;
  display: grid;
  place-items: center;
  color: var(--text);
  pointer-events: none;
}
.hand-row-opp .stone-scale-wrap.opp-hand {
  cursor: default;
}
.hand-row-opp .stone-card.card-back {
  /* Ensure backs stay opaque even if a face snuck in via CSS */
  background-color: #3a342e;
}

.stack-pile {
  position: relative;
  width: var(--cw);
  height: var(--ch);
}
.stack-pile.deck-clickable {
  cursor: pointer;
  border-radius: 6px;
}
.stack-pile.deck-clickable:hover {
  filter: brightness(1.12);
  box-shadow: 0 0 0 2px var(--accent);
}
.stack-pile.deck-clickable::after {
  content: "DRAW";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  color: rgba(245, 230, 200, 0.85);
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 9;
}
.stack-pile.deck-clickable:hover::after { opacity: 1; }
.stack-count {
  position: absolute;
  right: -3px;
  bottom: -3px;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.88);
  border: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  z-index: 8;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.stone-scale-wrap.picked {
  /* Modal pick — neutral, not yellow selection */
  outline: 2px solid rgba(160, 170, 180, 0.75);
  outline-offset: 1px;
  border-radius: 6px;
}

/* Owner face-down peek: soft cue on board backs you may hover */
.stone-scale-wrap.own-facedown-peek {
  cursor: help;
}
.stone-scale-wrap.own-facedown-peek:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 0 2px rgba(212, 168, 75, 0.45);
  border-radius: 4px;
}

/* Floating 2× in-hand face preview by cursor (any face-up card; owner face-down peeks too) */
.card-hover-preview,
.facedown-hover-preview {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  border-radius: 8px;
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(212, 168, 75, 0.35);
  overflow: hidden;
}
.card-hover-previewable {
  /* no layout change — cursor feedback only */
}
.facedown-hover-preview .stone-scale-wrap {
  pointer-events: none;
}
.facedown-hover-preview .stone-card {
  transform-origin: top left;
  cursor: default;
}

/* Far-right multiplayer chat */
.chat-panel {
  grid-row: 1;
  grid-column: 2;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: rgba(12, 10, 8, 0.96);
  z-index: 6;
}
.chat-head {
  flex-shrink: 0;
  padding: 0.4rem 0.55rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}
.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.45rem 0.5rem;
  font-size: 0.82rem;
  line-height: 1.35;
}
.chat-line {
  margin-bottom: 0.4rem;
  word-wrap: break-word;
}
.chat-line .chat-who {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-right: 0.25rem;
}
.chat-line.chat-system {
  color: #e8c87a;
  font-style: italic;
  border-left: 2px solid rgba(212, 168, 75, 0.55);
  padding-left: 0.4rem;
}
.chat-line.chat-system .chat-who {
  color: #e8c87a;
}
/* Card name “links” in chat — bold, hover shows card preview */
.chat-card-link {
  font-weight: 700;
  font-style: normal;
  color: inherit;
  cursor: help;
  text-decoration: underline;
  text-decoration-color: rgba(212, 168, 75, 0.55);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.chat-card-link:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
.chat-line.chat-system .chat-card-link {
  color: #f0d9a0;
}
.chat-line.chat-system .chat-card-link:hover {
  color: #fff1c4;
}
.draft-curse-observe-note {
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 0.35rem 0.5rem;
}
.chat-form {
  flex-shrink: 0;
  display: flex;
  gap: 0.3rem;
  padding: 0.4rem;
  border-top: 1px solid var(--border);
}
.chat-form input {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  padding: 0.35rem 0.45rem;
}
.chat-form .btn {
  flex-shrink: 0;
  padding: 0.35rem 0.5rem;
}

/* Attack arrow overlay — does not move slots */
.attack-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
  overflow: visible;
}
.attack-overlay .attack-line {
  fill: none;
  stroke: #f0c14b;
  stroke-width: 3.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(240, 193, 75, 0.85));
  stroke-dasharray: 12 8;
  animation: attack-dash 0.45s linear infinite;
}
.attack-overlay .attack-head {
  fill: #f0c14b;
  filter: drop-shadow(0 0 4px rgba(240, 193, 75, 0.85));
}
@keyframes attack-dash {
  to { stroke-dashoffset: -40; }
}
/* Aim mode only — no yellow “clicked” selection borders */
.slot.attack-source {
  z-index: 12 !important;
}
.board.attack-aiming .slot.attack-source {
  box-shadow: 0 0 0 2px rgba(232, 93, 76, 0.85), 0 0 12px rgba(232, 93, 76, 0.35) !important;
}
.slot.attack-aim-target {
  cursor: crosshair !important;
}
.slot.attack-aim-target:hover,
.board.attack-aiming .slot:hover {
  box-shadow: 0 0 0 2px #e85d4c, 0 0 14px rgba(232, 93, 76, 0.4);
}
.board.attack-aiming {
  cursor: crosshair;
}

/* Floating action stack: Attack on middle field */
.card-action-stack {
  position: absolute;
  left: 50%;
  bottom: 3px;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: stretch;
  pointer-events: auto;
}
.card-action-stack .btn {
  padding: 0.27rem 0.75rem !important;
  font-size: 0.85rem !important;
  letter-spacing: 0.08em;
  white-space: nowrap;
  min-width: 6.3rem;
  border-width: 1px;
}
.attack-btn {
  background: rgba(120, 30, 24, 0.95) !important;
  border-color: #e85d4c !important;
  color: #ffe8e0 !important;
}
.attack-btn:hover {
  filter: brightness(1.12);
}

/* Screen ping aim mode + reticle for opponent */
body.ping-aiming,
body.ping-aiming * {
  cursor: crosshair !important;
}
.ping-marker {
  position: fixed;
  z-index: 12000;
  width: 72px;
  height: 72px;
  margin-left: -36px;
  margin-top: -36px;
  pointer-events: none;
  color: #f0c14b;
  opacity: 0;
  transform: scale(0.55);
  filter: drop-shadow(0 0 10px rgba(240, 193, 75, 0.85));
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ping-marker.ping-marker-in {
  opacity: 1;
  transform: scale(1);
}
.ping-marker.ping-marker-out {
  opacity: 0;
  transform: scale(1.15);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.ping-marker.ping-seat-0 {
  color: #e53935;
  filter: drop-shadow(0 0 10px rgba(229, 57, 53, 0.85));
}
.ping-marker.ping-seat-1 {
  color: #1e88e5;
  filter: drop-shadow(0 0 10px rgba(30, 136, 229, 0.85));
}
.ping-marker .ping-reticle {
  width: 100%;
  height: 100%;
  display: block;
  stroke: currentColor;
  fill: none;
  animation: ping-pulse 0.9s ease-in-out infinite;
}
@keyframes ping-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.88; }
}
.attack-cancel-hint {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  z-index: 45;
  pointer-events: none;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  background: rgba(12, 10, 8, 0.9);
  border: 1px solid rgba(200, 200, 200, 0.35);
  font-size: 0.75rem;
  color: var(--text);
  white-space: nowrap;
}

.log-drawer {
  max-height: 120px;
  overflow: auto;
  border-top: 1px solid var(--border);
  background: rgba(12, 10, 8, 0.95);
  padding: 0.35rem 0.5rem;
}
.log-drawer.hidden { display: none !important; }
.log-drawer .match-log {
  max-height: 100px;
  font-size: 0.78rem;
}

.slot {
  border: 1px dashed rgba(180, 160, 120, 0.35);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  padding: 0.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
/* Absolute only when used outside the duel grid (custom templates / editor) */
.board:not(.legends-duel-board) > .slot {
  position: absolute;
  min-width: 80px;
  min-height: 110px;
}
/* Match play: no yellow “clicked slot” chrome (editor still uses .selected) */
.play-board .slot.selected {
  border-color: inherit;
  box-shadow: none;
}
.slot.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.slot.drop-target {
  border-color: #6dce8a;
  background: rgba(60, 120, 80, 0.18);
}
.slot-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}
.slot-meta {
  font-size: 0.75rem;
  color: var(--muted);
  pointer-events: none;
}
/* Empty pile/zone titles: large, single-line, padded inside the zone */
.abs-play-board .slot-meta {
  font-family: var(--font-display);
  font-weight: 600;
  /* Longest: "Market Pile" / "Trap bag" / "Banished" — one line with ~5% side gap */
  font-size: clamp(1.1rem, 11.5cqi, 1.6rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(232, 224, 212, 0.78);
  text-align: center;
  white-space: nowrap;
  max-width: 90%;
  padding: 0.25em 0.2em;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: clip;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}
.slot-body {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slot-hand {
  min-width: 0;
  border-style: solid;
  border-color: rgba(180, 160, 120, 0.28);
}
.slot-fd {
  background: rgba(0, 0, 0, 0.32);
}
/* (hand-row rules live with duel board styles above) */
/* Flip control sits on the card face (lower-right), not under the zone */
.stone-scale-wrap.has-flip-btn {
  position: relative;
}
.flip-btn,
.flip-btn.flip-on-card {
  position: absolute;
  right: 3px;
  bottom: 3px;
  z-index: 20;
  padding: 0.18rem 0.42rem;
  font-size: 0.78rem;
  pointer-events: auto !important;
  line-height: 1.1;
  margin: 0;
  border-width: 1px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
/* Card drag surface must not cover the flip control */
.stone-scale-wrap.has-flip-btn .stone-card {
  pointer-events: none;
}
.stone-scale-wrap.has-flip-btn {
  pointer-events: auto;
}
.stone-scale-wrap.has-flip-btn .flip-btn {
  pointer-events: auto !important;
}
.slot .slot-label {
  pointer-events: none;
  font-size: 0.55rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field-cell .slot-body,
.market-cell .slot-body,
.bag-cell .slot-body,
.purg-cell .slot-body,
.pile-cell .slot-body {
  min-height: 0;
}
.field-cell .pt-card,
.market-cell .pt-card {
  width: min(var(--c-w), 92%);
  aspect-ratio: 5 / 7;
  height: auto;
  max-height: calc(100% - 4px);
}

.duel-editor-note {
  padding: 0.65rem 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.duel-editor-list {
  overflow: auto;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.duel-editor-row {
  text-align: left;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  font-family: var(--font-body);
}
.duel-editor-row:hover { border-color: var(--border); }
.duel-editor-row.selected {
  border-color: var(--accent);
  background: rgba(212, 168, 75, 0.08);
}
.editor-duel-preview {
  display: flex;
  flex-direction: column;
}

/* Legacy pt-card removed — board uses Lab .stone-card faces with real art */

/* (legacy side life/hand strip removed — HUD chips + on-table hands) */

.match-log {
  flex: 0 0 120px;
  overflow: auto;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.match-log div { margin-bottom: 0.25rem; }

.inspect-panel {
  flex: 1;
  overflow: auto;
  font-size: 0.92rem;
}
.inspect-panel .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.editor-side {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.slot-props {
  font-size: 0.92rem;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.slot-props .field { padding-left: 0; padding-right: 0; }
.slot-props input[type="number"] {
  width: 100%;
  font-variant-numeric: tabular-nums;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-card {
  width: min(720px, 100%);
  max-height: min(80vh, 640px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.modal-body {
  padding: 0.75rem;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 1;
}
.modal-body .stone-scale-wrap {
  cursor: pointer;
  --stone-scale: 0.36;
  width: calc(300px * 0.36);
  height: calc(420px * 0.36);
}
.modal-body .stone-scale-wrap .stone-card {
  transform: scale(0.36);
}
.modal-body .stone-scale-wrap.picked {
  outline: 2px solid rgba(160, 170, 180, 0.8);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.45);
}
/* Curse pick: ~2× stack-modal card size so text is readable */
.modal-card.curse-pick-modal {
  width: min(1100px, 98vw);
  max-height: min(92vh, 820px);
}
.modal-body.curse-pick-body {
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem 1rem;
  flex-wrap: wrap;
  overflow: auto;
}
.modal-body.curse-pick-body .stone-scale-wrap {
  cursor: pointer;
  --stone-scale: 0.72;
  width: calc(300px * 0.72);
  height: calc(420px * 0.72);
  transition: transform 0.12s, box-shadow 0.12s;
}
.modal-body.curse-pick-body .stone-scale-wrap .stone-card {
  transform: scale(0.72);
  transform-origin: top left;
}
.modal-body.curse-pick-body .stone-scale-wrap:hover {
  transform: translateY(-6px);
}
.modal-body.curse-pick-body .stone-scale-wrap.picked {
  outline: 3px solid #b03040;
  box-shadow: 0 0 0 1px rgba(176, 48, 64, 0.4), 0 16px 36px rgba(0, 0, 0, 0.55);
}
/* Recruit modal: draft-style even rows/cols; scrolls when many faces */
.modal-card.worship-pick-modal {
  width: min(1280px, 98vw);
  max-height: min(92vh, 960px);
  overflow: hidden;
}
.modal-body.worship-pick-body {
  display: block !important;
  padding: 1rem 1.15rem;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  -webkit-overflow-scrolling: touch;
}
.modal-body.worship-pick-body .worship-pick-grid {
  display: grid;
  justify-content: center;
  align-content: start;
  justify-items: center;
  align-items: start;
  gap: 0.85rem 1.1rem;
  width: 100%;
}
.modal-body.worship-pick-body .stone-scale-wrap {
  --stone-scale: 0.68;
  width: calc(300px * 0.68) !important;
  height: calc(420px * 0.68) !important;
  flex: 0 0 auto;
}
.modal-body.worship-pick-body .stone-scale-wrap .stone-card {
  transform: scale(0.68) !important;
  transform-origin: top left;
}
.modal-body.worship-pick-body .stone-scale-wrap:hover {
  transform: translateY(-4px);
}
.modal-body.worship-pick-body .stone-scale-wrap.picked {
  outline: 3px solid var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim), 0 14px 32px rgba(0, 0, 0, 0.55);
}

/* Recruit + Reroll under/over market pile (width set in JS to match cardback) */
.worship-btn,
.recruit-btn,
.reroll-market-btn {
  padding: 0.62rem 0.35rem !important;
  font-size: 1.05rem !important;
  letter-spacing: 0.12em;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  text-transform: uppercase;
  font-family: var(--font-display);
  font-weight: 700;
  box-sizing: border-box;
  text-align: center;
  line-height: 1.15;
}
.worship-btn:hover,
.recruit-btn:hover,
.reroll-market-btn:hover {
  filter: brightness(1.08);
}
.bag-column-top-stack {
  pointer-events: none;
  gap: 0.4rem !important;
}
.bag-column-top-stack .reroll-market-btn {
  pointer-events: auto;
}
/* Market Pile title — sized to span cardback width */
.bag-column-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(232, 224, 212, 0.9);
  white-space: nowrap;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bag-column-label-market {
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  font-weight: 800;
}
.token-dest-note {
  width: 100%;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.token-select-hint {
  width: 100%;
  flex: 0 0 100%;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.35rem;
}
.modal-body.token-pick-body .stone-scale-wrap.picked {
  outline: 3px solid var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim), 0 14px 32px rgba(0, 0, 0, 0.55);
}
.modal-body.token-pick-body .stone-scale-wrap:not(.picked) {
  opacity: 0.55;
  filter: grayscale(0.15);
}
.worship-draw-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: auto;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.worship-draw-opt input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}
.worship-draw-opt.is-disabled {
  opacity: 0.45;
}
.worship-draw-opt.is-disabled input {
  cursor: not-allowed;
}
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.65rem 0.9rem 0.85rem;
  border-top: 1px solid var(--border);
}

.room-code-label {
  cursor: pointer;
  border-radius: 3px;
  transition: color 0.12s ease, background 0.12s ease;
}
.room-code-label:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.room-code-label.copied {
  color: var(--accent);
}

/* Resize handle fallback (match + legacy) */
.slot .resize-handle {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  cursor: se-resize;
  opacity: 0.6;
}
.slot.editor-slot.dragging .slot-label {
  color: var(--accent);
}
