:root {
  --wood-dark: #2b1a12;
  --wood: #3f2a1c;
  --wood-light: #5a3d28;
  --parchment: #f3e3c3;
  --parchment-dim: #e2cfa3;
  --ember: #c8752b;
  --ember-bright: #e08e3e;
  --ink: #2a1d14;
  --shadow: rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--wood-dark);
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.03), transparent 40%),
    radial-gradient(circle at 80% 60%, rgba(255, 255, 255, 0.02), transparent 45%);
  color: var(--parchment);
  line-height: 1.6;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

a {
  color: var(--ember-bright);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1, h2, h3 {
  font-family: 'Trebuchet MS', Georgia, serif;
  color: var(--parchment);
  margin-top: 0;
}

/* Header */
.site-header {
  background:
    linear-gradient(180deg, rgba(20, 12, 8, 0.4), rgba(20, 12, 8, 0.55)),
    url('images/menu-bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-bottom: 3px solid var(--ember);
  box-shadow: 0 2px 12px var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
  overflow: hidden;
}

.header-run {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 100%;
  width: auto;
  pointer-events: none;
  z-index: 1;
}

.site-header .wrap {
  padding-left: 200px;
}

.header-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--parchment);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 8px rgba(0, 0, 0, 0.6);
}
.brand:hover { text-decoration: none; }
.brand-icon {
  height: 40px;
  width: auto;
}

.site-nav a {
  margin-left: 24px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 8px rgba(0, 0, 0, 0.6);
  color: var(--parchment-dim);
  font-weight: bold;
}
.site-nav a:hover { color: var(--ember-bright); }

/* Hero */
.hero {
  padding: 70px 0;
  background: #000;
  border-bottom: 1px solid rgba(200, 117, 43, 0.3);
}

.hero-inner {
  display: flex;
  align-items: center;
  gap: 48px;
}

.hero-text {
  flex: 1 1 380px;
  text-align: center;
}

.hero h1 {
  font-size: 2.8rem;
  margin-bottom: 14px;
  text-shadow: 0 2px 4px var(--shadow);
}

.tagline {
  font-size: 1.2rem;
  color: var(--parchment-dim);
  max-width: 520px;
  margin: 0 auto 32px;
}

.hero-image {
  flex: 1 1 380px;
  max-width: 460px;
  width: 100%;
  height: auto;
}

@media (max-width: 780px) {
  .hero-inner { flex-direction: column; }
}

/* 404 */
.not-found-inner {
  text-align: center;
}

.not-found-image {
  max-width: 420px;
  width: 100%;
  height: auto;
  border-radius: 12px;
  margin-bottom: 32px;
}

/* Tavern Tables generator */
.tool-page {
  padding: 70px 0;
  min-height: 55vh;
}

.tool-page h1 {
  text-align: center;
  margin-bottom: 10px;
}

.tool-page .tagline {
  text-align: center;
}

.generator-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 0 auto 36px;
  max-width: 320px;
}

.generator-controls select,
.generator-controls button {
  width: 100%;
}

.generator-controls select {
  background: var(--wood);
  color: var(--parchment);
  border: 2px solid var(--ember);
  border-radius: 6px;
  padding: 10px 16px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
}

.generator-controls select:focus {
  outline: 2px solid var(--ember-bright);
}

.generator-results {
  list-style: none;
  padding: 0;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.generator-results li {
  background: var(--wood);
  border: 1px solid rgba(200, 117, 43, 0.3);
  border-radius: 8px;
  padding: 14px 20px;
  text-align: center;
  font-size: 1.1rem;
}

/* NPC Personality Spark */
.spark-card {
  max-width: 640px;
  margin: 0 auto;
  background: var(--wood);
  border: 1px solid rgba(200, 117, 43, 0.3);
  border-radius: 10px;
  padding: 4px 24px;
  box-shadow: 0 4px 14px var(--shadow);
}

.spark-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(200, 117, 43, 0.15);
}
.spark-row:last-child {
  border-bottom: none;
}

.spark-label {
  flex: 0 0 100px;
  font-weight: bold;
  color: var(--ember-bright);
  font-family: 'Trebuchet MS', Georgia, serif;
  text-align: left;
}

.spark-value {
  flex: 1 1 auto;
  text-align: left;
}

.spark-lock {
  flex: 0 0 auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  opacity: 0.45;
  padding: 4px;
  line-height: 1;
}
.spark-lock:hover {
  opacity: 0.85;
}
.spark-lock.locked {
  opacity: 1;
}

@media (max-width: 560px) {
  .spark-row {
    flex-wrap: wrap;
  }
  .spark-label {
    flex: 1 1 100%;
  }
}

/* Contact page */
.contact-wrap {
  max-width: 900px;
}

.contact-intro {
  display: flex;
  align-items: center;
  gap: 40px;
  margin-bottom: 48px;
}

.contact-text {
  flex: 1 1 320px;
}

.contact-intro .contact-text h1,
.contact-intro .contact-text .tagline {
  text-align: left;
  margin-left: 0;
  margin-right: 0;
}

.contact-image {
  flex: 1 1 260px;
  max-width: 340px;
  width: 100%;
  height: auto;
  border-radius: 12px;
}

@media (max-width: 700px) {
  .contact-intro { flex-direction: column; }
  .contact-intro .contact-text h1,
  .contact-intro .contact-text .tagline {
    text-align: center;
  }
}

.contact-wrap .tagline {
  margin-bottom: 0;
}

.contact-wrap .tagline a {
  font-weight: bold;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
  background: var(--wood);
  border: 1px solid rgba(200, 117, 43, 0.3);
  border-radius: 10px;
  padding: 32px;
  box-shadow: 0 4px 14px var(--shadow);
}

.contact-form h2 {
  text-align: center;
  margin-bottom: 16px;
}

.contact-form label {
  font-weight: bold;
  color: var(--parchment-dim);
  margin-top: 12px;
}

.contact-form input,
.contact-form textarea {
  background: var(--wood-dark);
  color: var(--parchment);
  border: 2px solid rgba(200, 117, 43, 0.4);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
  resize: vertical;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--ember-bright);
}

.contact-form button {
  margin-top: 20px;
  align-self: center;
}

.btn {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 6px;
  font-weight: bold;
  font-family: 'Trebuchet MS', Georgia, serif;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--ember);
  color: var(--ink);
  box-shadow: 0 3px 0 #8f4f18;
}
.btn-primary:hover { background: var(--ember-bright); }

.btn-secondary {
  background: transparent;
  border: 2px solid var(--ember);
  color: var(--ember-bright);
  padding: 10px 20px;
}
.btn-secondary:hover {
  background: var(--ember);
  color: var(--ink);
}

/* Tools */
.tools {
  padding: 70px 0;
}

.tools h2, .about h2 {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 40px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.tool-card {
  background: var(--wood);
  border: 1px solid rgba(200, 117, 43, 0.25);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 4px 14px var(--shadow);
  display: flex;
  flex-direction: column;
}

/* Pushes each card's closing link/badge to the same baseline regardless of
   how many lines the description above it wraps to (grid rows already
   stretch every card in a row to equal height by default). */
.tool-card > :last-child {
  margin-top: auto;
}

.tool-card--soon {
  opacity: 0.75;
  border-style: dashed;
}

.tool-crest {
  width: 140px;
  height: 140px;
  object-fit: contain;
  margin-bottom: 12px;
  border-radius: 50%;
  background: var(--wood-dark);
  box-shadow: 0 0 0 3px var(--ember), 0 4px 14px var(--shadow);
}

.tool-card h3 {
  font-size: 1.4rem;
  margin-bottom: 10px;
}

.tool-card p {
  color: var(--parchment-dim);
  margin-bottom: 20px;
}

.badge {
  display: inline-block;
  background: rgba(200, 117, 43, 0.2);
  color: var(--ember-bright);
  border: 1px solid var(--ember);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.85rem;
  font-weight: bold;
}

/* Reading Nook */
.nook-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  max-width: 900px;
  margin: 0 auto;
}

.nook-sidebar {
  flex: 0 0 220px;
}

.nook-new-btn {
  width: 100%;
  margin-bottom: 14px;
}

.nook-scene-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 480px;
  overflow-y: auto;
}

.nook-scene-list li {
  background: var(--wood);
  border: 1px solid rgba(200, 117, 43, 0.25);
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.92rem;
  overflow-wrap: break-word;
}

.nook-scene-list li:hover {
  border-color: var(--ember);
}

.nook-scene-list li.active {
  border-color: var(--ember-bright);
  background: var(--wood-light);
}

.nook-scene-list .nook-empty-list {
  cursor: default;
  color: var(--parchment-dim);
  text-align: center;
  font-style: italic;
  font-size: 0.85rem;
}

.nook-main {
  flex: 1 1 auto;
  min-width: 0;
}

.nook-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Author-stylesheet display rules above beat the UA stylesheet's default
   [hidden] { display: none }, so it has to be restated explicitly here with
   higher specificity or the editor/read views render on top of each other. */
.nook-editor[hidden],
.nook-read[hidden] {
  display: none;
}

.nook-generate-label {
  font-size: 0.85rem;
  color: var(--parchment-dim);
  margin-top: 4px;
}

.nook-generate-row {
  display: flex;
  gap: 8px;
}

.nook-generate-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.nook-generate-row button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.nook-editor input,
.nook-editor textarea {
  background: var(--wood-dark);
  color: var(--parchment);
  border: 2px solid rgba(200, 117, 43, 0.4);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
  resize: vertical;
  width: 100%;
}

.nook-editor input:focus,
.nook-editor textarea:focus {
  outline: none;
  border-color: var(--ember-bright);
}

.nook-editor textarea {
  min-height: 280px;
  line-height: 1.6;
}

.nook-editor-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-danger {
  background: transparent;
  border: 2px solid #a33;
  color: #e08e8e;
  padding: 10px 20px;
}
.btn-danger:hover {
  background: #a33;
  color: var(--parchment);
}

.nook-status {
  min-height: 1.2em;
  color: var(--ember-bright);
  font-size: 0.85rem;
  margin: 0;
}

.nook-read {
  background: var(--wood);
  border: 1px solid rgba(200, 117, 43, 0.3);
  border-radius: 10px;
  padding: 32px;
  box-shadow: 0 4px 14px var(--shadow);
}

.nook-read h2 {
  text-align: center;
  margin-bottom: 24px;
}

.nook-read-body {
  font-size: 1.35rem;
  line-height: 1.9;
  margin-bottom: 28px;
}

.nook-read-body p {
  margin: 0 0 1.1em;
}

.nook-note {
  text-align: center;
  color: var(--parchment-dim);
  font-size: 0.85rem;
  margin-top: 28px;
}

@media (max-width: 700px) {
  .nook-layout { flex-direction: column; }
  .nook-sidebar { flex: none; width: 100%; }
  .nook-scene-list { max-height: 200px; }
}

/* About */
.about {
  background: var(--wood);
  padding: 60px 0;
  border-top: 1px solid rgba(200, 117, 43, 0.25);
  border-bottom: 3px solid var(--ember);
}
.about p {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  color: var(--parchment-dim);
}

/* Footer */
.site-footer {
  padding: 28px 0;
  text-align: center;
  color: var(--parchment-dim);
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  .hero h1 { font-size: 2.1rem; }
  .header-inner { flex-direction: column; gap: 10px; }
  .site-nav a { margin: 0 12px; }
  .header-run { display: none; }
  .site-header .wrap { padding-left: 24px; }
}

/* The Fallen — cross-site obituary board */
.fallen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  max-width: 900px;
  margin: 0 auto;
}

.fallen-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--wood);
  border: 1px solid rgba(200, 117, 43, 0.3);
  border-radius: 10px;
  padding: 24px 18px;
  box-shadow: 0 4px 14px var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.fallen-card:hover {
  border-color: var(--ember);
  transform: translateY(-2px);
  text-decoration: none;
}

.fallen-portrait {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 14px;
  border: 2px solid var(--ember);
  background: var(--wood-dark);
}
.fallen-portrait--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  opacity: 0.7;
}

.fallen-name {
  font-family: 'Trebuchet MS', Georgia, serif;
  font-size: 1.1rem;
  color: var(--parchment);
  margin-bottom: 4px;
}

.fallen-cause {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--parchment-dim);
  margin-bottom: 8px;
}

.fallen-meta {
  font-size: 0.75rem;
  color: var(--ember-bright);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Founders Wall — Kickstarter backer recognition, fed from ScribeMaster */
.founders-tier-group {
  margin-bottom: 40px;
}
.founders-tier-heading {
  font-family: 'Trebuchet MS', Georgia, serif;
  font-size: 1.3rem;
  text-align: center;
  color: var(--ember-bright);
  margin-bottom: 4px;
}
.founders-tier-count {
  text-align: center;
  font-size: 0.8rem;
  color: var(--parchment-dim);
  margin-bottom: 18px;
}

.founders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
  max-width: 900px;
  margin: 0 auto;
}

.founder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--wood);
  border: 1px solid rgba(200, 117, 43, 0.3);
  border-radius: 10px;
  padding: 20px 14px;
  box-shadow: 0 4px 14px var(--shadow);
}

.founder-portrait {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
  border: 2px solid var(--ember);
  background: var(--wood-dark);
}
.founder-portrait--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  opacity: 0.7;
}

.founder-name {
  font-family: 'Trebuchet MS', Georgia, serif;
  font-size: 1rem;
  color: var(--parchment);
}

/* Tier badge colors, dimmest to brightest — Wanderer through Guildmaster */
.founders-tier-group[data-tier="wanderer"] .founders-tier-heading { color: #b08d6a; }
.founders-tier-group[data-tier="scribe"] .founders-tier-heading { color: #c8752b; }
.founders-tier-group[data-tier="chronicler"] .founders-tier-heading { color: #d9a441; }
.founders-tier-group[data-tier="lorekeeper"] .founders-tier-heading { color: #e8c14a; }
.founders-tier-group[data-tier="guildmaster"] .founders-tier-heading { color: #ffd76b; }
