:root {
  color-scheme: light;
  --bg: #f3ede2;
  --paper: #fffaf0;
  --ink: #1f1a16;
  --muted: #6c635a;
  --accent: #8c3b1f;
  --accent-soft: #d88d57;
  --line: #d4c2aa;
  --shadow: 0 20px 45px rgba(63, 39, 19, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(216, 141, 87, 0.22), transparent 30%),
    linear-gradient(180deg, #efe4d0 0%, var(--bg) 48%, #ece2d6 100%);
  min-height: 100vh;
}

.page-shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: 2.1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.hero-copy,
.hero-card,
.panel {
  background: rgba(255, 250, 240, 0.86);
  border: 1px solid rgba(140, 59, 31, 0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.hero-copy {
  padding: 28px;
}

.hero-card {
  padding: 24px;
  align-self: stretch;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
}

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

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin-bottom: 0;
}

h1 {
  font-size: clamp(2.4rem, 5vw, 4.6rem);
  line-height: 0.95;
  margin-bottom: 12px;
}

.lede {
  margin: 0;
  max-width: 54ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-card p {
  margin-top: 0;
  font-weight: 700;
}

.hero-card ul {
  margin: 0;
  padding-left: 20px;
}

.app-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 24px;
}

.panel {
  padding: 24px;
}

.reference-panel {
  grid-column: 1 / -1;
}

.results-panel {
  grid-column: 1 / -1;
  order: -1;
}

.details-panel {
  grid-column: 2;
}

.converter-panel {
  grid-column: 1 / -1;
}

.derivations-panel {
  grid-column: 1 / -1;
}

.writeup-panel {
  grid-column: 1 / -1;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--muted);
}

.label-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.label-title {
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: #fffdf8;
  color: var(--ink);
}

input[readonly],
select.autofill-locked,
.autofill-locked {
  background: #efe7da;
  color: #7b6d5f;
  border-color: #cbb8a0;
  cursor: not-allowed;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(140, 59, 31, 0.2);
  outline-offset: 2px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  background: var(--accent);
  color: #fffaf2;
  transition: transform 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: #713019;
}

button.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(140, 59, 31, 0.22);
}

.info-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: 999px;
  background: #f3e1cd;
  color: var(--accent);
  border: 1px solid rgba(140, 59, 31, 0.24);
  font-weight: 700;
  line-height: 1;
}

.info-button:hover {
  background: #e9cfb2;
}

.summary-card {
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(140, 59, 31, 0.94), rgba(216, 141, 87, 0.95));
  color: #fff7ef;
  margin-bottom: 18px;
}

.table-output {
  margin-bottom: 18px;
}

.gURPS-table-skill,
.gurps-table-skill {
  margin: 0 0 8px;
  color: var(--ink);
  font-weight: 700;
}

.gurps-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffdf8;
}

.gurps-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.gurps-table th,
.gurps-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(212, 194, 170, 0.7);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.gurps-table th {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.gurps-table tr:last-child td {
  border-bottom: 0;
}

.summary-card h3,
.summary-card p {
  margin: 0;
}

.summary-card p + p {
  margin-top: 8px;
}

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

.stat-card {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 16px;
  padding: 14px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.stat-card .label {
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.label-row .label {
  margin-bottom: 0;
}

.stat-info-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(140, 59, 31, 0.22);
  font-weight: 700;
  line-height: 1;
}

.stat-info-button:hover {
  background: rgba(216, 141, 87, 0.16);
}

.stat-card .value {
  font-size: 1.2rem;
  font-weight: 700;
}

.formula-line {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.validation {
  margin-bottom: 14px;
}

.validation-item,
.validation-ok {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.validation-ok {
  background: rgba(95, 128, 78, 0.12);
  border: 1px solid rgba(95, 128, 78, 0.2);
}

.validation-item.warning {
  background: rgba(216, 141, 87, 0.15);
  border: 1px solid rgba(216, 141, 87, 0.25);
}

.validation-item.error {
  background: rgba(140, 59, 31, 0.12);
  border: 1px solid rgba(140, 59, 31, 0.22);
}

.notes {
  margin-top: 18px;
  color: var(--muted);
}

.notes ul,
.reference-list {
  margin: 8px 0 0;
  padding-left: 20px;
}

.derivations {
  margin-top: 0;
}

.derivation-card {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 16px;
  padding: 16px;
  margin-top: 12px;
}

.derivation-card h4 {
  margin: 0 0 10px;
}

.derivation-card p {
  margin: 0 0 8px;
  line-height: 1.45;
}

.derivation-card ul {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.writeup-box {
  max-height: 900px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffdf8;
  padding: 18px;
}

.writeup-box h3 {
  margin-top: 18px;
  margin-bottom: 10px;
}

.writeup-box h3:first-child {
  margin-top: 0;
}

.writeup-box p,
.writeup-box li {
  color: var(--muted);
  line-height: 1.55;
}

.writeup-box pre {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4ecdf;
  overflow-x: auto;
}

.writeup-box code {
  font-family: "Consolas", "Courier New", monospace;
}

.writeup-list {
  margin: 8px 0 0;
  padding-left: 22px;
}

.writeup-frame {
  width: 100%;
  min-height: 900px;
  border: 0;
  background: #fffdf8;
}

.converter-lede {
  margin: 0 0 16px;
  color: var(--muted);
}

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

.converter-card {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 16px;
  padding: 16px;
}

.converter-card h3 {
  margin-bottom: 12px;
}

.toggle-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 700;
}

.form-toggle-field {
  margin-top: 18px;
}

.form-sync-note {
  margin-bottom: 0;
}

.toggle-field input[type="checkbox"] {
  width: auto;
  min-width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--accent);
}

.sync-note {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.sync-status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(140, 59, 31, 0.08);
  border: 1px solid rgba(140, 59, 31, 0.16);
  color: var(--ink);
}

.sync-status:empty {
  display: none;
}

.converter-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.converter-results {
  margin-top: 14px;
  border-top: 1px solid rgba(212, 194, 170, 0.7);
  padding-top: 12px;
  color: var(--muted);
}

.converter-results p {
  margin: 0 0 8px;
  line-height: 1.45;
}

body.modal-open {
  overflow: hidden;
}

.info-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 26, 22, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.info-modal-overlay[hidden] {
  display: none;
}

.info-modal {
  width: min(720px, 100%);
  max-height: min(80vh, 900px);
  overflow: auto;
  background: #fffaf0;
  border-radius: 20px;
  border: 1px solid rgba(140, 59, 31, 0.15);
  box-shadow: 0 24px 60px rgba(31, 26, 22, 0.28);
  padding: 22px;
}

.info-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.info-modal-head h3 {
  margin: 0;
}

.info-modal-close {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(140, 59, 31, 0.22);
  padding: 8px 12px;
}

.info-modal-intro {
  margin: 0 0 12px;
  color: var(--ink);
  line-height: 1.5;
}

.info-modal-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.info-section + .info-section {
  margin-top: 12px;
}

.info-section-title {
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 6px;
}

.info-sublist {
  margin: 0;
  padding-left: 18px;
}

.rules-text-block p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.5;
}

.table-note {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.5;
}

.rules-table-wrap + .rules-table-wrap {
  margin-top: 14px;
}

.rules-table-title {
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 6px;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.rules-table td {
  border-bottom: 1px solid rgba(212, 194, 170, 0.7);
  padding: 8px 10px;
  color: var(--muted);
  vertical-align: top;
}

.rules-table tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 900px) {
  .hero,
  .app-grid {
    grid-template-columns: 1fr;
  }

  .details-panel {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .field-grid,
  .stats-grid,
  .converter-grid,
  .converter-fields {
    grid-template-columns: 1fr;
  }

  .page-shell {
    width: min(100vw - 20px, 1000px);
    padding-top: 20px;
  }

  .panel,
  .hero-copy,
  .hero-card {
    padding: 18px;
  }
}
