:root {
  color-scheme: dark;
  --ink: #f3e7d3;
  --muted: #bba58a;
  --night: #211810;
  --panel: #2d2118;
  --panel-2: #3b2b1e;
  --line: rgba(218,188,163, 0.18);
  --gold: #d8ae70;
  --gold-soft: rgba(210,174,144, 0.15);
  --ember: #ce805e;
  --ember-soft: rgba(255,122,69, 0.16);
  --danger: #c76e56;
  --shadow: 0 26px 70px rgba(0,0,0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { height: 100%; overflow: hidden; }
body { margin: 0; min-width: 320px; height: 100vh; height: 100dvh; overflow: hidden; color: var(--ink); background: radial-gradient(circle at 50% -10%, #402b1a 0, var(--night) 48%, #17110c 100%); }
#app { height: 100%; min-height: 0; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, [role="button"]:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }

.entry-shell { height: 100%; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr); overflow: hidden; }
.brand-panel { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: clamp(3rem, 8vw, 8rem); border-right: 1px solid var(--line); }
.brand-panel::before { content: ""; position: absolute; width: 44rem; height: 44rem; right: -17rem; top: -12rem; background: repeating-radial-gradient(circle, transparent 0 48px, rgba(210,174,144,.06) 49px 50px); transform: rotate(-12deg); }
.brand-panel > * { position: relative; z-index: 1; }
.brand-mark { display: flex; gap: .35rem; margin-bottom: 2rem; }
.brand-mark span { width: 1.15rem; height: 1.3rem; background: var(--gold); clip-path: polygon(25% 6%,75% 6%,100% 50%,75% 94%,25% 94%,0 50%); opacity: .28; }
.brand-mark span:nth-child(2) { opacity: .66; }
.brand-mark span:nth-child(3) { opacity: 1; }
.eyebrow { margin: 0 0 .6rem; color: var(--gold); font-size: .75rem; font-weight: 750; letter-spacing: .18em; text-transform: uppercase; }
h1 { margin: 0; max-width: 9ch; font-family: Georgia, "Times New Roman", serif; font-size: clamp(4.4rem, 10vw, 9rem); font-weight: 500; line-height: .78; letter-spacing: -.07em; }
h1 em { color: transparent; -webkit-text-stroke: 1.5px var(--gold); font-style: italic; }
.lede { max-width: 34rem; margin: 2rem 0 0; color: #d0c2b7; font-size: clamp(1rem, 1.8vw, 1.25rem); line-height: 1.65; }
.faction-preview { display: flex; align-items: center; gap: 1rem; margin-top: 4rem; }
.sigil { width: 4rem; aspect-ratio: 1; display: grid; place-items: center; clip-path: polygon(25% 5%,75% 5%,100% 50%,75% 95%,25% 95%,0 50%); font-family: Georgia, serif; font-size: 1.5rem; font-weight: 800; }
.sigil-bastion { color: var(--gold); background: var(--gold-soft); }
.sigil-ember { color: var(--ember); background: var(--ember-soft); }
.versus { color: var(--muted); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; }
.join-panel { min-height: 0; display: flex; flex-direction: column; justify-content: safe center; gap: 1.15rem; padding: clamp(1rem, 4vh, 3rem) clamp(1rem, 4vw, 4rem); overflow-y: auto; background: rgba(18,12,7, .62); backdrop-filter: blur(16px); }
.join-panel > * { flex-shrink: 0; }
.connection-line { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .85rem; }
.status-dot { width: .55rem; height: .55rem; border-radius: 50%; background: #7d6f64; box-shadow: 0 0 0 4px rgba(125,111,100,.1); }
.status-dot.online { background: #b1b982; box-shadow: 0 0 0 4px rgba(85,228,156,.1); }
.field { display: grid; gap: .45rem; color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.field input { width: 100%; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: .45rem; color: var(--ink); background: #1a110a; font-size: 1rem; letter-spacing: normal; text-transform: none; }
.deck-picker { display: grid; gap: .65rem; margin: .2rem 0; padding: 0; border: 0; }
.deck-picker legend { margin-bottom: .6rem; color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.deck-option { position: relative; cursor: pointer; }
.deck-option input { position: absolute; opacity: 0; }
.deck-option span { display: grid; gap: .2rem; padding: 1rem; border: 1px solid var(--line); border-radius: .5rem; background: rgba(255,255,255,.025); transition: .16s ease; }
.deck-option strong { font-family: Georgia, serif; font-size: 1.03rem; }
.deck-option small { color: var(--muted); font-size: .78rem; }
.bastion-option input:checked + span { border-color: rgba(210,174,144,.72); background: var(--gold-soft); box-shadow: inset 3px 0 var(--gold); }
.ember-option input:checked + span { border-color: rgba(255,122,69,.72); background: var(--ember-soft); box-shadow: inset 3px 0 var(--ember); }
.primary-button, .secondary-button, .danger-button, .quiet-button, .pass-button, .action-button { min-height: 2.8rem; border: 0; border-radius: .42rem; cursor: pointer; font-weight: 760; transition: transform .12s ease, filter .12s ease, opacity .12s ease; }
.primary-button { background: var(--gold); color: #2b1b0d; }
.secondary-button { padding: 0 1.2rem; border: 1px solid var(--line); background: #2e1f13; }
.danger-button { background: rgba(255,89,109,.15); color: #e4a187; }
.quiet-button { background: transparent; color: var(--muted); }
button:not(:disabled):hover { filter: brightness(1.12); transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .42; }
.join-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: .6rem; }
.match-option { min-width: 0; margin: 0; padding: 0; border: 0; }
.match-option legend { margin-bottom: .45rem; padding: 0; color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.segmented-control { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .2rem; padding: .25rem; border: 1px solid var(--line); border-radius: .5rem; background: #1a110a; }
.segmented-control label { position: relative; min-width: 0; cursor: pointer; }
.segmented-control input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.segmented-control span { display: grid; place-items: center; min-height: 2.6rem; padding: .45rem .2rem; border-radius: .3rem; color: var(--muted); font-size: .82rem; font-weight: 700; transition: background .15s ease, color .15s ease; }
.segmented-control label:hover span { color: var(--ink); background: var(--gold-soft); }
.segmented-control input:checked + span { color: #2b1b0d; background: var(--gold); box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.segmented-control input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: -3px; }
.error-text { min-height: 1.3rem; margin: 0; color: #e4a187; font-size: .86rem; }

.game-shell {
  --topbar-height: 3.4rem;
  --action-dock-height: 4.2rem;
  height: 100%; min-height: 0; overflow: hidden; display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr) var(--action-dock-height);
  grid-template-columns: 100%;
  background: radial-gradient(circle at 50% 38%, #332215 0, #150e09 58%, #0d0905 100%);
}
.game-shell > * { min-width: 0; min-height: 0; }
.topbar {
  grid-row: 1;
  grid-column: 1;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(16,11,7,.92);
  backdrop-filter: blur(14px);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.topbar-center { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: .65rem; min-width: 0; justify-content: flex-end; }
.wordmark { font-family: Georgia, serif; font-size: .92rem; font-weight: 800; letter-spacing: .12em; }
.wordmark span { color: var(--gold); }
.wordmark { justify-self: start; padding: .4rem 0; border: 0; background: transparent; cursor: pointer; text-align: left; }
.room-chip { cursor: pointer; display: flex; align-items: baseline; gap: .45rem; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; }
.room-chip strong { color: var(--ink); font-size: .92rem; letter-spacing: .13em; }

.turn-chronometer { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; }
.turn-clock { display: flex; align-items: center; gap: .45rem; padding: .2rem .75rem; border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.03); transition: .2s ease; }
.turn-clock .clock-pulse { width: .65rem; height: .65rem; border: 2px solid #726052; border-radius: 50%; }
.turn-clock.running { border-color: rgba(210,174,144,.4); background: var(--gold-soft); }
.turn-clock.running .clock-pulse { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(210,174,144,.15); }
.turn-clock.danger { border-color: rgba(255,89,109,.6); background: rgba(255,89,109,.15); }
.turn-clock.danger .clock-pulse { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(255,89,109,.2); }
#turn-clock-time { font-family: system-ui, -apple-system, sans-serif; font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .04em; color: var(--ink); }
.turn-clock.running #turn-clock-time { color: var(--gold); }
.turn-clock.danger #turn-clock-time { color: var(--danger); }
#turn-player-label { margin-top: .15rem; font-size: .68rem; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); transition: color .15s ease; }
#turn-player-label.yours { color: var(--gold); }

.topbar-actions { display: flex; align-items: center; gap: .65rem; }
.phase-banner { padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: .77rem; font-weight: 720; }
.phase-banner.yours { color: var(--gold); border-color: rgba(210,174,144,.38); background: var(--gold-soft); }
.icon-button { width: 2.3rem; height: 2.3rem; border: 1px solid var(--line); border-radius: .4rem; background: transparent; cursor: pointer; letter-spacing: .1em; }

.battlefield-shell { grid-row: 2; grid-column: 1; position: relative; min-width: 0; min-height: 0; width: 100%; height: 100%; overflow: hidden; }
.board-frame { position: absolute; inset: 0; min-width: 0; min-height: 0; width: 100%; height: 100%; overflow: hidden; }

.board-controls {
  position: absolute;
  z-index: 10;
  right: .8rem;
  top: .8rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: auto;
}

.stack-widget {
  position: relative;
  width: min(20rem, calc(100vw - 2rem));
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.stack-popover-card {
  position: relative;
  background: rgba(22, 14, 9, 0.94);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(210, 174, 144, 0.35);
  border-radius: 10px;
  padding: .65rem .85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  user-select: none;
}
.stack-popover-card:hover, .stack-popover-card:focus-visible {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(255, 209, 105, 0.25), 0 8px 24px rgba(0,0,0,0.6);
  outline: none;
}
.stack-popover-card.has-items {
  border-color: rgba(255, 209, 105, 0.65);
  box-shadow: 0 0 16px rgba(255, 209, 105, 0.2), 0 8px 24px rgba(0,0,0,0.6);
}

.stack-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .35rem;
}
.stack-card-tag {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gold);
}
.stack-icon-mini {
  width: .9rem;
  height: .9rem;
  color: var(--gold);
}
.stack-badge {
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 .35rem;
  border-radius: 999px;
  background: #2f2115;
  border: 1px solid var(--line);
  font-size: .68rem;
  font-weight: 800;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.stack-popover-card.has-items .stack-badge {
  background: var(--gold);
  color: #1c1108;
  border-color: #ffd169;
  box-shadow: 0 0 8px rgba(255,209,105,.6);
  animation: stack-pulse 2s infinite ease-in-out;
}
@keyframes stack-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); box-shadow: 0 0 12px rgba(255,209,105,.9); }
}

.stack-top-content {
  min-height: 1.8rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stack-empty-hint {
  margin: 0;
  font-size: .75rem;
  color: var(--muted);
  font-style: italic;
}

.stack-action-preview {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.stack-action-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  font-size: .7rem;
}
.stack-controller-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-weight: 600;
  color: var(--seat-color, var(--gold));
}
.stack-speed-tag {
  padding: .1rem .35rem;
  border-radius: .25rem;
  font-size: .6rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .05em;
}
.stack-speed-tag.speed-fast {
  background: rgba(80, 200, 120, 0.15);
  color: #50c878;
  border: 1px solid rgba(80, 200, 120, 0.35);
}
.stack-speed-tag.speed-slow {
  background: rgba(255, 165, 0, 0.15);
  color: #ffa500;
  border: 1px solid rgba(255, 165, 0, 0.35);
}
.stack-action-title {
  font-size: .84rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.stack-action-body {
  font-size: .78rem;
  line-height: 1.35;
  color: rgba(240, 235, 230, 0.95);
}
.stack-more-hint {
  margin-top: .35rem;
  padding-top: .35rem;
  border-top: 1px dashed rgba(255,255,255,0.1);
  font-size: .68rem;
  color: var(--gold);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stack-tray {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  width: 100%;
  max-height: 55dvh;
  background: rgba(16, 10, 6, 0.97);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(210, 174, 144, 0.45);
  border-radius: 10px;
  padding: .8rem;
  box-shadow: 0 12px 36px rgba(0,0,0,0.75);
  display: flex;
  flex-direction: column;
  gap: .6rem;
  z-index: 20;
  overflow: hidden;
  animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.stack-tray[hidden] {
  display: none;
}
.stack-tray-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: .4rem;
}
.stack-tray-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  padding: .2rem .4rem;
  border-radius: .25rem;
}
.stack-tray-close:hover {
  color: var(--ink);
  background: rgba(255,255,255,0.08);
}

.stack-trigger-layer {
  position: absolute;
  bottom: calc(100% + .5rem);
  right: 0;
  width: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column-reverse;
  gap: .5rem;
  z-index: 30;
}
.trigger-dissolve-card {
  background: rgba(24, 15, 10, 0.96);
  backdrop-filter: blur(14px);
  border: 1.5px solid #00d2ff;
  border-radius: 8px;
  padding: .65rem .8rem;
  box-shadow: 0 0 16px rgba(0, 210, 255, 0.45), 0 8px 24px rgba(0,0,0,0.6);
  color: var(--ink);
  pointer-events: auto;
  animation: trigger-pop-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.trigger-dissolve-card.dissolving {
  animation: trigger-dissolve 0.85s forwards cubic-bezier(0.25, 1, 0.5, 1);
}
.trigger-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
  color: #00d2ff;
}
.trigger-title {
  font-size: .82rem;
  font-weight: 700;
  color: #e0f7ff;
}
.trigger-body {
  font-size: .75rem;
  line-height: 1.35;
  color: rgba(240, 245, 255, 0.95);
}
.trigger-status {
  font-size: .65rem;
  color: #00d2ff;
  font-weight: 700;
  text-align: right;
  letter-spacing: .06em;
  text-transform: uppercase;
}

@keyframes trigger-pop-in {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes trigger-dissolve {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px) brightness(1.2);
  }
  35% {
    opacity: 0.95;
    transform: translateY(-8px) scale(1.02);
    filter: blur(2px) brightness(2.0);
    box-shadow: 0 0 24px rgba(0, 210, 255, 0.8);
  }
  100% {
    opacity: 0;
    transform: translateY(-24px) scale(0.9);
    filter: blur(10px) brightness(2.5);
  }
}

/* Opponents HUD: Vertically centered on the very left */
.opponents-hud {
  position: absolute;
  z-index: 15;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: .85rem;
  align-items: center;
  pointer-events: auto;
}

.opponent-avatar-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.opponent-head-btn {
  position: relative;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 2px solid var(--seat-color);
  background: rgba(20, 14, 9, .88);
  backdrop-filter: blur(10px);
  color: var(--seat-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  box-shadow: 0 4px 14px rgba(0,0,0,.5);
}

.opponent-head-btn:hover, .opponent-head-btn:focus-visible {
  transform: scale(1.1);
  box-shadow: 0 0 16px var(--seat-color), 0 4px 16px rgba(0,0,0,.6);
}

.opponent-head-btn .head-svg {
  width: 1.45rem;
  height: 1.45rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.opponent-head-btn .head-seat-tag {
  position: absolute;
  bottom: -3px;
  right: -3px;
  font-size: .55rem;
  font-weight: 850;
  padding: .05rem .25rem;
  border-radius: 999px;
  background: #18100a;
  border: 1px solid var(--seat-color);
  color: var(--seat-color);
  line-height: 1;
}

.opponent-avatar-wrap.has-priority .opponent-head-btn {
  box-shadow: 0 0 14px var(--seat-color), 0 0 4px #fff;
  animation: head-turn-pulse 1.8s infinite ease-in-out;
}

@keyframes head-turn-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 12px var(--seat-color); }
  50% { transform: scale(1.08); box-shadow: 0 0 20px var(--seat-color), 0 0 8px rgba(255,255,255,.5); }
}

.opponent-avatar-wrap.eliminated .opponent-head-btn {
  opacity: .4;
  filter: grayscale(.7);
}

/* Flyout information tab towards the right */
.opponent-info-tab {
  position: absolute;
  left: calc(100% + .75rem);
  top: 50%;
  transform: translateY(-50%) translateX(-8px);
  min-width: 12.5rem;
  padding: .75rem .85rem;
  border: 1px solid var(--seat-color);
  border-radius: .6rem;
  background: rgba(18, 12, 7, .96);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 24px rgba(0,0,0,.7), 0 0 12px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  gap: .5rem;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
  z-index: 25;
}

.opponent-avatar-wrap.open .opponent-info-tab {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

.tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding-bottom: .35rem;
}

.tab-player-title {
  display: flex;
  align-items: center;
  gap: .45rem;
  min-width: 0;
}

.tab-player-name {
  font-family: Georgia, serif;
  font-weight: 700;
  font-size: .88rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 7.5rem;
}

.tab-status-badge {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

.tab-status-badge.active {
  color: var(--gold);
}

.tab-status-badge.eliminated {
  color: var(--danger);
}

.tab-body {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.resource-pills { display: flex; gap: .3rem; font-size: .7rem; font-weight: 750; }
.resource-pill { padding: .15rem .45rem; border-radius: 4px; }
.pill-action { color: var(--gold); background: rgba(210,174,144,.15); }
.pill-bonus { color: #60a5fa; background: rgba(96,165,250,.15); }
.connection-dot { width: .55rem; height: .55rem; border-radius: 50%; flex-shrink: 0; }
.connection-dot.connected { background: #4ade80; box-shadow: 0 0 6px rgba(74,222,128,.6); }
.connection-dot.lagging { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,.6); }
.connection-dot.disconnected { background: #ef4444; box-shadow: 0 0 6px rgba(239,68,68,.6); }

.stats-row { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .7rem; }
.stat-pill { padding: .35rem .5rem; border: 1px solid var(--line); border-radius: .3rem; font-size: .72rem; }
#board { display: block; width: 100%; height: 100%; min-height: 0; touch-action: none; overscroll-behavior: contain; user-select: none; cursor: grab; }
#board.panning, #board.panning .entity { cursor: grabbing; }
#board:focus-visible { outline: 2px solid var(--gold); outline-offset: -3px; }
.intention-layer { pointer-events: none; }
.hex polygon { fill: rgba(41,28,17,.55); stroke: rgba(199,155,119,.22); stroke-width: 1; transition: .12s ease; }
.hex.alternate polygon { fill: rgba(46,31,19,.68); }
.hex.choice polygon { fill: rgba(210,174,144,.16); stroke: var(--gold); stroke-width: 1.6; cursor: pointer; }
.hex.choice:hover polygon { fill: rgba(210,174,144,.3); }
body.dragging-card .hex.choice polygon { fill: rgba(246,203,91,.24) !important; stroke: var(--gold) !important; stroke-width: 2.2 !important; filter: drop-shadow(0 0 5px rgba(246,203,91,.45)); }
.hex.drop-target-hex polygon { fill: rgba(246,203,91,.52) !important; stroke: #ffffff !important; stroke-width: 3.2 !important; filter: drop-shadow(0 0 10px rgba(246,203,91,.95)) !important; }
.hex text { fill: rgba(217,194,176,.34); font-size: 7px; pointer-events: none; }
.entity { cursor: pointer; }
.entity .unit-shape { fill: #442e1c; stroke: var(--gold); stroke-width: 2; }
.entity.enemy .unit-shape { fill: #48251d; stroke: var(--ember); }
.entity .building-shape { fill: #392617; stroke: #be8c63; stroke-width: 1.5; }
.entity.enemy .building-shape { fill: #38251f; stroke: #b77b62; }
.entity text { fill: var(--ink); font-size: 10px; font-weight: 800; text-anchor: middle; pointer-events: none; }
.entity .health-text { font-size: 7px; fill: #dfd4cb; }
.entity .owner-text { font-size: 7px; fill: var(--piece-color); paint-order: stroke; stroke: #211810; stroke-width: 2px; }
.entity .unit-shape, .entity.enemy .unit-shape, .entity .building-shape, .entity.enemy .building-shape { stroke: var(--piece-color); fill: color-mix(in srgb, var(--piece-color) 24%, #211810); }
.action-indicator-ring {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2.2px;
  stroke-dasharray: 4 2.5;
  animation: action-ring-spin 8s linear infinite;
  pointer-events: none;
  filter: drop-shadow(0 0 4px rgba(216, 174, 112, 0.75));
}
@keyframes action-ring-spin {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: 26; }
}
.entity.can-act {
  filter: drop-shadow(0 0 5px rgba(216, 174, 112, 0.45));
}
.entity.selected .unit-shape, .entity.selected .building-shape { filter: drop-shadow(0 0 7px var(--gold)); stroke-width: 3; }
.entity.choice .unit-shape, .entity.choice .building-shape { stroke: #fff; stroke-dasharray: 3 2; }
.entity.choice-picked .unit-shape, .entity.choice-picked .building-shape { fill: #69472b; stroke: #e2be7c; stroke-width: 3; stroke-dasharray: none; filter: drop-shadow(0 0 7px rgba(255,209,105,.75)); }
.entity.enemy.choice-picked .unit-shape { fill: #713421; }
.intention { fill: none; stroke: #e2be7c; stroke-width: 2.3; stroke-dasharray: 6 4; marker-end: url(#arrowhead); filter: drop-shadow(0 0 4px rgba(255,209,105,.45)); }
.choice-panel { position: fixed; z-index: 12; left: 1.25rem; right: auto; bottom: calc(var(--action-dock-height) + .75rem); display: flex; flex-direction: column; width: min(22rem, calc(100% - 2.5rem)); max-height: calc(100dvh - var(--action-dock-height) - 5rem); overflow: hidden; padding: .9rem; border: 1px solid rgba(210,174,144,.45); border-radius: .55rem; background: rgba(19,13,8,.96); box-shadow: var(--shadow); }
.choice-panel h3 { margin: 0 0 .25rem; font-family: Georgia, serif; }
.choice-panel p { margin: 0 0 .7rem; color: var(--muted); font-size: .78rem; }
.choice-options { display: grid; gap: .4rem; min-height: 0; overflow-y: auto; }
.choice-option { padding: .65rem .7rem; border: 1px solid var(--line); border-radius: .35rem; text-align: left; background: #2b1d12; cursor: pointer; }
.choice-option.selected { border-color: var(--gold); background: var(--gold-soft); }
.choice-actions { display: flex; flex-shrink: 0; gap: .5rem; margin-top: .7rem; }
.stack-list { min-height: 0; display: grid; gap: .45rem; overflow: auto; }
.stack-item { padding: .6rem; border-left: 2px solid var(--gold); background: rgba(255,255,255,.035); font-size: .78rem; }
.stack-item.cancelled { border-color: var(--danger); opacity: .55; }
.stack-item.choice { cursor: pointer; border-color: #e2be7c; background: rgba(255,209,105,.09); }
.stack-item.choice:hover, .stack-item.choice:focus-visible { background: rgba(255,209,105,.17); }
.seat-badge { display: inline-grid; place-items: center; flex-shrink: 0; min-width: 1.6rem; height: 1.4rem; border: 1px solid var(--seat-color); border-radius: .25rem; color: var(--seat-color); font: 700 .65rem system-ui; }
.opponent-summary { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.opponent-summary.eliminated { opacity: .5; }
.opponent-summary.has-priority { background: var(--gold-soft); }
.waiting-roster { display: grid; gap: .5rem; margin: .4rem 0 1rem; padding: 0; list-style: none; font-size: .85rem; }
.waiting-roster li { display: flex; align-items: center; justify-content: center; gap: .6rem; }
.hand-zone {
  grid-row: 2;
  grid-column: 1;
  position: relative;
  z-index: 6;
  pointer-events: none;
  padding: .1rem 1rem 0;
  margin-top: auto;
  align-self: end;
  display: flex;
  justify-content: center;
  background: transparent;
}
.hand-fan-wrapper { pointer-events: auto; width: 100%; max-width: min(920px, 88vw); display: flex; flex-direction: column; align-items: center; }
.hand-heading { display: flex; gap: .5rem; align-items: center; font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: .2rem .65rem; border-radius: 999px; background: rgba(17,11,7,.75); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.05); margin-bottom: .2rem; }
.hand { min-height: 9.8rem; height: clamp(9.8rem, 20dvh, 12.8rem); display: flex; justify-content: center; align-items: flex-end; padding: 2.2rem 1.5rem .5rem; overflow: visible; perspective: 1000px; width: 100%; }
.card {
  position: relative;
  flex: 0 0 8.8rem;
  height: 10.8rem;
  margin-inline: -1.25rem;
  border-radius: .55rem;
  border: 1px solid rgba(210,174,144,.28);
  background: linear-gradient(155deg, #2b1c11, #160e08);
  cursor: pointer;
  user-select: none;
  transform-origin: 50% 120%;
  transform: translateY(var(--fan-y, 0px)) rotate(var(--fan-angle, 0deg));
  transition: transform .22s cubic-bezier(.18,.89,.32,1.28), box-shadow .22s ease, border-color .22s ease;
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
}
.card:hover, .card.card-hovered, .card:focus-visible {
  transform: translateY(-48px) scale(1.22) rotate(0deg) !important;
  z-index: 80 !important;
  border-color: var(--card-accent, var(--gold));
  box-shadow: 0 16px 36px rgba(0,0,0,.75), 0 0 18px var(--card-accent, var(--gold));
}
.card:hover::after, .card.card-hovered::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  bottom: -85px;
  pointer-events: auto;
  z-index: -1;
}
.card.selected { transform: translateY(-34px) scale(1.14) rotate(0deg); z-index: 60; border-color: var(--gold); box-shadow: 0 12px 28px rgba(0,0,0,.6), 0 0 14px var(--gold); }
.card.mulligan-selected { transform: translateY(-28px) rotate(0deg); box-shadow: 0 0 0 2px var(--danger), 0 10px 24px rgba(0,0,0,.6); opacity: .75; }
.card-art { height: 3.4rem; display: flex; align-items: flex-end; justify-content: space-between; padding: .55rem; background: radial-gradient(circle at 70% 30%, var(--card-accent, var(--gold)), transparent 12%), repeating-linear-gradient(130deg, transparent 0 16px, rgba(255,255,255,.06) 17px 18px), linear-gradient(145deg, color-mix(in srgb, var(--card-accent, var(--gold)) 25%, #24180f), #150e09); }
.card-type { color: rgba(255,255,255,.72); font-size: .58rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.card-cost { display: grid; place-items: center; min-width: 1.55rem; height: 1.55rem; border-radius: 50%; color: #150e09; background: var(--card-accent, var(--gold)); font-size: .68rem; font-weight: 900; }
.card-cost:has(.cost-circle-action),
.card-cost:has(.cost-triangle-bonus) { display: inline-flex; align-items: center; gap: 3px; background: transparent; border-radius: 0; min-width: auto; height: auto; }
.card-art { min-height: 1.6rem; flex: 0 1 3.4rem; }
.card-body { min-height: 0; flex: 1; display: flex; flex-direction: column; padding: .5rem .62rem; }
.card-body > h3, .card-body > .mini-stats { flex-shrink: 0; }
.card-body > p { min-height: 0; overflow-y: auto; }
.card h3 { margin: 0; font-family: Georgia, serif; font-size: .92rem; line-height: 1.1; }
.card p { margin: .38rem 0 0; color: var(--muted); font-size: .67rem; line-height: 1.35; }
.card .mini-stats { display: flex; gap: .35rem; margin-top: auto; padding-top: .35rem; color: #dccfc5; font-size: .64rem; }
.spell-speed { font-weight: 800; text-transform: capitalize; }
.spell-speed[data-speed="fast"] { color: var(--gold); }
.spell-speed[data-speed="slow"] { color: #e2be7c; }

.action-dock {
  grid-row: 3;
  grid-column: 1;
  z-index: 8;
  display: grid;
  grid-template-columns: auto minmax(9rem, .6fr) minmax(0, 2fr) 8rem;
  align-items: center;
  gap: .75rem;
  padding: .4rem 1.2rem;
  border-top: 1px solid var(--line);
  background: rgba(18,12,7,.95);
  backdrop-filter: blur(12px);
}
.self-hud { display: flex; align-items: center; }
.self-capsule { display: flex; align-items: center; gap: .5rem; padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: rgba(25,17,10,.88); backdrop-filter: blur(10px); font-size: .8rem; }
.self-capsule .player-name { font-family: Georgia, serif; font-weight: 700; color: var(--ink); }

/* Card-shaped Action Pop-Up Panel on right bottom */
.card-action-panel {
  position: fixed;
  z-index: 25;
  right: 1.2rem;
  bottom: calc(var(--action-dock-height, 4.2rem) + .4rem);
  width: 17rem;
  max-height: 24rem;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1.5px solid rgba(216, 174, 112, 0.38);
  background: rgba(22, 15, 10, 0.96);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 16px rgba(216, 174, 112, 0.16);
  overflow: visible;
  animation: panel-pop-in .2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

@keyframes panel-pop-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card-action-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
  padding: .75rem .9rem .5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(216, 174, 112, 0.08) 0%, transparent 100%);
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}

.card-action-title-wrap {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}

.card-action-type {
  font-size: .62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--gold);
}

.card-action-name {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-action-close {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: .85rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all .12s ease;
}

.card-action-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--ink);
  transform: scale(1.1);
}

.card-action-content {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 11rem;
  overflow-y: auto;
  padding: .6rem .8rem;
}

.card-action-list {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.card-action-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .75rem;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: all .14s ease;
  width: 100%;
}

.card-action-item.active {
  border: 1px solid rgba(216, 174, 112, 0.45);
  background: rgba(216, 174, 112, 0.12);
  color: var(--gold);
}

.card-action-item.active:hover {
  background: rgba(216, 174, 112, 0.28);
  border-color: var(--gold);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(216, 174, 112, 0.2);
}

.card-action-item.disabled,
.card-action-item[aria-disabled="true"] {
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  color: #7a6b5e;
  cursor: not-allowed;
  opacity: 0.55;
}

.card-action-item.disabled:hover,
.card-action-item[aria-disabled="true"]:hover {
  transform: none;
  filter: brightness(1.15);
  border-color: rgba(216, 174, 112, 0.25);
}

.action-item-name {
  font-weight: 750;
}

.action-item-cost {
  font-size: .72rem;
  opacity: .9;
  letter-spacing: .02em;
}

.default-action-star {
  color: var(--gold);
  font-size: 1.1em;
  line-height: 1;
  display: inline-block;
  margin-right: .25rem;
  filter: drop-shadow(0 0 4px rgba(246, 203, 91, 0.5));
}

.action-speed-fixed,
.action-bonus-fixed {
  font-size: .8rem;
  font-weight: 600;
  color: var(--gold);
  background: rgba(246, 203, 91, 0.12);
  padding: .15rem .45rem;
  border-radius: 4px;
  border: 1px solid rgba(246, 203, 91, 0.25);
  display: inline-flex;
  align-items: center;
}

.empty-actions-hint, .empty-triggers-hint {
  margin: .8rem 0;
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
  font-style: italic;
}

.card-specifics-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: .45rem .6rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(14, 9, 6, 0.7);
}

.specific-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
}

.specific-stat-label {
  font-size: .6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.specific-stat-val {
  font-size: .88rem;
  font-weight: 850;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.card-action-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: .45rem .6rem;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  background: rgba(18, 12, 8, 0.95);
}

.card-toggle-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #140d08;
  padding: 2px;
  gap: 2px;
}

.card-toggle-btn {
  padding: .25rem .85rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 750;
  cursor: pointer;
  transition: all .14s ease;
}

.card-toggle-btn:hover:not(.active) {
  color: var(--ink);
}

.card-toggle-btn.active {
  background: var(--gold);
  color: #211810;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
}

.card-triggers-view {
  padding: .6rem .6rem;
  max-height: 12rem;
  overflow-y: auto;
}

.triggers-block-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.triggers-block-list .scratch-block.shape-root {
  margin: 0 0 .5rem 0;
  min-width: 0;
  width: 100%;
}

/* Block definition preview docked on left of card action panel */
.action-block-preview {
  position: absolute;
  right: calc(100% + 14px);
  bottom: 0;
  width: min(25rem, calc(100vw - 20rem));
  max-height: 26rem;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1.5px solid rgba(216, 174, 112, 0.45);
  background: rgba(18, 12, 8, 0.98);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85), 0 0 16px rgba(216, 174, 112, 0.2);
  z-index: 35;
  animation: action-preview-in .16s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

@keyframes action-preview-in {
  from { opacity: 0; transform: translateX(10px) scale(0.97); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.action-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .65rem .85rem .5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(216, 174, 112, 0.12) 0%, transparent 100%);
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}

.action-preview-title-wrap {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}

.action-preview-tag {
  font-size: .6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gold);
}

.action-preview-title {
  font-family: Georgia, serif;
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-preview-close {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: .8rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all .12s ease;
}

.action-preview-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: var(--ink);
  transform: scale(1.1);
}

.action-preview-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 22rem;
  overflow-y: auto;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.action-preview-body .scratch-block.shape-root {
  margin: 0;
  min-width: 0;
  width: 100%;
}

@media (max-width: 750px) {
  .action-block-preview {
    right: 0;
    bottom: calc(100% + 10px);
    width: 100%;
    max-height: 18rem;
  }
}

.stack-drawer { width: min(34rem, calc(100vw - 2rem)); max-height: calc(100dvh - 5rem); padding: 0; border: 1px solid rgba(210,174,144,.4); border-radius: 12px; background: rgba(19,13,8,.97); backdrop-filter: blur(16px); color: var(--ink); box-shadow: var(--shadow); }
.stack-drawer::backdrop { background: rgba(6,4,2,.75); backdrop-filter: blur(6px); }
.stack-drawer-card { padding: 1.2rem; display: flex; flex-direction: column; gap: 1rem; max-height: inherit; overflow: hidden; }
.stack-drawer-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: .75rem; }
.stack-drawer-header h2 { margin: .2rem 0 0; font-family: Georgia, serif; font-size: 1.4rem; }
.stack-drawer-body { display: grid; gap: 1.2rem; min-height: 0; overflow-y: auto; }
.drawer-section-title { margin: 0 0 .5rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.selection-info { min-width: 0; overflow: hidden; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.available-actions { min-width: 0; min-height: 0; display: flex; align-items: center; gap: .5rem; overflow-x: auto; scrollbar-width: thin; }
.action-button { flex: 0 0 auto; min-height: 2.6rem; padding: 0 .9rem; border: 1px solid rgba(210,174,144,.32); background: var(--gold-soft); color: var(--gold); font-size: .78rem; }
.pass-button { background: var(--gold); color: #2b1b0d; }
.pass-button.reaction { background: var(--ember); color: #260b03; }
.waiting-card { width: min(33rem, calc(100% - 2rem)); margin: auto; padding: 2rem; border: 1px solid var(--line); border-radius: .7rem; text-align: center; background: rgba(26,18,11,.9); box-shadow: var(--shadow); }
#lobby-waiting { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); max-height: 100%; overflow-y: auto; padding: clamp(.5rem, 2vh, 2rem); }
#waiting-menu-button { padding: .5rem 1rem; }
.waiting-card h2 { margin: .3rem 0; font-family: Georgia, serif; font-size: 2rem; }
.code-display { margin: 1.2rem 0; color: var(--gold); font-size: 2rem; font-weight: 850; letter-spacing: .18em; }
.mulligan-banner { padding: .65rem .9rem; border: 1px solid rgba(255,209,105,.28); border-radius: .4rem; color: #e2be7c; background: rgba(255,209,105,.08); font-size: .78rem; }
dialog { width: min(24rem, calc(100% - 2rem)); padding: 0; border: 1px solid var(--line); border-radius: .65rem; color: var(--ink); background: #1c130c; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(6,4,2,.72); backdrop-filter: blur(5px); }
.menu-card { display: grid; gap: .75rem; padding: 1.25rem; }
.menu-card h2 { margin: 0; font-family: Georgia, serif; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 5.5rem; transform: translate(-50%, 1rem); max-width: min(28rem, calc(100% - 2rem)); padding: .75rem 1rem; border: 1px solid var(--line); border-radius: .42rem; background: #322214; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 980px) {
  .entry-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .brand-panel { padding: 1rem 1.5rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-mark, .brand-panel .lede, .faction-preview { display: none; }
  .brand-panel .eyebrow { margin-bottom: .4rem; font-size: .65rem; }
  .join-panel { gap: .75rem; padding: 1rem 1.5rem; }
  h1 { max-width: none; font-size: 2.8rem; line-height: 1; }
  .game-shell { --topbar-height: 3rem; }
  .action-dock { grid-template-columns: minmax(8rem, .8fr) minmax(0, 2fr) 7rem; padding: .4rem .6rem; }
  .self-hud { display: none; }
  .topbar { gap: .55rem; }
  .wordmark { font-size: .72rem; }
  .phase-banner { max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 .7rem; }
  .room-chip { display: none; }
  .phase-banner { display: none; }
  .player-bar { justify-content: flex-start; overflow-x: auto; }
  .player-name { min-width: 7rem; }
  .side-clock { min-width: 6.4rem; }
  .resource { min-width: 4.4rem; }
  .left-rail { top: 8rem; left: .8rem; width: 10.5rem; }
  .objective { padding: .6rem; }
  .objective p { display: none; }
  .game-shell { --topbar-height: 3rem; --action-dock-height: 5.8rem; }
  .card { flex-basis: 9.5rem; }
  .action-dock { grid-template-columns: minmax(0, 1fr) 6.2rem; grid-template-rows: auto minmax(0, 1fr); padding: .4rem .7rem; gap: .25rem .6rem; }
  .selection-info { grid-column: 1 / 3; }
  .available-actions { grid-column: 1; }
  .pass-button { grid-column: 2; }
  .card-action-panel { width: min(16.5rem, calc(100vw - 2rem)); right: 1rem; bottom: 4.8rem; }
}

@media (max-height: 700px) {
  .game-shell { --topbar-height: 2.8rem; --player-bar-height: 2.8rem; }
  .player-bar { gap: .5rem; padding: .1rem .6rem; }
  .side-clock { padding: .15rem .5rem; }
  .resource { padding: .2rem .5rem; }
  .table-layout { gap: .4rem; padding: .4rem; }
  .card-art { flex-basis: 2rem; padding: .3rem .5rem; }
  .card-body { padding: .35rem .5rem; }
  .card h3 { font-size: .85rem; }
  .card p { margin-top: .2rem; font-size: .62rem; }
  .hand-heading { margin-bottom: .15rem; }
  .join-panel { gap: .5rem; padding: .75rem 1rem; }
  .deck-picker { grid-template-columns: 1fr 1fr; }
  .deck-option span { padding: .65rem; }
  .field input { padding: .65rem .8rem; }
}

@media (max-height: 520px) {
  .game-shell { --action-dock-height: 4rem; }
  .action-dock { grid-template-columns: minmax(0, 1fr) 6.2rem; grid-template-rows: 1fr; gap: .5rem; padding: .35rem .7rem; }
  .action-dock > .selection-info { display: none; }
  .available-actions { grid-column: 1; }
  .pass-button { grid-column: 2; }
  .card { display: grid; grid-template-columns: 1.7rem minmax(0, 1fr); }
  .card-art { height: 100%; min-height: 0; padding: .15rem; align-items: center; }
  .card-type { display: none; }
  .card-body { padding: .25rem .4rem; }
  .card h3 { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .card-body > p { display: none; }
  .card-cost { min-width: 1.3rem; height: 1.3rem; }
  .left-rail .objective { display: none; }
  .entry-shell { grid-template-rows: minmax(0, 1fr); }
  .brand-panel { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

#auth-form { display: grid; gap: 12px; }
#account-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#account-summary[hidden], #match-entry[hidden] { display: none; }
#match-entry { display: grid; gap: 16px; }

/* Main menu archive: only the catalog scrolls; navigation and creation stay visible. */
.entry-shell { grid-template-rows: 64px minmax(0, 1fr); }
.main-nav { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; padding: 0 clamp(1rem, 4vw, 4rem); border-bottom: 1px solid var(--line); background: #1c130b; }
.main-nav > div { display: flex; gap: .5rem; height: 100%; align-items: center; }
.main-nav > div button:not(.hello-button) { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 0 1.3rem; cursor: pointer; color: var(--muted); }
.main-nav button[aria-current="page"] { color: var(--gold); border-bottom-color: var(--gold); }
.hello-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.35rem 0.9rem;
  min-height: auto;
  border-radius: 999px;
  border: 1px solid rgba(216, 174, 112, 0.45);
  background: rgba(216, 174, 112, 0.12);
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.hello-button:hover {
  background: rgba(216, 174, 112, 0.24);
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(216, 174, 112, 0.25);
  color: #fff;
}
.hello-button:active {
  transform: translateY(0);
}
.library-panel { grid-column: 1 / -1; min-height: 0; display: grid; grid-template-rows: auto auto minmax(0,1fr) 90px; padding: 24px clamp(16px,4vw,64px) 0; }
.library-panel h2 { font-family: Georgia, serif; font-size: 2.3rem; margin: 0; }
.library-panel header > p:last-child { color: var(--muted); margin: 8px 0; }
.library-grid { min-height: 0; overflow: auto; padding: 16px 12px 24px; display: grid; gap: 24px; align-content: start; }
.card-library { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.archive-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: linear-gradient(160deg,#3e2a19,#1a120b); box-shadow: 0 8px 18px #0004; }
.archive-art { height: 100px; padding: 12px; display: flex; align-items: center; justify-content: space-between; background: radial-gradient(ellipse at center,#895c3855,transparent); color: var(--gold); }
.archive-art > span, .archive-art > small { font-size: .7rem; text-transform: uppercase; max-width: 35%; }
.archive-art > strong { font-size: 3.5rem; font-weight: 400; opacity: .5; }
.archive-body { padding: 16px; }
.archive-body h3 { font: 1.25rem Georgia,serif; margin: 0 0 10px; }
.archive-body p { color: #cebcad; font-size: .8rem; line-height: 1.5; }
.archive-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.archive-stats span { padding: 4px 6px; background: #17100a; border: 1px solid var(--line); border-radius: 4px; font-size: .7rem; }
.deck-library { grid-template-columns: repeat(2,minmax(0,320px)); justify-content: center; padding-top: 30px; gap: 40px; }
.deck-box { position: relative; isolation: isolate; min-height: 340px; border: 1px solid var(--gold); border-radius: 12px; padding: 24px; background: linear-gradient(145deg,#4b321e,#1e140c); box-shadow: 5px 5px 0 #352315, 6px 6px 0 #8d6646, 10px 10px 0 #3b2b1e, 11px 11px 0 #644a34; }
.ember-deck { --gold: var(--ember); background: linear-gradient(145deg,#4a2b25,#1a1315); }
.deck-emblem { font: 3.5rem Georgia,serif; color: var(--gold); border: 1px solid currentColor; border-radius: 8px; width: 80px; height: 90px; display: grid; place-items: center; margin: 0 auto 24px; }
.deck-box h3 { font: 1.8rem Georgia,serif; margin: 12px 0; }
.deck-box > p:not(.eyebrow) { color: #d0c2b7; line-height: 1.5; font-size: .85rem; }
.deck-meta { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .8rem; }
.deck-meta strong { color: var(--gold); }
.library-footer { display: grid; justify-items: center; align-content: center; gap: 5px; background: #211810f5; border-top: 1px solid var(--line); }
.library-footer button { width: 190px; opacity: .65; cursor: not-allowed; }
.library-footer small, #username-help { color: var(--muted); font-size: .75rem; }
@media (max-width: 700px) { .entry-shell { grid-template-rows: 56px minmax(0,1fr); } .deck-library { grid-template-columns: minmax(0,320px); } .main-nav > div button { padding: 0 .8rem; } .library-panel { padding-top: 16px; } }

@media (max-width: 980px) { #entry > .brand-panel { display: none; } }

.card-library { grid-template-columns: repeat(auto-fill, minmax(170px, 230px)); justify-content: center; align-items: start; }
.archive-card { width: 100%; aspect-ratio: 5 / 7; display: grid; grid-template-rows: minmax(58px, auto) minmax(0,1fr) 56px; padding: 10px; gap: 8px; text-align: left; cursor: pointer; border: 2px solid #785a42; color: var(--ink); background: linear-gradient(145deg,#452e1c,#1c130b); }
.archive-card:hover { border-color: var(--gold); box-shadow: 0 10px 24px #0008; }
.archive-card-name { display: flex; align-items: center; padding: 8px; font: 1.15rem/1.2 Georgia, serif; color: #fff1d9; overflow-wrap: anywhere; background: #1a110a99; border: 1px solid var(--line); border-radius: 5px; }
.archive-card .archive-art { height: auto; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 5px; background: repeating-linear-gradient(60deg,transparent 0 28px,#d8ae7009 29px 30px),radial-gradient(ellipse at center,#895c3866,transparent); }
.archive-card .archive-art > span, .archive-card .archive-art > small { max-width: 100%; }
.archive-card .archive-art > strong { font-size: clamp(3rem,5vw,5rem); }
.archive-card-foot { display: flex; flex-direction: column; justify-content: center; gap: 5px; text-transform: capitalize; padding: 0 8px; color: var(--gold); font-size: .8rem; }
.archive-card-foot small { text-transform: none; color: var(--muted); font-size: .7rem; }
.archive-ember { --gold: var(--ember); background: linear-gradient(145deg,#4b2e29,#1d171b); border-color: #825448; }
.card-details-dialog { width: min(680px,calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid #8d6a4e; border-radius: 14px; color: var(--ink); background: linear-gradient(145deg,#3a2717,#1a110a); overflow-y: auto; }
.card-details-dialog::backdrop { background: #0b0704de; backdrop-filter: blur(5px); }
.card-details-content { padding: clamp(20px,4vw,36px); }
#card-details-close { display: block; margin-left: auto; margin-bottom: 20px; }
#card-details-title { margin: 0 0 16px; font: 2rem/1.15 Georgia,serif; overflow-wrap: anywhere; }
#card-details-summary { line-height: 1.7; color: #decfc3; }
.detail-blocks {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
}
.detail-blocks .scratch-block.shape-root {
  margin: 0 0 14px;
  min-width: 0;
  width: 100%;
}
.card-details-stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0; }
.card-details-stats > div { min-width: 80px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #18100a; }
.card-details-stats dt { color: var(--muted); font-size: .75rem; }
.card-details-stats dd { margin: 5px 0 0; font-size: 1.2rem; color: var(--gold); }
#card-details-damage { line-height: 1.6; }
#card-details-tags { color: var(--muted); font-size: .8rem; }
@media (max-width: 420px) { .card-library { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; padding-inline: 0; } .archive-card { padding: 6px; grid-template-rows: minmax(54px,auto) minmax(0,1fr) 48px; } .archive-card-name { font-size: .95rem; padding: 4px; } }

.card-library { grid-auto-rows: max-content; }
.archive-card { min-height: 322px; }
@media (max-width: 420px) { .archive-card { min-height: 245px; } }

.field select { width: 100%; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: .45rem; background: #1a110a; color: var(--ink); font: inherit; text-transform: none; }
.deck-box { text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 12px; }
.deck-title { font: 1.8rem/1.15 Georgia,serif; overflow-wrap: anywhere; }
.deck-description { color: #d0c2b7; line-height: 1.5; font-size: .85rem; }
.deck-box .deck-meta { margin-top: auto; }
.deck-library { grid-template-columns: repeat(auto-fill,minmax(240px,320px)); }
.library-footer button:not(:disabled) { cursor: pointer; opacity: 1; }
.deck-editor { grid-column: 1 / -1; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; padding: 20px clamp(12px,3vw,40px) 0; }
.editor-header { display: grid; grid-template-columns: auto minmax(160px,1fr) auto; align-items: center; gap: 24px; padding-bottom: 20px; }
.editor-header > div { color: var(--gold); text-align: right; }
.editor-header p { color: var(--muted); font-size: .75rem; margin: 5px 0 0; }
.editor-layout { min-height: 0; display: grid; grid-template-columns: minmax(230px,290px) minmax(0,1fr); gap: 24px; }
.editor-sidebar { min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; background: #21170e; padding: 14px; }
.editor-sidebar h3, .editor-owned h3 { margin: 0 0 12px; font: 1.3rem Georgia,serif; }
#editor-list { overflow-y: auto; min-height: 0; }
.editor-row { display: grid; grid-template-columns: 32px minmax(0,1fr) 32px; align-items: center; gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.editor-row > span { display: grid; gap: 4px; font-size: .8rem; overflow-wrap: anywhere; }
.editor-row small { color: var(--muted); }
.editor-row button { height: 32px; border: 1px solid var(--line); border-radius: 6px; background: #422d1b; cursor: pointer; font-size: 1.2rem; }
.editor-row button:disabled { opacity: .3; cursor: default; }
.editor-owned { display: grid; grid-template-rows: auto auto minmax(0,1fr); min-height: 0; }
.editor-owned > p { color: var(--muted); font-size: .8rem; margin: 0 0 8px; }
.editor-owned .card-library { grid-template-columns: repeat(auto-fill,minmax(150px,190px)); gap: 16px; }
.editor-owned .archive-card { min-height: 266px; }
.editor-owned .archive-card:disabled { opacity: .35; filter: grayscale(1); cursor: not-allowed; }
.editor-footer { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 20px; padding: 16px 0; }
.editor-footer button { padding: .65rem 1.5rem; }
#editor-status { color: var(--muted); font-size: .85rem; margin: 0; }
.empty-deck { color: var(--muted); line-height: 1.6; font-size: .85rem; }
@media (max-width: 700px) {
  .editor-header { grid-template-columns: auto minmax(0,1fr); gap: 12px; padding-bottom: 12px; }
  .editor-header > div { grid-column: 1 / -1; text-align: left; }
  .editor-header p { display: inline; margin-left: 12px; }
  .editor-layout { grid-template-columns: minmax(140px,.85fr) minmax(0,1fr); gap: 10px; }
  .editor-sidebar { padding: 9px; }
  .editor-row { grid-template-columns: 26px minmax(0,1fr) 26px; gap: 4px; }
  .editor-row button { height: 28px; }
  .editor-owned .card-library { grid-template-columns: minmax(0,190px); padding: 8px 2px; }
  .editor-owned .archive-card { min-height: 250px; }
  .editor-footer { gap: 10px; }
  .editor-footer button { padding: .5rem .6rem; font-size: .8rem; }
}

/* Autumn: walnut surfaces, parchment text, brass and russet accents. */
:root { --line: rgba(218,181,128,.22); scrollbar-color: #796044 #271c13; }
body { background: radial-gradient(ellipse at 20% 0,#543b27 0,transparent 65%),repeating-linear-gradient(94deg,#ffffff01 0 1px,transparent 1px 7px),#211810; }
h1 em { color: var(--gold); -webkit-text-stroke: 0; }
.brand-panel::before { border-radius: 90% 0 90% 0; width: 38rem; height: 48rem; top: -10rem; right: -18rem; transform: rotate(28deg); background: linear-gradient(145deg,#91683a20,#a6512a0a); border: 1px solid #d8ae7014; }
.primary-button, .pass-button { color: #2b1b0d; background: linear-gradient(#dfb97f,#c8995d); box-shadow: inset 0 1px #fff0cb55,0 3px 8px #0003; }
.primary-button:hover, .pass-button:hover { filter: brightness(1.05); }
.main-nav, .topbar { background: #241a12; border-bottom-color: #725132; }
.main-nav > div button[aria-current="page"] { background: #d8ae7009; }
.archive-card, .deck-box { box-shadow: 0 6px 14px #0004,inset 0 1px #f4d2a21a; }
.archive-card { border-color: #927247; background: linear-gradient(145deg,#58422c,#302219); }
.archive-card .archive-art { background: radial-gradient(ellipse at center,#c39b5d25,transparent),repeating-linear-gradient(120deg,transparent 0 19px,#e6c79606 20px 21px),#302419; }
.archive-card .archive-art > strong { opacity: .6; }
.archive-ember { --gold: var(--ember); background: linear-gradient(145deg,#57372a,#2e2119); border-color: #976049; }
.archive-ember .archive-art { background: radial-gradient(ellipse at center,#b5764725,transparent),#352219; }
.deck-box { background: linear-gradient(145deg,#61492e,#30231a); box-shadow: 4px 4px #2b2118,5px 5px #91744e,9px 9px #32261b,10px 10px #755737; }
.ember-deck { background: linear-gradient(145deg,#613d2c,#302019); }
.deck-emblem { border-radius: 45% 45% 6px 6px; }
.entity.selected .unit-shape, .entity.selected .building-shape { filter: none; }
.card-details-dialog { border-color: #a18458; }
.library-toolbar { display: flex; align-items: end; gap: 14px; padding: 12px 0 8px; }
.library-search { flex: 1; max-width: 420px; display: grid; gap: 6px; color: var(--muted); font-size: .75rem; }
.library-search input { min-width: 0; width: 100%; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 6px; background: #23190f; color: var(--ink); font: inherit; font-size: .95rem; }
.library-search input::placeholder { color: #bca78b; }
.card-filter-control { position: relative; }
.card-filter-options { position: absolute; top: calc(100% + 8px); right: 0; width: 185px; z-index: 20; padding: 7px; display: grid; gap: 4px; border: 1px solid #967344; border-radius: 8px; background: #342519; box-shadow: 0 10px 28px #0006; }
.card-filter-options button { padding: .7rem .8rem; text-align: left; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink); cursor: pointer; }
.card-filter-options button[aria-pressed="true"] { background: #d8ae7020; border-color: var(--gold); color: #f3d7aa; }
#library-status { color: var(--muted); font-size: .85rem; }
select:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
@media (max-width: 560px) { .library-toolbar { gap: 8px; flex-wrap: wrap; } .library-search { max-width: none; flex-basis: 100%; } #card-filter-button { font-size: .85rem; } .card-filter-options { left: 0; right: auto; } }

.library-panel #library-description { color: var(--muted); margin: 8px 0; }
#library-status { margin: 0; }
#library-status:not(:empty) { padding: 8px 0; }

/* Card workshop: fixed preview today, space for the block editor tomorrow. */
.card-workshop { grid-column: 1 / -1; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; padding: 18px clamp(12px,3vw,40px) 0; }
.workshop-header { display: flex; align-items: center; gap: 24px; padding-bottom: 18px; }
.workshop-header h2 { font: 1.8rem Georgia,serif; margin: 0; }
.workshop-header .eyebrow { margin: 0 0 5px; }
.workshop-badge { margin-left: auto; border: 1px solid var(--line); border-radius: 20px; padding: 8px 14px; font-size: .75rem; color: var(--gold); }
.workshop-body { display: grid; grid-template-columns: minmax(155px,.7fr) minmax(240px,1.6fr) minmax(230px,1fr); gap: 18px; min-height: 0; }
.workshop-palette, .workshop-preview, .workshop-canvas { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: 12px; padding: 20px; overflow-y: auto; }
.workshop-palette, .workshop-preview { background: #2c2016; }
.workshop-palette h3 { font: 1.35rem Georgia,serif; margin: 0; }
.workshop-palette p:not(.eyebrow), .fixed-program p { font-size: .8rem; color: var(--muted); line-height: 1.6; }
.palette-items { display: grid; gap: 10px; margin: 24px 0; }
.palette-items button { text-align: left; padding: 13px 10px; border: 1px solid var(--line); background: #59422b55; border-radius: 6px; color: #bfa98b; cursor: not-allowed; }
.palette-items span { padding-right: 10px; color: var(--gold); }
.palette-note { border-top: 1px solid var(--line); padding-top: 20px; }
.workshop-canvas { background: radial-gradient(circle,#d8ae7020 1px,transparent 1px) 0 0 / 20px 20px,#20180f; display: flex; flex-direction: column; }
.canvas-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.canvas-heading > span { font-size: .7rem; color: var(--muted); }
.fixed-program { width: min(100%,340px); margin: auto; padding: 24px 0; }
.program-label { display: block; color: var(--gold); font: 1.5rem Georgia,serif; margin-bottom: 24px; }
.program-block { padding: 18px; border: 1px solid #8c704a; border-left-width: 5px; border-radius: 7px; background: #58402a; box-shadow: 0 5px 12px #0003; font-size: .9rem; }
.target-block { background: #454634; border-color: #878660; }
.effect-block { background: #603d2b; border-color: #bc8052; }
.program-connector { color: #aa8b61; padding: 7px 20px; }
.fixed-program > p { margin-top: 24px; }
.workshop-preview .field { margin-bottom: 12px; }
.workshop-preview .field input, .workshop-preview .field select { padding: 9px 12px; }
.workshop-card { max-width: 260px; margin: 18px auto 0; padding: 14px; border: 2px solid #b08352; border-radius: 10px; background: linear-gradient(155deg,#714c30,#362418); box-shadow: 0 10px 20px #0005; }
.workshop-card-heading { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.workshop-card-heading h3 { margin: 0; overflow-wrap: anywhere; font: 1.2rem Georgia,serif; }
.workshop-card-heading > span { font-size: .75rem; text-transform: capitalize; color: var(--gold); }
.firebolt-art { height: 115px; margin-top: 12px; display: grid; place-items: center; font-size: 5rem; color: #ffd49b; background: radial-gradient(ellipse,#ce6c3755,transparent 70%),#251a12; border: 1px solid var(--line); border-radius: 6px; }
.workshop-card p { font-size: .85rem; line-height: 1.5; min-height: 40px; }
.workshop-card-stats { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 12px; font-size: .75rem; color: var(--gold); }
.validation-note { color: #babf94; font-size: .75rem; text-align: center; }
.workshop-footer { padding: 14px 0; background: #211810; }
.creator-destination-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 16px; }
.field-caption { display: block; color: var(--muted); font-size: .75rem; margin-bottom: 6px; }
.destination-toggle { display: flex; border: 1px solid #8a6942; border-radius: 7px; padding: 3px; background: #19120c; }
.destination-toggle button { border: 0; border-radius: 4px; background: transparent; color: var(--muted); padding: 9px 16px; cursor: pointer; white-space: nowrap; }
.destination-toggle button[aria-pressed="true"] { background: #715333; color: #fff0d6; }
.destination-toggle button:disabled { cursor: default; }
#creator-quota { display: block; font-size: .7rem; color: var(--muted); margin-top: 5px; }
#creator-set-field { min-width: 170px; }
.creator-destination-controls .field select, #creator-new-set input { padding: 9px 12px; }
#creator-new-set { display: flex; gap: 10px; align-items: end; }
.creator-submit-row { display: flex; align-items: center; gap: 12px; padding-top: 12px; }
#creator-status { margin: 0; color: var(--muted); font-size: .8rem; flex: 1; line-height: 1.5; }
.creator-submit-row button { white-space: nowrap; padding: 12px 20px; }
.library-scope { display: flex; align-items: end; gap: 12px; }
.library-scope .field select { padding: 9px; }
@media (max-width: 1000px) {
  .workshop-body { grid-template-columns: 140px minmax(200px,1fr) minmax(200px,1fr); gap: 10px; }
  .workshop-palette, .workshop-preview, .workshop-canvas { padding: 12px; }
  .library-toolbar { flex-wrap: wrap; }
}
@media (max-width: 720px) {
  .card-workshop { padding-top: 10px; }
  .workshop-header { gap: 10px; padding-bottom: 10px; }
  .workshop-header h2 { font-size: 1.25rem; }
  .workshop-badge { display: none; }
  .workshop-body { display: flex; flex-wrap: wrap; overflow-y: auto; align-content: start; }
  .workshop-palette { flex: 1 1 100%; overflow: visible; }
  .workshop-palette > p:not(.eyebrow), .workshop-palette h3 { display: none; }
  .palette-items { display: flex; gap: 5px; margin: 0; flex-wrap: wrap; }
  .palette-items button { padding: 8px; }
  .workshop-canvas, .workshop-preview { flex: 1 1 220px; overflow: visible; }
  .workshop-footer { max-height: 45dvh; overflow-y: auto; padding: 8px 0; }
  .creator-destination-controls { gap: 8px; }
  .creator-submit-row { flex-wrap: wrap; }
  .creator-submit-row button { padding: 9px 12px; }
  #creator-status { min-width: 100%; }
  #creator-new-set { flex-wrap: wrap; }
}

.rule-block { border: 1px solid #a7814b66; border-left: 3px solid #aa794a; background: #432f20; border-radius: 6px; margin: 7px 0; overflow-wrap: anywhere; font-size: .8rem; }
.rule-block summary { padding: 9px; cursor: pointer; color: #efd2a3; }
.rule-children { padding: 0 8px 8px 12px; }
.rule-value { padding: 4px 7px; margin: 3px 0; background: #251b13; color: #d9c7b0; border-radius: 3px; font: .75rem/1.5 ui-monospace,monospace; overflow-wrap: anywhere; }
.detail-blocks { margin-top: 20px; } .empty-blocks { color: var(--muted); font-size: .8rem; }
.preview-blocks { margin-top: 12px; } .selected-blocks { margin-top: 15px; }

/* Card plain text body styling (replaces block trees on inspection & preview) */
.card-text-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.ability-entry {
  background: linear-gradient(135deg, rgba(35, 25, 17, 0.95) 0%, rgba(22, 15, 10, 0.98) 100%);
  border: 1px solid rgba(170, 121, 74, 0.38);
  border-left: 3.5px solid #d99b38;
  border-radius: 8px;
  padding: 9px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 6px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ability-entry:hover {
  border-color: rgba(216, 174, 112, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 10px rgba(0, 0, 0, 0.45);
}

.ability-entry.action {
  border-left-color: #d99b38;
}

.ability-entry.trigger {
  border-left-color: #b182f0;
}

.ability-entry.aura {
  border-left-color: #4ecdc4;
}

.ability-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ability-name {
  font-family: Georgia, serif;
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffdfa9;
  letter-spacing: 0.01em;
}

.ability-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: #e2caa7;
  letter-spacing: 0.02em;
}

.ability-meta.speed-fast {
  color: #8ed0ff;
  text-shadow: 0 0 8px rgba(142, 208, 255, 0.35);
}

.ability-meta.speed-slow {
  color: #f7d28b;
}

.ability-body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.86rem;
  line-height: 1.5;
  color: #f2e8dc;
  overflow-wrap: break-word;
}

/* Subtle block type coloring inside card explanation sentences */
.card-text-token {
  font-weight: 600;
  display: inline;
}

.card-text-token.token-number {
  color: #f7d28b; /* warm gold / amber */
}

.card-text-token.token-unit {
  color: #8ed0ff; /* soft cyan */
}

.card-text-token.token-hex {
  color: #7bed9f; /* soft emerald / mint */
}

.card-text-token.token-status {
  color: #d4b2f8; /* soft violet / lavender */
}

.card-text-token.token-player {
  color: #ffaa75; /* soft warm coral */
}

.card-text-token.token-timing {
  color: #b8c5d6; /* slate / periwinkle */
}

.workshop-card .preview-blocks .card-text-container {
  gap: 6px;
}

.workshop-card .preview-blocks .ability-entry {
  padding: 7px 9px;
  gap: 3px;
  border-radius: 6px;
}

.workshop-card .preview-blocks .ability-name {
  font-size: 0.85rem;
}

.workshop-card .preview-blocks .ability-meta {
  font-size: 0.72rem;
}

.workshop-card .preview-blocks .ability-body {
  font-size: 0.8rem;
  line-height: 1.4;
}

.triggers-text-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.workshop-card { max-width: none; } .workshop-card .firebolt-art { height: 55px; font-size: 3rem; }
#block-workspace { margin-top: 16px; }
.ability-editor { border: 1px solid #735b3c; border-radius: 8px; margin-bottom: 16px; padding: 12px; background: #20170e; }
.ability-editor:focus-within, .focused-ability { border-color: #d9ad68; }
.ability-title { display: flex; align-items: center; justify-content: space-between; color: var(--gold); margin-bottom: 10px; }
.ability-title button, .block-order button { background: #21170e; border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; cursor: pointer; }
.block-control { display: flex; align-items: end; flex-wrap: wrap; gap: 8px; padding: 10px; margin: 8px 0; border-radius: 6px; border-left: 4px solid #aa794a; }
.block-control label { display: grid; gap: 4px; font-size: .7rem; flex: 1; min-width: 48px; }
.block-control select, .block-control input, .block-stats input { width: 100%; min-width: 0; padding: 7px; background: #251b13; color: var(--ink); border: 1px solid var(--line); border-radius: 4px; }
.block-control input { max-width: 75px; } .block-control strong { font-size: .8rem; align-self: center; text-transform: capitalize; }
.trigger-block { background: #5a432b; } .target-block { background: #454634; } .condition-block { background: #494036; } .effect-block { background: #603d2b; }
.effect-block[draggable="true"] { cursor: grab; }
.block-order { display: flex; gap: 4px; } .drop-hint { font-size: .75rem; color: var(--muted); padding: 10px 4px; }
.automatic-block { background: #484633; border: 1px solid #929368; padding: 12px; font-size: .8rem; border-radius: 6px; margin-bottom: 14px; }
.automatic-block small { display: block; margin-top: 8px; color: var(--muted); }
.block-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 15px 0; }
.block-stats label { font-size: .75rem; display: grid; gap: 5px; }
.king-field { display: flex; gap: 8px; font-size: .85rem; color: var(--gold); }
.workshop-palette .palette-items button { cursor: grab; color: #e0cbaa; padding: 10px; }
.workshop-palette .palette-items button:disabled { cursor: default; opacity: .5; }
.workshop-body { grid-template-columns: minmax(150px,.6fr) minmax(300px,1.7fr) minmax(230px,1fr); }
@media(max-width:1000px) and (min-width:721px) { .workshop-body {grid-template-columns:140px minmax(230px,1fr) 210px;} .card-workshop{padding-inline:10px;} }

/* Typed block silhouettes live on backplates so nested controls are never clipped. */
.workshop-body { grid-template-columns: minmax(185px,.7fr) minmax(300px,1.85fr) minmax(240px,.9fr); }
.workshop-palette, .workshop-preview, .workshop-canvas { scrollbar-width: thin; scrollbar-color: #765b38 #20180f; }
.workshop-palette .field select { width: 100%; padding: 9px 10px; }
.palette-items { margin: 18px 0; gap: 13px; }
:where(.palette-block, .scratch-block, .scratch-socket) { --block-shape: none; --block-radius: 0; }
.shape-root { --block-color: #8e6030; --block-outline: #dba45f; --block-shape: polygon(0 0, 20px 0, 27px 7px, 45px 7px, 52px 0, 100% 0, 100% 100%, 52px 100%, 45px calc(100% - 7px), 27px calc(100% - 7px), 20px 100%, 0 100%); }
.shape-player { --block-color: #386c8f; --block-outline: #7ebee2; --block-shape: polygon(15px 0,100% 0,calc(100% - 15px) 100%,0 100%); }
.shape-unit { --block-color: #406a46; --block-outline: #88bd88; --block-radius: 12px; }
.shape-target_unit { --block-color: #385b3e; --block-outline: #f3c96a; --block-shape: polygon(20% 0, 80% 0, 95% 15%, 100% 50%, 95% 85%, 80% 100%, 20% 100%, 5% 85%, 0 50%, 5% 15%); }
.shape-number { --block-color: #56699c; --block-outline: #a2b7ed; --block-shape: polygon(14px 0,calc(100% - 14px) 0,100% 100%,0 100%); }
.shape-status { --block-color: #775584; --block-outline: #c9a0db; --block-shape: url(#status-cloud); }
.shape-boolean { --block-color: #31776f; --block-outline: #75c6b6; --block-shape: polygon(17px 0,calc(100% - 17px) 0,100% 50%,calc(100% - 17px) 100%,17px 100%,0 50%); }
.shape-hex { --block-color: #526369; --block-outline: #83999f; --block-shape: polygon(15% 0,85% 0,100% 50%,85% 100%,15% 100%,0 50%); }
.shape-target_hex { --block-color: #4a5c63; --block-outline: #f3c96a; --block-shape: polygon(18% 0, 82% 0, 95% 35%, 100% 50%, 95% 65%, 82% 100%, 18% 100%, 5% 65%, 0 50%, 5% 35%); }
.shape-timing { --block-color: #876638; --block-outline: #d1ae70; --block-shape: polygon(0 0,100% 0,calc(100% - 12px) 50%,100% 100%,0 100%,12px 50%); }
.shape-event { --block-color: #9a5140; --block-outline: #e29979; --block-radius: 3px; }
.shape-trigger_condition { --block-color: #5c3c7e; --block-outline: #ac83e6; --block-shape: polygon(8px 0, calc(100% - 8px) 0, calc(100% - 8px) calc(50% - 7px), 100% 50%, calc(100% - 8px) calc(50% + 7px), calc(100% - 8px) 100%, 8px 100%, 8px calc(50% + 7px), 0 50%, 8px calc(50% - 7px)); }
.palette-block, .scratch-block, .scratch-socket { position: relative; isolation: isolate; }
.palette-block::before, .scratch-block::before, .scratch-socket::before,
.palette-block::after, .scratch-block::after, .scratch-socket::after { content: ''; position: absolute; z-index: -2; inset: 0; background: var(--block-outline); border-radius: var(--block-radius,0); clip-path: var(--block-shape,none); pointer-events: none; }
.palette-block::after, .scratch-block::after, .scratch-socket::after { z-index: -1; inset: 1.5px; background: var(--block-color); }
.scratch-block .scratch-block.shape-boolean { --block-color: #255d57; }
.scratch-block .scratch-block.shape-trigger_condition { --block-color: #442a60; }
.workshop-palette .palette-items .palette-block { background: transparent; border: 0; border-radius: 0; padding: 15px 20px; display: flex; flex-direction: column; gap: 5px; color: #fff4df; font-size: .79rem; line-height: 1.4; text-align: center; align-items: center; }
.workshop-palette .palette-items .palette-block span { padding: 0; color: inherit; }
.palette-block small { font-size: .6rem; opacity: .75; letter-spacing: .07em; }
.palette-block:hover:not(:disabled) { filter: brightness(1.2); }
.palette-block:focus-visible, .scratch-socket:focus-visible { outline: 2px solid #ffe1a0; outline-offset: 3px; }
.prompt-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: .62rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 170, 50, 0.22);
  color: #ffd88a;
  border: 1px solid rgba(255, 170, 50, 0.45);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-left: 4px;
  vertical-align: middle;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.palette-block .prompt-badge {
  font-size: .56rem;
  padding: 0 4px;
  margin-left: 0;
  margin-top: 2px;
}
.palette-block.opens-prompt {
  box-shadow: inset 0 0 0 1px rgba(255, 170, 50, 0.35);
}
.palette-block.disabled-for-trigger {
  opacity: .35;
  filter: grayscale(0.8);
  cursor: not-allowed !important;
}
.scratch-block.opens-prompt {
  box-shadow: 0 0 0 1px rgba(255, 170, 50, 0.25);
}
#block-workspace { flex: 1; min-height: 220px; overflow: auto; padding: 8px 4px 14px; }
.scratch-block { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 10px 20px; margin: 2px 0; vertical-align: middle; min-height: 36px; color: #fff5e4; font-size: .8rem; line-height: 1.5; max-width: 100%; }
.scratch-block[draggable="true"] { cursor: grab; }
.scratch-block.shape-unit { padding: 10px 20px; }
.scratch-block.shape-target_unit { padding: 12px 26px; }
.scratch-block.shape-hex, .scratch-block.shape-target_hex { padding: 10px 24px; }
.scratch-block.shape-status { padding-block: 16px; }
.scratch-block.shape-trigger_condition { padding: 10px 22px; }
.scratch-block.shape-root { display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 28px 14px 16px; margin: 0 0 22px; min-width: 260px; }
.scratch-root > .block-grip { position: absolute; top: 4px; left: 9px; }
.root-clause { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 50px; padding: 5px; }
.root-clause > strong { font-size: .7rem; letter-spacing: .06em; min-width: 64px; }
.root-clause > label { display: inline-flex; align-items: center; gap: 5px; font-size: .7rem; }
.root-clause > small { opacity: .8; }
.block-grip { font-size: 1rem; color: #fff9; cursor: grab; }
.scratch-socket { display: inline-flex; align-items: center; justify-content: center; padding: 12px 22px; min-width: 84px; min-height: 40px; flex-shrink: 0; border: 0; background: transparent; color: #f9eed9; font-size: .64rem; font-weight: 600; letter-spacing: .04em; cursor: pointer; }
.scratch-socket::after { background: color-mix(in srgb,var(--block-color) 35%,#171812); inset: 2px; }
.scratch-socket.selected-socket { filter: drop-shadow(0 0 4px #ffe1a0); }
.scratch-socket.selected-socket::before { background: #ffe1a0; }
.scratch-socket.selected-socket::after { background: #564821; }
.scratch-socket:disabled { cursor: default; }
.deferred-socket { opacity: .8; cursor: help; white-space: normal; text-align: center; font-size: .6rem; min-width: 110px; max-width: 135px; }
.scratch-block input, .scratch-block select { font: inherit; font-size: .73rem; border: 1px solid #ffffff60; border-radius: 4px; background: #171812ba; color: #fff4df; padding: 5px 6px; min-height: 32px; max-width: 100%; }
.scratch-block input[type="number"] { width: 65px; }
.scratch-block select { min-width: 54px; }
.scratch-tools { display: inline-flex; gap: 3px; margin-left: auto; }
.scratch-tools button { display: inline-flex; align-items: center; justify-content: center; padding: 0; width: 23px; height: 24px; background: #14161055; color: #fff1d4; border: 1px solid #fff3; border-radius: 4px; font-size: .8rem; cursor: pointer; }
.scratch-tools button:hover:not(:disabled) { background: #171812ae; }
.scratch-tools button:disabled { opacity: .35; cursor: default; }
.scratch-root > .scratch-tools { position: absolute; top: 3px; right: 7px; }
.scope-name { font-size: .6rem; color: #dcf2c8; }
.root-drop-zone { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; min-height: 92px; padding: 22px; border: 1px dashed #b9996466; border-radius: 9px; color: var(--muted); font-size: .75rem; text-align: center; }
.root-drop-zone:only-child { min-height: 290px; }
.root-drop-zone strong { font: 1.2rem Georgia,serif; color: #e2cba9; }
.root-drop-zone small { max-width: 240px; line-height: 1.6; opacity: .85; }
.core-costs { margin-bottom: 16px; }
.workshop-preview .block-stats input { width: 100%; padding: 9px; background: #20170f; color: var(--text); }
.preview-core { font-size: .72rem !important; line-height: 1.8 !important; min-height: 0 !important; color: #e2cba9; }
.empty-card-body { opacity: .65; min-height: 25px !important; }
.validation-incomplete { color: #e3b78b; }
.validation-complete { color: #b4ce9c; }
#block-selection-hint { min-height: 60px; }
@media (max-width:1100px) and (min-width:721px) { .workshop-body { grid-template-columns: 175px minmax(240px,1fr) 225px; gap: 9px; }.workshop-palette,.workshop-preview,.workshop-canvas { padding: 11px; }.scratch-block { gap: 6px; padding-inline: 20px; } }
@media (max-width:720px) { .workshop-body { display: flex; }.workshop-palette .palette-items { display: flex; }.workshop-palette .palette-items .palette-block { width: 145px; font-size: .7rem; }.workshop-preview { order: -1; flex-basis: 100%; }.workshop-canvas { flex-basis: 100%; }.workshop-palette #block-selection-hint { display: block; min-height: 0; }.root-drop-zone:only-child { min-height: 150px; } }

/* The deck browser uses the same controls as Cards, aligned with the collection. */
.editor-header { grid-template-columns: minmax(230px,290px) minmax(0,1fr); gap: 24px; padding-bottom: 14px; }
.editor-header > div { min-width: 0; text-align: left; }
.editor-heading { display: grid; gap: 12px; }
.editor-heading strong { font-size: .8rem; }
.editor-sidebar .field { margin-bottom: 16px; flex-shrink: 0; }
.editor-sidebar .field input { min-width: 0; width: 100%; }
#editor-toolbar-host .library-toolbar { flex-wrap: wrap; padding: 0; }
#editor-toolbar-host .library-search { min-width: 150px; flex: 1; }
.segmented-control input:disabled + span { opacity: .35; cursor: not-allowed; background: transparent; }
#match-mode-control .segmented-control:has(#match-mode-playtesting-field:not([hidden])) { grid-template-columns: repeat(2, minmax(0,1fr)); }
#match-mode-hint { display: block; margin-top: 5px; color: var(--muted); font-size: .7rem; }
@media (max-width: 700px) {
  .editor-header { grid-template-columns: minmax(140px,.85fr) minmax(0,1fr); gap: 10px; }
  .editor-header > div { grid-column: auto; }
  #editor-toolbar-host .library-toolbar { gap: 6px; }
  #editor-toolbar-host .library-scope { flex-wrap: wrap; gap: 6px; }
}
@media (max-height: 800px) {
  #match-entry { gap: .6rem; }
  .segmented-control span { min-height: 2rem; padding: .3rem .2rem; }
}

@media (max-width: 700px) {
  .editor-header { grid-template-columns: minmax(0,1fr); }
  .editor-heading { display: flex; align-items: center; gap: 12px; }
  .editor-heading strong { text-align: right; margin-left: auto; }
  #editor-toolbar-host .library-scope { flex-basis: 100%; }
  #editor-toolbar-host .library-search { flex-basis: 100%; max-width: none; min-width: 0; }
}

/* Master Panel Styling */
.master-panel-dialog {
  width: min(64rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 3rem);
  padding: 0;
  border: 1px solid rgba(216, 174, 112, 0.35);
  border-radius: 12px;
  background: rgba(18, 12, 8, 0.98);
  backdrop-filter: blur(16px);
  color: var(--ink);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(216, 174, 112, 0.15);
  overflow: hidden;
}

.master-panel-content {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 3rem);
  padding: 1.5rem;
  gap: 1.1rem;
  overflow: hidden;
}

.master-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.9rem;
}

.master-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.master-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: linear-gradient(135deg, rgba(216, 174, 112, 0.25), rgba(180, 120, 60, 0.15));
  border: 1px solid rgba(216, 174, 112, 0.4);
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.master-panel-header h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 1.5rem;
  color: var(--gold);
}

.master-panel-subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.master-metrics-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.master-metric-chip {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0.9rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.master-metric-chip .metric-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.master-metric-chip .metric-val {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--ink);
}

.master-filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.master-search-box {
  flex: 1;
  min-width: 180px;
}

.master-search-box input {
  width: 100%;
  padding: 0.5rem 0.8rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.85rem;
}

.master-search-box input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(216, 174, 112, 0.2);
}

.master-library-filter {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}

.master-filter-btn {
  padding: 0.5rem 0.85rem;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.master-filter-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.master-filter-btn.active,
.master-filter-btn[aria-pressed="true"] {
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 700;
}

.master-status {
  min-height: 1.2rem;
  margin: 0;
  font-size: 0.82rem;
  color: #e2be7c;
}

.master-cards-table-wrap {
  flex: 1 1 auto;
  min-height: 200px;
  max-height: calc(100dvh - 17rem);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
}

.master-cards-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}

.master-cards-table th {
  position: sticky;
  top: 0;
  background: #23160e;
  padding: 0.75rem 0.9rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.master-cards-table td {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.master-cards-table tr:hover td {
  background: rgba(216, 174, 112, 0.04);
}

.master-card-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.master-card-title strong {
  font-size: 0.9rem;
  color: var(--ink);
}

.master-card-title code {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: monospace;
}

.master-badge-pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.master-badge-standard {
  background: rgba(74, 144, 226, 0.15);
  color: #70b0ff;
  border: 1px solid rgba(74, 144, 226, 0.3);
}

.master-badge-chaos {
  background: rgba(186, 85, 211, 0.15);
  color: #dda0dd;
  border: 1px solid rgba(186, 85, 211, 0.3);
}

.master-row-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.master-inspect-btn {
  padding: 0.35rem 0.65rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font-size: 0.75rem;
  cursor: pointer;
}

.master-inspect-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--gold);
}

.master-delete-btn {
  padding: 0.35rem 0.65rem;
  background: rgba(180, 40, 30, 0.15);
  border: 1px solid rgba(220, 60, 50, 0.4);
  border-radius: 4px;
  color: #ff8577;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.master-delete-btn:hover {
  background: rgba(220, 60, 50, 0.35);
  border-color: #ff5544;
  color: #fff;
  transform: translateY(-1px);
}

.master-empty-hint {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-style: italic;
}

/* Hex Map Picker Button inside Scratch Blocks */
.hex-map-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 4px;
  background: rgba(216, 174, 112, 0.18);
  border: 1px solid rgba(216, 174, 112, 0.45);
  color: var(--gold);
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.15s ease;
  margin: 0 0.25rem;
}

.hex-map-picker-btn:hover:not(:disabled) {
  background: rgba(216, 174, 112, 0.35);
  border-color: var(--gold);
  transform: translateY(-1px);
}

.hex-map-picker-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Hex Map Selection Modal */
.hex-map-modal {
  width: min(56rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 3rem);
  padding: 0;
  border: 1px solid rgba(216, 174, 112, 0.4);
  border-radius: 14px;
  background: rgba(18, 12, 8, 0.98);
  backdrop-filter: blur(20px);
  color: var(--ink);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(216, 174, 112, 0.2);
  overflow: hidden;
}

.hex-map-modal::backdrop {
  background: rgba(8, 5, 3, 0.75);
  backdrop-filter: blur(6px);
}

.hex-map-content {
  display: flex;
  flex-direction: column;
  padding: 1.4rem;
  gap: 1rem;
  max-height: calc(100dvh - 3rem);
  overflow: hidden;
}

.hex-map-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.8rem;
  flex-wrap: wrap;
}

.hex-map-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hex-map-header h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 1.4rem;
  color: var(--gold);
}

.hex-map-subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 38rem;
}

.hex-map-subtitle strong {
  color: var(--ember);
}

.hex-map-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.hex-map-count {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--gold);
  background: rgba(216, 174, 112, 0.12);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(216, 174, 112, 0.25);
  white-space: nowrap;
}

.hex-map-view-container {
  flex: 1 1 auto;
  min-height: 380px;
  max-height: calc(100dvh - 17rem);
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #2a1c12 0%, #130d08 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  padding: 0.5rem;
}

.hex-map-svg {
  width: 100%;
  height: 100%;
  max-height: 480px;
  display: block;
}

.hex-map-tile {
  cursor: pointer;
  outline: none;
}

.hex-map-tile polygon {
  fill: rgba(38, 27, 18, 0.6);
  stroke: rgba(199, 155, 119, 0.2);
  stroke-width: 1;
  transition: fill 0.12s ease, stroke 0.12s ease;
}

.hex-map-tile:hover polygon {
  fill: rgba(216, 174, 112, 0.25);
  stroke: rgba(216, 174, 112, 0.75);
}

.hex-map-tile.selected polygon {
  fill: rgba(216, 174, 112, 0.75);
  stroke: #ffdf9e;
  stroke-width: 1.6;
  filter: drop-shadow(0 0 5px rgba(216, 174, 112, 0.45));
}

.hex-map-tile.center polygon {
  stroke: #ff8e3c;
  stroke-width: 2.2;
}

.hex-map-tile.center.selected polygon {
  fill: rgba(255, 142, 60, 0.85);
  stroke: #ffe099;
  stroke-width: 2.2;
  filter: drop-shadow(0 0 8px rgba(255, 142, 60, 0.6));
}

.hex-center-dot {
  fill: #ff8e3c;
  filter: drop-shadow(0 0 4px rgba(255, 142, 60, 0.8));
}

.hex-map-tile.selected .hex-center-dot {
  fill: #ffffff;
}

.hex-coord-text {
  font-family: monospace;
  font-size: 6.8px;
  fill: rgba(243, 231, 211, 0.35);
  user-select: none;
  pointer-events: none;
}

.hex-map-tile:hover .hex-coord-text {
  fill: rgba(243, 231, 211, 0.8);
}

.hex-map-tile.selected .hex-coord-text {
  fill: #190f08;
  font-weight: 700;
}

.hex-map-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.hex-map-legend {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.legend-center {
  background: rgba(255, 142, 60, 0.85);
  border: 1.5px solid #ff8e3c;
  box-shadow: 0 0 4px rgba(255, 142, 60, 0.6);
}

.legend-selected {
  background: rgba(216, 174, 112, 0.75);
  border: 1px solid #ffdf9e;
}

.legend-empty {
  background: rgba(38, 27, 18, 0.6);
  border: 1px solid rgba(199, 155, 119, 0.2);
}

.hex-map-shortcuts {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Card view action badges: small green circle for actions, small orange triangle for bonus actions */
.cost-circle-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  min-width: 1.25rem;
  border-radius: 50%;
  background: #16a34a;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  vertical-align: middle;
}

.cost-triangle-bonus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  min-width: 1.35rem;
  background: #ea580c;
  clip-path: polygon(50% 5%, 95% 90%, 5% 90%);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  padding-top: 0.25rem;
  box-sizing: border-box;
  vertical-align: middle;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Deck Editor Hover Preview */
.deck-editor-hover-preview {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  pointer-events: none;
  width: 280px;
  max-width: calc(100vw - 4rem);
  animation: hoverPreviewFadeIn 0.15s ease-out;
}

@keyframes hoverPreviewFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hover-preview-card {
  background: linear-gradient(160deg, #2c2016 0%, #1a120c 100%);
  border: 1.5px solid #a27a4a;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(216, 174, 112, 0.15);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hover-preview-card.archive-ember {
  border-color: #c85028;
}

.hover-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.hover-preview-title-wrap {
  display: flex;
  flex-direction: column;
}

.hover-preview-type {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold, #d8ae70);
}

.hover-preview-title {
  font-family: Georgia, serif;
  font-size: 1.1rem;
  color: #fff0d6;
  line-height: 1.2;
}

.hover-preview-cost {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hover-preview-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.preview-stat-pill {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(216, 174, 112, 0.2);
  border-radius: 4px;
  padding: 2px 6px;
  color: #d8ae70;
}

.hover-preview-body {
  font-size: 0.82rem;
  line-height: 1.45;
  color: #e6d3ba;
  max-height: 180px;
  overflow-y: hidden;
}

.hover-preview-foot {
  font-size: 0.7rem;
  color: var(--muted, #9f8c75);
  text-align: right;
  font-style: italic;
  margin-top: 2px;
}

/* Optimistic pre-activation view styling */
.optimistic-preview {
  opacity: 0.85;
  filter: drop-shadow(0 0 6px rgba(100, 200, 255, 0.7));
  animation: optimisticPulse 1.5s ease-in-out infinite alternate;
}

@keyframes optimisticPulse {
  from { filter: drop-shadow(0 0 4px rgba(100, 200, 255, 0.5)); opacity: 0.8; }
  to { filter: drop-shadow(0 0 9px rgba(100, 200, 255, 0.9)); opacity: 1; }
}

.optimistic-arrow {
  stroke: #60a5fa !important;
  stroke-dasharray: 6 3;
  animation: optimisticDash 1s linear infinite;
}

@keyframes optimisticDash {
  to { stroke-dashoffset: -18; }
}


