:root {
  --umber: #3a2416;
  --walnut: #5c3a22;
  --brass: #c4a35a;
  --brass-dim: #8a6d32;
  --cream: #f3e6c8;
  --tallow: #e8d7b0;
  --oxblood: #6e2c2c;
  --sage: #7a8a72;
  --ink: #1c120c;
  --paper: #efe0c4;
  --paper-edge: #d7c39a;
  --shadow: rgba(12, 6, 2, 0.55);
  --ui: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--ui);
  color: var(--cream);
  background: #0b0705;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

#app { position: relative; height: 100%; isolation: isolate; }

.scene {
  position: absolute;
  inset: -4%;
  z-index: 0;
  overflow: hidden;
  transition: transform 0.15s linear;
}
.plate {
  position: absolute;
  inset: 0;
  background:
    image-set(
      url("assets/workshop-full.webp") type("image/webp"),
      url("art/workshop-full.png") type("image/png")
    ) center / cover no-repeat;
  filter: saturate(0.92) contrast(1.04);
  transform: scale(1.06);
  transition: background-image 0.6s ease, filter 0.6s ease;
}
.scene[data-plate="empty"] .plate {
  background-image: image-set(
      url("assets/workshop-empty-bench.webp") type("image/webp"),
      url("art/workshop-empty-bench.png") type("image/png")
    );
}
.scene[data-plate="wall"] .plate {
  background-image: image-set(
      url("assets/workshop-back-wall.webp") type("image/webp"),
      url("art/workshop-back-wall.png") type("image/png")
    );
}
.lamp-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 40% 35% at 18% 62%, rgba(196,163,90,0.16), transparent 70%);
  mix-blend-mode: screen;
  animation: lamp 5.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes lamp {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}
#dust {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.55;
}
.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(8,4,2,0.55) 100%);
}

.ui {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(16px, 4vh, 40px) clamp(16px, 4vw, 48px) clamp(20px, 4vh, 36px);
  max-width: 1180px;
  margin: 0 auto;
}

.screen { width: 100%; }
.hidden { display: none !important; }

.eyebrow, .card-kicker, .mode-kicker, .dial-label {
  font-family: var(--ui);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--brass);
  margin: 0 0 0.4rem;
}
h1, h2 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 0.95;
  margin: 0 0 0.5rem;
  text-shadow: 0 2px 18px var(--shadow);
}
h1 { font-size: clamp(3.2rem, 8vw, 6.2rem); }
h2 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
.lede {
  max-width: 38rem;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--tallow);
  margin: 0 0 1.4rem;
}
.lede.small { font-size: 0.95rem; }
.fine {
  margin-top: 1.1rem;
  font-size: 0.82rem;
  color: rgba(243,230,200,0.72);
  max-width: 40rem;
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.mode-card, .chapter-btn, .primary-btn, .ghost-btn, .choice, .text-btn {
  font-family: var(--ui);
  cursor: pointer;
}
.mode-card {
  text-align: left;
  background: linear-gradient(180deg, rgba(239,224,196,0.16), rgba(28,18,12,0.45));
  border: 1px solid rgba(196,163,90,0.35);
  color: var(--cream);
  padding: 16px 16px 18px;
  border-radius: 2px;
  backdrop-filter: blur(6px);
  min-height: 148px;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.mode-card:hover, .mode-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--brass);
  background: linear-gradient(180deg, rgba(239,224,196,0.28), rgba(28,18,12,0.5));
  outline: none;
}
.mode-card strong {
  display: block;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 600;
  margin: 0.15rem 0 0.35rem;
}
.mode-card span:last-child {
  display: block;
  font-size: 0.84rem;
  line-height: 1.35;
  color: var(--tallow);
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.hud-progress { margin: 0; font-size: 0.9rem; color: var(--tallow); }
.instruments { display: flex; gap: 18px; }
.dial {
  min-width: 120px;
  background: rgba(16,10,6,0.55);
  border: 1px solid rgba(196,163,90,0.4);
  padding: 8px 12px 10px;
  box-shadow: inset 0 0 0 1px rgba(255,230,180,0.06);
}
.dial-value {
  display: block;
  font-family: var(--display);
  font-size: 1.7rem;
  color: var(--brass);
  line-height: 1;
}
.dial-bar {
  display: block;
  height: 3px;
  background: rgba(196,163,90,0.2);
  margin-top: 6px;
}
.dial-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--brass);
  transform-origin: left center;
}
.dial.timer .dial-value { color: var(--cream); }
.dial.warn .dial-value { color: #e0a060; }
.dial.danger .dial-value, .dial.danger .dial-bar i { color: #c45c4a; background: #c45c4a; }

.text-btn {
  background: none;
  border: none;
  color: var(--brass);
  padding: 6px 0;
  font-size: 0.9rem;
}
.text-btn:hover { color: var(--cream); }

.card {
  background:
    linear-gradient(180deg, rgba(247,236,210,0.94), rgba(232,209,166,0.92));
  color: var(--ink);
  padding: clamp(18px, 3vw, 28px);
  border-radius: 3px 4px 3px 3px;
  box-shadow:
    0 18px 50px rgba(0,0,0,0.45),
    inset 0 1px 0 rgba(255,255,255,0.35);
  border: 1px solid var(--paper-edge);
  max-width: 820px;
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px -6px;
  width: 10px;
  background: repeating-linear-gradient(
    180deg,
    transparent,
    transparent 10px,
    rgba(110,44,44,0.35) 10px,
    rgba(110,44,44,0.35) 12px
  );
  border-radius: 2px;
}
.card .card-kicker { color: var(--brass-dim); }
.definition {
  font-family: var(--display);
  font-size: clamp(1.25rem, 2.4vw, 1.7rem);
  line-height: 1.35;
  margin: 0 0 1rem;
}

.type-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.type-form input {
  flex: 1 1 240px;
  font-family: var(--display);
  font-size: 1.35rem;
  padding: 10px 14px;
  border: 1px solid #c4ae7e;
  background: rgba(255,250,240,0.7);
  color: var(--ink);
  outline: none;
}
.type-form input:focus { border-color: var(--brass-dim); box-shadow: 0 0 0 3px rgba(196,163,90,0.25); }

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.choice {
  text-align: left;
  padding: 12px 14px;
  background: rgba(255,250,240,0.55);
  border: 1px solid #c4ae7e;
  color: var(--ink);
  font-size: 1rem;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.choice:hover, .choice:focus-visible {
  background: #fff8ea;
  border-color: var(--brass-dim);
  outline: none;
}
.choice b {
  color: var(--brass-dim);
  font-size: 0.78rem;
  margin-right: 8px;
}

.primary-btn, .ghost-btn {
  border-radius: 1px;
  padding: 11px 18px;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}
.primary-btn {
  background: var(--umber);
  color: var(--cream);
  border: 1px solid var(--walnut);
}
.primary-btn:hover { background: #4a2e1c; }
.ghost-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid #b79a62;
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 16px;
  max-height: 42vh;
  overflow: auto;
}
.chapter-btn {
  text-align: left;
  padding: 14px;
  background: rgba(16,10,6,0.62);
  border: 1px solid rgba(196,163,90,0.28);
  color: var(--cream);
}
.chapter-btn:hover { border-color: var(--brass); }
.chapter-btn small { display: block; color: var(--tallow); margin-top: 4px; }

.aliases { margin: 0 0 0.6rem; font-size: 0.9rem; color: #6a4e28; font-style: italic; }
.coach {
  font-size: 0.95rem;
  color: #3e2a18;
  border-top: 1px solid rgba(92,58,34,0.2);
  padding-top: 0.8rem;
}
.delta { font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brass-dim); }
.reveal-card.bad { box-shadow: 0 18px 50px rgba(80,10,10,0.35); }
.reveal-card.good { box-shadow: 0 18px 50px rgba(60,80,30,0.28); }

.missed {
  max-height: 28vh;
  overflow: auto;
  padding-left: 1.1rem;
  color: #3e2a18;
}
.workflow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  font-size: 0.82rem;
  color: var(--tallow);
}
.workflow li { margin-right: 6px; }
.workflow li::after { content: " →"; color: var(--brass); }
.workflow li:last-child::after { content: ""; }

.notes-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  min-height: 42vh;
}
.notes-nav button {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(16,10,6,0.5);
  color: var(--cream);
  border: 1px solid transparent;
  padding: 8px 10px;
  margin-bottom: 4px;
  cursor: pointer;
}
.notes-nav button.active, .notes-nav button:hover {
  border-color: var(--brass);
}
.notes-list {
  background: linear-gradient(180deg, rgba(247,236,210,0.94), rgba(232,209,166,0.9));
  color: var(--ink);
  padding: 16px 18px;
  max-height: 48vh;
  overflow: auto;
}
.note-item { margin-bottom: 1rem; padding-bottom: 0.8rem; border-bottom: 1px solid rgba(92,58,34,0.15); }
.note-item h3 { font-family: var(--display); margin: 0 0 0.25rem; font-size: 1.25rem; }
.note-item p { margin: 0; font-size: 0.92rem; line-height: 1.4; }

@media (max-width: 900px) {
  .mode-row { grid-template-columns: 1fr 1fr; }
  .choices { grid-template-columns: 1fr; }
  .notes-layout { grid-template-columns: 1fr; }
  h1 { font-size: 2.6rem; }
  .ui { justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  .lamp-glow, .scene, .plate { animation: none; transition: none; }
}

.dial-bar i {
  transition: transform 0.4s ease, background 0.4s ease;
}
.card {
  transition: opacity 0.22s ease, transform 0.22s ease, box-shadow 0.25s ease;
}
.card.busy {
  opacity: 0;
  transform: translateY(8px);
}
.card.good {
  box-shadow: 0 18px 50px rgba(60,80,30,0.28), inset 0 1px 0 rgba(255,255,255,0.35);
}
.card.bad {
  box-shadow: 0 18px 50px rgba(80,10,10,0.32), inset 0 1px 0 rgba(255,255,255,0.35);
}
.feedback h2 {
  text-shadow: none;
  color: var(--ink);
  margin-bottom: 0.2rem;
}
.skip-hint {
  margin: 0.8rem 0 0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a6d32;
}
.chapter-banner {
  font-family: var(--display);
  font-size: 1.15rem;
  color: var(--cream);
  margin: 0 0 10px;
  text-shadow: 0 2px 12px var(--shadow);
}
.text-btn.inline {
  display: inline;
  padding: 0;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: none;
  color: var(--brass);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  background: rgba(8,4,2,0.45);
  padding: inherit;
}
#screen-play { position: relative; }
.overlay.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  .card, .dial-bar i { transition: none; }
}
