@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600;700&family=DM+Sans:wght@400;500;600;700&display=swap');
:root {
  color-scheme: light;
  --paper: #f7f0e2;
  --ink: #402a16;
  --gold: #a17b3b;
  --muted: #655940;
  font-family: 'DM Sans', sans-serif;
  color: var(--ink);
  background: #343324;
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 48% 20%, #6d5f3b55, transparent 72%),
    repeating-linear-gradient(0deg, #c9b48b0d 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, #140e0955 0 1px, transparent 1px 3px),
    #343324;
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #1b5f9c; outline-offset: 4px; }
button:disabled { opacity: .38; cursor: default; }
button:not(:disabled) { touch-action: manipulation; }
.museum { max-width: 936px; margin: auto; padding: 14px 24px 24px; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 24px 10px; color: #fff1d8; }
h1, h2 { font-family: 'Cormorant Garamond', Georgia, serif; }
h1 { font-size: clamp(25px, 3vw, 35px); line-height: 1.02; font-weight: 700; margin: 0; text-align: center; }
.mobile-break { display: none; }
.menu-toggle, .tools > button {
  color: var(--ink);
  border: 1px solid #aa8250;
  background: linear-gradient(164deg, #fff3d9, #e5c79e);
  box-shadow: inset 0 2px 1px #fffaec, inset 0 -3px 3px #ad805143, 0 3px 0 #76532d, 0 5px 8px #301b163d;
}
.menu-toggle { flex: none; min-width: 60px; min-height: 53px; display: grid; justify-items: center; gap: 1px; border-radius: 22px; font-size: 15px; padding: 5px 10px; }
.menu-toggle > span:first-child { font-size: 25px; line-height: 1; }
.menu-toggle:hover:not(:disabled), .tools > button:hover:not(:disabled) { background: #fff1d8; }
.masthead button:focus-visible { outline-color: #fff4d9; }
.easel {
  position: relative;
  isolation: isolate;
  padding: 54px 28px 46px;
}
.easel::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url('assets/painters-palette.webp') center / 100% 100% no-repeat;
  filter: drop-shadow(0 10px 10px #160e0ba8);
}
.painting-heading { position: relative; width: 81%; margin: 0 auto; text-align: center; z-index: 3; }
/* Keep the top two lines on the broad face, clear of the cutout. */
.painting-heading h2, .lesson-progress { width: 67%; margin-inline: 8% auto; }
.painting-heading h2 { font-weight: 700; font-size: clamp(34px, 5vw, 49px); margin-block: 0; line-height: .98; }
.lesson-progress { margin-block: 0 5px; font-size: 15px; color: #64482b; font-weight: 700; }
.live-caption { display: flex; align-items: center; justify-content: center; min-height: 49px; margin: 0 auto; max-width: 600px; }
.live-caption p { font-size: 18px; line-height: 1.35; margin: 7px 0; color: #4b341f; }
.live-caption.error p { color: #8b2e25; }
.live-caption.mix p { color: #285b36; }
.board { width: 100%; position: relative; aspect-ratio: 1.78; isolation: isolate; touch-action: none; user-select: none; -webkit-user-select: none; }
.easel.gallery-board .board { min-height: 410px; }
.board > svg, .board > canvas, .node-controls { position: absolute; inset: 0; width: 100%; height: 100%; }
.board > svg { overflow: visible; z-index: 1; }
.board > canvas { z-index: 2; pointer-events: none; }
.node-controls { z-index: 3; pointer-events: none; }
.node-button { position: absolute; width: 94px; height: 94px; transform: translate(-50%, -50%); border: 0; background: none; border-radius: 50%; padding: 0; pointer-events: auto; touch-action: none; display: flex; align-items: center; justify-content: center; isolation: isolate; }
.node-button:not(:disabled) { touch-action: none; }
.node-button::before { content: ''; position: absolute; inset: 2px; border: 2px solid transparent; border-radius: 50%; transition: border .2s, box-shadow .2s; pointer-events: none; }
.node-button.selected::before { inset: -6px; border: 3px solid #6c4b14; box-shadow: 0 0 0 4px #fff9e8; }
.node-button.reachable::before { inset: -4px; border: 3px dashed #72521e; box-shadow: 0 0 0 3px #fff9e8c9; }
.node-button.reachable:hover::before { background: #fff8e935; }
.node-button.hint-target::before { inset: -7px; border: 5px solid #825400; box-shadow: 0 0 0 5px #fff8da; }
.node-button.hint-source::before { border: 4px solid #825400; }
.node-symbol { display: flex; align-items: center; justify-content: center; width: 80px; height: 44px; font: 700 38px Georgia, serif; line-height: 1; color: white; filter: drop-shadow(0 1px 1px #18294780); pointer-events: none; }
.pigment-symbols { display: block; width: 100%; height: 100%; overflow: visible; }
.node-symbol.mixed-all { height: 62px; }
.node-button.empty .node-symbol { color: #554528; filter: none; }
.node-button.goal .node-symbol { color: var(--pigment); filter: none; }
.node-button.junction { width: 88px; height: 88px; }
.node-button.junction .node-symbol { width: 70px; height: 39px; }
.node-button.source.empty .node-symbol { opacity: .7; }
.completion-check { position: absolute; right: -1px; top: -4px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #fff9e9; border: 2px solid #34613b; font-size: 22px; font-weight: 700; color: #285233; }
.hint-badge { position: absolute; top: -16px; right: -13px; background: #fff7df; color: #553906; border: 3px solid #825400; border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; font-size: 24px; font-weight: 700; }
.completion-check, .hint-badge { pointer-events: none; }
.board-callout[hidden] { display: none; }
.tools { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 6px 24px 3px; }
.tools > button { min-height: 56px; min-width: 170px; border-radius: 30px; font-size: 21px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px; }
.tools > button > span { font: 34px Georgia, serif; line-height: 1; }
.paper-dialog { max-width: 500px; width: calc(100vw - 28px); max-height: calc(100dvh - 28px); border: 1px solid #bd9c63; padding: 36px 34px 28px; text-align: center; background: radial-gradient(ellipse at 50% 0, #fffdf6, #f5ebd8); color: var(--ink); border-radius: 9px; box-shadow: 0 25px 100px #3d2b214a; overflow-y: auto; }
.paper-dialog::backdrop { background: #342e225c; backdrop-filter: blur(5px); }
.paper-dialog h2 { font-size: 42px; font-weight: 600; line-height: 1.05; margin: 15px 0 20px; }
.paper-dialog p:not(.eyebrow) { font-size: 18px; line-height: 1.5; color: #574a33; }
.paper-dialog .eyebrow { font-size: 15px; font-weight: 600; letter-spacing: 1px; color: #72552a; }
.dialog-close { position: absolute; right: 10px; top: 8px; border: 0; background: transparent; min-width: 48px; min-height: 48px; font-size: 36px; color: #594628; }
.dialog-flourish { font-size: 37px; color: #a48246; }
.recipe { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 8px 0; }
.recipe-dot { display: grid; place-items: center; height: 64px; min-width: 64px; padding: 0 6px; border-radius: 50%; color: #fff; font-size: 28px; box-shadow: inset 0 3px 5px #ffffff80, inset 0 -5px 8px #0003, 0 2px 3px #0002; }
.recipe-dot.blue { background: #2264cb; }
.recipe-dot.yellow { background: #eebd21; color: #382a0e; }
.recipe-dot.green { background: #33824f; }
.recipe b { color: #6c5630; font-size: 23px; font-weight: 500; }
.primary { display: flex; justify-content: center; align-items: center; gap: 20px; width: 100%; min-height: 56px; padding: 14px 16px; border: 1px solid #506441; border-radius: 5px; background: #526943; color: #fffaf0; margin-top: 22px; font-size: 21px; font-weight: 500; }
.primary:hover { background: #445b35; }
.tools .primary { width: auto; margin: 0; border: 1px solid #506441; border-radius: 30px; background: #526943; color: #fffaf0; box-shadow: inset 0 2px 1px #ffffff24, 0 3px 0 #35492c, 0 5px 8px #301b163d; }
.tools .primary:hover:not(:disabled) { background: #445b35; }
.text-button { background: transparent; border: 0; text-decoration: underline; text-underline-offset: 4px; min-height: 48px; font-size: 18px; margin-top: 12px; }
.arcade-return { display: inline-flex; align-items: center; color: inherit; }
.gallery-nav { display: grid; gap: 10px; margin: 20px 0; }
.gallery-chapter { text-align: left; }
.gallery-chapter summary { min-height: 52px; padding: 13px; border: 1px solid #c6b087; border-radius: 5px; background: #f3e6cb; font-size: 18px; font-weight: 700; cursor: pointer; }
.gallery-chapter summary small { float: right; font-size: 15px; font-weight: 500; color: #64482b; }
.chapter-paintings { display: grid; gap: 6px; padding: 6px 0 0 10px; }
.painting-tab { min-height: 58px; background: #fffbf0; border: 1px solid #c6b087; border-radius: 5px; padding: 12px 14px; font-size: 19px; text-align: left; }
.painting-tab span { margin-right: 12px; color: #705633; }
.painting-tab.active { border: 2px solid #82612c; background: #eee0c3; }
.painting-tab .painting-check { margin: 0 0 0 8px; color: #34613b; }
.menu-actions { display: grid; gap: 8px; border-top: 1px solid #d3be97; padding-top: 16px; }
.menu-actions button { min-height: 54px; border: 0; border-radius: 4px; background: #ece1cb; font-size: 18px; padding: 10px; }
.menu-actions button > span { display: inline-block; min-width: 25px; margin-right: 8px; font-size: 26px; vertical-align: -1px; }
.menu-actions button:hover { background: #e5d5b8; }
.easel.restored .board { filter: saturate(1.08); }
@media (max-width: 900px) {
  .museum { padding: 12px 16px 20px; }
  .node-button { width: 86px; height: 86px; }
  .node-button.junction { width: 80px; height: 80px; }
  .node-symbol { width: 73px; height: 40px; }
}
@media (max-width: 600px), (max-width: 1000px) and (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  html, body { height: 100%; min-height: 0; overflow: hidden; overscroll-behavior: none; }
  body { -webkit-text-size-adjust: 100%; }
  .museum {
    --tool-height: 46px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    height: 100svh;
    padding: max(4px, env(safe-area-inset-top)) max(5px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(5px, env(safe-area-inset-left));
  }
  .masthead { gap: 8px; padding: 0 6px 5px; }
  .masthead h1 { font-size: clamp(18px, 5.25vw, 25px); letter-spacing: -.4px; }
  .mobile-break { display: block; }
  .menu-toggle { min-width: 50px; min-height: 44px; padding: 3px 6px; font-size: 13px; }
  .menu-toggle > span:first-child { font-size: 22px; }
  .easel {
    display: grid;
    grid-template: "heading" auto "board" minmax(0, 1fr) "tools" var(--tool-height) / minmax(0, 1fr);
    row-gap: 4px;
    min-height: 0;
    padding: 22px 10px 10px;
    padding-block: clamp(18px, 4.5svh, 38px) clamp(8px, 2svh, 16px);
  }
  .painting-heading {
    --title-size: clamp(21px, 6.1vw, 28px);
    --caption-height: 58px;
    grid-area: heading;
    display: grid;
    grid-template-rows: 16px calc(2.04 * var(--title-size)) var(--caption-height);
    row-gap: 2px;
    width: 100%;
    min-height: 0;
  }
  .painting-heading h2, .lesson-progress { width: 68%; margin: 0 auto 0 4%; }
  .painting-heading h2 { align-self: center; font-size: var(--title-size); line-height: 1.02; }
  .lesson-progress { align-self: center; font-size: 13px; }
  .live-caption {
    display: grid;
    align-content: safe center;
    width: 94%;
    min-height: 0;
    padding: 2px 7px;
    overflow: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    border-radius: 9px;
    background: #fff3dd80;
    scrollbar-width: thin;
  }
  .live-caption p { margin: 0; font-size: clamp(14px, 3.8vw, 17px); line-height: 1.2; }
  .board { grid-area: board; aspect-ratio: auto; min-height: 0; }
  .easel.gallery-board .board { min-height: 0; }
  .node-button, .node-button.junction { width: var(--node-size, 76px); height: var(--node-size, 76px); }
  .node-symbol { width: 90%; height: 50%; font-size: clamp(22px, calc(var(--node-size, 76px) * .48), 36px); }
  .node-button.junction .node-symbol { width: 84%; height: 48%; }
  .node-button .node-symbol.mixed-all { height: 76%; }
  .node-button.selected::before { inset: -3px; border-width: 2px; box-shadow: 0 0 0 2px #fff9e8; }
  .node-button.reachable::before { inset: -2px; border-width: 2px; box-shadow: 0 0 0 2px #fff9e8c9; }
  .node-button.hint-target::before { inset: -4px; border-width: 3px; box-shadow: 0 0 0 2px #fff8da; }
  .completion-check { width: clamp(20px, calc(var(--node-size, 76px) * .37), 28px); height: clamp(20px, calc(var(--node-size, 76px) * .37), 28px); right: -3px; top: -4px; font-size: clamp(15px, calc(var(--node-size, 76px) * .28), 21px); }
  .hint-badge { width: clamp(24px, calc(var(--node-size, 76px) * .45), 34px); height: clamp(24px, calc(var(--node-size, 76px) * .45), 34px); right: -7px; top: -5px; font-size: clamp(15px, calc(var(--node-size, 76px) * .3), 22px); }
  .tools { grid-area: tools; gap: 8px; padding: 0 7%; }
  .tools > button, .tools > .recovery { flex: 1 1 0; min-width: 0; }
  .tools > button, .tools .primary { min-height: var(--tool-height); padding: 4px 6px; font-size: clamp(15px, 4.3vw, 19px); line-height: 1.12; gap: 6px; }
  .tools .recovery .primary { width: 100%; }
  .tools > button > span { font-size: 26px; }
  .paper-dialog { padding: 34px 20px 22px; overscroll-behavior: contain; touch-action: pan-y; }
  .paper-dialog h2 { font-size: 36px; }
  .recipe { gap: 10px; }
  .recipe-dot { height: 56px; min-width: 56px; font-size: 26px; }
}
@media (max-width: 600px) and (max-height: 550px) {
  .museum { --tool-height: 44px; }
  .easel { padding-block: 16px 8px; row-gap: 3px; }
  .painting-heading { --title-size: clamp(19px, 5.8vw, 24px); --caption-height: 48px; grid-template-rows: 15px calc(2.04 * var(--title-size)) var(--caption-height); }
  .live-caption p { font-size: 14px; }
}
@media (max-width: 600px) and (max-height: 460px) and (orientation: portrait) {
  .painting-heading { --caption-height: 42px; }
}
@media (max-width: 1000px) and (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  .museum { --tool-height: 44px; --side-width: clamp(132px, 26vw, 224px); position: relative; grid-template-rows: minmax(0, 1fr); }
  .masthead {
    position: absolute;
    z-index: 4;
    inset-block-start: calc(max(4px, env(safe-area-inset-top)) + 5px);
    inset-inline-start: calc(max(5px, env(safe-area-inset-left)) + 10px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px 4px;
    width: var(--side-width);
    padding: 0 0 0 5px;
    color: var(--ink);
  }
  .masthead h1 { grid-area: 1 / 1 / 2 / -1; font-size: 16px; }
  .masthead .menu-toggle { grid-row: 2; min-width: 0; }
  .masthead button:focus-visible { outline-color: #1b5f9c; }
  .easel {
    grid-template: "heading board" minmax(0, 1fr) "tools board" var(--tool-height) / var(--side-width) minmax(0, 1fr);
    align-items: stretch;
    gap: 6px 10px;
    padding: 4px 10px 6px;
  }
  .easel::before { border-radius: 22px; background-size: 100% 132%; background-position: center bottom; }
  .painting-heading { --title-size: clamp(18px, 3.5vw, 27px); grid-template-rows: 16px auto minmax(0, 1fr); padding: 83px 0 0 5px; }
  .painting-heading h2, .lesson-progress { width: 100%; margin-inline: 0; }
  .live-caption { width: 100%; }
  .live-caption p { font-size: 14px; }
  .tools { gap: 4px; padding: 0 0 0 5px; }
  .tools > button, .tools .primary { font-size: clamp(12px, 2vw, 16px); }
  .tools > button > span { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
