:root {
  --bg: #0b0f14;
  --panel: #141a22;
  --panel2: #1b232e;
  --line: #263140;
  --text: #d7dee8;
  --muted: #8b98a8;
  --accent: #44aa99;
  --accent-dim: #2b6f66;
  --red: #e05555;
  --red-dim: #6b2f2f;
  --green: #4cc38a;
  --green-dim: #25543c;
  --blue: #5aa9e6;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: radial-gradient(1200px 600px at 20% -10%, #16202c 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 22px;
  background: linear-gradient(180deg, #18212c 0%, #10161d 100%);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, #2b6f66 100%);
  color: #10161d; font-weight: 800; font-size: 18px;
  display: grid; place-items: center;
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.35);
}
.brand h1 { font-size: 18px; letter-spacing: 0.4px; }
.brand-sub { font-size: 11px; color: var(--muted); }

#nav { display: flex; gap: 4px; margin-left: auto; }
#nav a {
  color: var(--muted); padding: 8px 14px; border-radius: 8px;
  font-weight: 600; font-size: 13px; transition: all .15s;
}
#nav a:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
#nav a.active { color: #10161d; background: var(--accent); }

/* analytics feature flag: off by default, so the deck chip and the
   Matchups / My Deck navigation only appear once body.analytics-on is set
   from /api/config */
#nav a[data-view="matchups"], #nav a[data-view="deck"], #nav a[data-view="sim"], .deck-chip { display: none; }
body.analytics-on #nav a[data-view="matchups"], body.analytics-on #nav a[data-view="deck"], body.analytics-on #nav a[data-view="sim"] { display: inline-block; }
body.analytics-on .deck-chip { display: flex; }

.deck-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; font-size: 12.5px;
  max-width: 260px; overflow: hidden; white-space: nowrap;
}
.chip-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red-dim); flex: none; }
.deck-chip.has-deck .chip-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
#chip-text { text-overflow: ellipsis; overflow: hidden; }

/* ---------- layout ---------- */
#view { flex: 1; padding: 22px; max-width: 1500px; width: 100%; margin: 0 auto; }

.page-head { margin-bottom: 18px; }
.page-head h2 { font-size: 22px; color: #fff; letter-spacing: .3px; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 900px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}
.panel h3 {
  font-size: 14px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--accent); margin-bottom: 12px;
}
.panel h4 { font-size: 13.5px; color: #fff; margin-bottom: 8px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- import ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 46px 24px; text-align: center; cursor: pointer;
  transition: all .15s; background: var(--panel);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #1a212c; }
.dropzone .dz-big { font-size: 34px; }
.dropzone h3 { color: #fff; margin: 10px 0 4px; font-size: 17px; }
.dropzone p { color: var(--muted); font-size: 13px; }

.import-row { display: flex; gap: 18px; margin-top: 18px; flex-wrap: wrap; }
.import-row .panel { flex: 1; min-width: 340px; }

textarea.paste-box {
  width: 100%; min-height: 220px; resize: vertical;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px;
}

button {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: linear-gradient(135deg, #5ec9b8, #2b6f66); color: #10161d; border: none; }
button.primary:hover { filter: brightness(1.1); color: #10161d; }
button.danger { color: var(--red); }
button.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }

.import-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; }
.stat-box {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
  padding: 12px; text-align: center;
}
.stat-box .stat-num { font-size: 22px; font-weight: 700; color: var(--accent); }
.stat-box .stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin-top: 2px; }

.warn-list { color: #e0b45a; font-size: 12.5px; margin-top: 8px; }
.warn-list li { margin-left: 18px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button {
  border-radius: 999px; padding: 7px 16px; font-size: 12.5px;
}
.tabs button.active { background: var(--accent); color: #10161d; border-color: var(--accent); }

/* ---------- summary cards ---------- */
.summary-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.summary-row .stat-box .stat-num { font-size: 19px; }
.stat-box.risk-high .stat-num { color: var(--red); }
.stat-box.risk-mid .stat-num { color: #e0a34a; }
.stat-box.risk-low .stat-num { color: var(--green); }

/* ---------- ranked lists ---------- */
.ranked-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .ranked-grid { grid-template-columns: 1fr; } }

.rank-list { display: flex; flex-direction: column; gap: 6px; }
.rank-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 10px; cursor: pointer;
  transition: all .12s;
}
.rank-item:hover { border-color: var(--accent); }
.rank-item.open { border-color: var(--accent); background: #202a36; }

.card-thumb {
  width: 34px; height: 49px; border-radius: 5px; flex: none;
  object-fit: cover; background: #0e141b; border: 1px solid var(--line);
}
.rank-main { flex: 1; min-width: 0; }
.rank-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-meta { font-size: 11px; color: var(--muted); }
.bar-wrap { width: 110px; flex: none; }
.bar {
  height: 7px; border-radius: 4px; background: #0d1218; overflow: hidden;
}
.bar > div { height: 100%; border-radius: 4px; }
.bar.threat > div { background: linear-gradient(90deg, #7c2f2f, var(--red)); }
.bar.eff > div { background: linear-gradient(90deg, #1f5c40, var(--green)); }
.bar-score { font-size: 11px; color: var(--muted); margin-top: 2px; text-align: right; }

.rank-detail {
  display: none; padding: 8px 10px 4px 54px; font-size: 12.5px; color: var(--muted);
}
.rank-item.open + .rank-detail, .rank-detail.open { display: block; }
.rank-detail ul { list-style: none; }
.rank-detail li { padding: 4px 0; border-top: 1px dashed var(--line); }
.rank-detail .hit-name { color: var(--text); font-weight: 600; }
.rank-detail .reason { display: block; color: var(--muted); font-size: 11.5px; }
.rank-detail .score-pill {
  float: right; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--accent);
}
.rank-detail .factor-list { display: block; margin-top: 3px; }
.rank-detail .factor {
  display: inline-block; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px; font-size: 10.5px; color: var(--muted);
  margin: 2px 4px 2px 0; cursor: help;
}
.rank-detail .factor:hover { border-color: var(--accent); color: var(--accent); }
.rank-detail-hint {
  font-size: 10.5px; color: var(--muted); opacity: .8;
  margin-bottom: 6px; text-transform: none; letter-spacing: .3px;
}

.era-toggle {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px;
  color: var(--muted); cursor: pointer; margin-left: auto; padding: 4px 0;
}
.era-toggle input { accent-color: var(--accent); }

/* ---------- tables ---------- */
table.matrix { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.matrix th, table.matrix td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; }
table.matrix th { color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .6px; }
table.matrix td.num, table.matrix th.num { text-align: right; }
table.matrix tr:hover td { background: rgba(255,255,255,.02); }

.matchup-table .deck-name { font-weight: 600; color: var(--accent); }

/* ---------- cards grid (search / deck) ---------- */
.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px; margin-top: 14px;
}
.card-tile {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px; cursor: pointer; transition: all .12s; text-align: center;
  position: relative;
}
.card-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-tile img { width: 100%; border-radius: 6px; aspect-ratio: 177/254; object-fit: cover; background: #0e141b; }
.card-tile .tile-name { font-size: 11.5px; margin-top: 6px; line-height: 1.25; min-height: 2.5em; }
.card-tile .tile-sub { font-size: 10.5px; color: var(--muted); }
.card-tile .count-badge {
  position: absolute; top: 4px; right: 4px; background: var(--accent); color: #10161d;
  border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px;
}
.tile-img-wrap { position: relative; }
.card-tile.era-miss img { filter: grayscale(.7); }

/* ---------- filters ---------- */
.filter-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 8px;
}
.filter-bar input, .filter-bar select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; width: 100%;
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--accent); }
.filter-bar label { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; margin-bottom: 4px; }
.filter-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.result-count { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.load-more { margin: 16px auto 0; display: block; }

/* ---------- deck stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.stat-bars .bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 12.5px; }
.stat-bars .bar-row .lbl { width: 130px; color: var(--muted); flex: none; }
.stat-bars .bar-row .bar { flex: 1; }
.stat-bars .bar-row .val { width: 34px; text-align: right; color: var(--text); flex: none; }
.chip-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; font-size: 12px;
}
.chip .n { color: var(--accent); font-weight: 700; }

.section-block { margin-bottom: 20px; }
.section-block h3 { margin-bottom: 8px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,8,12,.78);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  max-width: 860px; width: 100%; max-height: 88vh; overflow-y: auto;
  padding: 20px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal .m-head { display: flex; gap: 16px; }
.modal img.m-art {
  width: 130px; border-radius: 8px; flex: none; object-fit: cover; background: #0e141b;
}
.modal h2 { font-size: 19px; color: #fff; }
.modal .m-type { color: var(--accent); font-size: 13px; margin: 3px 0 8px; }
.modal .m-stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.modal .m-stats b { color: var(--text); }
.modal .m-desc { margin-top: 14px; padding: 12px; background: var(--bg); border-radius: 8px; font-size: 13px; color: #c9d3de; }
.modal .m-psct { margin-top: 10px; padding: 12px; background: #101b26; border: 1px solid #1d3246; border-radius: 8px; font-size: 13px; color: #b9d3ec; }
.modal .m-psct .tag { font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 4px; }
.modal .m-section { margin-top: 16px; }
.modal .m-section h4 { color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.modal .entity-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.modal .entity-chips .chip { font-size: 11px; }
.modal details { margin-top: 10px; }
.modal details summary { cursor: pointer; color: var(--blue); font-size: 13px; }
.modal details ul { margin: 8px 0 0 20px; color: var(--muted); font-size: 12.5px; }
.modal .close-x { float: right; background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 2px 8px; }
.modal .close-x:hover { color: var(--red); }

/* ---------- toasts ---------- */
.toast-wrap { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 10px 16px; font-size: 13px; max-width: 380px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); animation: slidein .2s ease;
}
.toast.warn { border-left-color: #e0a34a; }
.toast.error { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.foot {
  padding: 14px 22px; color: var(--muted); font-size: 11.5px;
  border-top: 1px solid var(--line); text-align: center;
}

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .big { font-size: 40px; margin-bottom: 10px; }

.spinner {
  width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* Sim results view (Phase 4b) */
.sim-table { width: 100%; border-collapse: collapse; font-size: 0.92em; }
.sim-table th, .sim-table td { padding: 5px 8px; border-bottom: 1px solid var(--border, #333); text-align: left; }
.sim-table.small td { font-size: 0.85em; padding: 3px 6px; }
.win-bar { width: 120px; height: 8px; background: #333; border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-left: 8px; }
.win-bar-fill { height: 100%; background: linear-gradient(90deg, #4a9, #6c5); }
.sim-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.sim-card-block { border: 1px solid var(--border, #333); border-radius: 8px; padding: 8px 12px; }
.sim-card-block summary { cursor: pointer; font-weight: 600; }
.sim-two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }
@media (max-width: 720px) { .sim-two-cols { grid-template-columns: 1fr; } }

/* Sim view tabs + meta manager + policy editor */
#view .tabs button { margin-right: 6px; }
#view .tabs button.active { background: var(--accent); color: #111; }
.pol-val { width: 64px; }
.pol-card { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#md-ydk { min-height: 80px; }
button.small { font-size: 0.8em; padding: 2px 8px; }

/* Play vs AI view */
.play-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
/* preview + game log share the right-hand column: the log hangs under the
   hovered-card preview rather than under the field */
.play-side { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; min-width: 0; min-height: 0; }
/* the action panel and the auto-pass toggles share the row's right-hand column */
.play-aside { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
.play-side .play-log { margin-top: 0; }
@media (max-width: 860px) {
  .play-layout { grid-template-columns: 1fr; }
  /* a sticky sidebar must not ride over the preview once it is stacked */
  .play-actions { position: static; }
  .play-side { grid-template-rows: auto auto; }
}
.play-grid { display: flex; flex-direction: column; gap: 12px; }
.play-opp, .play-me { display: flex; flex-direction: column; gap: 4px; }
.play-lp { font-weight: 700; font-size: 1.1em; }
.play-row { display: flex; align-items: center; gap: 6px; }
.play-label { width: 34px; color: var(--muted, #888); font-size: 0.8em; }
.play-zone { display: flex; gap: 6px; min-height: 64px; background: rgba(255,255,255,0.03); border-radius: 6px; padding: 6px; flex-wrap: wrap; }
.play-card { width: 56px; height: 76px; border: 1px solid #555; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 1.5em; background: #1a1a2a; }
.play-card.hand { cursor: default; }
.play-hand { display: flex; gap: 6px; flex-wrap: wrap; min-height: 40px; }
.play-hand-names { max-width: 100%; }
.play-actions { position: sticky; top: 12px; align-self: start; }
.play-act { display: block; width: 100%; margin: 4px 0; text-align: left; }
.play-act.picked { outline: 2px solid var(--accent); }
.play-prompt-label { font-weight: 700; margin-bottom: 6px; }
/* card action submenu (opened from a highlighted hand/field card) */
.play-submenu { position: fixed; z-index: 85; background: #141a26; border: 1px solid #2c3a4d; border-radius: 8px; box-shadow: 0 12px 40px rgba(0,0,0,0.7); padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 170px; }
.play-submenu-btn { background: #10161f; border: 1px solid #2c3a4d; color: #cde; border-radius: 5px; padding: 6px 10px; font-size: 0.82em; cursor: pointer; text-align: left; }
.play-submenu-btn:hover { border-color: var(--accent); color: var(--accent); }

/* declare-a-card-name input (announce_card prompt) */
.play-act-input {
  width: 100%; box-sizing: border-box;
  background: #10161f; color: #cde;
  border: 1px solid #2c3a4d; border-radius: 6px;
  padding: 6px 8px; font-size: 0.85em;
}
.play-act-input:focus { border-color: var(--accent); outline: none; }
.announce-results { margin-top: 6px; }

/* targeting trays: clickable card grids for deck/GY/banished/hand targets */
.play-tray { margin-bottom: 8px; }
.play-tray-label { font-size: 0.78em; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.play-tray-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.play-tray-card { width: 64px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; border-radius: 4px; padding: 2px; border: 1px solid transparent; }
.play-tray-card:hover { border-color: var(--accent); }
.play-tray-card.picked { border-color: #ff6a00; box-shadow: 0 0 8px rgba(255,106,0,0.7); }
.play-tray-img { width: 60px; aspect-ratio: 3/4; object-fit: cover; border-radius: 3px; background: #1a1a2a; }
.play-tray-name { font-size: 0.58em; text-align: center; line-height: 1.15; max-height: 2.3em; overflow: hidden; color: #cde; }
.play-end { padding: 24px; text-align: center; }
.play-status { color: var(--muted, #888); }

/* Play view: real card images + log */
.play-card { position: relative; }
.play-card-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.play-card.faceup { width: 58px; height: 82px; }
.play-card.hand { width: 58px; height: 82px; }
.play-card-back { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-size: 1.6em; background: linear-gradient(135deg, #223, #445); }
.play-card-name { position: absolute; left: 0; right: 0; bottom: 0; font-size: 0.58em; line-height: 1.1; background: rgba(0,0,0,0.72); padding: 1px 2px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-card-stat { position: absolute; top: 2px; right: 2px; font-size: 0.6em; font-weight: 700; background: rgba(0,0,0,0.7); padding: 1px 3px; border-radius: 3px; }
.play-zone { min-height: 86px; }
.play-log { margin-top: 14px; max-height: 220px; overflow-y: auto; }
.play-log-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: 0; background: #10161f; z-index: 2; }
.play-log-head h4 { margin: 0; }
.play-log-lines { display: flex; flex-direction: column; gap: 2px; font-size: 0.9em; }
.play-log-line.ai { color: #d88; }
.play-log-line.me { color: #8d8; }

/* Play view: phase display */
.play-mid { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.play-turn { font-weight: 700; }
.play-phase { font-weight: 800; color: var(--accent); font-size: 1.05em; letter-spacing: 0.4px; }

/* Play view: targeted cards glow */
.play-card.targeted { border: 3px solid #ff6a00; box-shadow: 0 0 14px rgba(255, 106, 0, 0.9); z-index: 3; }
.play-target-badge { position: absolute; top: -8px; right: -8px; font-size: 1.1em;
  background: rgba(0,0,0,0.85); border: 1px solid #ff6a00; border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  line-height: 1; pointer-events: none; }

/* Scenario Lab */
#sl-json { width: 100%; box-sizing: border-box; }
.sl-chosen td { background: rgba(255, 106, 0, 0.15); font-weight: 600; }

/* ================= reusable board component (board.js / .ygb-*) ========= */
.ygb-board { display: flex; flex-direction: column; gap: 8px; background: linear-gradient(180deg, #141b26, #1a2332 40%, #10161f 60%, #0d1220); border: 1px solid #2c3a4d; border-radius: 10px; padding: 12px 14px; }
.ygb-half { display: flex; flex-direction: column; gap: 6px; }
.ygb-lp {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 800;
  font-size: 1.15em;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  width: fit-content;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
  user-select: none;
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.ygb-lp-label { font-size: 0.72em; font-weight: 700; letter-spacing: 1px; opacity: 0.75; }
.ygb-lp-val { font-size: 1.08em; font-weight: 900; letter-spacing: 0.5px; min-width: 3.2em; }
.ygb-lp-opp { color: #ff9999; border-color: rgba(255, 80, 80, 0.25); }
.ygb-lp-me { color: #88ffaa; border-color: rgba(60, 220, 120, 0.25); }

/* LP hit / heal highlight.  The flash + shake itself is animated in
   board/animations.js (anime.js, timed from the server's duration); this is
   only the "lit up" look it holds while that runs. */
.ygb-lp-hit {
  background: rgba(255, 30, 30, 0.42);
  border-color: #ff3344;
  color: #fff;
  box-shadow: 0 0 22px 6px rgba(255, 50, 50, 0.85);
}
.ygb-lp-heal {
  background: rgba(46, 204, 113, 0.32);
  border-color: #2ecc71;
  color: #fff;
  box-shadow: 0 0 20px 5px rgba(46, 204, 113, 0.8);
}

/* Floating damage numbers popup.  Positioning avoids `transform` so anime.js
   owns the transform (float up + pop) without fighting the centring. */
.ygb-damage-popup {
  position: absolute;
  left: calc(100% + 12px);
  top: calc(50% - 0.7em);
  pointer-events: none;
  z-index: 120;
  white-space: nowrap;
  font-size: 1.4em;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #ff3344;
  text-shadow: 0 0 12px rgba(255, 40, 40, 0.95), 0 0 4px #ffe600, 0 2px 4px rgba(0, 0, 0, 0.95);
}

.ygb-damage-heavy {
  font-size: 1.85em;
  color: #ff1a2e;
  text-shadow: 0 0 18px rgba(255, 20, 20, 1), 0 0 6px #ffcc00, 0 3px 6px rgba(0, 0, 0, 1);
}

.ygb-damage-lethal {
  font-size: 2.1em;
  color: #ff0022;
  text-shadow: 0 0 22px rgba(255, 0, 0, 1), 0 0 8px #ffffff, 0 3px 8px rgba(0, 0, 0, 1);
}

/* Floating recovery numbers popup (see the damage popup note) */
.ygb-recover-popup {
  position: absolute;
  left: calc(100% + 12px);
  top: calc(50% - 0.7em);
  pointer-events: none;
  z-index: 120;
  white-space: nowrap;
  font-size: 1.4em;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #38ef7d;
  text-shadow: 0 0 12px rgba(56, 239, 125, 0.95), 0 0 3px #fff, 0 2px 4px rgba(0, 0, 0, 0.95);
}
.ygb-row { display: flex; align-items: center; gap: 8px; }
.ygb-label { width: 34px; flex: none; color: var(--muted, #88a); font-size: 0.78em; font-weight: 700; letter-spacing: 0.5px; }
.ygb-zone { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; flex: 1; }
.ygb-slot { aspect-ratio: 3/4; min-height: 64px; }
.ygb-card { position: relative; width: 100%; height: 100%; border: 1px solid #556; border-radius: 6px; overflow: visible; background: #1a1a2a; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ygb-img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 5px; }
/* custom face-down card back: dark panel + a swirling teal vortex, matching
   the board's navy/teal theme (no external artwork needed) */
.ygb-back {
  position: relative;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 42%, #1c1308 0%, #10161f 62%, #0b0f14 100%);
  border: 2px solid var(--accent-dim);
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(68,170,153,0.25);
}
.ygb-back::before {
  content: "";
  position: absolute;
  inset: 17%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #5ec9b8, #1f5c52, #5ec9b8, #1f5c52, #5ec9b8, #1f5c52, #5ec9b8);
  opacity: 0.9;
  box-shadow: 0 0 10px rgba(68,170,153,0.4);
}
.ygb-back::after {
  content: "";
  position: absolute;
  inset: 31%;
  border-radius: 50%;
  background: #0b0f14;
  border: 1px solid rgba(68,170,153,0.6);
}
.ygb-def { transform: rotate(-90deg); }
.ygb-def .ygb-name { display: none; }
.ygb-unknown { position: absolute; top: 2px; left: 2px; font-size: 0.8em; font-weight: 800; color: #ffd24a; background: rgba(0,0,0,0.75); border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; }
.ygb-name { position: absolute; left: 0; right: 0; bottom: 0; font-size: 0.5em; line-height: 1.1; background: rgba(0,0,0,0.75); padding: 1px 2px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ygb-stat { position: absolute; top: 2px; right: 2px; font-size: 0.55em; font-weight: 700; background: rgba(0,0,0,0.75); padding: 1px 3px; border-radius: 3px; }
.ygb-targeted { border: 3px solid #ff6a00; box-shadow: 0 0 14px rgba(255,106,0,0.85); z-index: 3; }
/* a card that can be clicked during a targeting prompt */
.ygb-selectable { outline: 2px dashed var(--accent); outline-offset: -2px; cursor: pointer; z-index: 2; }
.ygb-selectable:hover { box-shadow: 0 0 10px rgba(68,170,153,0.55); }
/* a card with an available action (summon / activate effect / change position) */
.ygb-actionable { outline: 2px solid #ffd24a; outline-offset: -2px; cursor: pointer; z-index: 2; box-shadow: 0 0 8px rgba(255,210,74,0.55); }
.ygb-actionable:hover { box-shadow: 0 0 14px rgba(255,210,74,0.9); }
/* a monster that can declare an attack (battle phase) */
.ygb-attackable { cursor: pointer; }
.ygb-atk-badge { position: absolute; bottom: -8px; left: -8px; font-size: 0.85em; background: rgba(0,0,0,0.85); border: 1px solid #ff6a00; border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; line-height: 1; pointer-events: none; }
.ygb-badge { position: absolute; top: -9px; right: -9px; font-size: 1em; background: rgba(0,0,0,0.85); border: 1px solid #ff6a00; border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; line-height: 1; pointer-events: none; }
/* poker-chip counter indicator (counters placed on a card) */
.ygb-counter-chip {
  position: absolute; top: 3px; left: 3px; z-index: 4;
  width: 20px; height: 20px; border-radius: 50%;
  background: #f5e9c9; border: 3px solid #c0392b;
  color: #7b241c; font-size: 0.72em; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.ygb-empty { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; border: 1px dashed #3a4a5e; border-radius: 6px; color: #5a6c82; font-size: 1.2em; cursor: pointer; background: rgba(255,255,255,0.02); }
.ygb-empty:hover { border-color: var(--accent); color: var(--accent); background: rgba(74, 153, 144, 0.08); }
.ygb-empty-plain { cursor: default; }
.ygb-field-slot .ygb-empty-plain { font-size: 0.62em; color: #4a5a6e; }
.ygb-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 2px 0; }
.ygb-turn { font-weight: 700; color: #cde; font-size: 0.9em; }
.ygb-phase { font-weight: 800; color: var(--accent); font-size: 1.05em; letter-spacing: 0.4px; }
.ygb-phase-track { position: relative; display: flex; width: 100%; max-width: 340px; border-radius: 8px; background: rgba(0,0,0,0.35); overflow: hidden; border: 1px solid #2c3a4d; }
.ygb-phase-ind { position: absolute; top: 0; left: 0; height: 100%; width: calc(100% / 6); border-radius: 7px; background: linear-gradient(135deg, #5ec9b8, #2b6f66); box-shadow: 0 0 12px rgba(68,170,153,0.45); transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1); }
.ygb-phase-cell { flex: 1; text-align: center; padding: 3px 2px; font-size: 0.66em; font-weight: 700; letter-spacing: 0.2px; color: var(--muted); z-index: 1; position: relative; transition: color 0.3s; }
.ygb-phase-cell.active { color: #10161d; }
.ygb-phase-cell.clickable { color: #ffd24a; cursor: pointer; text-shadow: 0 0 6px rgba(255,210,74,0.6); }
.ygb-phase-cell.clickable:hover { color: #ffe08a; }
/* prominent "Pass" button shown mid-board during a chain window */
.ygb-pass-btn { margin-top: 4px; align-self: center; background: linear-gradient(135deg, #3a4a5e, #232f3d); color: #e8eef5; border: 2px solid #5a6c82; border-radius: 999px; padding: 8px 26px; font-size: 0.95em; font-weight: 800; letter-spacing: 0.4px; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,0.45); }
.ygb-pass-btn:hover { border-color: var(--accent); color: var(--accent); }
/* yes/no prompt shown mid-board for an optional trigger effect (e.g. Swap Frog) */
.ygb-effectyn { margin-top: 4px; display: flex; align-items: center; gap: 8px; background: rgba(20,26,38,0.92); border: 1px solid #2c3a4d; border-radius: 999px; padding: 5px 8px 5px 14px; box-shadow: 0 4px 16px rgba(0,0,0,0.5); }
.ygb-effectyn-label { font-size: 0.85em; font-weight: 700; color: #cde; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ygb-effectyn-yes { background: linear-gradient(135deg, #5ec9b8, #2b6f66); color: #10161d; border: none; border-radius: 999px; padding: 6px 16px; font-weight: 800; cursor: pointer; }
.ygb-effectyn-no { background: #232f3d; color: #cde; border: 1px solid #3a4a5e; border-radius: 999px; padding: 6px 14px; font-weight: 700; cursor: pointer; }
.ygb-effectyn-yes:hover { filter: brightness(1.1); }
.ygb-effectyn-no:hover { border-color: var(--red); color: var(--red); }
/* summon battle-position picker (shown in the middle of the board, like the
   effectyn yes/no) — a mini card glyph in each pose + a text label */
.ygb-pospick {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(20, 26, 38, 0.92);
  border: 1px solid #2c3a4d;
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.ygb-pospick-title {
  font-size: 0.78em;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.ygb-pospick-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: linear-gradient(135deg, #2f3d50, #1d2733);
  border: 1px solid #3a4a5e;
  color: #dce7f2;
  border-radius: 10px;
  padding: 6px 12px 6px 9px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85em;
}
.ygb-pospick-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: linear-gradient(135deg, #2a3a4c, #16222e);
}
/* tiny card glyph: upright = attack, sideways = defense, dark = face-down */
.ygb-pospick-icon { flex: none; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35); }
.ygb-pospick-icon-atk { width: 22px; height: 30px; background: linear-gradient(135deg, #8fd8cd, #2b4a4a); }
.ygb-pospick-icon-def { width: 30px; height: 22px; background: linear-gradient(135deg, #8fd8cd, #2b4a4a); }
.ygb-pospick-icon-fd  { width: 22px; height: 30px; background: linear-gradient(135deg, #3a2a18, #15100a 70%); }
.ygb-pospick-label { white-space: nowrap; }
/* "choose a number" prompt (Card Trooper etc.) — description + dropdown,
   defaulting to the largest option, shown in the middle like yes/no */
.ygb-numpick {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20, 26, 38, 0.92);
  border: 1px solid #2c3a4d;
  border-radius: 999px;
  padding: 6px 10px 6px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.ygb-numpick-label { font-size: 0.85em; font-weight: 700; color: #cde; }
.ygb-numpick-sel {
  background: #10161f; color: #cde;
  border: 1px solid #3a4a5e; border-radius: 6px;
  padding: 4px 8px; font-weight: 700; cursor: pointer;
}
.ygb-numpick-sel:hover { border-color: var(--accent); }
.ygb-numpick-go {
  background: linear-gradient(135deg, #5ec9b8, #2b6f66);
  color: #10161d; border: none; border-radius: 999px;
  padding: 6px 16px; font-weight: 800; cursor: pointer;
}
.ygb-numpick-go:hover { filter: brightness(1.1); }
/* rock-paper-scissors (MSG_ROCK_PAPER_SCISSORS): three centre throws */
.ygb-rps {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(20, 26, 38, 0.92);
  border: 1px solid #2c3a4d;
  border-radius: 14px;
  padding: 6px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.ygb-rps-title { font-size: 0.82em; font-weight: 700; color: #cde; margin-right: 2px; }
.ygb-rps-btn {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: #1a2432; color: #cde;
  border: 1px solid #3a4a5e; border-radius: 10px;
  padding: 5px 12px; cursor: pointer;
}
.ygb-rps-btn:hover { border-color: var(--accent); color: var(--accent); }
.ygb-rps-icon { font-size: 1.4em; line-height: 1.1; }
.ygb-rps-label { font-size: 0.68em; font-weight: 700; }
/* declare a race / attribute: centre dialog (dropdown or logo grid) */
.ygb-choice {
  margin-top: 6px;
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(20, 26, 38, 0.94);
  border: 1px solid #2c3a4d; border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  max-width: 420px;
}
.ygb-choice-title { font-size: 0.82em; font-weight: 700; color: #cde; }
.ygb-choice-select {
  background: #10161f; color: #cde;
  border: 1px solid #3a4a5e; border-radius: 6px;
  padding: 4px 8px; font-weight: 700; cursor: pointer;
}
.ygb-choice-select:hover { border-color: var(--accent); }
.ygb-choice-go {
  align-self: flex-start;
  background: linear-gradient(135deg, #5ec9b8, #2b6f66);
  color: #10161d; border: none; border-radius: 999px;
  padding: 6px 16px; font-weight: 800; cursor: pointer;
}
.ygb-choice-go:disabled { opacity: 0.45; cursor: not-allowed; }
.ygb-choice-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.ygb-choice-opt {
  display: flex; align-items: center; gap: 6px;
  background: #1a2432; color: #cde;
  border: 1px solid #3a4a5e; border-radius: 8px;
  padding: 4px 9px; cursor: pointer; font-weight: 700; font-size: 0.82em;
}
.ygb-choice-opt:hover { border-color: var(--accent); }
.ygb-choice-opt.picked { border-color: var(--accent); background: #24384a; color: #fff; box-shadow: 0 0 0 1px var(--accent) inset; }
.ygb-choice-logo { width: 22px; height: 22px; flex: none; border-radius: 50%; }
.ygb-choice-name { white-space: nowrap; }
/* action-panel fallback for the attribute logo picker */
.play-attrib-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.play-attrib-opt {
  display: flex; align-items: center; gap: 6px;
  background: #1a2432; color: #cde;
  border: 1px solid #3a4a5e; border-radius: 8px;
  padding: 5px 10px; cursor: pointer; font-weight: 700;
}
.play-attrib-opt:hover { border-color: var(--accent); }
.play-attrib-opt.picked { border-color: var(--accent); background: #24384a; color: #fff; }
.play-attrib-logo { width: 24px; height: 24px; flex: none; border-radius: 50%; }
/* counter allocation: selectable field cards + per-card amount badge */
.ygb-card.ygb-counter-target { cursor: crosshair; box-shadow: 0 0 0 2px rgba(94, 201, 184, 0.55); border-radius: 6px; }
.ygb-alloc-chip {
  position: absolute; bottom: 2px; right: 2px; z-index: 5;
  min-width: 18px; padding: 0 5px;
  background: linear-gradient(135deg, #5ec9b8, #2b6f66);
  color: #08131a; font-weight: 800; font-size: 0.75em;
  border-radius: 999px; text-align: center; pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.ygb-sideinfo { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 2px; }
.ygb-field { display: flex; gap: 10px; align-items: flex-start; }
.ygb-rows { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ygb-rail { width: 90px; flex: none; display: flex; flex-direction: column; gap: 3px; }
.ygb-pile { display: flex; align-items: center; gap: 6px; }
.ygb-pile-label { font-size: 0.72em; color: var(--muted, #88a); font-weight: 700; }
.ygb-pile-cards { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.ygb-pile-count { font-size: 0.78em; color: #aab; }
.ygb-pile-empty { font-size: 0.72em; color: #556; }
.ygb-chip { display: inline-block; min-width: 18px; padding: 1px 5px; font-size: 0.68em; border: 1px solid #3a4a5e; border-radius: 4px; color: #9ab; cursor: pointer; text-align: center; }
.ygb-chip:hover { border-color: var(--accent); color: var(--accent); }
.ygb-chip-add { border-style: dashed; }
.ygb-handcount { font-size: 0.78em; color: #aab; }
.ygb-hand-row { display: flex; align-items: flex-start; gap: 8px; margin-top: 4px; }
.ygb-hand-label { width: 72px; flex: none; font-size: 0.75em; color: var(--muted, #88a); font-weight: 700; padding-top: 6px; }
.ygb-hand { display: flex; gap: 6px; flex-wrap: wrap; min-height: 58px; }
.ygb-hand-card { width: 56px; height: 78px; }
.ygb-lg .ygb-card { border-radius: 7px; }
.ygb-lg .ygb-name { font-size: 0.58em; }
.ygb-lg .ygb-stat { font-size: 0.62em; }


/* reveal tray (cards shown by an effect) — draggable via its header */
.reveal-overlay { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.reveal-popup { position: fixed; bottom: 3vh; left: 50%; transform: translateX(-50%); pointer-events: auto; background: #141a26; border: 1px solid #2c3a4d; border-radius: 10px; box-shadow: 0 18px 60px rgba(0,0,0,0.6); padding: 10px 12px; max-width: 90vw; }
.reveal-popup.dragging { transform: none; }
.reveal-head { cursor: move; user-select: none; }
.reveal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.reveal-title { font-weight: 700; color: var(--accent); font-size: 0.9em; }
.reveal-x { background: transparent; border: none; color: #88a; font-size: 1.1em; cursor: pointer; }
.reveal-cards { display: flex; gap: 8px; flex-wrap: wrap; max-width: 720px; max-height: 200px; overflow-y: auto; }
.reveal-card { width: 72px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; border-radius: 4px; padding: 2px; border: 1px solid transparent; }
.reveal-card:hover { border-color: var(--accent); }
.reveal-img { width: 72px; aspect-ratio: 3/4; object-fit: cover; border-radius: 4px; background: #1a1a2a; }
.reveal-name { font-size: 0.62em; text-align: center; line-height: 1.15; max-height: 2.3em; overflow: hidden; color: #cde; }

/* ================= scenario editor + card search modal =================== */
.sl-board { margin: 8px 0 4px; }
.sl-json-wrap { margin-top: 10px; }
.sl-json-wrap summary { cursor: pointer; }
.sl-board { min-height: 200px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(8, 10, 16, 0.82); z-index: 90; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 4vw; overflow-y: auto; }
.modal { background: #141a26; border: 1px solid #2c3a4d; border-radius: 10px; width: min(760px, 94vw); padding: 16px; box-shadow: 0 18px 60px rgba(0,0,0,0.6); }
.modal h3 { margin-top: 0; }
.card-modal .filter-row { margin-bottom: 10px; }
.cs-results { max-height: 56vh; overflow-y: auto; }
.cs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.cs-card { background: #10161f; border: 1px solid #2c3a4d; border-radius: 7px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; align-items: center; transition: border-color 0.15s; }
.cs-card:hover { border-color: var(--accent); }
.cs-img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 4px; background: #1a1a2a; }
.cs-name { font-size: 0.68em; text-align: center; line-height: 1.15; max-height: 2.4em; overflow: hidden; color: #cde; }

/* scenario editor card inspector */
.sl-inspector { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 8px; background: rgba(255,255,255,0.03); border-radius: 6px; margin-top: 6px; min-height: 34px; }
.sl-insp-label { font-size: 0.8em; color: #aab; font-weight: 700; }
.sl-insp-btn { border: 1px solid #3a4a5e; background: #10161f; color: #cde; border-radius: 5px; padding: 3px 10px; font-size: 0.78em; cursor: pointer; }
.sl-insp-btn:hover { border-color: var(--accent); color: var(--accent); }
.sl-insp-off { color: #ffd24a; border-color: #6a5a2a; }
.sl-insp-remove { color: #e88; border-color: #5a2a2a; }
.sl-insp-remove:hover { color: #faa; border-color: #f66; }

/* scenario results: per-decision verdict + outcome board */
.sl-decision { margin-bottom: 8px; }
.sl-verdict { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; padding: 6px 8px; background: rgba(255,255,255,0.04); border-left: 3px solid var(--accent); border-radius: 4px; margin-bottom: 6px; }
.sl-verdict-num { font-weight: 800; color: var(--accent); font-size: 0.85em; }
.sl-verdict-type { color: var(--muted, #88a); font-size: 0.8em; }
.sl-verdict-choice { font-weight: 700; }
.sl-verdict-wr { color: #ffd24a; font-size: 0.85em; }
.sl-outcome { margin-top: 4px; }
.sl-outcome .play-log { max-height: 180px; }
.sl-insp-primary { border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* the summon landing pop is animated in board/animations.js */

/* attacker glow while it lunges (transient — cleared on the next render) */
.ygb-attacker { box-shadow: 0 0 16px rgba(255, 80, 60, 0.85); border-color: #ff6a00; }

/* selected card in the scenario editor */
.ygb-selected { outline: 3px solid var(--accent); outline-offset: -2px; box-shadow: 0 0 12px rgba(74,153,144,0.7); z-index: 2; }

/* scenario outcome: before/after boards */
.sl-outcome-label { font-size: 0.75em; color: var(--muted, #88a); font-weight: 700; margin: 8px 0 2px; }
.sl-outcome .ygb-board { margin-bottom: 6px; }

/* ================= play-vs-AI board (reusable .ygb-board + drawer) ====== */
.play-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.play-board-canvas .ygb-board { box-shadow: 0 2px 18px rgba(0,0,0,0.35); }

/* toggleable graveyard / banished / extra drawers */
.ygb-drawer { border: 1px solid #2c3a4d; border-radius: 6px; background: rgba(255,255,255,0.02); min-width: 96px; }
.ygb-drawer-summary { display: flex; align-items: center; gap: 6px; padding: 4px 8px; cursor: pointer; list-style: none; font-size: 0.72em; user-select: none; }
.ygb-drawer-summary::-webkit-details-marker { display: none; }
.ygb-drawer-summary::before { content: "▸"; color: var(--muted, #88a); font-size: 0.85em; transition: transform 0.15s; }
.ygb-drawer[open] .ygb-drawer-summary::before { transform: rotate(90deg); }
.ygb-drawer-body { display: flex; flex-direction: column; gap: 3px; padding: 4px 8px 8px; max-height: 240px; overflow-y: auto; }
.ygb-drawer-item { display: flex; align-items: center; gap: 6px; }
.ygb-drawer-img { width: 30px; height: 42px; object-fit: cover; border-radius: 3px; background: #1a1a2a; flex: none; }
.ygb-drawer-name { font-size: 0.72em; color: #cde; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ygb-sideinfo .ygb-pile-label { font-size: 0.7em; }

/* keep the action panel pinned while scrolling a long game */
@media (max-width: 860px) {
  .play-actions { position: static; }
}

/* ================= play-vs-AI: full-viewport one-page layout ============= */
/* The play view fills the browser window (DuelingBook-style): the board
   scales to fit the remaining height, and only the log / action list scroll
   internally — the page itself never scrolls. */
body.play-mode { height: 100vh; overflow: hidden; }
body.play-mode .foot { display: none; }
#view.play-view {
  display: flex;
  flex-direction: column;
  padding: 12px 16px 16px;
  max-width: 1720px;
  min-height: 0;
}
.play-view .page-head { margin-bottom: 8px; flex: none; }
.play-view .page-head h2 { font-size: 18px; }
.play-view .page-head p { margin-top: 2px; font-size: 12px; max-width: none; }
.play-view .tabs { margin-bottom: 8px; flex: none; }
.play-view .play-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.play-view .play-setup { margin-bottom: 10px; padding: 10px 14px; flex: none; }
.play-view .play-setup .filter-row { flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.play-view #play-board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px;
  margin-bottom: 0;
}
.play-view .play-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: 1fr;
  gap: 14px;
}
.play-view .play-main { min-height: 0; }
/* the field column's contents fill it.  Without this the row keeps its content
   height: the board sits at the top with all the slack below it and the action
   panel's box stops short, while the log (an `auto` row at the bottom of the
   side column) reaches the bottom of the layout. */
.play-view .play-board-row { flex: 1; min-height: 0; }
.play-view .play-board-canvas {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.play-view .play-log { margin-top: 0; max-height: 132px; overflow-y: auto; }
.play-view .play-aside {
  width: 280px;
  flex: none;
  align-self: stretch;
  min-height: 0;
}
.play-view .play-actions {
  position: static;
  flex: 1 1 auto;
  width: auto;
  min-height: 0;
  overflow-y: auto;
  max-height: none;
  margin-bottom: 0;
}

/* compact, viewport-fit card sizing for the reusable board (board.js fit:true).
   Field-zone cards are deliberately smaller than hand cards so the four field
   rows stay short and the player's hand is always fully visible.
   The previous constants (~ (100vh-320px)/4.1, hand cap 124px) came out ~10%
   too large: on a typical 1080p window the board was taller than the canvas,
   so it only looked right when the browser was zoomed to ~90%.  The overhead
   is raised and the divisor/cap lowered so a 100%-zoom window fits cleanly. */
.ygb-fit {
  /* Deliberately generous: the play board measures the canvas it is in and
     shrinks this until the field fits (fitBoard in board/layout.js), so aiming
     high costs nothing and an undersized board would be the real bug. */
  --field-h: clamp(40px, calc((100vh - 200px) / 5), 150px);
  --hand-h: calc(var(--field-h) * 1.3);
  gap: 4px;
  padding: 8px 14px;
  width: max-content;
  max-width: 100%;
}
.ygb-fit .ygb-field { gap: 8px; }
.ygb-fit .ygb-rows { flex: none; gap: 3px; }
.ygb-fit .ygb-rail { width: 78px; gap: 2px; }
.ygb-fit .ygb-row { justify-content: flex-start; gap: 5px; }
.ygb-fit .ygb-zone { display: flex; gap: 4px; flex: 0 0 auto; }
/* 0.7 is the real card ratio (59x86 ≈ 0.697), so the artwork is no longer
   cropped to fit a too-wide slot */
.ygb-fit .ygb-slot { width: calc(var(--field-h) * 0.7); height: var(--field-h); aspect-ratio: auto; min-height: 0; }
.ygb-fit .ygb-lp { font-size: 0.92em; }
/* a fixed strip for the prompt widgets (pass / effectyn / attack-position pick)
   keeps the board the same height whether or not one is up, so the measured fit
   cannot resize the cards in the middle of a prompt */
.ygb-fit .ygb-mid { padding: 0; gap: 2px; min-height: 78px; justify-content: center; }
.ygb-fit .ygb-turn { font-size: 0.78em; }
.ygb-fit .ygb-phase { font-size: 0.95em; }
.ygb-fit .ygb-phase-track { width: 300px; max-width: 100%; }
.ygb-fit .ygb-hand-row { margin-top: 2px; gap: 6px; }
.ygb-fit .ygb-hand-label { width: auto; flex: none; padding-top: calc(var(--hand-h) * 0.34); }
.ygb-fit .ygb-hand { min-height: 0; gap: 5px; }
.ygb-fit .ygb-hand-card { width: calc(var(--hand-h) * 0.72); height: var(--hand-h); }
.ygb-fit .ygb-name { font-size: 0.44em; }
.ygb-fit .ygb-stat { font-size: 0.48em; }

/* narrow screens: stack the action sidebar beneath the board, and let the whole
   layout scroll so a tall action panel or preview can never overlap it */
@media (max-width: 900px) {
  .play-view .play-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    overflow-y: auto;
  }
  .play-view .play-board-row { flex-direction: column; }
  .play-view .play-aside { width: auto; flex: none; }
  .play-view .play-actions { width: -webkit-fill-available; max-height: 36vh; }
  .play-view .play-side { grid-template-rows: auto auto; }
  .play-view .play-preview { max-height: 46vh; }
  .play-view .play-log { max-height: 26vh; }
}

/* ================= card preview + pile popups (play vs AI) ============= */
.play-board-row { display: flex; gap: 10px; min-height: 0; align-items: stretch; }
.play-board-row .play-board-canvas { flex: 1; min-width: 0; }

.play-preview {
  width: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  overflow-y: auto;
  min-height: 0;
  font-size: 12px;
}
.play-preview-card { display: flex; flex-direction: column; gap: 6px; }
.play-preview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.play-preview-name { font-weight: 700; font-size: 14px; color: #fff; }
.play-preview-img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 6px; background: #1a1a2a; }
.play-preview-type { font-size: 11px; color: var(--accent); font-weight: 600; }
.play-preview-stat { font-size: 12px; color: #cde; }
.play-preview-attr { font-size: 11px; color: var(--muted); }
.play-preview-desc { font-size: 12px; color: #cde; white-space: pre-wrap; line-height: 1.4; }
.play-preview-back { display: flex; align-items: center; justify-content: center; height: 200px; font-size: 4em; background: linear-gradient(135deg, #223, #445); border-radius: 8px; }

.ygb-pile-btn:hover { border-color: var(--accent); color: var(--accent); }
.ygb-pile-btn-row { display: flex; align-items: center; gap: 5px; }
.ygb-pile-btn-label { font-weight: 600; color: var(--muted); }
.ygb-pile-btn-count { font-weight: 700; color: #cde; }

/* GY / Banished are little zones: the last card put in is shown inside the box,
   which is still the button that opens the floating tray */
.ygb-pile-btn.has-face {
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 3px 4px;
  white-space: normal;
}
.ygb-pile-face {
  display: block;
  width: 46px;
  height: 62px;
  border-radius: 4px;
  overflow: hidden;
  background: #1a1a2a;
  border: 1px solid #2b3542;
}
.ygb-pile-face-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ygb-pile-face-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; font-size: 11px; color: #5d6b7d;
}
.ygb-fit .ygb-pile-btn.has-face .ygb-pile-face { width: 38px; height: 52px; }
.ygb-fit .ygb-sideinfo { flex-direction: column; align-items: stretch; gap: 3px; }

/* draggable pile tray (replaces the old modal pile popup) */
.ygb-tray {
  position: fixed;
  z-index: 85;
  background: #141a26;
  border: 1px solid #2c3a4d;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.6);
  padding: 10px 12px;
  width: min(560px, 92vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}
.ygb-tray-head {
  cursor: move; user-select: none; flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 8px;
}
.ygb-tray-title { font-weight: 700; color: var(--accent); font-size: 0.9em; }
.ygb-tray-x { background: transparent; border: none; color: #88a; font-size: 1.2em; cursor: pointer; line-height: 1; padding: 0; }
.ygb-tray-x:hover { color: #fff; }
.ygb-tray-body { overflow-y: auto; min-height: 0; }
.ygb-tray-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px; }
.ygb-tray-card { display: flex; flex-direction: column; gap: 3px; align-items: center; cursor: pointer; border-radius: 4px; padding: 2px; border: 1px solid transparent; }
.ygb-tray-card:hover { border-color: var(--accent); }
.ygb-tray-img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 4px; background: #1a1a2a; }
.ygb-tray-name { font-size: 0.62em; text-align: center; line-height: 1.15; max-height: 2.3em; overflow: hidden; color: #cde; }

/* close button reused by the card preview pane */
.ygb-pile-popup-x {
  width: 28px; height: 28px; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1; padding: 0;
}
.ygb-pile-popup-x:hover { color: #fff; border-color: var(--red); }

/* very narrow screens: drop the side preview (board already fills the width) */
@media (max-width: 700px) {
  .play-preview { display: none; }
}

/* multiplayer room code display + copy button */
.play-room-code { display: flex; align-items: center; gap: 8px; justify-content: center; margin: 8px 0; }
.play-room-code code { font-size: 1.4em; font-weight: 800; letter-spacing: 2px; color: var(--accent); background: rgba(0,0,0,0.35); padding: 4px 14px; border-radius: 6px; user-select: all; }

/* best-of-3 side-deck window */
.side-root { padding: 10px 12px; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.side-head h3 { margin: 0; }
.side-score { font-weight: 800; color: var(--accent); }
.side-pools { display: grid; grid-template-columns: 2fr 1.2fr 1.2fr; gap: 10px; }
@media (max-width: 900px) { .side-pools { grid-template-columns: 1fr; } }
.side-pool { background: rgba(255,255,255,0.03); border: 1px solid var(--line, #2c3a4d); border-radius: 8px; padding: 8px; min-width: 0; }
.side-pool-label { font-size: 0.75em; font-weight: 800; letter-spacing: 0.4px; color: var(--muted, #88a); text-transform: uppercase; margin-bottom: 6px; }
.side-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; max-height: 48vh; overflow-y: auto; }
.side-card { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; border-radius: 6px; padding: 2px; border: 1px solid transparent; background: #10161f; }
.side-card:hover { border-color: var(--accent); }
.side-card.picked { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: -2px; box-shadow: 0 0 8px rgba(74,153,144,0.6); }
.side-card-img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 4px; background: #1a1a2a; }
.side-card-name { font-size: 0.55em; text-align: center; line-height: 1.15; max-height: 2.3em; overflow: hidden; width: 100%; color: #cde; }
.side-msg { margin-top: 8px; }
.side-msg.side-error { color: var(--red, #e77); font-weight: 700; }
.side-first { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; min-height: 26px; }
.side-first-ask { font-weight: 700; }
.side-first-state { font-weight: 700; color: var(--accent); }
.side-first-pick { padding: 3px 12px; }
.side-actions { justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* decision review view */
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rv-opts { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.rv-opt { display: flex; gap: 12px; align-items: center; padding: 6px 9px;
          border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.rv-opt:hover { background: rgba(255,255,255,.07); }
.rv-opt.rv-chosen { background: rgba(96,140,220,.20); }
.rv-opt.rv-pick { background: rgba(96,190,120,.22); outline: 1px solid #57a86a; }
#rv-panel pre { white-space: pre-wrap; font: 13px/1.5 ui-monospace, monospace; }
.btn-good { border-color: #3f7d4c; } .btn-ok { border-color: #5a6d8a; }
.btn-bad { border-color: #8a4450; }
.btn-active { outline: 2px solid currentColor; }

/* review view: real board + sidebar */
.rv-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; align-items: start; }
.rv-board .ygb-board { width: 100%; }
.rv-side { min-width: 0; }
.rv-opt.rv-chosen { box-shadow: inset 3px 0 0 #5f8fdd; }
@media (max-width: 900px) { .rv-grid { grid-template-columns: 1fr; } }

/* review view inside the play layout */
#rv-actions .play-act-buttons { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
#rv-actions .play-act { text-align: left; justify-content: space-between; }
#rv-actions .rv-chosen { outline: 2px solid #5f8fdd; }
#rv-actions .rv-pick { outline: 2px solid #57a86a; background: rgba(87,168,106,.22); }
#rv-actions .play-act b { color: #ffd479; }

/* engine-steps timeline rows inside the review actions panel */
#rv-hist { border-top: 1px solid rgba(255,255,255,.09); max-height: 46vh; overflow-y: auto; }
.rv-hist-item { padding: 8px 0; border-bottom: 1px dashed rgba(255,255,255,.09); }
.rv-hist-item:last-child { border-bottom: none; }
.rv-hist-item .hist-r { font-size: 12px; padding: 2px 9px; }
.rv-hist-item .hist-better { font-size: 12px; padding: 2px 8px; }
.rv-hist-item .hist-better.hist-chosen { outline: 1px solid #5f8fdd; }

/* ===========================================================================
   P2 event animations: card flips, chain negation, coin/dice toss and the
   "missed the timing" tray.
   =========================================================================== */

/* --- flip face-up / face-down -------------------------------------------- */
/* overlay positioned over the card's slot; the inner element turns over while
   the wrapper un/rotates a Defense-position card at the same time */
.ygb-flip {
  position: fixed; z-index: 70; pointer-events: none;
  perspective: 700px;
}
/* a card flying between zones (draw, summon, discard, graveyard...); anime.js
   drives the transform, so left/top/width/height here are only the start box */
.ygb-fly {
  position: fixed; z-index: 72; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  will-change: transform, opacity;
}
.ygb-fly-img {
  width: 100%; height: 100%; object-fit: contain; border-radius: 5px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
}
.ygb-fly .ygb-back { width: 100%; height: 100%; border-radius: 5px; }
.ygb-flip-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
}
.ygb-flip-face {
  position: absolute; inset: 0; border-radius: 6px; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.ygb-flip-front { transform: rotateY(180deg); }
.ygb-flip-img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* --- chain negated / disabled -------------------------------------------- */
.ygb-negate {
  position: absolute; inset: 0; z-index: 8;
  pointer-events: none; border-radius: 6px; overflow: hidden;
}
/* crackling static electricity first */
.ygb-negate-spark {
  position: absolute; inset: -12%;
  background:
    repeating-linear-gradient(72deg, rgba(190,240,255,0) 0 5px, rgba(190,240,255,.95) 5px 7px, rgba(190,240,255,0) 7px 14px),
    repeating-linear-gradient(-64deg, rgba(120,200,255,0) 0 7px, rgba(120,200,255,.75) 7px 9px, rgba(120,200,255,0) 9px 17px);
  mix-blend-mode: screen;
  opacity: 0;
}
/* then the red "negated" stamp */
.ygb-negate-no {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 2.6em; line-height: 1; color: #ff3b30;
  opacity: 0; transform: scale(1.8) rotate(-14deg);
  filter: drop-shadow(0 0 8px rgba(255, 40, 40, .9));
}
.ygb-negate-disabled .ygb-negate-no {
  filter: drop-shadow(0 0 6px rgba(255, 40, 40, .55));
}

/* --- coin / dice toss tray ------------------------------------------------ */
.ygb-toss-tray {
  position: fixed; z-index: 80; transform: translate(-50%, -50%);
  display: flex; gap: 24px; align-items: flex-end;
  pointer-events: none;
}
.ygb-toss-cell { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ygb-coin { width: 64px; height: 64px; perspective: 500px; }
.ygb-coin-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
}
.ygb-coin-side {
  position: absolute; inset: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.5em;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border: 4px solid #b8860b;
  background: radial-gradient(circle at 35% 30%, #ffe89a, #e0b84a 60%, #a97c09);
  color: #6b4a05;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .5);
}
.ygb-coin-tails {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 35% 30%, #f6f6f6, #c4c4c4 60%, #8d8d8d);
  color: #333; border-color: #9a9a9a;
}
.ygb-die {
  width: 58px; height: 58px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #f7f7f7, #cfcfcf);
  color: #222; font-weight: 900; font-size: 1.7em;
  border: 3px solid #8a8a8a; box-shadow: 0 4px 10px rgba(0, 0, 0, .5);
}
.ygb-toss-label {
  font-size: .78em; font-weight: 800; color: #ffd24a;
  opacity: 0; transform: translateY(4px);
  text-shadow: 0 1px 4px #000;
}
.ygb-toss-label.show { opacity: 1; transform: translateY(0); }

/* --- "missed the timing" tray (non-modal, draggable) --------------------- */
.missed-popup {
  position: fixed; z-index: 90; width: 250px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px 10px 10px;
  background: rgba(18, 24, 34, .97); color: #cde;
  border: 1px solid #3a4a5e; border-left: 4px solid #ffb300;
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .6);
}
.missed-popup.dragging { cursor: grabbing; }
.missed-head { display: flex; align-items: center; justify-content: space-between; cursor: grab; }
.missed-title { font-size: .82em; font-weight: 800; color: #ffd24a; }
.missed-x { background: none; border: none; color: #9ab; font-size: 1.1em; cursor: pointer; line-height: 1; }
.missed-x:hover { color: #fff; }
.missed-body { display: flex; align-items: center; gap: 8px; }
.missed-img { width: 44px; height: 64px; object-fit: cover; border-radius: 4px; flex: none; }
.missed-text { font-size: .82em; font-weight: 700; line-height: 1.25; }
.missed-foot { display: flex; justify-content: flex-end; }

/* --- "waiting for the opponent" indicator --------------------------------
   A spinner + three pulsing dots.  Purely CSS (no JS timer), so a re-render
   simply replaces the node and nothing keeps ticking. */
.ygb-waiting {
  display: inline-flex; align-items: center; gap: 9px;
  margin-top: 6px;
  padding: 6px 14px;
  background: rgba(20, 26, 38, 0.92);
  border: 1px solid #2c3a4d;
  border-radius: 999px;
  color: #cde; font-size: 0.84em; font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  animation: ygb-waiting-breathe 2.6s ease-in-out infinite;
}
@keyframes ygb-waiting-breathe {
  0%, 100% { border-color: #2c3a4d; }
  50%      { border-color: rgba(94, 201, 184, 0.75); }
}
.ygb-waiting-spinner {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 2px solid rgba(94, 201, 184, 0.25);
  border-top-color: #5ec9b8;
  animation: ygb-waiting-spin 0.8s linear infinite;
}
@keyframes ygb-waiting-spin { to { transform: rotate(360deg); } }
.ygb-waiting-text { white-space: nowrap; }
.ygb-waiting-dots { display: inline-flex; gap: 3px; }
.ygb-waiting-dots i {
  width: 4px; height: 4px; border-radius: 50%;
  background: #5ec9b8; opacity: 0.3;
  animation: ygb-waiting-dot 1.2s ease-in-out infinite;
}
.ygb-waiting-dots i:nth-child(2) { animation-delay: 0.15s; }
.ygb-waiting-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ygb-waiting-dot {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  40%      { opacity: 1;   transform: translateY(-3px); }
}
/* the side-panel copy is left-aligned and stretches to the panel width */
.play-actions .ygb-waiting { align-self: flex-start; }

/* deck editor: hover preview column (reuses the play board's card preview) */
.deck-preview { position: sticky; top: 12px; max-height: 80vh; }

/* deck editor: legality banner */
.deck-validity { border: 1px solid var(--line, #2c3a4d); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; background: rgba(255,255,255,0.03); }
.deck-validity.is-valid { border-color: #2f6f4f; background: rgba(47,111,79,0.12); }
.deck-validity.is-invalid { border-color: #7a3b3b; background: rgba(122,59,59,0.14); }
.deck-validity-head { font-size: 13px; }
.deck-validity-list { margin: 6px 0 0; padding-left: 20px; font-size: 12.5px; color: var(--muted, #88a); }
.deck-validity-list li { margin: 2px 0; }

/* deck editor: legality badges on catalogue + pool cards */
.rule-badge {
  position: absolute; top: 3px; right: 3px; z-index: 2;
  min-width: 15px; padding: 0 4px; border-radius: 8px;
  font-size: 10px; font-weight: 800; line-height: 15px; text-align: center;
  border: 1px solid rgba(0,0,0,0.5);
}
.rule-badge-ban { background: #8b1f1f; color: #ffd9d9; }
.rule-badge-limited { background: #7a5a12; color: #ffe9b0; }
.rule-badge-semi { background: #35597a; color: #d6ecff; }
.rule-badge-token { background: #3d3d46; color: #d0d0d8; }
.rule-badge-count { background: rgba(0,0,0,0.65); color: #cde; }
.side-card { position: relative; }
.side-card.rule-blocked { opacity: 0.62; }
.side-card.rule-blocked .side-card-img { filter: grayscale(0.5) brightness(0.8); }
.side-card.rule-over { outline: 2px solid #8b1f1f; outline-offset: -2px; }

/* profile deck list: illegal decks */
.deck-invalid-warning {
  color: #ffb4b4; background: rgba(139,31,31,0.18); border: 1px solid #7a3b3b;
  border-radius: 6px; padding: 5px 8px; margin-bottom: 8px; font-size: 11.5px; line-height: 1.35;
}
.deck-card-invalid { border-color: #7a3b3b !important; }

/* profile: name a new deck (hidden until "New deck" is clicked) */
.new-deck {
  display: flex; gap: 8px; align-items: center;
  margin: 0 0 14px; padding: 10px 12px;
  border: 1px dashed var(--border); border-radius: 8px;
}
.new-deck input { flex: 1; max-width: 320px; }


/* deck editor: the deck owns the page (preview+legality | deck | search) */
.deck-view { max-width: 1800px; margin: 12px auto; padding: 12px 16px; }
.deck-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 10px; }
.deck-head h2 { margin: 0; }
.deck-head-acts { display: flex; gap: 8px; }
.deck-lab {
  display: grid; gap: 12px; align-items: start;
  grid-template-columns: 232px minmax(0, 1fr) 300px;
}
.deck-left { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 10px; }
.deck-preview { min-height: 300px; }
.deck-board { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.deck-pool { border: 1px solid var(--line, #2c3a4d); border-radius: 8px; padding: 6px 8px 8px; background: rgba(255,255,255,0.02); }
.deck-pool-main { border-color: #3c4a63; }
.deck-pool-extra { border-color: #6b4a2a; }
.deck-pool-side { border-color: #2f5a63; }
.deck-pool-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 5px; }
.deck-pool-name { font-size: 11px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--muted, #88a); }
.deck-pool-count { font-size: 13px; font-weight: 800; color: var(--text, #dbe6f2); }
.deck-pool-hint { font-size: 10.5px; }
/* 10 columns for the main deck block; extra/side are single strips of 15 (a
   full pool), DuelingBook-style.  Short screens pack the main deck denser so it
   still fits without scrolling. */
.deck-grid { display: grid; grid-template-columns: repeat(var(--deck-cols, 10), minmax(0, 1fr)); gap: 4px; }
.deck-pool-main .deck-grid { --deck-cols: 10; }
.deck-pool-extra .deck-grid, .deck-pool-side .deck-grid { --deck-cols: 15; }
@media (max-height: 860px) {
  .deck-pool-main .deck-grid { --deck-cols: 12; }
}
.deck-pool-count.bad { color: #ff9a9a; }
.deck-tile {
  position: relative; aspect-ratio: 177 / 254; border-radius: 4px; overflow: hidden;
  background: #10161f; border: 1px solid transparent; cursor: pointer; min-width: 0;
}
.deck-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.deck-tile:hover { border-color: var(--accent); }
.deck-tile.rule-over { outline: 2px solid #8b1f1f; outline-offset: -2px; }
.deck-tile .rule-badge { top: 2px; right: 2px; }
.deck-empty { grid-column: 1 / -1; padding: 10px 4px; }

.deck-search { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.deck-search-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.deck-results { min-height: 200px; max-height: 74vh; overflow-y: auto; padding-right: 2px; }
.deck-results .side-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
.side-card-meta { font-size: 0.5em; color: var(--muted, #88a); text-align: center; line-height: 1.2; }
.side-card-acts { display: flex; gap: 2px; margin-top: 3px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 1400px) {
  .deck-lab { grid-template-columns: 200px minmax(0, 1fr) 260px; }
  .deck-grid { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
}
@media (max-width: 1050px) {
  .deck-lab { grid-template-columns: minmax(0, 1fr) 280px; }
  .deck-left { display: none; }
  .deck-grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
}
@media (max-width: 760px) {
  .deck-lab { grid-template-columns: 1fr; }
  .deck-results { max-height: none; }
}

/* card filter bar (shared by the Search view and the deck editor) */
.card-filters { margin-bottom: 10px; }
.card-filters .filter-bar.filter-text { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card-filters .filter-bar.filter-ranges { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); }
.card-filters .filter-field { min-width: 0; }
.card-filters .filter-actions { margin-top: 8px; gap: 14px; align-items: center; }
.card-filters .filter-actions .ghost { padding: 6px 12px; font-size: 12px; }
.card-filters .era-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); text-transform: none; letter-spacing: 0; }
.card-filters .era-toggle input { width: auto; }
/* the deck editor's panel is narrow: keep the text boxes, hide the bulk */
.deck-search .card-filters .filter-text { grid-template-columns: 1fr; gap: 6px; }
.filter-more { margin-top: 6px; }
.filter-more > summary {
  cursor: pointer; font-size: 11.5px; color: var(--muted, #88a);
  text-transform: uppercase; letter-spacing: .6px; padding: 3px 0;
}
.filter-more[open] > summary { color: var(--text, #dbe6f2); }
.filter-more .filter-bar { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); margin-top: 6px; }
.filter-more .filter-ranges { grid-template-columns: repeat(auto-fit, minmax(78px, 1fr)); }
.filter-more .filter-actions { margin-top: 6px; }

/* --- auto-pass toggles (bottom-right of the board) ----------------------- */
.play-board-canvas { position: relative; }
/* Auto-pass toggles: parked under the action panel (they used to overlay the
   bottom-right of the board, which stole room from the field). */
.play-autopass {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px;
  padding: 5px 8px;
  background: rgba(14, 19, 28, 0.88);
  border: 1px solid #2c3a4d; border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  font-size: 11px;
}
.play-ap-btn {
  background: #1a2432; color: #b9c6d6;
  border: 1px solid #3a4a5e; border-radius: 999px;
  padding: 4px 10px; font-weight: 700; font-size: 11px; cursor: pointer;
  white-space: nowrap;
}
.play-ap-btn:hover { border-color: var(--accent); color: #fff; }
.play-ap-btn.active {
  background: linear-gradient(135deg, #5ec9b8, #2b6f66);
  color: #0d1a17; border-color: #5ec9b8;
}
.play-autopass.holding .play-ap-btn#ap-hold {
  background: linear-gradient(135deg, #ffd24a, #d69a12);
  color: #241c05; border-color: #ffd24a;
}
.play-ap-hint { color: #6b7b8c; font-size: 10px; }
/* while a mode is armed, show it without stealing attention */
.play-autopass[data-state="auto-passing"] { border-color: rgba(94, 201, 184, 0.6); }
.play-autopass[data-state="responding"] { border-color: #ffd24a; }

/* ---------- signed-out gate ---------- */
/* Signed out there is nothing to navigate to, so the nav and the account chip
   go away entirely and the sign-in screen owns the page. */
body.signed-out #nav { display: none; }
body.signed-out .deck-chip { display: none !important; }
body.signed-out #auth-status-chip { display: none !important; }
body.signed-out .foot { display: none; }

.auth-view { max-width: 900px; margin: 36px auto; padding: 0 20px; }
.auth-view h2 { margin-bottom: 6px; }
.auth-lede { color: var(--muted); margin-bottom: 22px; }
.auth-grid { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.auth-card {
  flex: 1 1 320px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.auth-card h3 { margin-top: 0; margin-bottom: 14px; }
.auth-field { margin-bottom: 14px; }
.auth-field label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.auth-field input {
  width: 100%; padding: 9px 10px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 14px; font-family: inherit;
}
.auth-field input:focus { outline: none; border-color: var(--accent); }
.auth-field input[name="access_key"] { letter-spacing: 0.06em; text-transform: uppercase; }
.auth-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- matchmaking / private room ---------- */
/* Both human-play modes share the deck picker; the panel is now chosen by the
   Play tab instead of the old two-button "vs Human / vs AI" toggle. */
.mp-deck-row { margin-bottom: 12px; gap: 10px; align-items: center; }
.mp-deck-row label { font-weight: 500; font-size: 13px; }
.mp-deck-select {
  padding: 8px; min-width: 220px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px;
}
.mp-match-status { margin-top: 10px; }
/* the room code stays on screen for the whole game, not just while waiting */
.play-room-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.play-room-bar code { letter-spacing: 0.08em; font-weight: 600; }
/* ---------- the clocks (chess rules) ---------- */
/* Two match clocks and, when a decision is running out, the countdown for it.
   All of it lives at the far end of the room bar: visible without being in the
   way of the board.  `low`/`critical` are what make it readable at a glance. */
.mp-clocks { margin-left: auto; display: flex; gap: 8px; }
.mp-clock {
  font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.04);
  opacity: 0.75;
}
.mp-clock.on-clock { opacity: 1; border-color: var(--accent); }
.mp-clock.low { color: #ffd479; border-color: #7a6a3b; background: rgba(122,106,59,0.18); opacity: 1; }
.mp-clock.critical {
  color: #ffb4b4; border-color: #7a3b3b; background: rgba(139,31,31,0.22); opacity: 1;
  animation: mp-clock-throb 1s ease-in-out infinite;
}
.mp-action-countdown {
  font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 700;
  padding: 2px 10px; border-radius: 999px;
  color: #ffd479; border: 1px solid #7a6a3b; background: rgba(122,106,59,0.18);
}
/* past 10 seconds it stops being information and starts being a warning */
.mp-action-countdown.urgent {
  color: #fff; background: rgba(139,31,31,0.55); border-color: #a33;
  animation: mp-clock-throb 0.5s ease-in-out infinite;
}
@keyframes mp-clock-throb {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* the siding countdown, next to the Ready button in the between-games window */
.side-clock {
  font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600;
  color: #ffd479; border: 1px solid #7a6a3b; background: rgba(122,106,59,0.18);
  border-radius: 999px; padding: 2px 10px;
}
.side-clock.critical {
  color: #ffb4b4; border-color: #7a3b3b; background: rgba(139,31,31,0.22);
  animation: mp-clock-throb 1s ease-in-out infinite;
}

/* the opponent's forfeit clock (see mpForfeitTick): pushed to the far end so it
   is read as a status, not as part of the room code */
.mp-forfeit {
  font-size: 12px; font-weight: 600;
  color: #ffb4b4; background: rgba(139,31,31,0.18);
  border: 1px solid #7a3b3b; border-radius: 999px; padding: 2px 10px;
}

/* ---------- replays: watch a recorded game back ---------- */
/* The page hangs off the profile's match history: game picker, transport
   controls, then the same board component the live game uses (read-only). */
.replay-view { max-width: 1100px; margin: 0 auto; }
.replay-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 10px;
}
.replay-games { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.replay-controls {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 10px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.replay-controls select.replay-speed {
  background: var(--panel); color: inherit; border: 1px solid var(--line);
  border-radius: 6px; padding: 2px 6px; font-size: 12px;
}
.replay-board { min-height: 320px; }
.replay-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.replay-link:hover { text-decoration: underline; }

/* ---------- card links (equips, Unions, maintained effects) ---------- */
/* A card tied to another — an equip spell, a Union monster, or a maintained
   effect like Call of the Haunted — shows a link chip on itself and a count chip
   on the card it points at; hovering either end highlights the other, so "what
   dies if I destroy this" is answerable at a glance and in detail. See
   linkCards() in board/layout.js. */
.ygb-link-chip {
  position: absolute; top: 2px; left: 2px;
  background: rgba(12, 16, 22, 0.85);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0 4px; font-size: 10px; line-height: 15px;
  pointer-events: none;
}
.ygb-attached-chip {
  position: absolute; top: 2px; right: 2px;
  background: rgba(12, 16, 22, 0.85);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0 4px; font-size: 10px; line-height: 15px;
  pointer-events: none;
}
/* the other end of the link, while one end is hovered */
.ygb-link-glow {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  box-shadow: 0 0 12px rgba(68, 170, 153, 0.85);
  z-index: 3;
}
.ygb-has-attached { position: relative; }
