:root {
  --bg: #16110b;
  --bg-panel: #1e1710;
  --bg-panel-raised: #251c13;
  --wood-line: #2c2115;
  --ink: #f1e6cc;
  --ink-dim: #c9b98f;
  --ink-faint: #8f7f5c;
  --gold: #cea44a;
  --gold-bright: #e8c877;
  --bronze: #8a6a3f;
  --rule: #46351f;
  --good: #8faf7c;
  --bad: #b06a52;
  --focus: #e8c877;
  --font-display: "Playfair Display", "Iowan Old Style", "Georgia", serif;
  --font-body: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(0,0,0,0) 0px,
      rgba(0,0,0,0) 46px,
      rgba(0,0,0,0.10) 47px,
      rgba(0,0,0,0) 49px
    ),
    radial-gradient(ellipse at 50% -10%, #2a2013 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--gold);
  color: #201811;
  padding: 0.6rem 1rem;
  z-index: 100;
  font-family: var(--font-body);
  font-weight: 600;
}
.skip-link:focus { left: 0.75rem; top: 0.75rem; }

a { color: var(--gold-bright); }
a:hover { color: var(--gold); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, #1c150e, transparent);
}
.header-container {
  max-width: 780px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.author-link { text-decoration: none; color: var(--ink-dim); font-family: var(--font-display); font-size: 1rem; letter-spacing: 0.02em; }
.author-link:hover { color: var(--gold-bright); }
.lang-switch { display: flex; gap: 0.4rem; }
.lang-btn {
  text-decoration: none;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  padding: 0.25rem 0.65rem;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}
.lang-btn.active, .lang-btn:hover { color: var(--gold-bright); border-color: var(--bronze); }

main { max-width: 780px; margin: 0 auto; padding: 0 1.25rem; }

/* Hero, styled as the crest of a peal board */
.hero {
  padding: 3rem 0 1.75rem;
  border-bottom: 3px double var(--rule);
  margin-bottom: 2rem;
}
.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--bronze);
  margin: 0 0 0.9rem;
}
.title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 5.5vw, 3.2rem);
  line-height: 1.12;
  color: var(--gold-bright);
  margin: 0 0 1.1rem;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.lead {
  font-size: 1.15rem;
  color: var(--ink);
  max-width: 62ch;
  margin: 0;
}

/* Stat banner, evoking painted rows on a peal board */
.stat-banner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 2.75rem;
  background: var(--bg-panel);
}
.stat-card {
  padding: 1.1rem 1rem;
  border-left: 1px solid var(--rule);
  text-align: center;
}
.stat-card:first-child { border-left: none; }
.stat-number {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--gold-bright);
  letter-spacing: 0.01em;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 0.3rem;
  line-height: 1.35;
}

article { padding-bottom: 1rem; }
section { margin-bottom: 2.6rem; }

.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--gold-bright);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.5rem;
  margin: 0 0 1.1rem;
}

p { margin: 0 0 1.05rem; color: var(--ink); }
p:last-child { margin-bottom: 0; }
strong { color: var(--gold-bright); font-weight: 600; }
em { color: var(--ink-dim); }

.aside-note {
  font-size: 0.95rem;
  color: var(--ink-dim);
  border-left: 2px solid var(--bronze);
  padding-left: 0.9rem;
  margin-top: 1.3rem;
}

/* Interactive instrument shell */
.instrument {
  background: var(--bg-panel);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.4rem 1.3rem 1.6rem;
  margin: 1.6rem 0;
}
.instrument-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--gold-bright);
  margin: 0 0 0.25rem;
}
.instrument-hint {
  font-size: 0.88rem;
  color: var(--ink-faint);
  margin: 0 0 1.2rem;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.1rem;
}
input[type="range"] {
  flex: 1;
  accent-color: var(--gold);
  height: 1.6rem;
}
.bell-count-display {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--ink);
  min-width: 6.2rem;
  text-align: right;
}

.growth-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 480px) {
  .growth-readout { grid-template-columns: 1fr; }
}
.readout-block {
  background: var(--bg-panel-raised);
  border: 1px solid var(--wood-line);
  border-radius: 4px;
  padding: 0.85rem 1rem;
}
.readout-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin-bottom: 0.3rem;
}
.readout-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  color: var(--gold-bright);
  word-break: break-word;
}

.growth-bar-track {
  position: relative;
  height: 10px;
  background: var(--bg-panel-raised);
  border: 1px solid var(--wood-line);
  border-radius: 5px;
  margin: 1.6rem 0 0.4rem;
}
.growth-bar-fill {
  position: absolute;
  inset: 0;
  width: 20%;
  background: linear-gradient(90deg, var(--bronze), var(--gold));
  border-radius: 5px 0 0 5px;
  transition: width 0.2s ease;
}
.growth-marker {
  position: absolute;
  top: -0.35rem;
  width: 2px;
  height: 1.7rem;
  background: var(--ink-faint);
  transform: translateX(-50%);
}
.growth-marker-label {
  position: absolute;
  top: 1.4rem;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
  white-space: nowrap;
}
.growth-legend {
  margin-top: 2.1rem;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.annotation {
  min-height: 3.2rem;
  font-size: 0.95rem;
  color: var(--ink-dim);
  border-top: 1px solid var(--wood-line);
  padding-top: 0.85rem;
  margin-top: 1.4rem;
}

/* Four-bell game */
.game-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  margin: 1.1rem 0 1.3rem;
}
.game-bell {
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--gold-bright);
  background: var(--bg-panel-raised);
  border: 1px solid var(--wood-line);
  border-radius: 4px;
}
.swap-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}
.btn-swap {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  background: var(--bg-panel-raised);
  color: var(--ink);
  border: 1px solid var(--bronze);
  border-radius: 4px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}
.btn-swap:hover { border-color: var(--gold); color: var(--gold-bright); }
.btn-reset {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: transparent;
  color: var(--ink-faint);
  border: 1px solid var(--wood-line);
  border-radius: 4px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  display: block;
  margin: 0 auto;
}
.btn-reset:hover { color: var(--ink); border-color: var(--ink-faint); }

.game-progress {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.3rem;
  margin: 1.2rem 0;
  max-width: 22rem;
  margin-left: auto;
  margin-right: auto;
}
.game-dot {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--bg-panel-raised);
  border: 1px solid var(--wood-line);
}
.game-dot.hit { background: var(--gold); border-color: var(--gold-bright); }

.game-status {
  text-align: center;
  font-size: 0.92rem;
  color: var(--ink-dim);
  min-height: 1.6rem;
}
.game-status.repeat { color: var(--bad); }
.game-status.complete { color: var(--good); }

.js-only { display: block; }
.no-js .js-only { display: none; }
noscript p { color: var(--ink-dim); font-style: italic; }

/* Sources */
.sources-list { padding-left: 1.15rem; margin: 0; }
.sources-list li { margin-bottom: 0.6rem; color: var(--ink-dim); font-size: 0.95rem; }
.sources-list a { text-decoration-color: var(--bronze); }

.method-note {
  font-size: 0.9rem;
  color: var(--ink-faint);
  margin-top: 1.2rem;
}

/* Footer */
.site-footer { border-top: 1px solid var(--rule); margin-top: 2rem; }
.footer-container {
  max-width: 780px;
  margin: 0 auto;
  padding: 1.6rem 1.25rem 2.5rem;
}
.footer-nav { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.footer-nav a { text-decoration: none; font-family: var(--font-mono); font-size: 0.82rem; color: var(--ink-faint); }
.footer-nav a:hover { color: var(--gold-bright); }
.footer-note { font-size: 0.82rem; color: var(--ink-faint); max-width: 60ch; margin: 0; }

@media (max-width: 560px) {
  .stat-banner { grid-template-columns: 1fr; }
  .stat-card { border-left: none; border-top: 1px solid var(--rule); }
  .stat-card:first-child { border-top: none; }
  .game-progress { grid-template-columns: repeat(8, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .growth-bar-fill { transition: none !important; }
}
