:root {
  --bg: #efe7d2;
  --paper: rgba(255, 251, 242, 0.88);
  --panel: rgba(255, 248, 235, 0.84);
  --panel-strong: rgba(255, 252, 247, 0.96);
  --line: rgba(65, 47, 25, 0.16);
  --line-strong: rgba(39, 71, 52, 0.24);
  --ink: #21170d;
  --muted: #6e5741;
  --gold: #b7872d;
  --gold-soft: rgba(183, 135, 45, 0.12);
  --forest: #274734;
  --forest-soft: rgba(39, 71, 52, 0.12);
  --crimson: #7e3f32;
  --shadow: 0 18px 48px rgba(50, 34, 15, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(183, 135, 45, 0.24), transparent 28%),
    radial-gradient(circle at top right, rgba(39, 71, 52, 0.18), transparent 24%),
    linear-gradient(180deg, #f4ecda 0%, #e7dcc1 100%);
  font-family: Georgia, "Palatino Linotype", serif;
}

button,
input,
select {
  font: inherit;
}

input[readonly] {
  opacity: 0.78;
  background: rgba(65, 47, 25, 0.05);
}

.page-shell {
  max-width: 1520px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 380px);
  gap: 24px;
  align-items: center;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background:
    linear-gradient(135deg, rgba(255, 251, 241, 0.96), rgba(235, 225, 201, 0.92)),
    linear-gradient(180deg, rgba(39, 71, 52, 0.05), rgba(126, 63, 50, 0.05));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.eyebrow,
.sheet-kicker {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.77rem;
  color: var(--forest);
  font-family: "Trebuchet MS", sans-serif;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 4vw, 4.3rem);
  line-height: 0.96;
}

.hero-text {
  max-width: 60ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.7;
}

.storage-status {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.hero-account {
  margin-top: 14px;
}

.account-card {
  display: grid;
  gap: 8px;
  max-width: 32rem;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.88);
  border: 1px solid rgba(65, 47, 25, 0.1);
}

.status-pill {
  width: fit-content;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  background: rgba(255, 252, 247, 0.88);
}

.status-pill.is-live {
  border-color: rgba(39, 71, 52, 0.26);
  background: rgba(39, 71, 52, 0.1);
  color: var(--forest);
}

.status-pill.is-fallback {
  border-color: rgba(126, 63, 50, 0.24);
  background: rgba(126, 63, 50, 0.1);
  color: var(--crimson);
}

.hero-crest {
  position: relative;
  min-height: 280px;
  display: grid;
  place-items: center;
}

.crest-ring {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  border: 1px solid rgba(126, 63, 50, 0.18);
  background:
    radial-gradient(circle, rgba(183, 135, 45, 0.18) 0%, rgba(183, 135, 45, 0.02) 54%, transparent 70%),
    repeating-radial-gradient(circle, rgba(39, 71, 52, 0.08) 0 2px, transparent 2px 16px);
}

.hero-icon {
  position: relative;
  width: min(58vw, 260px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(160deg, rgba(39, 71, 52, 0.92), rgba(126, 63, 50, 0.78));
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255, 248, 235, 0.35), 0 18px 36px rgba(39, 71, 52, 0.22);
}

.hero-icon img {
  width: 54%;
  height: 54%;
  filter: brightness(0) invert(1);
}

.portal-layout {
  display: grid;
  gap: 22px;
  margin-top: 24px;
  align-items: start;
}

.workspace-switcher {
  display: inline-flex;
  gap: 10px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.82);
  border: 1px solid rgba(65, 47, 25, 0.1);
  box-shadow: var(--shadow);
}

.workspace-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  cursor: pointer;
  font-family: "Trebuchet MS", sans-serif;
  background: transparent;
  color: var(--muted);
}

.workspace-button.is-active {
  background: linear-gradient(135deg, var(--forest), #385e48);
  color: white;
}

.workspace-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.workspace-view[hidden] {
  display: none !important;
}

.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) 320px;
  gap: 18px;
  align-items: start;
}

.builder-aside,
.sheet-layout {
  display: grid;
  gap: 18px;
}

.sheet-layout {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  align-items: start;
}

.live-summary {
  grid-row: span 2;
}

.panel,
.guide-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
  backdrop-filter: blur(10px);
}

.wizard-shell {
  padding: 24px;
}

.wizard-head,
.panel-header,
.wizard-footer,
.option-topline,
.saved-card footer,
.ability-line,
.action-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.wizard-head {
  align-items: flex-start;
}

.panel-header,
.wizard-footer {
  align-items: baseline;
}

.panel-header h2,
.wizard-head h2,
.option-card h3,
.guide-card h3,
.section-intro h3 {
  margin: 0;
}

.helper-text,
.panel-header p,
.section-intro p,
.inline-note,
.ability-bonus-note,
.info-tile span,
.review-card p,
.saved-card p,
.note-card p,
.action-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.stepper {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 18px;
}

.step-pill {
  border: 1px solid rgba(65, 47, 25, 0.12);
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255, 252, 247, 0.8);
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.step-pill:hover,
.step-pill:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(183, 135, 45, 0.45);
}

.step-pill.is-current {
  border-color: rgba(39, 71, 52, 0.55);
  background: linear-gradient(180deg, rgba(245, 249, 244, 1), rgba(238, 245, 236, 0.94));
  box-shadow: 0 10px 24px rgba(39, 71, 52, 0.12);
}

.step-pill.is-review {
  border-color: rgba(183, 135, 45, 0.45);
  background: linear-gradient(180deg, rgba(255, 249, 235, 1), rgba(249, 240, 218, 0.95));
}

.step-pill.is-complete .step-index {
  background: var(--forest);
  color: white;
}

.step-pill.is-locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.step-index {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(33, 23, 13, 0.08);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.85rem;
}

.step-copy {
  display: grid;
  gap: 2px;
}

.step-copy strong {
  font-size: 0.96rem;
}

.step-copy span {
  color: var(--muted);
  font-size: 0.83rem;
  font-family: "Trebuchet MS", sans-serif;
}

.wizard-stage-layout {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.wizard-stage-wrap,
.guide-card {
  background: var(--panel-strong);
}

.wizard-stage-wrap {
  border: 1px solid rgba(65, 47, 25, 0.1);
  border-radius: 24px;
  padding: 20px;
}

.wizard-guide {
  display: grid;
  gap: 14px;
}

.guide-card {
  padding: 18px;
}

.wizard-stage,
.summary-content,
.stack,
.sheet-main,
.sheet-columns,
.sheet-frame,
.sheet-abilities,
.section-intro,
.mini-grid,
.review-grid,
.scenario-grid,
.abilities-grid,
.card-grid,
.compact-grid,
.form-grid,
.advancement-grid,
.catalog-toolbar,
.selection-tags,
.inline-actions {
  display: grid;
  gap: 14px;
}

.stage-section {
  display: grid;
  gap: 18px;
}

.section-intro p {
  max-width: 72ch;
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.mini-grid,
.review-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.review-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.info-tile,
.review-card,
.ability-card,
.scenario-card,
.sub-panel,
.stat-card,
.note-card,
.action-card,
.saved-card,
.empty-state,
.sheet-box,
.vital-card {
  padding: 15px 16px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid rgba(65, 47, 25, 0.1);
}

.info-tile,
.review-card,
.saved-card,
.note-card,
.action-card {
  display: grid;
  gap: 6px;
}

.builder-alert {
  border-color: rgba(183, 135, 45, 0.28);
  background: linear-gradient(180deg, rgba(255, 249, 235, 1), rgba(249, 240, 218, 0.95));
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.catalog-toolbar {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.9);
  border: 1px solid rgba(65, 47, 25, 0.08);
}

.inline-actions {
  grid-template-columns: repeat(auto-fit, minmax(160px, max-content));
  align-items: center;
}

.option-card {
  border: 1px solid rgba(65, 47, 25, 0.12);
  border-radius: 22px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.99), rgba(246, 238, 221, 0.96));
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  box-shadow: 0 10px 24px rgba(38, 26, 11, 0.08);
  position: relative;
  overflow: hidden;
}

.option-card:hover,
.option-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(183, 135, 45, 0.55);
  box-shadow: 0 16px 32px rgba(38, 26, 11, 0.12);
}

.option-card.is-selected {
  border-color: rgba(39, 71, 52, 0.7);
  box-shadow: 0 16px 30px rgba(39, 71, 52, 0.18);
  background: linear-gradient(180deg, rgba(245, 249, 244, 1), rgba(238, 245, 236, 0.94));
}

.option-card.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.option-banner {
  display: none;
}

.option-banner.is-visible {
  display: block;
  margin: -16px -16px 14px;
  padding: 10px 14px;
  background: linear-gradient(90deg, rgba(39, 71, 52, 0.14), rgba(183, 135, 45, 0.18));
  color: var(--forest);
  font-size: 0.82rem;
  font-family: "Trebuchet MS", sans-serif;
}

.option-icon {
  width: 44px;
  height: 44px;
  padding: 8px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(39, 71, 52, 0.15), rgba(183, 135, 45, 0.18));
}

.source-pill,
.chip,
.sheet-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(33, 23, 13, 0.07);
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1;
  font-family: "Trebuchet MS", sans-serif;
}

.chip-strong,
.sheet-tag {
  background: rgba(39, 71, 52, 0.12);
  color: var(--forest);
}

.description,
.explanation {
  margin: 8px 0 0;
  line-height: 1.5;
}

.description {
  color: var(--ink);
}

.explanation {
  color: var(--muted);
  font-size: 0.95rem;
}

.chips,
.sheet-tags,
.selection-tags,
.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.selection-tags {
  margin-top: 8px;
}

.sheet-actions {
  margin-top: 0;
  justify-content: flex-end;
}

label {
  display: grid;
  gap: 6px;
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.92rem;
}

input[type="text"],
input[type="email"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid rgba(65, 47, 25, 0.18);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 252, 248, 0.92);
  color: var(--ink);
}

.auth-code-input {
  letter-spacing: 0.28em;
  font-family: "Trebuchet MS", sans-serif;
}

.abilities-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.ability-card h3,
.scenario-card h3,
.sub-panel h3 {
  margin: 0 0 6px;
  font-size: 0.94rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--forest);
  font-family: "Trebuchet MS", sans-serif;
}

.ability-line {
  margin-top: 12px;
}

.ability-total {
  font-size: 1.3rem;
}

.ability-mod {
  color: var(--muted);
}

.ability-bonus-note {
  margin-top: 10px;
  font-size: 0.82rem;
}

.advancement-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.inline-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.inline-note {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--gold-soft);
  border: 1px solid rgba(183, 135, 45, 0.16);
}

.primary-button,
.ghost-button,
.load-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  padding: 11px 16px;
  font-family: "Trebuchet MS", sans-serif;
}

.primary-button {
  background: linear-gradient(135deg, var(--forest), #385e48);
  color: white;
}

.ghost-button,
.load-button {
  background: rgba(39, 71, 52, 0.08);
  color: var(--forest);
}

.ghost-button:disabled,
.primary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(39, 71, 52, 0.11), rgba(183, 135, 45, 0.14));
  border: 1px solid rgba(39, 71, 52, 0.12);
}

.sheet-header h3 {
  margin: 2px 0 6px;
  font-size: 1.5rem;
}

.sheet-header p {
  margin: 0;
  color: var(--muted);
}

.sheet-frame {
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: start;
}

.sheet-abilities {
  grid-template-columns: 1fr;
}

.sheet-ability {
  padding: 10px 8px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(246, 238, 221, 0.92));
  border: 1px solid rgba(65, 47, 25, 0.1);
  text-align: center;
  display: grid;
  gap: 4px;
}

.sheet-ability-label {
  font-family: "Trebuchet MS", sans-serif;
  color: var(--forest);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.sheet-vitals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.vital-card {
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(246, 238, 221, 0.92));
}

.vital-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: "Trebuchet MS", sans-serif;
}

.vital-card strong {
  display: block;
  font-size: 1.35rem;
  margin-top: 6px;
}

.sheet-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sheet-box h4 {
  margin: 0 0 10px;
  color: var(--forest);
  font-size: 0.98rem;
  font-family: "Trebuchet MS", sans-serif;
}

.sheet-box-wide {
  margin-top: 2px;
}

.sheet-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.saved-card footer {
  align-items: center;
}

.scenario-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.empty-state {
  display: grid;
  gap: 14px;
}

.empty-state h3 {
  margin: 0;
}

@media (max-width: 1280px) {
  .builder-layout,
  .sheet-layout {
    grid-template-columns: 1fr;
  }

  .live-summary {
    grid-row: auto;
  }
}

@media (max-width: 1080px) {
  .sheet-frame {
    grid-template-columns: 1fr;
  }

  .sheet-abilities {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .stepper {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sheet-vitals,
  .sheet-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 18px 12px 40px;
  }

  .hero,
  .panel,
  .wizard-shell {
    padding: 18px;
  }

  .wizard-head,
  .wizard-footer,
  .panel-header,
  .sheet-header,
  .sheet-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .stepper {
    grid-template-columns: 1fr;
  }

  .sheet-abilities {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
