/* ===== Tokens ===== */
:root {
  --app-max-width: 720px;
  --app-gutter: 0.875rem;

  --bg: #eef3ff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(243, 247, 255, 0.9);
  --surface-muted: #eef2f7;

  --text: #16213d;
  --text-body: #33415d;
  --text-muted: #70809d;
  --accent: #2852d6;
  --accent-strong: #2147b2;
  --accent-soft: rgba(40, 82, 214, 0.12);

  --border: rgba(114, 133, 176, 0.24);
  --border-strong: rgba(76, 104, 168, 0.32);
  --shadow-soft: 0 14px 30px rgba(18, 33, 68, 0.09);
  --shadow-strong: 0 18px 44px rgba(17, 31, 63, 0.12);

  --radius-lg: 1.35rem;
  --radius-md: 1rem;
  --radius-sm: 0.8rem;
  --glass: blur(16px) saturate(145%);

  --fs-xs: 0.78rem;
  --fs-sm: 0.86rem;
  --fs-md: 0.93rem;
  --fs-base: 1rem;
  --fs-lg: 1.06rem;
  --fs-xl: 1.14rem;
  --fs-2xl: 1.42rem;
  --fs-3xl: 1.95rem;

  /* Backward-compatible aliases for existing component rules */
  --panel: var(--surface);
  --panel-soft: var(--surface-soft);
  --panel-muted: var(--surface-muted);
  --muted: var(--text-muted);
  --app-body: var(--text-body);
  --app-title: var(--text);
  --app-muted: var(--text-muted);
  --app-accent: var(--accent);
}

/* ===== Base ===== */
* {
  box-sizing: border-box;
}

html {
  background:
    radial-gradient(circle at top left, rgba(83, 106, 176, 0.18), transparent 31%),
    radial-gradient(circle at top right, rgba(55, 145, 179, 0.1), transparent 24%),
    linear-gradient(180deg, #eef3ff 0%, #e8eef8 44%, #eef2f8 100%);
}

body {
  max-width: var(--app-max-width);
  margin: 0 auto;
  padding: 5.1rem var(--app-gutter) 2rem;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-body);
}

#main-content {
  display: grid;
  gap: 0.9rem;
}

.site-header {
  position: relative;
  z-index: 20;
}

label {
  width: 100%;
  margin-bottom: 0.45rem;
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--text);
}

.small-text,
.skill-action-hint,
.spell-qr-modal-note,
.deity-item-sub,
.site-footer,
.site-hero p,
.quo-text {
  color: var(--text-muted);
}

.small-text {
  font-size: var(--fs-sm);
  line-height: 1.55;
}

.is-hidden {
  display: none;
}

.summary-title-inline {
  display: inline;
  margin: 0;
}

/* ===== Navigation ===== */
.tabs-shell {
  position: fixed;
  top: 0.55rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: min(var(--app-max-width), calc(100vw - 1rem));
  padding: 0.32rem;
  border: 1px solid rgba(112, 134, 184, 0.18);
  border-radius: 1.35rem;
  background: rgba(241, 246, 255, 0.86);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow: var(--shadow-strong);
}

.tabs {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  width: 100%;
  margin: 0;
}

.tab-button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 2.7rem;
  padding: 0.7rem 0.3rem;
  border: 0;
  border-radius: 1.1rem;
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 800;
  letter-spacing: 0.01em;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.18s ease, box-shadow 0.2s ease;
}

.tab-button:hover:not(.active) {
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(145, 165, 205, 0.18);
}

.tab-button.active {
  background: linear-gradient(180deg, var(--accent-strong) 0%, #2962e8 100%);
  color: #fff;
  box-shadow: 0 8px 18px rgba(31, 100, 255, 0.32);
}

.tab-content {
  display: none;
  width: 100%;
  padding-bottom: 0;
}

.tab-content.active {
  display: block;
}

.tab-content > .section + .section,
.tab-content > .section + details.section,
.tab-content > details.section + .section,
.tab-content > details.section + details.section {
  margin-top: 0.95rem;
}

#tab-skills > * + *,
#tab-equipment > * + *,
#tab-spells > * + * {
  margin-top: 0.95rem;
}

/* ===== Surfaces ===== */
.section {
  margin-bottom: 0;
  padding: 1rem 1rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

.section:hover,
details.section:hover {
  border-color: var(--border-strong);
}

.section > h3,
.section summary h3,
h3 {
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.section > h3,
#tab-actions > h3,
#tab-equipment .section > h3,
#tab-spells .section > h3 {
  margin-bottom: 0.75rem;
  font-size: var(--fs-lg);
  font-weight: 850;
}

details > summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2rem;
  padding-bottom: 0.1rem;
  list-style: none;
  cursor: pointer;
}

details > summary:not(.equipment-note-summary)::before {
  content: "▸";
  color: var(--accent);
  font-size: 0.9rem;
  line-height: 1;
  transform-origin: center;
  transition: transform 0.18s ease, color 0.18s ease;
}

details[open] > summary:not(.equipment-note-summary)::before {
  transform: rotate(90deg);
}

details > summary::-webkit-details-marker,
.spell-level-section > summary::-webkit-details-marker {
  display: none;
}

#equipment-notes-section details {
  margin-top: 0.65rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1rem;
  background: rgba(246, 249, 255, 0.72);
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

#equipment-notes-section details:hover {
  border-color: rgba(76, 104, 168, 0.32);
  background: rgba(248, 251, 255, 0.9);
}

#equipment-notes-section .equipment-note-summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.8rem 0.95rem;
  font-weight: 800;
  color: var(--text);
}

#equipment-notes-section .equipment-note-summary::before {
  content: "▸";
  color: var(--accent);
  font-size: 0.9rem;
  line-height: 1;
  transform-origin: center;
  transition: transform 0.18s ease, color 0.18s ease;
}

#equipment-notes-section details[open] > .equipment-note-summary::before {
  transform: rotate(90deg);
}

#equipment-notes-section .equipment-note-summary:hover {
  color: var(--accent-strong);
}

#equipment-notes-section .equipment-note-body {
  margin: 0;
  padding: 0 0.95rem 0.95rem;
}

.output,
#warlock-invocation-summary,
#weapon-mastery-summary,
.condition-display-card,
.save-pair,
.skill-cell,
.spell-slot-column,
.action-collapsible-wrap,
.hp-card,
.mini-stat-card,
.site-footer {
  background: var(--surface-soft);
  border-color: rgba(151, 168, 201, 0.26);
}

.output {
  padding: 0.95rem 1rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.05rem;
  white-space: pre-wrap;
  line-height: 1.5;
}

#raceFeatures {
  white-space: normal;
}

#raceFeatures .race-feature-line {
  line-height: 1.55;
}

#raceFeatures .race-feature-line + .race-feature-line {
  margin-top: 0.2rem;
}

#raceFeatures .race-feature-spacer {
  height: 0.8rem;
}

#raceFeatures .race-feature-table-wrap {
  margin: 0.8rem 0;
  overflow-x: auto;
}

#raceFeatures .race-feature-table-wrap table {
  width: 100%;
  min-width: 28rem;
  border-collapse: collapse;
}

#raceFeatures .race-feature-table-wrap td,
#raceFeatures .race-feature-table-wrap th {
  padding: 0.45rem 0.55rem;
  white-space: normal;
}

#tab-basic .output {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

#tab-basic .output table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
}

#tab-basic .output th,
#tab-basic .output td {
  white-space: normal !important;
  word-break: break-word;
}

.selection-summary {
  margin-top: 6px;
  padding: 12px;
  border: 1px solid rgba(128, 148, 184, 0.28);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(244, 248, 255, 0.98) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.selection-summary-empty {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.selection-summary-list {
  display: grid;
  gap: 10px;
}

.selection-summary-card {
  padding: 10px 12px;
  border: 1px solid rgba(151, 168, 201, 0.3);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
}

.selection-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.selection-summary-title {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 900;
}

.selection-summary-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(40, 82, 214, 0.12);
  color: var(--accent-strong);
  font-size: var(--fs-xs);
  font-weight: 900;
}

.selection-summary-body {
  white-space: pre-wrap;
  line-height: 1.55;
  color: var(--text-body);
}

#metamagic-summary {
  margin-bottom: 12px;
}

#backgroundFeatures {
  white-space: normal;
}

/* ===== Forms ===== */
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

select,
input[type="number"],
input[type="text"],
textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(145, 163, 197, 0.34);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 1px 2px rgba(22, 38, 80, 0.04);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

/* 基本資料四個下拉改為一般方角樣式 */
select,
input[type="text"],
textarea {
  min-height: 2.9rem;
  padding: 0.8rem 0.95rem;
  font-size: var(--fs-base);
}

input[type="number"] {
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  font-size: var(--fs-lg);
  font-weight: 800;
  text-align: center;
}

select:focus,
input[type="number"]:focus,
input[type="text"]:focus,
textarea:focus {
  border-color: rgba(36, 93, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(36, 93, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

textarea {
  min-height: 6.5rem;
  resize: vertical;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  vertical-align: middle;
}

button {
  width: 100%;
  min-height: 2.9rem;
  margin-bottom: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(132, 156, 204, 0.24);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #ffffff 0%, #eef4ff 100%);
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(31, 55, 112, 0.08);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #ffffff 0%, #e9f0ff 100%);
  box-shadow: 0 12px 24px rgba(31, 55, 112, 0.11);
}

button:active {
  transform: translateY(0) scale(0.98);
}

.button-compact {
  margin-bottom: 0;
  font-size: var(--fs-sm);
  font-weight: 800;
}

.form-grid-2col,
.form-grid-3col,
.form-grid-6col,
.save-grid,
.skill-grid,
.ability-grid,
.spell-picked-grid,
.spell-slot-grid,
.spell-casting-stats,
.bottom-buttons,
.share-actions-wrap {
  gap: 0.75rem;
}

.form-grid-2col,
.form-grid-3col {
  display: grid;
  margin-bottom: 0.75rem;
}

.form-grid-2col {
  grid-template-columns: 1fr;
}

.form-grid-3col {
  grid-template-columns: 1fr;
  align-items: end;
}

.form-grid-6col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0.85rem;
  font-size: var(--fs-md);
  background: var(--surface-soft);
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 0.95rem;
}

.form-grid-6col label {
  margin-bottom: 0;
  color: var(--text-muted);
}

.form-grid-6col > span:empty {
  display: none;
}

.language-card > h3 {
  margin-bottom: 0.8rem;
}

.language-section,
.language-base-grid,
.language-field,
.language-extra-container,
.language-extra-container > div {
  display: grid;
  gap: 0.75rem;
}

.language-section {
  margin-top: 0;
}

.language-section > label,
.language-field > label,
.language-extra-container > div > label,
.language-extra-label {
  margin-bottom: 0;
}

.language-select {
  width: 100%;
  margin-left: 0;
}

.language-extra-container {
  margin-top: 0;
}

.language-extra-container:empty {
  display: none;
}

.language-extra-row {
  display: grid;
  gap: 0.45rem;
  margin-top: 0;
}

.language-extra-label {
  margin-right: 0;
}

.inline-check-label {
  width: auto;
  margin: 0 6px 0 0;
}

/* ===== Basic Tab ===== */
.hp-card,
.mini-stat-card {
  padding: 0.95rem 1rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.25rem;
  box-shadow: var(--shadow-soft);
}

#tab-basic .mini-stat-card {
  padding: 0.85rem;
  border-radius: 1.1rem;
}

.hp-title,
.mini-stat-label {
  margin-bottom: 0.35rem;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hp-title {
  display: grid;
  gap: 0.55rem;
}

.basic-overview {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.basic-row {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.basic-row--class-level {
  grid-template-columns: 1fr;
}

.basic-row--origin {
  grid-template-columns: minmax(0, 3.2fr) minmax(5.5rem, 0.9fr);
}

.basic-row--vitals,
.basic-row--misc {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.basic-row--combat {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.basic-pair-card {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.basic-pair-card--class-level {
  grid-template-columns: minmax(0, 2.6fr) minmax(4.75rem, 1fr);
}

.basic-pair-card--equal {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.basic-pair-field,
.basic-single-card {
  min-width: 0;
}

.basic-metric-card {
  min-width: 0;
}

.basic-metric-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.basic-metric-values > * {
  min-width: 0;
}

.hp-value,
#ac-display,
#hp-display {
  color: var(--accent);
  font-size: var(--fs-2xl);
  font-weight: 900;
}

#tab-basic #hp-display,
#tab-basic #ac-display,
#tab-basic .basic-display-checkbox,
#tab-basic .tight-input,
#tab-basic .hp-card input[type="number"] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border-radius: 1rem;
  border: 1px solid rgba(151, 168, 201, 0.34);
  background: #fff;
  color: var(--text);
  text-align: center;
  font-size: var(--fs-xl);
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 1px 2px rgba(22, 38, 80, 0.04);
}

#tab-basic #hp-display,
#tab-basic #ac-display {
  margin-left: 0;
  color: var(--accent);
}

#tab-basic .basic-display-checkbox {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  width: 100%;
  min-width: 0;
  height: auto;
  cursor: pointer;
  position: relative;
}

#tab-basic .basic-display-checkbox::after {
  content: "";
  width: 1.35rem;
  height: 1.35rem;
  border: 1.5px solid rgba(110, 110, 110, 0.72);
  border-radius: 0.16rem;
  background:
    linear-gradient(135deg, transparent 36%, rgba(110, 110, 110, 0.86) 37%, rgba(110, 110, 110, 0.86) 43%, transparent 44%) center/100% 100%,
    linear-gradient(225deg, transparent 36%, rgba(110, 110, 110, 0.86) 37%, rgba(110, 110, 110, 0.86) 43%, transparent 44%) center/100% 100%,
    linear-gradient(315deg, transparent 36%, rgba(110, 110, 110, 0.86) 37%, rgba(110, 110, 110, 0.86) 43%, transparent 44%) center/100% 100%,
    linear-gradient(45deg, transparent 36%, rgba(110, 110, 110, 0.86) 37%, rgba(110, 110, 110, 0.86) 43%, transparent 44%) center/100% 100%,
    linear-gradient(180deg, #ffffff 0%, #f4f4f4 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.92), 0 1px 2px rgba(22, 38, 80, 0.08);
}

#tab-basic .basic-display-checkbox:checked::after {
  border-color: rgba(70, 70, 70, 0.9);
  background:
    linear-gradient(135deg, transparent 34%, rgba(55, 55, 55, 0.96) 35%, rgba(55, 55, 55, 0.96) 44%, transparent 45%) center/100% 100%,
    linear-gradient(225deg, transparent 34%, rgba(55, 55, 55, 0.96) 35%, rgba(55, 55, 55, 0.96) 44%, transparent 45%) center/100% 100%,
    linear-gradient(315deg, transparent 34%, rgba(55, 55, 55, 0.96) 35%, rgba(55, 55, 55, 0.96) 44%, transparent 45%) center/100% 100%,
    linear-gradient(45deg, transparent 34%, rgba(55, 55, 55, 0.96) 35%, rgba(55, 55, 55, 0.96) 44%, transparent 45%) center/100% 100%,
    linear-gradient(180deg, #ffffff 0%, #efefef 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.96), 0 1px 2px rgba(22, 38, 80, 0.12);
}

#tab-basic .mini-stat-card input[type="number"],
#tab-basic .mini-stat-card button,
.tight-input {
  min-height: 2.7rem;
  font-size: var(--fs-base);
}

#tab-basic #initiative-input {
  text-align: center;
}

#class,
#class option,
#level,
#level option,
#background,
#background option,
#race,
#race option,
#alignment,
#alignment option {
  font-weight: 800;
}

.ability-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem;
}

.ability {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
  min-height: 0;
  padding: 0.95rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.25rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(241, 246, 255, 0.88) 100%);
  box-shadow: var(--shadow-soft);
}

.ability-title {
  font-size: var(--fs-sm);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  color: var(--text-muted);
}

.modifier {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 4.65rem;
  margin: 0;
  border: 1px solid rgba(129, 153, 194, 0.28);
  border-radius: 0.95rem;
  background: linear-gradient(180deg, #f7faff 0%, #eef4ff 100%);
  color: var(--text);
  font-size: var(--fs-3xl);
  font-weight: 900;
}

.modifier-main {
  white-space: nowrap;
}

.ability-score {
  min-height: 3rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(151, 168, 201, 0.34);
  border-radius: 0.95rem;
  background: #fff;
  color: var(--text);
  font-size: var(--fs-xl);
  font-weight: 900;
  text-align: center;
}

/* ===== Skills ===== */
.save-grid,
.skill-grid {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.save-grid {
  grid-template-columns: 1fr;
}

.skill-grid {
  grid-template-columns: 1fr;
}

.save-pair,
.skill-cell {
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1rem;
}

.save-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4rem;
  align-items: stretch;
  padding: 0.8rem 0.9rem;
}

.save-pair label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.save-name {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  font-weight: 800;
  color: var(--text);
}

.save-name .save-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.08;
}

.save-name .save-abbr {
  font-weight: 900;
}

.save-name .save-full,
.skill-name {
  color: var(--text-body);
}

.save-pair input[type="text"],
.save-pair input[type="number"] {
  width: 100%;
  min-width: 0;
  margin: 0;
  text-align: center;
  font-size: var(--fs-xl);
  font-weight: 800;
}

.save-pair input[type="number"] {
  min-height: 3rem;
}

.skill-cell {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0.8rem 0.9rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.skill-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.2rem;
  align-items: center;
  gap: 0.65rem;
}

.skill-control-row input[type="text"] {
  min-width: 0;
  margin: 0;
  text-align: center;
  font-size: var(--fs-xl);
  font-weight: 800;
  background: #fff;
}

.skill-name {
  width: auto;
  margin: 0 0 2px;
  font-size: var(--fs-sm);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.skill-rank-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.skill-legend {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 0.6rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1rem;
  background: linear-gradient(180deg, #fbfcff 0%, #f3f6fb 100%);
  font-size: var(--fs-md);
  font-weight: 800;
}

.skill-action-hint {
  margin: 0.6rem 0 0;
  font-size: var(--fs-sm);
  line-height: 1.45;
  text-align: left;
}

.legend-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-box,
.legend-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 2px solid #667085;
  background: #fff;
}

.legend-circle {
  border-radius: 999px;
}

#tab-skills > .section:nth-of-type(2) > div[style*="font-size: 0.92em"] {
  padding: 10px 12px;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: var(--fs-base);
  font-weight: 700;
  line-height: 1.45;
}

.circle-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-left: 0;
  border: 2px solid #7a8697;
  border-radius: 50%;
  background: #fff;
  vertical-align: middle;
  cursor: pointer;
  position: relative;
  flex: 0 0 auto;
}

.circle-checkbox:checked {
  border-color: #4a6cf7;
  background: #4a6cf7;
  box-shadow: inset 0 0 0 4px #fff;
}

/* ===== Actions / Conditions / Equipment ===== */
.condition-display-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.condition-display-card {
  padding: 12px;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 12px;
}

.condition-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: var(--fs-md);
  font-weight: 700;
}

.condition-title-row span {
  color: var(--text-muted);
  font-weight: 600;
}

.condition-display-card ul {
  margin: 0;
  padding-left: 18px;
}

#condition-button-grid .active-condition {
  background: var(--accent-soft);
  border-color: #b8c8ff;
  color: #2447c7;
}

.action-help {
  margin-bottom: 14px;
  padding: 0.9rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.action-help table {
  width: 100%;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
}

.action-info-table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 0.95em;
}

.action-info-table thead tr {
  background-color: #f0f0f0;
}

.action-info-table th,
.action-info-table td {
  padding: 6px;
  border: 1px solid #ccc;
}

.action-help th,
.action-help td {
  padding: 9px 8px;
}

.action-help th {
  background: #eef3ff;
}

.action-grid-pretty {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action-grid-pretty button {
  min-height: 2.75rem;
  padding: 0.5rem 0.4rem;
  font-size: var(--fs-sm);
}

.action-description,
.action-grid-panel {
  margin-top: 10px;
}

.action-collapsible-wrap {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9fd 100%);
}

.action-collapsible-wrap summary {
  cursor: pointer;
}

.action-note-title {
  margin-top: 0.9rem;
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

.action-note-copy {
  margin-top: 4px;
  margin-left: 10px;
}

.action-attack-block,
.action-note-card {
  margin-bottom: 0.95rem;
}

.action-attack-block > h3,
.action-note-card > h3 {
  margin-bottom: 0.8rem;
}

#tab-skills > .section > button,
#tab-actions > .section > button,
#tab-actions button[onclick='populateHandAttacks()'] {
  margin-bottom: 0.75rem;
}

#tab-equipment .form-row.small-text {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.55rem;
}

#tab-equipment .form-row.small-text span,
#armor-info-line1,
#armor-info-line2,
#main-hand-info-line1,
#main-hand-info-line2,
#off-hand-info-line1,
#off-hand-info-line2 {
  display: block;
  min-height: 3rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid rgba(144, 163, 201, 0.22);
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, rgba(240, 245, 255, 0.92) 100%);
  color: var(--text-body);
}

#tab-actions .form-row.small-text {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

#tab-actions .form-row.small-text input {
  min-height: 2.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: #fff;
  font-size: var(--fs-md);
  font-weight: 750;
  text-align: left;
  box-shadow: none;
}

#atk-main-name,
#atk-off-name,
#atk-main-hit,
#atk-off-hit,
#atk-main-dmg,
#atk-main-note,
#atk-off-dmg,
#atk-off-note {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 3rem;
  display: block;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}

#atk-main-name,
#atk-off-name {
  grid-column: 1;
  min-width: calc(3em + 2rem);
  max-width: calc(3em + 2rem);
  justify-self: start;
}

#atk-main-hit,
#atk-off-hit {
  grid-column: 2;
  min-width: calc(4ch + 1.8rem);
  max-width: 7.5ch;
  justify-self: start;
}

#atk-main-dmg,
#atk-off-dmg {
  grid-column: 3;
  align-self: stretch;
}

#atk-main-note,
#atk-off-note {
  grid-column: 1 / -1;
  white-space: normal;
}

#atk-main-name,
#atk-main-hit,
#atk-main-dmg,
#atk-off-name,
#atk-off-hit,
#atk-off-dmg {
  white-space: nowrap;
}

#tab-actions .form-row.small-text:has(#atk-main-name),
#tab-actions .form-row.small-text:has(#atk-off-name) {
  grid-template-columns: minmax(calc(3em + 2rem), calc(3em + 2rem)) minmax(calc(4ch + 1.8rem), calc(4ch + 1.8rem)) minmax(0, 1fr);
  align-items: start;
  gap: 0.7rem;
}

#tab-actions .form-row.small-text:has(#atk-main-name) + div,
#tab-actions .form-row.small-text:has(#atk-off-name) + div {
  margin: 0.55rem 0 0.9rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.18em;
}

#weapon-mastery-summary-wrap {
  margin-top: 0.8rem;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
}

#weapon-mastery-summary {
  margin-top: 0.45rem;
}

#weapon-mastery-summary-wrap + h3 {
  margin-top: 0.2rem;
}

/* ===== Spells / Feats ===== */
.spell-toolbar,
.equipment-toolbar {
  width: 100%;
  margin-top: 0.32rem;
  padding: 0.45rem 0 0;
  border-top: 1px solid rgba(112, 134, 184, 0.16);
  background: transparent;
  box-shadow: none;
}

.spell-toolbar-row,
.equipment-toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: nowrap;
  width: 100%;
  min-width: 0;
}

.spell-toolbar #spell-search,
.equipment-toolbar #equipment-search {
  flex: 1 1 auto;
  min-width: 0;
  height: 38px;
  padding: 8px 38px 8px 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.equipment-search-count {
  flex: 0 0 auto;
  min-width: 3.8rem;
  color: var(--text-muted);
  font-size: var(--fs-md);
  text-align: center;
  white-space: nowrap;
}

.equipment-search-input-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.equipment-search-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #d7deea;
  background: #fff;
  color: #667085;
  box-shadow: none;
  line-height: 1;
  margin-bottom: 0;
}

.equipment-search-clear.is-hidden {
  display: none;
}

.spell-toolbar-actions {
  display: flex;
  gap: 0.6rem;
  flex: 0 0 auto;
  width: auto;
  margin-left: auto;
}

.spell-toolbar-actions button {
  width: auto;
  min-height: 38px;
  padding: 0 12px;
  margin-bottom: 0;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: none;
}

#tab-spells {
  padding-top: 0.55rem;
}

#tab-spells.spell-toolbar-visible {
  padding-top: 3.85rem;
}

#tab-equipment {
  padding-top: 0.55rem;
}

#tab-equipment.equipment-toolbar-visible {
  padding-top: 3.85rem;
}

#spell-slot-management-wrap {
  margin: 1rem 0 1.15rem;
  padding: 0.95rem 1rem 1rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.05rem;
  background: var(--surface-soft);
}

#spell-slot-management-wrap > h3 {
  margin-bottom: 0.8rem;
}

#spell-slot-management-wrap .form-row {
  margin-top: 0.9rem;
  margin-bottom: 0;
}

.equipment-search-block + .equipment-search-block {
  margin-top: 0.7rem;
}

.equipment-search-block table {
  margin-top: 0.35rem;
  width: 100%;
}

.equipment-search-table-wrap {
  overflow-x: auto;
}

.equipment-search-highlight {
  background: #fff1a8;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

.equipment-search-results.is-hidden {
  display: none;
}

.spell-picked-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.95rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

#feats-area .form-row,
#cantrips-area .form-row,
div[id$="spells-area"] .form-row {
  margin-bottom: 1rem;
}

.spell-picked-box {
  padding: 8px 10px;
  border-radius: 1rem;
}

.spell-picked-content {
  white-space: pre-line;
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--text-body);
}

.spell-highlight {
  color: #c40000;
}

.spell-level-section > summary {
  cursor: pointer;
  list-style: none;
}

.feat-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-bottom: 6px;
}

.feat-row-head label {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 850;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.feat-row-controls {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  justify-content: flex-end;
  margin-left: auto;
}

.spell-row-top {
  display: grid;
  grid-template-columns: 118px max-content max-content 1fr;
  grid-template-rows: auto auto;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.spell-row-top select:first-child,
.spell-row-index,
.spell-row-top select:last-of-type,
.spell-row-top .feat-row-controls,
.feat-row-controls {
  width: 100%;
}

.spell-row-top select:first-child {
  grid-column: 1;
  grid-row: 1;
}

.spell-row-index {
  grid-column: 2;
  grid-row: 1;
  width: auto;
  min-width: 2.5rem;
  color: #98a2b3;
  font-size: var(--fs-sm);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.spell-row-top .feat-row-controls {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  width: auto;
  justify-self: start;
  margin-left: 0;
}

.spell-row-top select:last-of-type {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
}

.feat-icon-btn,
.spell-qr-modal-close,
.deity-info-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  max-width: 36px;
  min-height: 36px;
  max-height: 36px;
  padding: 0;
  border-radius: 999px;
  box-shadow: none;
  line-height: 1;
}

.feat-icon-btn {
  border: 1px solid #d7deea;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5fc 100%);
  font-size: var(--fs-base);
  font-weight: 900;
}

.feat-icon-btn--add {
  color: #2a55d4;
}

.feat-icon-btn--delete {
  color: #c53a4a;
}

.feat-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.spell-slot-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
  align-items: start;
}

.spell-slot-column {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: nowrap;
  padding: 8px 7px;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 14px;
  text-align: left;
  background: linear-gradient(180deg, #ffffff 0%, #f7f9fd 100%);
}

.spell-slot-column h4 {
  margin: 0 0 6px;
  font-size: var(--fs-base);
}

.spell-slot-label {
  display: inline-block;
  width: auto;
  margin: 0;
  white-space: nowrap;
  flex: 0 0 auto;
}

.spell-slot-placeholder {
  visibility: hidden;
  pointer-events: none;
}

.spell-note-muted {
  margin-top: 0.85rem;
  font-size: var(--fs-xs);
  line-height: 1.3;
  color: #999;
}

.spell-casting-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
  align-items: start;
}

.spell-casting-field {
  display: grid;
  gap: 0.45rem;
}

.spell-casting-stats .stat-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #475467;
  text-align: left;
}

.spell-casting-stats select,
.spell-casting-stats input {
  min-height: 40px;
  padding: 6px 4px;
  font-size: var(--fs-xl);
  font-weight: 800;
  text-align: center;
}

/* ===== Share / Utility ===== */
.bottom-buttons,
.share-actions-wrap {
  display: grid;
  grid-template-columns: 1fr;
  margin: 14px 0 16px;
}

.bottom-buttons button,
.share-export-btn,
.share-import-btn {
  width: 100%;
  max-width: none;
}

.utility-emoji-btn {
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  padding: 0;
  border-radius: 16px;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.share-mode-tip,
.share-actions-wrap {
  margin: -4px 0 16px;
}


.share-mode-tip {
  padding: 10px 12px;
  border: 1px solid #f3c76e;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff9e8 0%, #fff2c8 100%);
  color: #7a4b00;
  font-weight: 700;
}

.share-export-btn {
  background: linear-gradient(180deg, #ffffff 0%, #edf3ff 100%);
  color: #214cb8;
  border-color: #b8cbff;
}

.share-import-btn {
  background: linear-gradient(180deg, #ffffff 0%, #eefcf2 100%);
  color: #1f7a3b;
  border-color: #b7e4c4;
}

.share-url-btn {
  background: linear-gradient(180deg, #5f7cff 0%, #4765ea 100%);
  color: #fff;
  border-color: #3f5add;
  box-shadow: 0 10px 18px rgba(71, 101, 234, 0.24);
}

#clear-storage-btn {
  background: linear-gradient(180deg, #ffefef 0%, #ffdede 100%);
  color: #8d1f1f;
  border-color: #efb0b0;
}

#restart-onboarding-btn {
  width: 100%;
  margin: 0.5rem 0 0;
  background: linear-gradient(180deg, #fff6e6 0%, #ffe8c0 100%);
  border-color: #e8c27a;
  display: block;
}

.invocation-block {
  margin-bottom: 16px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.invocation-block:last-child {
  margin-bottom: 0;
}

.invocation-prereq {
  display: inline-block;
  margin: 2px 0 6px;
  padding: 2px 8px;
  border: 1px solid #d7deea;
  border-radius: 999px;
  background: #eef3fb;
  color: #51627c;
  font-size: 0.9em;
  line-height: 1.35;
  font-weight: 800;
}

/* ===== Hero / Footer ===== */
.site-hero {
  padding: 8px 14px 2px;
}

.site-hero h1 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 900;
}

.site-hero p {
  margin: 2px 0 0;
  font-size: var(--fs-sm);
}

.site-footer {
  width: 100%;
  margin-top: 0.75rem;
  padding: 1rem;
  border: 1px solid rgba(151, 168, 201, 0.26);
  border-radius: 1.25rem;
  box-shadow: var(--shadow-soft);
  font-size: var(--fs-xs);
}

.site-footer-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.site-footer a {
  color: #2d58dd;
  font-weight: 700;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  text-decoration: underline;
}

/* ===== Floating UI ===== */
#scrollToTopBtn {
  position: fixed;
  right: max(0.95rem, calc((100vw - var(--app-max-width)) / 2 + 0.95rem));
  bottom: 0.85rem;
  z-index: 999;
  width: auto;
  height: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  box-shadow: none;
  opacity: 1;
}

#spell-search-fab,
#equipment-search-fab {
  position: fixed;
  top: 4.2rem;
  right: max(0.95rem, calc((100vw - var(--app-max-width)) / 2 + 0.95rem));
  z-index: 1200;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: inherit;
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: none;
  opacity: 1;
  transition: transform 0.2s ease;
}

#spell-search-fab.is-hidden,
#equipment-search-fab.is-hidden {
  display: none;
}

#spell-search-fab.toolbar-open,
#equipment-search-fab.toolbar-open {
  transform: translateY(3.15rem);
}

#spell-search-fab:hover,
#equipment-search-fab:hover {
  opacity: 1;
}

#scrollToTopBtn:hover {
  opacity: 1;
}

#tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: none;
  pointer-events: none;
}

.tour-mask {
  position: fixed;
  background: rgba(10, 16, 30, 0.72);
  pointer-events: auto;
}

#tour-focus-ring,
#tour-focus-ring-secondary {
  position: fixed;
  border: 3px solid #7aa2ff;
  border-radius: 12px;
  box-shadow: 0 0 0 2px rgba(122, 162, 255, 0.38), 0 0 26px rgba(122, 162, 255, 0.7);
  pointer-events: none;
}

#tour-tooltip {
  position: fixed;
  width: min(252px, calc(100vw - 20px));
  padding: 10px;
  border: 1px solid #c7d2e9;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(10, 16, 30, 0.24);
  pointer-events: auto;
}

#tour-step-title {
  margin: 0 0 4px;
  font-size: var(--fs-md);
  font-weight: 900;
}

#tour-step-text {
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: #34425b;
}

.tour-btn-row {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

#tour-next-btn,
#tour-skip-btn,
#tour-prev-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: var(--fs-xs);
}

#tour-prev-btn {
  background: linear-gradient(180deg, #f7f9ff 0%, #edf2ff 100%);
  color: #32415f;
}

#tour-prev-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

#tour-next-btn {
  background: linear-gradient(180deg, #6d89ff 0%, #5675f2 100%);
  color: #fff;
}

/* ===== Modals / Popups ===== */
#beastPopup,
#skillPopup {
  position: fixed;
  z-index: 9999;
  max-width: 320px;
  display: none;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: #111827;
  color: #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  font-size: var(--fs-sm);
  line-height: 1.45;
}

#beastPopup .title,
#skillPopup .title {
  margin-bottom: 6px;
  font-size: var(--fs-md);
  font-weight: 700;
}

#beastPopup .row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

#beastPopup .muted,
#beastPopup .close,
#skillPopup .close {
  opacity: 0.85;
}

#beastPopup .close,
#skillPopup .close {
  float: right;
  margin-left: 10px;
  cursor: pointer;
}

.beast-tip,
.skill-tip {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#spell-qr-modal,
#deity-info-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}

#spell-qr-modal {
  z-index: 10001;
  padding: 16px;
  background: rgba(0, 0, 0, 0.58);
}

#deity-info-modal {
  z-index: 10002;
  padding: 12px;
  background: rgba(7, 12, 24, 0.62);
}

#spell-qr-modal.open,
#deity-info-modal.open {
  display: flex;
}

.spell-qr-modal-card {
  position: relative;
  width: min(92vw, 320px);
  padding: 20px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.28);
}

.spell-qr-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid #d2d9e5;
  background: #fff;
  font-size: 1.1rem;
}

.spell-qr-modal-image {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #d9dfea;
  border-radius: 10px;
}

.deity-info-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(94vw, 860px);
  max-height: min(88vh, 920px);
  overflow: hidden;
  border: 1px solid #d5deef;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
  box-shadow: 0 24px 56px rgba(20, 35, 74, 0.34);
}

.deity-info-header {
  padding: 16px 54px 12px 16px;
  border-bottom: 1px solid #dbe3f2;
  background: linear-gradient(180deg, #f4f8ff 0%, #eef3ff 100%);
}

.deity-info-header h3 {
  margin: 0;
  font-size: var(--fs-lg);
  color: #1f315f;
}

.deity-info-header p {
  margin: 6px 0 0;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: #506080;
}

.deity-info-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid #cfdaee;
  background: #fff;
  font-weight: 900;
}

.deity-info-content {
  padding: 12px;
  overflow-y: auto;
}

.deity-group {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #d8e2f3;
  border-radius: 14px;
  background: #fff;
}

.deity-group h4 {
  margin: 0 0 8px;
  font-size: var(--fs-base);
  color: #243968;
}

.deity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}

.deity-item {
  padding: 8px 9px;
  border: 1px solid #e2e9f5;
  border-radius: 12px;
  background: linear-gradient(180deg, #fcfdff 0%, #f5f8ff 100%);
}

.deity-item-main {
  margin-bottom: 4px;
  font-weight: 900;
  color: #192645;
}

#legal-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  background: rgba(0, 0, 0, 0.45);
}

.legal-modal-card {
  position: relative;
  max-width: 332px;
  margin: 72px auto 0;
  padding: 18px 14px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 24px #0003;
}

#legal-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 6px;
  font-size: var(--fs-md);
  line-height: 24px;
}

.legal-modal-title {
  margin: 0 0 6px;
  font-size: var(--fs-lg);
  line-height: 1.15;
}

.legal-modal-section-title {
  margin-top: 16px;
}

.legal-modal-copy {
  font-size: var(--fs-xs);
  line-height: 1.55;
  color: #222;
}

.legal-modal-meta {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e4e8f2;
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: #49566d;
  text-align: center;
}

.legal-modal-meta-title {
  font-weight: 700;
  color: #2a3b56;
}

.legal-modal-dismiss {
  margin-top: 9px;
  font-size: var(--fs-sm);
  line-height: 1.2;
}

#legal-start-tour-btn,
#legal-ack-btn {
  width: 100%;
}

#legal-start-tour-btn {
  margin-top: 12px;
  padding: 8px 0;
  border: 1px solid #3f65df;
  border-radius: 8px;
  background: linear-gradient(180deg, #6d89ff 0%, #5675f2 100%);
  display: block;
  color: #fff;
  font-size: var(--fs-base);
}

#legal-ack-btn {
  margin-top: 8px;
  padding: 6px 0;
  border: 1px solid #888;
  border-radius: 6px;
  font-size: var(--fs-base);
}

.selection-pill {
  display: inline-block;
  margin: 2px 6px 2px 0;
  padding: 2px 6px;
  border: 1px solid #ccc;
  border-radius: 999px;
}

.feat-desc-spacer {
  height: 10px;
}

.feat-desc-title {
  margin-bottom: 2px;
  font-size: var(--fs-base);
  font-weight: 800;
}

.feat-desc-subtitle {
  margin-bottom: 10px;
  font-size: var(--fs-sm);
  color: #555;
}

.feat-desc-body {
  line-height: 1.35;
}

.monster-detail-line + .monster-detail-line {
  margin-top: 6px;
}

.monster-detail-line--first {
  margin-top: 8px;
}

.background-guide-block {
  line-height: 1.25;
}

.background-guide-note {
  margin-top: 8px;
}

.background-guide-section {
  margin-top: 12px;
}

.background-guide-description {
  margin-top: 16px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Responsive ===== */
@media (max-width: 319px) {
  body {
    padding-inline: 0.7rem;
  }

  .tabs-shell {
    width: calc(100vw - 0.7rem);
  }

.tab-button {
    min-height: 2.65rem;
    font-size: var(--fs-sm);
  }

  #tab-actions .form-row.small-text {
    grid-template-columns: 1fr;
  }

  .spell-casting-stats {
    grid-template-columns: 1fr;
  }

}

@media (min-width: 320px) {
  .bottom-buttons,
  .share-actions-wrap {
    grid-template-columns: 1fr auto 1fr;
  }

  .utility-emoji-btn {
    width: 3.4rem;
    min-width: 3.4rem;
    min-height: 3.4rem;
    font-size: 1.55rem;
  }

  .spell-slot-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem 1rem;
  }

  .spell-slot-column {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    justify-content: center;
    justify-items: center;
    align-content: start;
    gap: 0.45rem 0.55rem;
    text-align: center;
  }

  .spell-slot-label {
    display: block;
    grid-column: 1 / -1;
  }
}

@media (min-width: 501px) {
  .spell-slot-column {
    display: flex;
    justify-content: center;
    text-align: left;
  }

  .spell-slot-label {
    display: inline-block;
  }
}

@media (min-width: 360px) {
  .spell-picked-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #tab-skills .save-grid,
  #tab-skills .skill-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 360px) {
  .action-grid-pretty {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 360px) {
  #tab-basic .ability-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 620px) {
  body {
    padding-top: 5.35rem;
  }

  .tabs {
    width: 100%;
  }

  .tabs-shell {
    width: min(var(--app-max-width), calc(100vw - 1.5rem));
  }

  .tab-button {
    font-size: var(--fs-base);
  }

  .form-grid-2col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid-3col {
    grid-template-columns: 1fr auto 1fr;
  }
}

@media (min-width: 720px) {
  #tab-basic .ability-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  #tab-skills .save-grid,
  #tab-skills .skill-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .spell-picked-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 720px) {
  .action-grid-pretty {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.spell-highlight-action {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 0.14em;
}

.spell-prepare-popover {
  position: fixed;
  z-index: 10050;
  width: min(220px, calc(100vw - 24px));
  padding: 0.85rem 0.9rem;
  border: 1px solid rgba(114, 133, 176, 0.24);
  border-radius: 0.95rem;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 38px rgba(17, 31, 63, 0.16);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.spell-prepare-popover__title {
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 800;
  line-height: 1.4;
}

.spell-prepare-popover__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.spell-prepare-popover__btn {
  min-width: 3rem;
  padding: 0.38rem 0.72rem;
  border: 1px solid rgba(114, 133, 176, 0.24);
  border-radius: 0.7rem;
  background: rgba(243, 247, 255, 0.92);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 800;
  cursor: pointer;
}

.spell-prepare-popover__btn--confirm {
  background: linear-gradient(180deg, var(--accent-strong) 0%, #2962e8 100%);
  border-color: transparent;
  color: #fff;
}
