@font-face {
  font-family: Cinzel;
  src: url("./fonts/cinzel.ttf") format("truetype");
  font-weight: 400 900;
  font-display: swap;
}

@font-face {
  font-family: "Source Sans 3";
  src: url("./fonts/source-sans-3.ttf") format("truetype");
  font-weight: 200 900;
  font-display: swap;
}

:root {
  --ink: #342416;
  --ink-soft: #6d5942;
  --paper: #f1e8d3;
  --paper-light: #faf5e9;
  --gold: #8c6428;
  --gold-dark: #4f3515;
  --wine: #6d2620;
  --line: #bbae92;
  --heading: cinzel, georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Source Sans 3", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background:
    radial-gradient(ellipse at 50% 0, #61462655, transparent 65%),
    repeating-linear-gradient(90deg, transparent 0 80px, #ffffff03 81px 82px),
    linear-gradient(145deg, #2a1d12, #130f0b 55%, #090806);
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--gold-dark);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--gold);
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-family: var(--heading);
  line-height: 1.25;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

h3 {
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.page-shell {
  padding: 40px 20px;
}

.parchment {
  position: relative;
  max-width: 1180px;
  margin: auto;
  padding: clamp(24px, 4vw, 48px);
  border: 1px solid #a18c67;
  background:
    radial-gradient(ellipse at 0 0, #c6a46820, transparent 45%),
    radial-gradient(ellipse at 100% 100%, #b5976420, transparent 45%),
    linear-gradient(110deg, #f7f0df, var(--paper));
  box-shadow:
    0 24px 70px #0008,
    0 0 0 5px #342416,
    0 0 0 6px #887047;
}

.parchment::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid #bbae9280;
  pointer-events: none;
}

.guild-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 3px double var(--gold);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.guild-crest {
  width: 48px;
  flex-shrink: 0;
  color: var(--gold-dark);
}

.guild-crest svg {
  display: block;
  width: 100%;
  stroke: currentcolor;
  stroke-width: 1.7;
}

.guild-crest text {
  fill: currentcolor;
  stroke: none;
  font:
    bold 22px Georgia,
    serif;
}

h1 {
  font-size: clamp(1.5rem, 3.3vw, 2.5rem);
  letter-spacing: -0.025em;
  margin: 0;
}

.eyebrow,
.section-kicker,
.quest-type,
.sheet-label {
  font-size: 0.69rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}

.eyebrow {
  margin-bottom: 5px;
}

.edition-mark {
  margin: 0;
  text-align: right;
  font-family: var(--heading);
  font-size: 0.72rem;
  color: var(--gold-dark);
}

.edition-mark span {
  display: block;
  margin-top: 5px;
  font-family: "Source Sans 3", Arial, sans-serif;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.character-sheet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(200px, 1fr);
  gap: 28px;
  align-items: center;
  padding: 28px 0;
}

.character-identity {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  min-width: 0;
}

.player-name {
  font-family: var(--heading);
  font-size: 1.5rem;
  overflow-wrap: anywhere;
  max-width: 100%;
  line-height: 1.4;
  margin: 3px 0 5px;
}

.role-badge {
  font-size: 0.75rem;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  padding-top: 5px;
  min-width: 100px;
}

.character-stats {
  display: flex;
  gap: 12px;
  margin: 0;
}

.stat-box {
  display: flex;
  flex-direction: column-reverse;
  text-align: center;
  min-width: 84px;
  padding: 9px 12px 7px;
  border: 1px solid var(--gold-dark);
  border-radius: 9px 9px 20px 20px;
  outline: 1px solid var(--line);
  outline-offset: 3px;
  background: #fff5;
}

.stat-box dt {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat-box dd {
  margin: 0;
  font-family: var(--heading);
  font-size: 1.8rem;
  line-height: 1.3;
}

.xp-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 0.8rem;
  margin-bottom: 8px;
}

.xp-track {
  padding: 2px;
  height: 11px;
  border: 1px solid var(--gold);
  background: #70532714;
}

.xp-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #705025, #b88c43);
}

.xp-caption {
  display: block;
  margin-top: 7px;
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.guild-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 24px;
  padding: 0 0 0 2px;
  border-block: 1px solid var(--line);
  margin-bottom: 28px;
}

.guild-nav a,
.guild-nav button {
  display: inline-block;
  padding: 12px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
}

.guild-nav a:hover,
.guild-nav button:hover {
  color: var(--ink);
}

.guild-nav [aria-current="page"] {
  color: var(--gold-dark);
  border-bottom-color: var(--gold-dark);
}

.guild-nav form {
  margin: 0 0 0 auto;
}

.guildmaster-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  padding: 14px 18px;
  border-left: 3px solid var(--gold);
  background: #8c64280b;
}

.guildmaster-panel .section-kicker {
  margin-bottom: 2px;
}

.guildmaster-panel h2 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.guildmaster-panel p:last-child {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.guildmaster-panel .btn {
  flex-shrink: 0;
}

.adventure-layout {
  display: grid;
  grid-template-columns: minmax(0, 330px) minmax(0, 1fr);
  align-items: start;
  gap: 32px;
}

.quest-sidebar {
  border: 1px solid var(--line);
  padding: 24px 18px;
  background: #fff4;
  position: relative;
}

.quest-sidebar::before {
  content: "✦";
  display: block;
  text-align: center;
  color: var(--gold);
  font-size: 1.4rem;
  margin-bottom: 14px;
}

.quest-picker {
  text-align: center;
}

.quest-picker h2 {
  font-size: 1.4rem;
}

.section-kicker {
  margin-bottom: 6px;
}

.picker-intro {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 22px;
}

.time-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.time-picker label {
  position: relative;
  cursor: pointer;
}

.time-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.time-picker span {
  display: block;
  padding: 9px 8px;
  border: 1px solid var(--line);
  background: #fff4;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.time-picker input:checked + span {
  background: #e7d6ae;
  border-color: var(--gold);
  color: var(--gold-dark);
  box-shadow: inset 0 0 0 1px var(--gold);
  font-weight: 700;
}

.time-picker input:focus-visible + span {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.time-picker .btn-primary {
  grid-column: 1 / -1;
  margin-top: 6px;
}

.btn {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--gold);
  border-radius: 2px;
  background: transparent;
  color: var(--gold-dark);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  transition:
    background 120ms ease,
    transform 120ms ease;
}

.btn:hover {
  background: #8c642814;
  color: var(--gold-dark);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: #faf3df;
  background: var(--gold-dark);
  box-shadow:
    inset 0 0 0 2px #ffffff15,
    0 2px 3px #34241618;
}

.btn-primary:hover {
  color: #fff8e9;
  background: #684a23;
}

.btn-small {
  font-size: 0.78rem;
  padding: 7px 11px;
}

.btn-ghost {
  border-color: var(--line);
  color: var(--ink-soft);
}

.chosen-slot {
  margin-top: 26px;
}

.empty-state {
  font-family: Georgia, serif;
  font-size: 0.88rem;
  font-style: italic;
  line-height: 1.6;
  color: var(--ink-soft);
  margin-bottom: 0;
}

.featured-quest {
  position: relative;
  text-align: left;
  border: 1px solid var(--gold);
  padding: 24px 14px 16px;
  background: var(--paper-light);
  box-shadow: 3px 3px 0 #8c642815;
}

.featured-quest h3 {
  overflow-wrap: anywhere;
  font-size: 1.3rem;
}

.quest-ribbon {
  position: absolute;
  top: -11px;
  left: 12px;
  padding: 2px 9px;
  background: var(--gold-dark);
  color: var(--paper-light);
  text-transform: uppercase;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
}

.quest-type {
  font-size: 0.62rem;
}

.quest-description {
  color: var(--ink-soft);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.quest-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid var(--line);
  margin: 18px 0;
}

.quest-stats div {
  padding: 10px 4px;
}

.quest-stats div + div {
  border-left: 1px solid var(--line);
}

.quest-stats dt {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.quest-stats dd {
  margin: 3px 0 0;
  font-size: 0.74rem;
  font-weight: 700;
}

.quest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.quest-actions form {
  margin: 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.section-heading .btn {
  flex-shrink: 0;
}

.ledger-section {
  margin-top: 22px;
}

.ledger-section h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
  padding-bottom: 10px;
  font-size: 0.85rem;
  border-bottom: 2px solid var(--ink-soft);
}

.ledger-section h3::before {
  content: "◇";
  color: var(--gold);
  font-size: 1rem;
}

.ledger-active h3::before {
  content: "⚔";
}

.ledger-completed h3::before {
  content: "✦";
}

.ledger-abandoned h3::before {
  content: "—";
}

.quest-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  transition: opacity 0.2s ease;
}

.quest-row.htmx-swapping {
  opacity: 0;
}

.quest-main {
  min-width: 0;
}

.quest-main strong {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.quest-main span {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.quest-main .quest-description {
  margin: 7px 0 0;
}

.reward {
  align-self: start;
  border: 1px solid var(--line);
  padding: 3px 7px;
  color: var(--gold-dark);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  background: #8c64280a;
}

.live-row .quest-actions {
  grid-column: 1 / -1;
}

.empty-list {
  padding: 14px 0;
  margin: 0;
  color: var(--ink-soft);
  font-family: Georgia, serif;
  font-size: 0.83rem;
  font-style: italic;
  line-height: 1.6;
}

.quest-list:has(.quest-row) > .empty-list {
  display: none;
}

.completed .quest-main > strong {
  color: var(--ink-soft);
}

.auth-panel {
  max-width: 440px;
  margin: 32px auto;
}

.auth-panel h2 {
  font-size: 1.5rem;
}

.welcome-line {
  text-align: center;
  margin: 26px 0 0;
  font-family: Georgia, serif;
  font-style: italic;
  color: var(--ink-soft);
}

.quest-editor {
  max-width: 650px;
  margin: auto;
}

.ledger-form {
  display: grid;
  gap: 9px;
  margin: 20px 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-top: 3px double var(--gold);
  background: #fff4;
}

.ledger-form label {
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 6px;
}

.ledger-form input,
.ledger-form textarea,
.ledger-form select {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--paper-light);
  color: var(--ink);
}

.ledger-form textarea {
  resize: vertical;
}

.ledger-form small,
.ledger-form p,
.form-hint {
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.5;
}

.ledger-form .btn {
  margin-top: 9px;
}

.form-error {
  color: var(--wine);
  padding: 12px;
  border-left: 3px solid var(--wine);
  background: #6d262008;
}

#feedback {
  overflow-wrap: anywhere;
}

#feedback:empty {
  display: none;
}

#feedback:not(:empty) {
  margin-bottom: 20px;
}

#feedback p {
  padding: 12px 16px;
  background: #8c64280d;
  border-left: 3px solid var(--gold);
}

.loading-rune {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.9rem;
  margin-top: 14px;
  color: var(--ink-soft);
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: block;
}

.ornament {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px auto;
  max-width: 300px;
  color: var(--gold);
}

.ornament span {
  height: 1px;
  flex: 1;
  background: var(--line);
}

.paper-footer {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 40px;
  color: var(--ink-soft);
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.8rem;
}

.footer-rule {
  flex: 1;
  height: 1px;
  background: var(--line);
}

.seal {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: 3px double #481410;
  border-radius: 50%;
  background: var(--wine);
  color: #ecd7b4;
  font-style: normal;
  font-size: 0.7rem;
  transform: rotate(-9deg);
}

@media (width <= 900px) {
  .character-sheet {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
  }

  .xp-wrap {
    grid-column: 1 / -1;
  }

  .adventure-layout {
    grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
    gap: 22px;
  }

  .section-heading {
    flex-wrap: wrap;
  }
}

@media (width <= 700px) {
  .page-shell {
    padding: 18px 12px;
  }

  .parchment {
    padding: 24px 18px;
  }

  .guild-header {
    gap: 12px;
  }

  .edition-mark {
    display: none;
  }

  .brand-lockup {
    gap: 12px;
  }

  .guild-crest {
    width: 38px;
  }

  .adventure-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }

  .quest-sidebar {
    padding: 20px;
  }

  .quest-sidebar::before {
    display: none;
  }

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

  .time-picker .btn-primary {
    justify-self: center;
    min-width: 220px;
  }

  .guildmaster-panel {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .guild-nav {
    gap: 0 16px;
  }

  .guild-nav a,
  .guild-nav button {
    font-size: 0.8rem;
  }

  .ledger-form {
    padding: 18px;
  }
}

@media (width <= 390px) {
  .character-sheet {
    gap: 16px 10px;
  }

  .character-stats {
    gap: 9px;
  }

  .stat-box {
    min-width: 62px;
    padding-inline: 8px;
  }

  .stat-box dd {
    font-size: 1.4rem;
  }

  .player-name {
    font-size: 1.15rem;
  }

  .guild-nav {
    gap: 0 12px;
  }

  .guild-nav form {
    margin-left: 0;
  }

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

  .time-picker .btn-primary {
    min-width: 0;
    width: 100%;
  }

  .quest-row {
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
