/* CHARLATAN — woodcut & parchment, patent-medicine premium */

:root {
  --ink: #2b2118;
  --ink-soft: #4a3526;
  --paper: #e9ddc0;
  --paper-bright: #f4ecd8;
  --paper-deep: #d8c9a3;
  --rust: #8a4a12;
  --blood: #7a1f1f;
  --moss: #4a5d23;
  --amber: #b8742d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--ink);
  min-height: 100vh;
  background-color: var(--paper-deep);
  /* layered paper: stain blotches, fiber lines, vignette — never flat */
  background-image:
    radial-gradient(ellipse 28% 18% at 16% 10%, rgba(138, 74, 18, 0.07), transparent),
    radial-gradient(ellipse 22% 16% at 86% 26%, rgba(122, 31, 31, 0.05), transparent),
    radial-gradient(ellipse 26% 20% at 72% 88%, rgba(74, 93, 35, 0.06), transparent),
    radial-gradient(ellipse 16% 12% at 8% 70%, rgba(138, 74, 18, 0.05), transparent),
    repeating-linear-gradient(93deg, rgba(43, 33, 24, 0.027) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg, rgba(255, 250, 235, 0.05) 0 2px, transparent 2px 5px),
    radial-gradient(ellipse at 50% 30%, #ecdfc2 0%, var(--paper-deep) 60%, #bda87c 100%);
  background-attachment: fixed;
}

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 10px 120px 10px 20px;
  border-bottom: 3px double var(--ink);
  background:
    repeating-linear-gradient(92deg, rgba(43, 33, 24, 0.03) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, var(--paper-bright), var(--paper));
  font-weight: bold; font-size: 18px;
  box-shadow: 0 2px 0 rgba(43, 33, 24, 0.12);
}
#stat-cash { color: var(--moss); font-variant-numeric: tabular-nums; }
#heat-wrap { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.heat-label { font-size: 11px; letter-spacing: 3px; }

/* the mercury thermometer */
#thermo { display: flex; align-items: center; }
.thermo-bulb {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--ink);
  background: radial-gradient(circle at 35% 32%, #d96b4a 0%, #a23c1e 55%, #6e1d10 100%);
  margin-right: -5px; position: relative; z-index: 1;
  box-shadow: inset -2px -2px 3px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.4s;
}
.thermo-tube {
  width: 150px; height: 11px;
  border: 2px solid var(--ink); border-left: none;
  border-radius: 0 7px 7px 0;
  background: linear-gradient(180deg, #fbf5e4, #efe5cb);
  position: relative; overflow: hidden;
}
.thermo-tube::after { /* graduation ticks over the mercury */
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 17px, rgba(43, 33, 24, 0.35) 17px 18px);
  pointer-events: none;
}
#heat-fill {
  height: 100%; width: 0;
  background: linear-gradient(180deg, #cf7350 0%, #a23c1e 50%, #7e2412 100%);
  transition: width 0.5s ease;
}
#heat-fill.hot {
  background: linear-gradient(180deg, #c4453a 0%, var(--blood) 55%, #4e1010 100%);
}
#thermo.hot .thermo-bulb {
  box-shadow: 0 0 10px 2px rgba(170, 32, 22, 0.75), inset -2px -2px 3px rgba(0, 0, 0, 0.35);
  animation: bulbthrob 1.1s ease-in-out infinite alternate;
}
@keyframes bulbthrob {
  from { box-shadow: 0 0 6px 1px rgba(170, 32, 22, 0.55), inset -2px -2px 3px rgba(0, 0, 0, 0.35); }
  to   { box-shadow: 0 0 14px 4px rgba(170, 32, 22, 0.9), inset -2px -2px 3px rgba(0, 0, 0, 0.35); }
}

/* ---------- mute ---------- */
.mute-btn {
  position: fixed; top: 10px; right: 12px; z-index: 60;
  font-family: inherit; font-style: italic; font-size: 12px;
  letter-spacing: 1px; cursor: pointer;
  color: var(--ink-soft); background: rgba(244, 236, 216, 0.85);
  border: 1px solid var(--ink-soft); border-radius: 2px;
  padding: 4px 10px;
}
.mute-btn:hover { background: var(--paper-bright); }

/* ---------- layout ---------- */
#layout { display: flex; gap: 18px; padding: 16px 20px; max-width: 1100px; margin: 0 auto; }
#screen { flex: 1; min-height: 60vh; min-width: 0; }
#screen.screen-in { animation: screenIn 0.32s ease-out; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- the Ledger: a real ledger book ---------- */
#ledger {
  width: 280px; flex-shrink: 0;
  align-self: flex-start;
  border: 2px solid var(--ink);
  border-left: 7px solid #3d2c1d; /* the binding */
  box-shadow:
    inset 0 0 0 1px rgba(43, 33, 24, 0.25),
    5px 6px 0 rgba(43, 33, 24, 0.28);
  padding: 12px 12px 16px 20px;
  background-color: var(--paper-bright);
  background-image:
    linear-gradient(90deg, transparent 12px, rgba(122, 31, 31, 0.30) 12px, rgba(122, 31, 31, 0.30) 13px, transparent 13px),
    repeating-linear-gradient(180deg, transparent 0 21px, rgba(43, 33, 24, 0.13) 21px 22px),
    repeating-linear-gradient(91deg, rgba(43, 33, 24, 0.02) 0 1px, transparent 1px 3px);
}
#ledger h2 {
  margin: 0 0 10px; font-size: 15px;
  font-variant: small-caps; letter-spacing: 2px;
  border-bottom: 3px double var(--ink); padding-bottom: 6px;
  text-align: center;
}
.ledger-empty { font-style: italic; opacity: 0.55; font-size: 14px; }
.ledger-entry {
  margin-bottom: 11px; padding-left: 8px; position: relative;
  border-left: 3px solid var(--amber);
}
.ledger-entry.over-3 { border-left-color: var(--blood); }
.ledger-entry.fresh { animation: inkStamp 0.55s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes inkStamp {
  0%   { opacity: 0; transform: scale(1.4) rotate(-4deg); filter: blur(1px); }
  55%  { opacity: 1; filter: none; }
  100% { transform: none; }
}
.ledger-quote { font-style: italic; font-size: 14px; line-height: 1.35; }
.ledger-meta { font-size: 11.5px; opacity: 0.65; font-style: italic; }
.wax-dot {
  position: absolute; right: 2px; top: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #a8362e 0%, var(--blood) 60%, #4e1010 100%);
  box-shadow: 0 1px 1px rgba(43, 33, 24, 0.5), inset 0 0 0 2px rgba(78, 16, 16, 0.6);
}

/* ---------- title screen ---------- */
.title-wrap { text-align: center; padding-top: 12px; }
h1.logo {
  font-size: 70px; letter-spacing: 12px; margin: 6px 0 0;
  font-weight: 900;
  text-shadow: /* ink bleed */
    0 0 1px var(--ink),
    1px 1px 0 rgba(43, 33, 24, 0.45),
    2px 2px 0 rgba(43, 33, 24, 0.18),
    0 0 18px rgba(43, 33, 24, 0.28);
}
.tagline { font-style: italic; font-size: 22px; margin: 8px 0 0; color: var(--ink-soft); }
.subtitle { max-width: 480px; margin: 18px auto 6px; }
.arm-badge { font-size: 12px; letter-spacing: 1px; opacity: 0.55; margin-top: 18px; }

.orn-rule {
  display: flex; align-items: center; gap: 14px;
  max-width: 460px; margin: 14px auto 0;
  font-size: 15px; color: var(--ink-soft);
}
.orn-rule.top { margin-top: 22px; }
.orn-rule::before, .orn-rule::after {
  content: ''; flex: 1; border-top: 3px double var(--ink); opacity: 0.75;
}

/* patent-medicine label placards */
.placards {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
  margin: 26px auto 8px; max-width: 860px;
}
.placard {
  width: 250px; padding: 14px 14px 16px;
  background:
    repeating-linear-gradient(92deg, rgba(43, 33, 24, 0.025) 0 1px, transparent 1px 3px),
    linear-gradient(170deg, #f7efd9, var(--paper-bright));
  border: 1.5px solid var(--ink);
  box-shadow:
    inset 0 0 0 3px var(--paper-bright),
    inset 0 0 0 4.5px rgba(43, 33, 24, 0.6),
    5px 6px 0 rgba(43, 33, 24, 0.22);
  text-align: center;
  opacity: 0; animation: placardIn 0.7s ease-out forwards;
}
.placard:nth-child(2) { animation-delay: 0.22s; }
.placard:nth-child(3) { animation-delay: 0.44s; }
@keyframes placardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.placard-no { display: block; font-size: 13px; letter-spacing: 4px; color: var(--rust); }
.placard-title {
  margin: 2px 0 12px; font-size: 19px;
  font-variant: small-caps; letter-spacing: 4px;
}
.placard-title::before { content: '✠ '; font-size: 13px; color: var(--rust); }
.placard-title::after { content: ' ✠'; font-size: 13px; color: var(--rust); }
.placard-text { font-size: 13px; line-height: 1.55; font-style: italic; color: var(--ink-soft); margin: 12px 0 0; }
.demo { min-height: 58px; display: flex; align-items: center; justify-content: center; gap: 10px; }

/* placard I: three tonic bottles */
.demo-bottle {
  width: 17px; height: 36px; position: relative;
  border-radius: 3px 3px 5px 5px;
  background: linear-gradient(var(--ink) 0 38%, var(--paper) 38% 62%, var(--ink) 62%);
  box-shadow: 1px 2px 0 rgba(43, 33, 24, 0.3);
}
.demo-bottle::before { /* neck */
  content: ''; position: absolute; top: -8px; left: 4.5px;
  width: 8px; height: 9px; background: var(--ink);
}
.demo-bottle::after { /* cork */
  content: ''; position: absolute; top: -12px; left: 3.5px;
  width: 10px; height: 5px; background: var(--rust); border-radius: 1px;
}
.demo-bottle.b1 { height: 30px; transform: rotate(-3deg); }
.demo-bottle.b3 { height: 42px; transform: rotate(2.5deg); }

/* placard II: claim card + meter */
.demo-claim {
  font-size: 11.5px; font-style: italic; padding: 7px 8px; max-width: 110px;
  border: 1px solid var(--ink); background: var(--paper-bright);
  box-shadow: inset 0 0 0 2px var(--paper-bright), inset 0 0 0 3px rgba(43, 33, 24, 0.55), 2px 2px 0 rgba(43, 33, 24, 0.25);
  transform: rotate(-2deg);
  color: var(--blood);
}
.demo-meter { display: flex; align-items: baseline; gap: 6px; }
.demo-meter b { font-size: 30px; color: var(--moss); }
.demo-meter b.doubt { color: var(--blood); }
.demo-vs { font-style: italic; font-size: 12px; opacity: 0.7; }

/* placard III: inked quote with wax seal */
.demo-quote {
  position: relative; font-style: italic; font-size: 12.5px; color: var(--rust);
  padding: 10px 14px 12px 10px; max-width: 180px;
  background:
    repeating-linear-gradient(180deg, transparent 0 15px, rgba(43, 33, 24, 0.16) 15px 16px);
  border-left: 3px solid var(--blood);
}
.demo-seal {
  position: absolute; right: -7px; bottom: -7px;
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #a8362e 0%, var(--blood) 60%, #4e1010 100%);
  box-shadow: 0 1px 2px rgba(43, 33, 24, 0.5), inset 0 0 0 3px rgba(78, 16, 16, 0.55);
  transform: rotate(-12deg);
}

/* ---------- general type ---------- */
h2 {
  font-size: 28px; border-bottom: 3px double var(--ink); padding-bottom: 6px;
  font-variant: small-caps; letter-spacing: 2px;
}
.hint { font-style: italic; opacity: 0.75; }

/* ---------- cards: victorian medicine labels ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 14px 0; }
.ing-card, .claim-card {
  position: relative;
  border: 1.5px solid var(--ink);
  background:
    repeating-linear-gradient(92deg, rgba(43, 33, 24, 0.02) 0 1px, transparent 1px 3px),
    linear-gradient(168deg, #f7efd9, var(--paper-bright));
  padding: 12px 14px 14px;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow:
    inset 0 0 0 3px var(--paper-bright),
    inset 0 0 0 4.5px rgba(43, 33, 24, 0.55),
    4px 4px 0 rgba(43, 33, 24, 0.22);
}
.ing-card::after, .claim-card::after { /* ornament foot */
  content: '❦'; display: block; text-align: center;
  font-size: 11px; color: rgba(43, 33, 24, 0.4); margin-top: 6px;
  font-style: normal;
}
.ing-card:hover, .claim-card:hover {
  transform: translate(-2px, -3px);
  box-shadow:
    inset 0 0 0 3px var(--paper-bright),
    inset 0 0 0 4.5px rgba(43, 33, 24, 0.55),
    7px 8px 0 rgba(43, 33, 24, 0.26);
}
.ing-card.selected, .claim-card.selected { /* stamped */
  background: linear-gradient(168deg, #332821, var(--ink));
  color: var(--paper);
  transform: rotate(-1deg) translate(1px, 2px);
  box-shadow:
    inset 0 0 0 3px var(--ink),
    inset 0 0 0 4.5px rgba(233, 221, 192, 0.55),
    1px 1px 0 rgba(43, 33, 24, 0.45);
}
.selected.ing-card::after, .selected.claim-card::after { color: rgba(233, 221, 192, 0.45); }
.ing-card h3 {
  margin: 0 0 8px; font-size: 17px; text-align: center;
  font-variant: small-caps; letter-spacing: 2px;
  border-bottom: 1px solid rgba(43, 33, 24, 0.35); padding-bottom: 5px;
}
.ing-card h3::before { content: '☙ '; font-size: 12px; color: var(--rust); }
.ing-card h3::after { content: ' ❧'; font-size: 12px; color: var(--rust); }
.selected.ing-card h3 { border-bottom-color: rgba(233, 221, 192, 0.35); }
.selected.ing-card h3::before, .selected.ing-card h3::after { color: rgba(233, 221, 192, 0.6); }

.claim-line, .claim-text { font-style: italic; font-size: 14px; margin-bottom: 4px; line-height: 1.4; }
.claim-stats {
  display: block; font-style: normal; font-size: 11px; opacity: 0.7;
  letter-spacing: 0.6px; font-variant: small-caps;
}
/* ink hierarchy: over-2 rust, over-3 deep blood red */
.over-2 .claim-text, .claim-line.over-2 { color: var(--rust); }
.over-3 .claim-text, .claim-line.over-3 {
  color: var(--blood); font-weight: bold;
  text-shadow: 0 0 1px rgba(122, 31, 31, 0.4);
}
.selected .claim-text, .selected .claim-line, .selected .claim-stats { color: inherit; opacity: 0.92; }

.tonic-line {
  border: 2px dashed var(--ink-soft);
  background:
    repeating-linear-gradient(92deg, rgba(43, 33, 24, 0.02) 0 1px, transparent 1px 3px),
    #f7efd9;
  padding: 8px 14px;
  font-style: italic; font-size: 15px; margin-bottom: 12px;
}
.ing-badge {
  display: inline-block; font-size: 10.5px; letter-spacing: 1.5px; text-transform: uppercase;
  background: rgba(43, 33, 24, 0.12); padding: 2px 8px; margin-bottom: 6px; border-radius: 2px;
}
.selected .ing-badge { background: rgba(233, 221, 192, 0.22); }
.claim-card.slot-0 { border-left: 6px solid var(--moss); }
.claim-card.slot-1 { border-left: 6px solid var(--rust); }
.claim-card.slot-2 { border-left: 6px solid #1f3a5d; }

/* ---------- mark panel ---------- */
.mark-panel {
  border: 1.5px solid var(--ink);
  background:
    repeating-linear-gradient(92deg, rgba(43, 33, 24, 0.02) 0 1px, transparent 1px 3px),
    linear-gradient(170deg, #f2e8cf, #ecdfc2);
  padding: 10px 16px;
  box-shadow:
    inset 0 0 0 3px #efe5cd,
    inset 0 0 0 4.5px rgba(43, 33, 24, 0.45),
    4px 4px 0 rgba(43, 33, 24, 0.22);
}
.mark-panel h3 { margin: 4px 0 8px; font-size: 22px; font-variant: small-caps; letter-spacing: 1.5px; }
.tells { margin: 0 0 8px; padding-left: 20px; }
.tells li { margin-bottom: 2px; }

/* ---------- the pitch meter: a balance of persuasion vs. doubt ---------- */
.meter { margin: 14px 0 4px; }
.meter-scale { display: flex; align-items: flex-end; justify-content: center; gap: 22px; }
.meter-pan { text-align: center; min-width: 86px; }
.meter-label {
  display: block; font-size: 10.5px; letter-spacing: 2.5px;
  text-transform: uppercase; opacity: 0.6; margin-bottom: 2px;
}
.meter-num {
  font-size: 42px; line-height: 1; font-weight: bold;
  font-variant-numeric: tabular-nums;
  text-shadow: 1px 1px 0 rgba(43, 33, 24, 0.25);
}
.meter-num.dim { opacity: 0.35; }
.meter-num.doubt { color: var(--blood); }
.meter.good .meter-num:not(.doubt) { color: var(--moss); }
.meter.bad .meter-num:not(.doubt) { color: var(--rust); }
.meter-beam {
  font-size: 30px; display: inline-block; margin-bottom: 4px;
  transition: transform 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);
  color: var(--ink-soft);
}
.meter-note {
  text-align: center; font-style: italic; font-weight: bold;
  font-size: 16px; margin-top: 6px;
}
.meter.good .meter-note { color: var(--moss); }
.meter.bad .meter-note { color: var(--blood); }

textarea {
  width: 100%; font-family: inherit; font-size: 15px; font-style: italic;
  background:
    repeating-linear-gradient(180deg, transparent 0 24px, rgba(43, 33, 24, 0.1) 24px 25px),
    var(--paper-bright);
  border: 1.5px solid var(--ink); padding: 8px; margin: 10px 0;
  box-shadow: inset 2px 2px 0 rgba(43, 33, 24, 0.08);
}

/* ---------- buttons: letterpress wood type ---------- */
button.big, .button-link {
  display: inline-block; font-family: inherit; font-size: 18px;
  background: linear-gradient(180deg, #3a2d22, var(--ink));
  color: var(--paper); border: none; padding: 12px 28px;
  cursor: pointer; letter-spacing: 1.5px; margin: 8px 8px 8px 0;
  box-shadow:
    inset 0 0 0 1.5px rgba(233, 221, 192, 0.3),
    4px 4px 0 rgba(43, 33, 24, 0.35);
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
}
button.big:hover:not(:disabled), .button-link:hover {
  background: linear-gradient(180deg, #51402f, var(--ink-soft));
  transform: translate(-1px, -1px);
  box-shadow:
    inset 0 0 0 1.5px rgba(233, 221, 192, 0.35),
    5px 5px 0 rgba(43, 33, 24, 0.4);
}
button.big:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: inset 0 0 0 1.5px rgba(233, 221, 192, 0.3), 1px 1px 0 rgba(43, 33, 24, 0.35); }
button.big:disabled { opacity: 0.4; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
button.big.walk { background: linear-gradient(180deg, #7a6747, #5c4d35); }
button.big.walk:hover:not(:disabled) { background: linear-gradient(180deg, #8a7656, #6b5a3e); }

.good { color: var(--moss); font-weight: bold; font-size: 18px; }
.bad { color: var(--blood); font-weight: bold; font-size: 18px; }
.inked { color: var(--rust); font-style: italic; }
.judge-note { font-style: italic; opacity: 0.85; }

canvas.verdict-card {
  max-width: 100%; border: 2px solid var(--ink); margin-top: 12px; display: block;
  box-shadow: 5px 6px 0 rgba(43, 33, 24, 0.28);
}

#log {
  max-width: 1100px; margin: 0 auto; padding: 8px 20px 24px;
  font-size: 13px; opacity: 0.6; max-height: 140px; overflow-y: auto;
  font-style: italic;
}
.logline { margin-bottom: 2px; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  #layout { flex-direction: column; }
  #ledger { width: 100%; order: 2; }
}
@media (max-width: 600px) {
  h1.logo { font-size: 40px; letter-spacing: 6px; }
  .tagline { font-size: 17px; }
  h2 { font-size: 22px; }
  #topbar { gap: 12px; padding: 8px 12px; font-size: 15px; flex-wrap: wrap; }
  #heat-wrap { margin-left: 0; width: 100%; }
  .thermo-tube { width: calc(100vw - 140px); max-width: 220px; }
  #layout { padding: 12px 10px; gap: 12px; }
  .card-grid { grid-template-columns: 1fr; gap: 10px; }
  .ing-card, .claim-card { padding: 14px 14px 16px; }
  .placards { gap: 12px; }
  .placard { width: 100%; max-width: 340px; }
  button.big, .button-link { font-size: 17px; padding: 14px 22px; width: 100%; margin-right: 0; text-align: center; }
  .row { flex-direction: column; gap: 0; }
  .mute-btn { top: auto; bottom: 10px; right: 10px; }
  .meter-num { font-size: 34px; }
  .meter-beam { font-size: 24px; }
}

/* the quirk tell — the line worth more than the numbers */
.tells .quirk-tell {
  font-style: italic; color: #6b3a1e; margin-top: 6px;
  border-top: 1px dotted rgba(43, 33, 24, 0.4); padding-top: 6px;
}
.tells .quirk-tell::before { content: '❧ '; }
