/* Character Force — Character Forge design language
   Deep plum-black surfaces · periwinkle accent · serif display + mono labels */

:root {
  --bg: #0c0a12;
  --bg-card: #15111e;
  --bg-inset: #1a1525;
  --bg-deep: #100d18;
  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.05);
  --text: #f5f2fa;
  --text-dim: #9a93a8;
  --text-faint: #6e6880;
  --accent: #a78bfa;
  --accent-dim: #8b6ff0;
  --accent-soft: rgba(167, 139, 250, 0.12);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --blue: #67b7e8;
  --amber: #f0b45a;
  --red: #f0726a;
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  padding: 0 16px 56px;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- micro labels ---------- */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68em;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--text-faint);
  font-weight: 600;
}

/* ---------- header ---------- */

header {
  max-width: 1060px;
  margin: 0 auto 26px;
  padding: 26px 8px 0;
  background: none;
  border: none;
  text-align: left;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #a78bfa 0%, #f0728c 55%, #f0a45a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

header h1 {
  font-family: var(--font-display);
  color: var(--text);
  font-size: 1.65em;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin: 0;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.62em;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-faint);
  margin-top: 3px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.88em;
  margin-top: 10px;
  max-width: 640px;
}

main { max-width: 1060px; margin: 0 auto; }

/* ---------- cards / panels ---------- */

.sheet,
.creator {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.creator { max-width: 1060px; margin: 0 auto; }

.features-section,
.resources-panel,
.spells-panel,
.masks-panel,
.actions,
.info-box,
.review-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin: 18px 0;
}

.features-section h3,
.resources-panel h3,
.spells-panel h3,
.masks-panel h3,
.actions h3 {
  font-family: var(--font-display);
  color: var(--text);
  font-size: 1.1em;
  margin-bottom: 12px;
}

.masks-panel h4 { color: var(--accent); margin: 16px 0 8px; font-size: 0.92em; }

/* ---------- sheet header ---------- */

.sheet-header { margin-bottom: 22px; }

.sheet-header h2 {
  font-family: var(--font-display);
  color: var(--text);
  font-size: 1.9em;
  font-weight: 700;
}

.sheet-header .eyebrow { display: block; margin-bottom: 8px; }

.subclass { color: var(--accent); font-style: italic; font-size: 0.95em; }

.sheet-top { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }

.level-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-weight: 600;
}

/* ---------- stat tiles ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.stat-box {
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  padding: 14px 10px;
  border-radius: var(--radius-sm);
  text-align: center;
}

.stat-box label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62em;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-faint);
  margin-bottom: 6px;
  font-weight: 600;
}

.stat-value { font-size: 1.7em; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-value.hp { color: var(--green); }
.stat-value.ac { color: var(--blue); }
.stat-value.init { color: var(--amber); }

.stat-box small { color: var(--text-faint); font-size: 0.72em; }

/* ---------- abilities ---------- */

.abilities-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  margin-bottom: 22px;
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

@media (max-width: 640px) {
  .abilities-grid { grid-template-columns: repeat(3, 1fr); }
}

.ability-box {
  padding: 14px 8px;
  text-align: center;
  border-right: 1px solid var(--border-soft);
}

.ability-box:last-child { border-right: none; }

.ability-box label {
  font-family: var(--font-mono);
  font-size: 0.6em;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
}

.ability-score { font-size: 1.4em; font-weight: 700; margin: 3px 0 1px; }
.ability-mod { font-size: 0.85em; font-weight: 600; }
.ability-mod.pos { color: var(--green); }
.ability-mod.neg { color: var(--red); }
.ability-mod.zero { color: var(--text-dim); }

/* ---------- v6.13: ability generation methods ---------- */

.method-tabs { display: flex; gap: 8px; margin: 12px 0 18px; }
.method-tab {
  padding: 8px 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9em;
}
.method-tab.active {
  background: var(--bg-panel, #2a2118);
  color: var(--text, #e8dcc0);
  border-color: var(--amber, #c9a227);
  font-weight: 700;
}
.ability-box select {
  margin: 6px 0;
  padding: 4px;
  font-size: 1.1em;
  text-align: center;
}
.pb-controls { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 0; }
.pb-controls button {
  width: 28px; height: 28px;
  font-size: 1.1em; line-height: 1;
  cursor: pointer;
}
.pb-controls button:disabled { opacity: 0.35; cursor: default; }
.pb-score { font-size: 1.4em; font-weight: 700; min-width: 1.4em; }
.roll-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 640px) { .roll-grid { grid-template-columns: repeat(2, 1fr); } }
.roll-card {
  padding: 12px 8px;
  text-align: center;
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.roll-dice { display: flex; justify-content: center; gap: 6px; margin-bottom: 6px; }
.die {
  display: inline-block;
  width: 30px; height: 30px; line-height: 30px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-weight: 700;
  background: var(--bg-panel, #241d14);
}
.die.dropped { opacity: 0.35; text-decoration: line-through; }
.roll-total { font-size: 1.6em; font-weight: 700; margin: 4px 0 8px; }
.roll-card select { margin-bottom: 8px; max-width: 100%; }

/* ---------- features ---------- */

.feature {
  padding: 12px 14px;
  margin: 8px 0;
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  font-size: 0.9em;
}

.feature strong { color: var(--text); }

.info-box { border-left: 3px solid var(--accent); font-size: 0.9em; }
.info-box strong { color: var(--accent); }

.species-info { margin-top: 8px; padding: 10px; background: var(--card); border-radius: 8px; font-size: 0.9em; }
.species-info p { margin: 6px 0; }
.species-info ul { margin: 6px 0; padding-left: 20px; }
.species-info li { margin: 4px 0; }

/* ---------- masks ---------- */

.mask-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.mask-option {
  background: var(--bg-inset);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--border);
  font-size: 0.88em;
  transition: border-color 0.15s;
}

.mask-option.crafted { border-left-color: var(--amber); }
.mask-option.wearing { border-left-color: var(--green); }

.worn-mask {
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--green);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  font-size: 0.9em;
}

.worn-mask ul { margin: 10px 0 10px 20px; }
.worn-mask li { margin: 5px 0; }

.badge { color: var(--green); font-weight: 700; font-size: 0.82em; }

/* ---------- buttons ---------- */

button {
  font-family: var(--font-sans);
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 18px;
  margin: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88em;
  transition: border-color 0.15s, background 0.15s;
}

button:hover:not(:disabled) { border-color: var(--accent-dim); background: #211b31; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary,
.big-button {
  background: linear-gradient(135deg, var(--accent) 0%, #c4b5fd 100%);
  border: none;
  color: #17122b;
}

button.primary:hover:not(:disabled),
.big-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #b9a3fb 0%, #d3c7fe 100%);
  border: none;
}

.big-button {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 1em;
  margin-top: 20px;
}

.rest-row { display: flex; gap: 10px; margin: 16px 0; }
.rest-row button { flex: 1; }

/* ---------- status badge ---------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  background: var(--green-soft);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: var(--green);
  font-size: 0.78em;
  font-weight: 600;
}

/* ---------- resources ---------- */

.resource-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  margin: 6px 0;
  font-size: 0.9em;
}

.resource-row strong { flex: 1; font-weight: 600; }
.resource-row .res-count { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.resource-row small { color: var(--text-faint); font-size: 0.78em; }

/* ---------- skills ---------- */

.skill-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }

@media (max-width: 560px) {
  .skill-list { grid-template-columns: 1fr; }
}

.skill-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 0.86em;
  border-radius: 6px;
  border-bottom: 1px solid var(--border-soft);
}

.skill-row.proficient { color: var(--accent); background: var(--accent-soft); }

.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.skill-check {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.86em;
  transition: border-color 0.15s;
}

.skill-check:hover { border-color: var(--accent-dim); }
.skill-check.selected { background: var(--accent-soft); border-color: var(--accent); }
.skill-check input { margin-right: 8px; accent-color: var(--accent); }

/* ---------- creator / forms ---------- */

.creator h2 {
  font-family: var(--font-display);
  color: var(--text);
  margin-bottom: 6px;
  font-size: 1.6em;
  font-weight: 700;
}

.creator .creator-sub { color: var(--text-dim); font-size: 0.9em; margin-bottom: 20px; }

.creator h3 { color: var(--text); margin: 22px 0 10px; font-size: 1em; font-weight: 700; }

.steps {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.step {
  padding: 6px 16px;
  border-radius: 20px;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  font-family: var(--font-mono);
  font-size: 0.68em;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  font-weight: 600;
}

.step.active {
  background: linear-gradient(135deg, var(--accent) 0%, #c4b5fd 100%);
  border-color: transparent;
  color: #17122b;
}

.step.done { border-color: rgba(52, 211, 153, 0.4); color: var(--green); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-field { margin-bottom: 4px; }

.form-field > label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.64em;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-faint);
  margin-bottom: 7px;
  font-weight: 600;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 0.92em;
  font-family: var(--font-sans);
  transition: border-color 0.15s;
}

.form-field input::placeholder,
.form-field textarea::placeholder { color: var(--text-faint); }

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.form-field small { color: var(--text-faint); font-size: 0.78em; }

.nav-row { display: flex; justify-content: space-between; margin-top: 24px; gap: 12px; }

.data-info { text-align: center; margin-top: 16px; color: var(--text-faint); font-size: 0.82em; }

/* ---------- class picker ---------- */

.class-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.class-option {
  padding: 18px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, transform 0.1s;
}

.class-option:hover { border-color: var(--accent-dim); transform: translateY(-1px); }
.class-option.selected { border-color: var(--accent); background: var(--accent-soft); }
.class-option strong { display: block; color: var(--text); font-size: 0.94em; }
.class-option small { color: var(--text-faint); font-size: 0.74em; }

/* ---------- source chips ---------- */

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.source-chip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.86em;
  transition: border-color 0.15s, opacity 0.15s;
}

.source-chip .chip-check {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #17122b;
}

.source-chip.on .chip-check { background: var(--accent); border-color: var(--accent); }
.source-chip.off { opacity: 0.5; }
.source-chip strong { display: block; color: var(--text); }
.source-chip small { color: var(--text-faint); }

/* ---------- spells ---------- */

.spell-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  margin: 4px 0;
  font-size: 0.88em;
}

.spell-row small { color: var(--text-faint); }

.spell-row.clickable { cursor: pointer; }
.spell-row.clickable:hover { border-color: var(--accent); background: var(--card); }
.spells-panel h4 {
  font-family: var(--font-mono);
  color: var(--text-faint);
  margin: 14px 0 8px;
  font-size: 0.68em;
  text-transform: uppercase;
  letter-spacing: 1.4px;
}

/* ---------- modal ---------- */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(6, 5, 10, 0.78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 620px;
  max-height: 82vh;
  overflow-y: auto;
  width: 100%;
}

.modal h3 { font-family: var(--font-display); color: var(--text); margin-bottom: 12px; }
.modal-actions { margin-top: 22px; display: flex; gap: 10px; justify-content: flex-end; }

.asi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.asi-grid label { font-size: 0.84em; }
.asi-grid select {
  margin-left: 6px;
  padding: 6px 8px;
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ---------- footer ---------- */

footer {
  text-align: center;
  margin-top: 40px;
  padding: 20px;
  color: var(--text-faint);
  font-size: 0.78em;
  max-width: 1060px;
  margin-left: auto;
  margin-right: auto;
}

footer code {
  font-family: var(--font-mono);
  color: var(--accent);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  padding: 2px 8px;
  border-radius: 6px;
}

/* ---------- scrollbars ---------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: #2c2740; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

a { color: var(--accent); }
h3 { font-size: 1.02em; }

/* ============ v6.0 — Preact polish additions ============ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.sheet-header.hero {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-inset) 100%);
  border: 1px solid var(--border);
}

.sheet-header.hero h2 {
  font-size: 2em;
  margin: 4px 0;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-head h3 { margin: 0; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
}

.icon-btn:hover { color: var(--text); border-color: var(--text-faint); }

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

button.ghost:hover { color: var(--text); border-color: var(--text-faint); }

.sheet-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  padding: 10px 0;
}

.sheet-actions { display: flex; gap: 8px; }

.creator-body {
  animation: cf-fadein 0.25s ease-out;
}

@keyframes cf-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.step { cursor: pointer; transition: all 0.15s ease; }
.step:hover { border-color: var(--accent-dim); color: var(--text); }

.class-option { transition: all 0.15s ease; }
.class-option:hover { transform: translateY(-2px); border-color: var(--accent-dim); }

.skill-check.beast:hover { border-color: var(--accent-dim); }

.pips {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent);
  font-weight: 600;
}

.die {
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: var(--text-dim);
  background: var(--bg-inset);
  padding: 2px 8px;
  border-radius: 6px;
}

.feat-desc {
  font-size: 0.9em;
  color: var(--text-dim);
  margin: 8px 0;
  max-height: 120px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
}

.coin-grid { grid-template-columns: repeat(5, 1fr); }

.spell-row.clickable { cursor: pointer; transition: background 0.15s ease; }
.spell-row.clickable:hover { background: var(--accent-soft); }

.resource-row { align-items: center; }

.modal { animation: cf-pop 0.18s ease-out; }

@keyframes cf-pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
  border-color: var(--accent);
}

/* v6.9: combat toggles, infusion picker */
.toggle-btn {
  padding: 8px 14px; border: 2px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); cursor: pointer; font-size: 0.9em;
}
.toggle-btn:hover { border-color: var(--accent-dim); }
.toggle-btn.active { background: var(--accent-soft); border-color: var(--accent); font-weight: bold; }
.check-row {
  display: flex; gap: 8px; align-items: flex-start; padding: 8px;
  border: 1px solid var(--border); border-radius: 8px; margin: 4px 0; cursor: pointer;
}
.check-row:hover { border-color: var(--accent-dim); }
.check-row.disabled { opacity: 0.5; cursor: not-allowed; }
.check-row input { margin-top: 4px; accent-color: var(--accent); }
.infusion-replicate {
  border: 1px dashed var(--accent-dim); border-radius: 8px; padding: 10px; margin: 8px 0;
}
.infusion-replicate .row { display: flex; justify-content: space-between; align-items: center; margin: 4px 0; }
