/* Cyberdark chargen + sheet + table d20 */
.cd-pick-grid {
  display: grid;
  gap: 8px;
}
.cd-pick {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin: 0;
  cursor: pointer;
}
.cd-pick.is-on,
.cd-pick:has(input:checked) {
  border-color: var(--accent);
}
.cd-pick input { margin-top: 4px; }
.cd-pick span { display: flex; flex-direction: column; gap: 2px; }
.cd-detail {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.sheet-preview .detail-panel-copy { padding: 0 0 4px; }
.sheet-preview .detail-panel-copy ul.compact { margin: 6px 0 0; padding-left: 1.1rem; }

.cd-xp-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 18px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.cd-xp-bar label { margin: 0; }
.cd-xp-bar input { width: 8rem; }
.cd-xp-bar p { margin: 0; flex: 1 1 220px; }
.cd-glitch-tier { margin: 12px 0 6px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.cd-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.cd-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.cd-stat input { width: 100%; }
.cd-mod { color: var(--accent); font-weight: 700; }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}
.cd-sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 700px) {
  .cd-sheet-grid { grid-template-columns: 1fr; }
}

/* Table dice — only paint when this table's ruleset uses d20 */
#cd-dice {
  display: none !important;
}
html[data-table-dice="d20"] #story-bar,
html[data-table-dice="d20"] #pool-builder,
html[data-table-dice="d20"] .pool-action-row,
html[data-table-ruleset="cyberdark"] #story-bar,
html[data-table-ruleset="cyberdark"] #pool-builder,
html[data-table-ruleset="cyberdark"] .pool-action-row {
  display: none !important;
}
html[data-table-dice="d20"] #cd-dice,
html[data-table-ruleset="cyberdark"] #cd-dice {
  display: flex !important;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

html[data-table-dice="d20"] .cd-who-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
html[data-table-dice="d20"] .cd-who {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  line-height: 1.3;
}
html[data-table-dice="d20"] .cd-who-clear {
  flex: 0 0 auto;
}
html[data-table-dice="d20"] .cd-formula {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.22)),
    var(--bg-deep, #0e121c);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
html[data-table-dice="d20"] .cd-formula-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
html[data-table-dice="d20"] .cd-formula-count .btn-step {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
}
html[data-table-dice="d20"] .cd-formula-count strong {
  min-width: 1.1rem;
  text-align: center;
}
html[data-table-dice="d20"] .cd-formula-die {
  display: inline-grid;
  place-items: center;
  min-width: 2.6rem;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f4f4f5;
  color: #18181b;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
html[data-table-dice="d20"] .cd-formula-die:hover,
html[data-table-dice="d20"] .cd-formula-die[aria-expanded="true"] {
  box-shadow: 0 0 0 2px var(--accent);
}
html[data-table-dice="d20"] .cd-die-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
html[data-table-dice="d20"] .cd-die-menu[hidden] {
  display: none !important;
}
html[data-table-dice="d20"] .cd-die-menu .btn.is-on,
html[data-table-dice="d20"] #cd-mode-presets .btn.is-on {
  border-color: var(--accent);
  color: var(--accent);
}
html[data-table-dice="d20"] .cd-formula-vs {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
html[data-table-dice="d20"] .cd-formula.is-flat .cd-formula-vs {
  display: none;
}
html[data-table-dice="d20"] .cd-formula strong {
  font-size: 1.25rem;
  color: var(--accent, #2dd4bf);
}
html[data-table-dice="d20"] .cd-formula-vs,
html[data-table-dice="d20"] #cd-dc-kind {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
html[data-table-dice="d20"] .cd-meters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
html[data-table-dice="d20"] .cd-meter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 8px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  min-width: 0;
}
html[data-table-dice="d20"] .cd-meter.is-pulse {
  box-shadow: 0 0 0 2px var(--accent);
}
html[data-table-dice="d20"] .cd-step-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--btn-h, 32px) 52px var(--btn-h, 32px);
  align-items: center;
  gap: 6px;
  min-width: 0;
}
html[data-table-dice="d20"] .cd-step-name {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html[data-table-dice="d20"] .cd-meter-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding-left: 1px;
}
html[data-table-dice="d20"] .cd-step-row input[type="number"] {
  width: 52px;
  min-width: 0;
  box-sizing: border-box;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 800;
  font-family: var(--mono, ui-monospace, monospace);
  background: var(--bg-deep, #0e121c);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  -moz-appearance: textfield;
  appearance: textfield;
}
html[data-table-dice="d20"] .cd-step-row input[type="number"]::-webkit-outer-spin-button,
html[data-table-dice="d20"] .cd-step-row input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
html[data-table-dice="d20"] .cd-dc-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
html[data-table-dice="d20"] .cd-dc-presets .btn.is-on {
  border-color: var(--accent);
  color: var(--accent);
}
html[data-table-dice="d20"] .cd-advanced {
  border-top: 1px solid var(--border-soft);
  padding-top: 8px;
}
html[data-table-dice="d20"] .cd-advanced summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
}
html[data-table-dice="d20"] .cd-mode-row,
html[data-table-dice="d20"] .cd-kind-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}
html[data-table-dice="d20"] .cd-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 5px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
}
html[data-table-dice="d20"] .cd-mode-pill:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
html[data-table-dice="d20"] .cd-mode-pill input {
  margin: 0;
}
html[data-table-dice="d20"] .cd-pulse {
  box-shadow: 0 0 0 2px var(--accent);
  border-radius: 8px;
}

/* d20 crit/fumble flags: cloth only — no Genesys triumph/despair glyphs */
html[data-table-dice="d20"] .roll-flag-sym,
html[data-table-ruleset="cyberdark"] .roll-flag-sym {
  display: none !important;
}

/* Stage uses Genesys .slot-die cards; only extras live here */
html[data-table-dice="d20"] .slot-tray {
  overflow: visible;
  position: relative;
}
html[data-table-dice="d20"] .slot-die-face {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 2rem;
  font-weight: 800;
}
html[data-table-dice="d20"] .slot-die.is-nat20 {
  box-shadow: 0 0 0 2px #fbbf24, 0 0 18px rgba(251, 191, 36, 0.45);
}
html[data-table-dice="d20"] .slot-die.is-nat1 {
  box-shadow: 0 0 0 2px #f87171, 0 0 18px rgba(248, 113, 113, 0.4);
}
html[data-table-dice="d20"] .slot-die.cd-slot-flash {
  animation: cd-slot-blink-box 0.16s ease-out;
}
html[data-table-dice="d20"] .slot-die.cd-slot-flash .slot-die-label {
  animation: cd-slot-blink-label 0.16s ease-out;
}
html[data-table-dice="d20"] .slot-die.cd-slot-flash .slot-die-face {
  animation: cd-slot-blink-face 0.16s ease-out;
}
@keyframes cd-slot-blink-face {
  0%,
  45% {
    background: #fbbf24;
    filter: brightness(1.18);
  }
  100% {
    background: var(--die-color);
    filter: brightness(1);
  }
}
@keyframes cd-slot-blink-label {
  0%,
  45% { color: #fbbf24; }
  100% { color: var(--die-color); }
}
@keyframes cd-slot-blink-box {
  0%,
  45% {
    box-shadow: 0 0 0 2px #fbbf24, 0 0 16px rgba(251, 191, 36, 0.55);
  }
  100% {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  }
}
html[data-table-dice="d20"] .cd-stage-eq {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}
html[data-table-dice="d20"] .cd-stage-dice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
html[data-table-dice="d20"] .cd-stage-op {
  flex: 0 0 auto;
  min-width: 1.1em;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-muted, #8fa3bd);
  text-align: center;
  user-select: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
html[data-table-dice="d20"] .slot-die.is-merge-target {
  position: relative;
  z-index: 5;
}
html[data-table-dice="d20"] .slot-die.is-sliding,
html[data-table-dice="d20"] .cd-stage-op.is-sliding {
  position: relative;
  z-index: 1;
  pointer-events: none;
  transition: none !important;
}
html[data-table-dice="d20"] .slot-die.cd-merge-glow {
  box-shadow: 0 0 0 2px #fbbf24, 0 0 22px rgba(251, 191, 36, 0.6);
}
html[data-table-dice="d20"] .slot-die.cd-merge-glow .slot-die-window {
  background: #fbbf24;
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.85), 0 0 22px rgba(251, 191, 36, 0.7);
}
html[data-table-dice="d20"] .slot-die.cd-merge-glow .slot-die-face {
  opacity: 0 !important;
  color: transparent !important;
}
html[data-table-dice="d20"] .slot-die-face {
  transition: opacity 0.16s ease;
}

.cd-chargen textarea,
.cd-sheet textarea,
.cd-sheet .sheet-note-composer textarea,
.cd-sheet .sheet-note-composer input[type="url"] {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
  resize: vertical;
}
.cd-talent-picks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 12px;
}
.cd-talent-pick-card {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
}
.cd-talent-pick-card select {
  font: inherit;
  max-width: 100%;
}

.cd-chargen textarea {
  min-height: 7.5rem;
}
.cd-sheet .sheet-note-composer textarea {
  min-height: 5.5rem;
}
.cd-chargen textarea:focus,
.cd-sheet textarea:focus,
.cd-sheet .sheet-note-composer input:focus {
  outline: none;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.cd-chargen .wizard-panel { display: none; }
.cd-chargen .wizard-panel.active { display: block; }
.cd-chargen .wizard-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 16px 0 32px;
}
.cd-check-list { display: grid; gap: 6px; }
.cd-check {
  display: block;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  margin: 0;
}
.cd-shop {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 14px;
}
.cd-shop-item {
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: inherit;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font: inherit;
}
.cd-shop-item.is-on {
  border-color: var(--accent);
}
.cd-sheet-block { margin-bottom: 10px; }
