:root {
  --night: #070b0a;
  --granite: #0d1312;
  --gold: #d9b25f;
  --gold-dim: rgba(217, 178, 95, 0.55);
  --gold-faint: rgba(217, 178, 95, 0.22);
  --verd: #8fcfae;
  --verd-dim: rgba(143, 207, 174, 0.55);
  --chalk: #e9e4d3;
  --bronze-hi: #a67c45;
  --bronze: #5d4426;
  --bronze-lo: #3c2a15;
  --paper: #efe9d8;
  --ink: #12261e;
  --ink-half: rgba(18, 38, 30, 0.62);
  --cond: "Oswald", "Arial Narrow", sans-serif;
  --roman: "Marcellus SC", "Cinzel", "Times New Roman", serif;
  --mono: "Cutive Mono", "Courier New", monospace;
  --hand: "Architects Daughter", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }
html { height: 100%; background: var(--night); }
body {
  margin: 0 auto; min-height: 100%; width: 100%;
  container-type: inline-size;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background-color: var(--night);
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='s' x='0' y='0' width='100%25' height='100%25'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.62 0 0 0 0 0.66 0 0 0 0 0.62 0 0 0 0.15 0'/></filter><rect width='320' height='320' filter='url(%23s)'/></svg>"),
    radial-gradient(ellipse at 50% 32%, #111a17 0%, #0a100e 45%, var(--night) 100%);
  background-attachment: fixed, fixed;
  color: var(--chalk);
  font-family: var(--cond);
}

/* the lintel: the name cut over the works, not stretched across the sheet */
.lintel { text-align: center; padding: clamp(12px, 2vh, 24px) 16px 0; overflow-wrap: anywhere; }
.capstone { display: block; width: 0; height: 0; margin: 0 auto 9px; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 11px solid var(--gold); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.8)); }
.name {
  display: flex; align-items: center; justify-content: center; gap: clamp(12px, 2cqw, 26px);
  margin: 0; font-family: var(--roman); font-weight: 400; color: var(--gold);
  font-size: clamp(20px, 2.7cqw, 34px); letter-spacing: 0.2em; line-height: 1.1;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.95), 0 1px 0 rgba(255, 236, 190, 0.14);
}
.name::before, .name::after { content: ""; flex: 0 0 clamp(20px, 7cqw, 120px); height: 1px; background: var(--gold-dim); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.8); }
.sub { margin: 9px 0 0; font-size: clamp(11px, 1cqw, 13px); letter-spacing: 0.24em; color: var(--verd); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8); }
.creed { margin: 5px 0 0; font-size: clamp(10px, 0.85cqw, 11px); letter-spacing: 0.26em; color: var(--gold-dim); }
/* a hairline bar stands between words where a dot would (in SVG text the same bar is a tspan) */
.sep { display: inline-block; width: 1px; height: 0.85em; margin: 0 0.6em; vertical-align: -0.08em; background: var(--gold); opacity: 0.6; }
.paper .sep, .articles .sep { background: var(--ink); opacity: 0.5; }
svg text .bar { fill-opacity: 0.5; letter-spacing: 0; }

/* the works: the chalk on the left, the monument in the middle under the name, the counter on the right */
.works { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; justify-items: center; gap: 14px 2cqw; padding: 4px clamp(12px, 2cqw, 32px) 0; min-height: 0; }
.monument { width: 100%; max-width: 100%; height: 100%; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
.monument-svg { display: block; width: 100%; height: auto; max-height: none; filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.55)); }
.chalkboard { width: 100%; max-width: 560px; min-width: 0; font-family: var(--hand); color: var(--chalk); padding: 0 8px; display: flex; flex-direction: column; gap: 18px; }
.chalk-notes { order: 1; }
.quarry { order: 2; }
.chalk { margin: 0 0 5px; font-size: clamp(14px, 1.1vw, 16px); line-height: 1.35; opacity: 0.88; transform: rotate(-0.6deg); }
.chalk.lead { font-size: clamp(16px, 1.35vw, 19px); margin-bottom: 12px; }
.chalk.bright { color: #fff4d6; opacity: 1; font-size: clamp(15px, 1.25vw, 18px); margin-bottom: 3px; }
.chalk.dim { opacity: 0.5; font-size: clamp(12px, 0.95vw, 14px); margin-top: 8px; }
.chalk:empty { display: none; }
.quarry { width: min(252px, 100%); }
.quarry svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.6)); }
.quarry:empty { display: none; }

@container (min-width: 880px) {
  /* equal margins either side, so the axis of the monument is the axis of the page */
  .works { grid-template-columns: 250px minmax(0, 1fr) 250px; align-items: stretch; padding-top: 0; gap: 0 1cqw; }
  .chalkboard { align-self: stretch; justify-self: start; max-width: 268px; height: 100%; justify-content: space-between; padding: 9vh 8px 3vh; }
  .quarry { order: 0; }
  .chalk-notes { order: 1; }
  .monument-svg { width: 100%; height: 100%; max-height: calc(100vh - 215px); min-height: 360px; }
  .counter { align-self: center; }
}

.monument-svg text { font-family: var(--cond); font-weight: 400; }
.monument-svg text.cut { fill: var(--gold); }
.monument-svg text.dim { opacity: 0.6; }
.monument-svg text.gold { fill: var(--gold); }
.monument-svg text.num { font-family: var(--mono); fill: var(--gold); }
.monument-svg text.chalk { font-family: var(--hand); fill: var(--chalk); opacity: 0.86; }
.monument-svg text.chalk.dim { opacity: 0.55; }
.monument-svg .hit { cursor: pointer; }
.monument-svg .hit:hover { fill: rgba(217, 178, 95, 0.07); }
body.mining .monument-svg #cage { animation: lower 5s ease-in-out infinite; }
body.mining .monument-svg #boom { animation: swing 5s ease-in-out infinite; transform-origin: center; }
@keyframes lower { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-46px); } }
@keyframes swing { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
body.mining .monument-svg .edge { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* raised letters on bronze, in the monument and on the standalone plates */
svg text.raised { font-family: var(--roman); fill: #f2dfae; font-weight: 400; }
svg text.raised.gold { fill: #ffe9b3; }
svg text.raised-shadow { font-family: var(--roman); fill: rgba(20, 12, 4, 0.9); }
.plate-svg { display: block; }

/* the counter: five bronze medallions hung one under another on a gilt cord */
.counter { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(14px, 2.6vh, 30px); padding: 6px 4px; width: 100%; min-width: 0; }
.counter::before { content: ""; position: absolute; left: 50%; top: 4%; bottom: 4%; width: 1px; transform: translateX(-0.5px); background: linear-gradient(180deg, transparent, var(--gold-dim) 12%, var(--gold-dim) 88%, transparent); pointer-events: none; }
.medal { position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px; text-decoration: none; color: var(--verd-dim); }
.coin {
  display: block; width: clamp(56px, 7.6vh, 76px); aspect-ratio: 1; border-radius: 50%;
  background-size: cover; background-position: center; background-color: #1a1410;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.75), 0 2px 6px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(217, 178, 95, 0.18);
  transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}
.medal:hover .coin, .medal:focus-visible .coin { transform: translateY(-3px) scale(1.04); filter: brightness(1.1) saturate(1.05); box-shadow: 0 20px 34px rgba(0, 0, 0, 0.8), 0 0 0 3px rgba(217, 178, 95, 0.22); }
.medal .tag { display: block; width: 148px; height: 32px; }
.medal .tag svg { width: 100%; height: 100%; }
.medal.lead .coin { width: clamp(84px, 11.5vh, 116px); box-shadow: 0 18px 36px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.6), 0 0 0 4px rgba(217, 178, 95, 0.14), inset 0 0 0 1px rgba(217, 178, 95, 0.28); }
.medal.lead .tag { width: 210px; height: 42px; }
.medal small { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--verd-dim); margin-top: -2px; }
.medal:focus-visible { outline: none; }

/* the cornerstone: the sheet line and the live line */
.cornerstone { text-align: center; padding: 4px 16px 12px; color: var(--gold-dim); }
.cornerstone .line { margin: 0; font-size: 12px; letter-spacing: 0.22em; }
.cornerstone .badge { color: var(--verd); margin-left: 10px; }
.cornerstone .badge:empty { display: none; }
.cornerstone .live { margin: 5px 0 0; font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; }

/* stamps: bronze buttons inside the papers */
.stamp {
  display: inline-block; text-decoration: none; cursor: pointer; user-select: none;
  font-family: var(--roman); letter-spacing: 3px; text-transform: uppercase;
  color: #f2dfae; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8), 0 -1px 0 rgba(255, 235, 190, 0.18);
  background: linear-gradient(160deg, var(--bronze-hi), var(--bronze) 55%, var(--bronze-lo));
  border: 1px solid #1c140a; border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 225, 160, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.55), 0 8px 22px rgba(0, 0, 0, 0.65);
  padding: 12px 18px; font-size: 15px; line-height: 1; transition: transform 0.12s ease, filter 0.12s ease;
  position: relative;
}
.stamp::after { content: ""; position: absolute; inset: 0; border-radius: 3px; background: radial-gradient(ellipse at 30% 20%, rgba(90, 169, 135, 0.35), transparent 60%), radial-gradient(ellipse at 80% 90%, rgba(63, 143, 110, 0.3), transparent 55%); pointer-events: none; mix-blend-mode: multiply; }
.stamp:hover { transform: translateY(-1px) scale(1.02); filter: brightness(1.08); }
.stamp.big { color: #ffe9b3; padding: 17px 30px; font-size: 22px; letter-spacing: 5px; border-color: #d9b25f; box-shadow: inset 0 1px 0 rgba(255, 225, 160, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(217, 178, 95, 0.18), 0 10px 26px rgba(0, 0, 0, 0.7); }
.stamp.ghost { background: linear-gradient(160deg, #23302b, #141c19); color: var(--verd); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8); border-color: #1a2320; }
.stamp.ghost::after { display: none; }
.stamp.small { padding: 8px 12px; font-size: 12px; letter-spacing: 2px; }
.stamp[disabled], .stamp:disabled { opacity: 0.4; cursor: default; }

/* the papers: the Clerk's forms, old paper and green black ink */
.veil { position: fixed; inset: 0; background: rgba(3, 6, 5, 0.7); z-index: 8; }
.paper {
  position: fixed; z-index: 9; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--paper) repeating-linear-gradient(0deg, rgba(18, 38, 30, 0.05) 0 1px, transparent 1px 28px);
  color: var(--ink); border: 1px solid rgba(18, 38, 30, 0.35); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), inset 0 0 60px rgba(120, 90, 40, 0.12);
}
.paper .card { padding: 26px 30px 30px; }
.paper header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 3px double var(--ink); padding-bottom: 12px; margin-bottom: 18px; }
.paper h1 { margin: 0; font-family: var(--roman); font-size: 27px; letter-spacing: 4px; font-weight: 400; text-transform: uppercase; }
.paper h2 { font-size: 15px; letter-spacing: 3px; margin: 22px 0 10px; font-weight: 600; }
.paper .sub { margin: 4px 0 0; font-family: var(--hand); font-size: 17px; color: var(--ink-half); letter-spacing: 0; text-shadow: none; }
.paper .close { background: none; border: 1px solid var(--ink); color: var(--ink); width: 38px; height: 38px; font-size: 24px; line-height: 1; cursor: pointer; border-radius: 3px; }
.paper .body { font-size: 17px; line-height: 1.45; }
.paper p { margin: 0 0 12px; }
.paper .lead { font-size: 19px; font-weight: 500; }
.paper .note { font-family: var(--hand); font-size: 16px; color: var(--ink-half); }
.paper .bad { color: #8a2a22; }
.paper a { color: var(--ink); }
.paper .m { font-family: var(--mono); font-size: 0.95em; }
.paper .half { color: var(--ink-half); }
.paper footer { margin-top: 20px; padding-top: 12px; border-top: 1px solid rgba(18, 38, 30, 0.4); font-size: 14px; letter-spacing: 1px; color: var(--ink-half); text-transform: uppercase; line-height: 1.5; }

.field { margin: 14px 0; }
.field label { display: block; font-size: 13px; letter-spacing: 3px; font-weight: 600; margin-bottom: 6px; }
.field input[type="number"], .count input[type="number"] { font-family: var(--mono); font-size: 20px; padding: 8px 10px; width: 140px; border: 1px solid var(--ink); background: rgba(255, 255, 255, 0.45); color: var(--ink); border-radius: 3px; }
.field input[type="range"] { width: 100%; accent-color: #3f8f6e; }
.figures { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 14px 0; font-size: 17px; }
.figures dt { font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: var(--ink-half); align-self: center; }
.figures dd { margin: 0; }
.acts { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.paper .stamp { font-size: 14px; }
.paper .stamp.big { font-size: 19px; padding: 14px 24px; }
.count { font-size: 15px; letter-spacing: 1px; }
.count input { width: 76px; font-size: 16px; padding: 6px 8px; }
.wallet { font-size: 15px; }
.link { background: none; border: none; color: var(--ink-half); text-decoration: underline; cursor: pointer; font: inherit; }
.status { font-size: 15px; min-height: 1.4em; }
.result { border: 2px solid #3f8f6e; padding: 12px 14px; margin-top: 12px; background: rgba(63, 143, 110, 0.08); }
.link-text { word-break: break-all; }

table.ledger { width: 100%; border-collapse: collapse; font-size: 15px; margin: 8px 0 14px; }
table.ledger th { text-align: left; font-size: 11px; letter-spacing: 3px; color: var(--ink-half); border-bottom: 1px solid rgba(18, 38, 30, 0.4); padding: 6px 6px; }
table.ledger td { padding: 7px 6px; border-bottom: 1px solid rgba(18, 38, 30, 0.15); vertical-align: middle; }
.acts-cell { display: flex; gap: 6px; }
.cardwrap svg { width: 100%; height: auto; display: block; max-height: 62vh; margin: 0 auto 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45); }

.tip { position: fixed; z-index: 7; pointer-events: none; background: rgba(7, 11, 10, 0.96); color: var(--chalk); border: 1px solid var(--gold-dim); padding: 8px 12px; font-size: 14px; letter-spacing: 0.5px; max-width: 320px; }
.notice { position: fixed; z-index: 10; left: 50%; top: 18px; transform: translateX(-50%); background: var(--gold); color: #1a1408; font-weight: 500; padding: 10px 18px; font-size: 16px; letter-spacing: 0.5px; border-radius: 3px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); max-width: min(90vw, 720px); }
.hidden { display: none !important; }
.noscript { position: fixed; inset: 40% 10%; text-align: center; font-size: 20px; }

/* the narrow page: the monument first, the chalk under it, the medallions in a row, no cord */
@container (max-width: 879px) {
  .monument { order: 1; }
  .chalkboard { order: 2; }
  .counter { order: 3; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 10px 14px; padding: 8px 8px 4px; }
  .counter::before { display: none; }
  .chalkboard { gap: 14px; }
  .coin { width: 72px; }
  .medal.lead .coin { width: 104px; }
  .medal .tag { width: 128px; height: 30px; }
  .medal.lead .tag { width: 196px; height: 40px; }
  .medal small { font-size: 10px; }
}

@container (max-width: 720px) {
  .paper .card { padding: 20px 16px 24px; }
  .paper h1 { font-size: 22px; letter-spacing: 3px; }
  .stamp.big { font-size: 18px; padding: 14px 20px; letter-spacing: 4px; }
  .stamp { font-size: 13px; padding: 10px 14px; letter-spacing: 2px; }
}
