@font-face { font-family: Mincho; src: url(./fonts/mincho.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: Pixel; src: url(./fonts/pixel.woff2) format("woff2"); font-display: swap; }

:root {
  --ink: #070406;
  --char: #120709;
  --blood: #7d0d18;
  --scarlet: #d9162b;
  --lily: #ff3d4a;
  --bone: #efe6dc;
  --bone-dim: rgba(239, 230, 220, .6);
  --hairline: rgba(217, 22, 43, .38);
  --glass: rgba(12, 5, 7, .78);
  /* A stepped corner, so panels read as pixel art rather than web UI. */
  --notch: polygon(0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px));
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: var(--ink); color: var(--bone); font-family: Mincho, Georgia, serif; -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
img { image-rendering: pixelated; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
#stage:active { cursor: grabbing; }

/* Scanlines and a heavy vignette tie the smooth render to the pixel art around it. */
#veil { position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 72% 68% at 50% 45%, transparent 42%, rgba(3, 1, 2, .86) 100%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .13) 0 1px, transparent 1px 3px);
}

#petals { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }

#mast { position: fixed; top: 20px; left: 26px; pointer-events: none; }
.wordmark { font: 500 28px Mincho, serif; letter-spacing: .24em; line-height: 1; text-shadow: 0 0 14px rgba(217, 22, 43, .7); }
.edition { margin-top: 8px; font: 13px Pixel, monospace; letter-spacing: .1em; color: var(--lily); }

.panel { position: fixed; width: 246px; background: var(--glass); backdrop-filter: blur(10px); border: 2px solid var(--blood); clip-path: var(--notch); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px 8px; background: linear-gradient(180deg, rgba(125, 13, 24, .55), rgba(125, 13, 24, .12)); border-bottom: 1px solid var(--hairline); font: 14px Pixel, monospace; letter-spacing: .08em; color: var(--bone); }
.ghost { background: none; border: 0; padding: 0 2px; font: 13px Pixel, monospace; color: var(--bone-dim); cursor: pointer; }
.ghost:hover { color: var(--lily); }

#outliner { top: 98px; left: 26px; max-height: calc(100vh - 280px); display: flex; flex-direction: column; }
#tree { overflow-y: auto; padding: 5px 0 7px; scrollbar-width: thin; scrollbar-color: var(--blood) transparent; }
.node { display: flex; align-items: center; gap: 7px; padding: 4px 10px 4px calc(10px + var(--depth, 0) * 12px); font: 14px Pixel, monospace; line-height: 1.15; cursor: pointer; border-left: 3px solid transparent; }
.node:hover { background: rgba(217, 22, 43, .13); }
.node.selected { background: rgba(217, 22, 43, .24); border-left-color: var(--lily); color: var(--lily); }
.node.group-node { color: var(--bone-dim); }
.node .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .tris { font-size: 11px; color: var(--bone-dim); }
.node .eye { width: 11px; height: 11px; padding: 0; background: none; border: 2px solid var(--bone-dim); cursor: pointer; flex: none; }
.node .eye.on { background: var(--scarlet); border-color: var(--lily); }

#inspector { top: 20px; right: 26px; }
#inspector .panel-head { color: var(--lily); }
#part-facts { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; padding: 11px 12px; font-size: 14px; }
#part-facts dt { font: 12px Pixel, monospace; color: var(--bone-dim); align-self: center; }
#part-facts dd { text-align: right; }
#part-maps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; padding: 0 12px 10px; }
#part-maps:empty { display: none; }
#part-maps canvas { width: 100%; aspect-ratio: 1; border: 1px solid var(--hairline); image-rendering: pixelated; }
.row { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--hairline); }
.row button { background: none; border: 0; border-right: 1px solid var(--hairline); padding: 8px 0; font: 13px Pixel, monospace; color: var(--bone-dim); cursor: pointer; }
.row button:last-child { border-right: 0; }
.row button:hover, .row button.on { color: var(--ink); background: var(--lily); }

#downloads { right: 26px; bottom: 74px; width: 246px; }
#inspector:not([hidden]) ~ #downloads { display: none; }
#download-list { padding: 4px 0 6px; }
.dl { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 6px 12px; background: none; border: 0; color: var(--bone); font: 14px Pixel, monospace; text-decoration: none; cursor: pointer; }
.dl:hover { background: var(--scarlet); }
.dl small { font-size: 11px; color: var(--bone-dim); }
.dl:hover small { color: var(--bone); }

#dock { position: fixed; right: 26px; bottom: 24px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; font: 13px Pixel, monospace; color: var(--bone-dim); }
.group { display: flex; background: var(--glass); border: 2px solid var(--blood); clip-path: var(--notch); }
.group button { background: none; border: 0; border-right: 1px solid var(--hairline); padding: 7px 10px; font: inherit; color: inherit; cursor: pointer; }
.group button:last-child { border-right: 0; }
.group button:hover { color: var(--lily); }
.group button[aria-checked="true"] { color: var(--bone); background: var(--scarlet); }
.toggle, #dock select { background: var(--glass); border: 2px solid var(--blood); clip-path: var(--notch); padding: 7px 10px; font: inherit; color: inherit; cursor: pointer; border-radius: 0; }
.toggle.on { color: var(--bone); background: var(--blood); }
#dock select option { background: var(--char); }
.slider { display: flex; align-items: center; gap: 8px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 92px; height: 4px; background: var(--blood); cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 14px; background: var(--lily); border: 0; }

#clips { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 7px 12px; background: var(--glass); border: 2px solid var(--blood); clip-path: var(--notch); font: 13px Pixel, monospace; }
#clips[hidden] { display: none; }
#clips button, #clips select { background: none; border: 0; cursor: pointer; }
#clips select option { background: var(--char); }
#clip-time { width: 220px; }

#placard { position: fixed; left: 26px; bottom: 22px; max-width: min(46vw, 480px); pointer-events: none; }
#title { font: 500 29px Mincho, serif; line-height: 1.1; text-shadow: 0 0 16px rgba(217, 22, 43, .55), 0 2px 0 rgba(0, 0, 0, .8); }
#facts { margin-top: 7px; font: 13px Pixel, monospace; letter-spacing: .05em; color: var(--bone-dim); line-height: 1.5; }
#facts b { color: var(--lily); font-weight: 400; }

#signature { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 7px; color: var(--lily); pointer-events: none; font: 14px Pixel, monospace; letter-spacing: .06em; }
#signature img { width: 32px; height: 32px; }

#hint { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); font: 13px Pixel, monospace; color: var(--bone-dim); pointer-events: none; transition: opacity 1.2s; white-space: nowrap; }
#hint.gone { opacity: 0; }

#curtain { position: fixed; inset: 0; background: var(--ink) url(./art/field.png) center bottom / auto 62% repeat-x; image-rendering: pixelated; display: grid; place-content: center; justify-items: center; text-align: center; transition: opacity .9s steps(6); z-index: 5; }
#curtain.up { opacity: 0; pointer-events: none; }
#curtain img { width: min(38vh, 320px); height: auto; }
.curtain-word { margin-top: 8px; font: 500 clamp(24px, 5vw, 42px) Mincho, serif; letter-spacing: .3em; margin-right: -.3em; text-shadow: 0 0 18px rgba(217, 22, 43, .8); }
#curtain-line { margin-top: 8px; font: 15px Pixel, monospace; color: var(--lily); }

@media (max-width: 760px) {
  #mast { top: 12px; left: 14px; }
  .wordmark { font-size: 18px; }
  #signature { top: auto; left: auto; right: 12px; bottom: 94px; transform: none; font-size: 12px; }
  #signature img { width: 24px; height: 24px; }
  #outliner { display: none; }
  #inspector { top: 56px; right: 14px; left: 14px; width: auto; }
  #placard { left: 14px; right: 14px; bottom: 92px; max-width: none; }
  #title { font-size: 21px; }
  #dock { left: 10px; right: 10px; bottom: 10px; justify-content: center; gap: 6px; }
  #hint { display: none; }
  #downloads { left: 14px; right: 14px; bottom: auto; top: 56px; width: auto; }
  #downloads:not(.open) #download-list { display: none; }
  .slider input { width: 60px; }
  #clips { bottom: 136px; }
}

/* Studio mode renders stills for chat: the art plate is drawn, the controls are not. */
body.studio #downloads, body.studio #outliner, body.studio #inspector, body.studio #dock, body.studio #hint, body.studio #clips, body.studio #curtain { display: none !important; }
body.studio #mast { top: 30px; left: 36px; }
body.studio .wordmark { font-size: 30px; }
body.studio #placard { left: 36px; bottom: 32px; max-width: 62%; }
body.studio #title { font-size: 38px; }
body.studio #facts { font-size: 15px; }
body.studio #signature { top: auto; left: auto; right: 34px; bottom: 28px; transform: none; font-size: 18px; }
body.studio #signature img { width: 64px; height: 64px; }
