/* =============================================================================
   5E SRD Character Sheet & Creation Styles — d5e- prefix
   =============================================================================

   Font Size Hierarchy:
     Labels:       0.7rem   (section labels, card labels, level headers)
     Body/names:   0.85rem  (skill names, spell names, body text)
     Values:       1rem-1.3rem (scores, modifiers, slot counts)
     Large values: 1.5rem   (core stats, primary values)
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Shared Stat Card Base — common pattern for card-like elements
   ----------------------------------------------------------------------------- */
.d5e-card {
  background: var(--bg-hover);
  border-radius: 6px;
  padding: 0.75rem 0.5rem;
  text-align: center;
}
.d5e-card-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.d5e-card-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* -----------------------------------------------------------------------------
   Standard Array Assignment (Creation)
   ----------------------------------------------------------------------------- */
.d5e-standard-array {
  max-width: 500px;
}
.d5e-array-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.d5e-array-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.d5e-array-label {
  min-width: 120px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.d5e-array-select {
  width: 120px;
}
.d5e-array-mod {
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 40px;
  text-align: center;
  color: var(--text-secondary);
}
.d5e-array-mod.positive {
  color: var(--success);
}
.d5e-array-mod.negative {
  color: var(--error);
}

/* -----------------------------------------------------------------------------
   5E Score Generation Method Selector
   ----------------------------------------------------------------------------- */
.d5e-score-method-selector {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.d5e-roll-prompt {
  text-align: center;
  padding: 1.5rem;
}

.d5e-roll-prompt .button {
  margin-top: 0.75rem;
}

/* -----------------------------------------------------------------------------
   5E Species Detail (Creation)
   ----------------------------------------------------------------------------- */
.d5e-species-detail {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.d5e-asi {
  margin-top: 0.25rem;
}
.d5e-asi ul {
  margin: 0.25rem 0 0 1.5rem;
  padding: 0;
}
.d5e-asi li {
  color: var(--success);
  font-weight: 500;
  font-size: 0.85rem;
}

/* -----------------------------------------------------------------------------
   5E Class Detail (Creation)
   ----------------------------------------------------------------------------- */
.d5e-class-detail {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.d5e-class-info {
  font-size: 0.85rem;
  color: var(--text-primary);
}
.d5e-skill-choices-preview {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* -----------------------------------------------------------------------------
   5E Background Detail (Creation)
   ----------------------------------------------------------------------------- */
.d5e-bg-detail {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.d5e-bg-skills {
  font-size: 0.85rem;
}

/* -----------------------------------------------------------------------------
   5E Skill Proficiency Picker (Creation)
   ----------------------------------------------------------------------------- */
.d5e-skill-picker {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.d5e-bg-granted h4,
.d5e-class-choices h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.d5e-skill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.d5e-skill-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border-primary);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  text-transform: capitalize;
}
.d5e-skill-chip:hover {
  border-color: var(--accent-red);
  color: var(--text-primary);
}
.d5e-skill-chip.selected {
  background: rgba(230, 57, 70, 0.15);
  border-color: var(--accent-red);
  color: var(--text-primary);
}
.d5e-skill-chip.granted {
  background: rgba(74, 222, 128, 0.15);
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--success);
  cursor: default;
}
.d5e-skill-chip.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.d5e-skill-chip.from-bg {
  opacity: 0.5;
  cursor: default;
}
.d5e-skill-chip input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent-red);
}
.d5e-from-bg-tag {
  font-size: 0.7rem;
  color: var(--success);
  font-style: italic;
}

/* -----------------------------------------------------------------------------
   5E Summary Panel (Creation)
   ----------------------------------------------------------------------------- */
.d5e-summary {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.d5e-summary-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.d5e-stat-card {
  background: var(--bg-hover);
  border-radius: 6px;
  padding: 0.75rem 0.5rem;
  text-align: center;
}
.d5e-stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.d5e-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}
.d5e-summary-abilities h4,
.d5e-summary-skills h4 {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 0.5rem;
}
.d5e-summary-ability-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}
.d5e-summary-ability {
  text-align: center;
  background: var(--bg-hover);
  border-radius: 6px;
  padding: 0.5rem;
}
.d5e-summary-attr {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  display: block;
}
.d5e-summary-score {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}
.d5e-summary-mod {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: block;
}
.d5e-summary-skill-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.d5e-summary-skill-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  text-transform: capitalize;
}

/* Proficiency dot — single class used in summary and session */
.d5e-prof-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  flex-shrink: 0;
}
.d5e-prof-dot.filled {
  background: var(--success);
  border-color: var(--success);
}
.d5e-skill-bonus {
  margin-left: auto;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: monospace;
}

/* -----------------------------------------------------------------------------
   5E Session View — HP Display
   ----------------------------------------------------------------------------- */
.d5e-hp-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.d5e-hp-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.d5e-hp-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-red);
}

/* -----------------------------------------------------------------------------
   5E Session View — Core Stats Row
   ----------------------------------------------------------------------------- */
.d5e-core-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.d5e-core-stat {
  background: var(--bg-hover);
  border-radius: 6px;
  padding: 0.75rem 0.5rem;
  text-align: center;
}
.d5e-core-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.d5e-core-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* -----------------------------------------------------------------------------
   5E Session View — Ability Score Cards
   ----------------------------------------------------------------------------- */
.d5e-ability-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}
.d5e-ability-card {
  background: var(--bg-hover);
  border-radius: 6px;
  padding: 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  border: 1px solid transparent;
}
.d5e-ability-card:hover {
  background: var(--border-primary);
}
.d5e-ability-card.d5e-ability-rolled {
  background: rgba(74, 222, 128, 0.15);
  border-color: rgba(74, 222, 128, 0.3);
}
.d5e-ability-name {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}
.d5e-ability-score {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.d5e-ability-mod {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--info);
}
.d5e-ability-roll-result {
  font-size: 0.7rem;
  color: var(--success);
  font-weight: 600;
  margin-top: 0.15rem;
}

/* -----------------------------------------------------------------------------
   5E Session View — Skill Rows
   ----------------------------------------------------------------------------- */
.d5e-skills-list {
  display: flex;
  flex-direction: column;
}
.d5e-skill-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border-primary);
  cursor: pointer;
  transition: background 0.1s, transform 0.05s;
  border-radius: 3px;
}
.d5e-skill-row:hover {
  background: rgba(255, 255, 255, 0.03);
}
.d5e-skill-row.d5e-skill-rolled {
  background: rgba(74, 222, 128, 0.1);
}
.d5e-skill-name {
  color: var(--text-primary);
  font-size: 0.85rem;
  text-transform: capitalize;
  flex: 1;
}
.d5e-skill-bonus-val {
  font-weight: 600;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.85rem;
  min-width: 30px;
  text-align: right;
}
.d5e-skill-roll-result {
  color: var(--success);
  font-weight: 600;
  font-size: 0.85rem;
  min-width: 25px;
  text-align: right;
}

/* -----------------------------------------------------------------------------
   5E Session View — Saving Throw Rows
   ----------------------------------------------------------------------------- */
.d5e-save-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border-primary);
  cursor: pointer;
  transition: background 0.1s, transform 0.05s;
  border-radius: 3px;
}
.d5e-save-row:hover {
  background: rgba(255, 255, 255, 0.03);
}
.d5e-save-row.d5e-save-rolled {
  background: rgba(74, 222, 128, 0.1);
}
.d5e-save-name {
  color: var(--text-primary);
  font-size: 0.85rem;
  flex: 1;
}
.d5e-save-bonus {
  font-weight: 600;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.85rem;
  min-width: 30px;
  text-align: right;
}
.d5e-save-roll-result {
  color: var(--success);
  font-weight: 600;
  font-size: 0.85rem;
  min-width: 25px;
  text-align: right;
}

/* -----------------------------------------------------------------------------
   Spell Slots Section (shared OSR + 5E)
   ----------------------------------------------------------------------------- */
.spell-slots-section {
  /* Inherits .cs-section spacing */
}
.spell-slots-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.spell-slot-card {
  background: var(--bg-hover);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  text-align: center;
  min-width: 70px;
  border: 1px solid var(--border-primary);
}
.spell-slot-level {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}
.spell-slot-count {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--info);
}
.spell-slot-note {
  font-size: 0.7rem;
  color: var(--success);
  font-style: italic;
  margin-top: 0.1rem;
}

/* -----------------------------------------------------------------------------
   Class Features Section (shared OSR + 5E)
   ----------------------------------------------------------------------------- */
.class-features-section {
  /* Inherits .cs-section spacing */
}
.class-features-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.class-feature-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border-primary);
  border-radius: 3px;
}
.class-feature-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.class-feature-level {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}
.class-feature-desc {
  width: 100%;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 0.15rem;
}

/* -----------------------------------------------------------------------------
   Roll Click Animation — tactile press feedback
   ----------------------------------------------------------------------------- */
.d5e-ability-card:active,
.d5e-skill-row:active,
.d5e-save-row:active {
  transform: scale(0.97);
  transition: transform 0.05s;
}

/* Roll result flash animation */
@keyframes d5e-roll-flash {
  0% { background: rgba(74, 222, 128, 0.3); }
  100% { background: transparent; }
}
.d5e-ability-rolled,
.d5e-skill-rolled,
.d5e-save-rolled {
  animation: d5e-roll-flash 0.5s ease-out;
}

/* -----------------------------------------------------------------------------
   Mobile Responsive
   ----------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .d5e-ability-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .d5e-core-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .d5e-summary-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .d5e-summary-ability-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .spell-slots-grid {
    gap: 0.35rem;
  }
  .spell-slot-card {
    min-width: 60px;
    padding: 0.4rem 0.5rem;
  }
}

@media (max-width: 400px) {
  .d5e-ability-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .d5e-skill-list {
    flex-direction: column;
  }
}

/* -----------------------------------------------------------------------------
   5E Advantage / Disadvantage Roll Mode Toggle
   ----------------------------------------------------------------------------- */
.d5e-roll-mode {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  margin: 0.5rem 0;
}
.d5e-roll-mode button {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.d5e-roll-mode button.active {
  border-color: var(--accent-red);
  color: var(--accent-red);
  background: rgba(230, 57, 70, 0.1);
}
.d5e-roll-mode button:hover {
  border-color: var(--text-muted);
}

/* -----------------------------------------------------------------------------
   5E Spell Preparation Section
   ----------------------------------------------------------------------------- */
.d5e-spells-section {
  /* Inherits .cs-section */
}
.d5e-spells-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.d5e-spells-header .cs-section-title {
  margin: 0;
}
.d5e-spells-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.d5e-spell-prep-badge {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--info);
  background: rgba(96, 165, 250, 0.15);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
}
.d5e-spell-prep-badge.over-limit {
  color: var(--error);
  background: var(--error-bg);
}

/* Prepared spells display list */
.d5e-prepared-spells-list {
  display: flex;
  flex-direction: column;
}
.d5e-prepared-level-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.5rem 0 0.25rem;
  border-bottom: 1px solid var(--border-primary);
  margin-top: 0.25rem;
}
.d5e-prepared-level-header:first-child {
  margin-top: 0;
}
.d5e-prepared-spell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border-primary);
  border-radius: 3px;
}
.d5e-prepared-spell-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}
.d5e-prepared-spell-meta {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.d5e-spell-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  white-space: nowrap;
}

/* Spell management panel */
.d5e-spell-mgmt-panel {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.d5e-spell-mgmt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.d5e-spell-mgmt-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.d5e-spell-prep-counter {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--info);
  text-align: center;
  margin-bottom: 0.75rem;
  padding: 0.4rem;
  background: rgba(96, 165, 250, 0.1);
  border-radius: 4px;
}
.d5e-spell-prep-counter.over-limit {
  color: var(--error);
  background: var(--error-bg);
}
.d5e-spell-mgmt-group {
  margin-bottom: 0.5rem;
}
.d5e-spell-mgmt-level {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 0.25rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-primary);
}
.d5e-spell-mgmt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  border-radius: 3px;
  transition: background 0.1s;
}
.d5e-spell-mgmt-row:hover {
  background: rgba(255, 255, 255, 0.03);
}
.d5e-spell-mgmt-row.prepared {
  background: rgba(96, 165, 250, 0.08);
}
.d5e-spell-mgmt-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  flex: 1;
}
.d5e-spell-mgmt-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--info);
  cursor: pointer;
  flex-shrink: 0;
}
.d5e-spell-always-known {
  display: inline-block;
  width: 16px;
  text-align: center;
  color: var(--success);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.d5e-spell-mgmt-name {
  font-size: 0.85rem;
  color: var(--text-primary);
}
.d5e-spell-mgmt-meta {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Mobile responsive for spell prep */
@media (max-width: 600px) {
  .d5e-prepared-spell-meta,
  .d5e-spell-mgmt-meta {
    display: none;
  }
  .d5e-spells-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}
