@font-face {
  font-family: "La Belle Aurore";
  src: url("fonts/LaBelleAurore.woff2") format("woff2");
  font-display: block;
}

:root {
  --cream: #efe6d2;
  --verm: #c8402f;
  --gold: #b58d3b;
  --ink: #1b3a6b;
  --s: 1;
  --shift: 0px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #2a1c14;
}

body {
  font-family: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  color: var(--cream);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ───────────── wood ───────────── */

#desk {
  position: fixed;
  inset: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='800'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0035 0.12' numOctaves='4' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.08  0 0 0 0 0.04  0 0 0 0 0.02  1.9 0 0 0 -0.62'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E"),
    repeating-linear-gradient(0deg, transparent 0 318px, rgba(0,0,0,.42) 318px 320px, rgba(255,220,180,.06) 320px 321px),
    linear-gradient(100deg, #62432f, #523726 45%, #5b3d2b 70%, #4a3122);
}

/* ───────────── stage ───────────── */

#stage {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 1600px;
  height: 1000px;
  transform: translate(-50%, -50%) scale(var(--s)) translateX(var(--shift));
}

#desk-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.clickable { cursor: pointer; }
.d-caption {
  font-size: 11px;
  letter-spacing: .28em;
  fill: rgba(239, 230, 210, .42);
}

.target { cursor: pointer; animation: glow 1.9s ease-in-out infinite; }
@keyframes glow {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(255, 216, 150, 0)); }
  50% { filter: drop-shadow(0 0 9px rgba(255, 216, 150, .95)); }
}

.steam path {
  fill: none;
  stroke: rgba(255, 255, 255, .55);
  stroke-width: 7;
  stroke-linecap: round;
  opacity: 0;
  animation: steam 7s ease-in-out infinite;
}
.steam path:nth-child(2) { animation-delay: -2.4s; }
.steam path:nth-child(3) { animation-delay: -4.6s; }
@keyframes steam {
  0% { opacity: 0; transform: translate(0, 12px); }
  40% { opacity: .5; }
  100% { opacity: 0; transform: translate(10px, -28px); }
}

.d-ink .ring { opacity: 0; transition: opacity .3s; }
.d-ink.on .ring { opacity: 1; }
.d-ink text { font-family: "Shippori Mincho", serif; font-weight: 700; }
body[data-mode="idle"] .d-ink { cursor: default; }

body:not([data-mode="idle"]) #d-pen-barrel { opacity: 0; }
body[data-mode="ritual"] #d-pen-cap { opacity: 0; }
#d-pen-barrel, #d-pen-cap { transition: opacity .5s; }
body[data-mode="ritual"] #d-pen { cursor: default; }
body[data-mode="writing"] #d-pen-barrel { pointer-events: none; }
#d-pen:focus-visible { outline: 2px solid var(--gold); outline-offset: 8px; }
.pen-caption { letter-spacing: .08em; fill: rgba(239, 230, 210, .65); }

/* title */
#title {
  position: absolute;
  left: 65px;
  top: 48px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: rgba(239, 230, 210, .85);
}
#title h1 { margin: 0; font-size: 44px; font-weight: 500; letter-spacing: .02em; text-shadow: 0 2px 10px rgba(0,0,0,.4); }
#title h1 button { all: unset; cursor: pointer; border-bottom: 1px solid rgba(239,230,210,.25); }
#title h1 button:hover { color: #fff7e5; border-color: var(--gold); }
#title h1 button:focus-visible { outline: 1px solid var(--gold); outline-offset: 6px; }
#title p { margin: 0; font-size: 13px; letter-spacing: .03em; opacity: .8; }
#title small { font-size: 11px; letter-spacing: .05em; opacity: .5; }
.maker-credit { color: #d2bd96; font-size: 12px; letter-spacing: .04em; text-decoration: none; width: fit-content; }
.maker-credit:hover { color: #fff7e5; text-decoration: underline; }
.maker-credit:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }

/* ───────────── draft tape ───────────── */

#ticker {
  position: absolute;
  left: 490px;
  top: 40px;
  width: 620px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-radius: 7px;
  background: linear-gradient(#2a1a15, #130b09);
  box-shadow: 0 12px 24px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.14), inset 0 0 0 1px rgba(181,141,59,.35);
  opacity: 0;
  transform: translateY(-16px);
  transition: opacity .7s, transform .7s cubic-bezier(.2,.7,.2,1);
}
body[data-mode="writing"] #ticker { opacity: 1; transform: none; }

.tk-label { font-size: 13px; letter-spacing: .2em; color: rgba(239,230,210,.6); white-space: nowrap; }
.tk-right { font-size: 10px; letter-spacing: .34em; text-transform: uppercase; }

.tk-window {
  flex: 1;
  height: 38px;
  position: relative;
  overflow: hidden;
  border-radius: 3px;
  background: linear-gradient(#e9dfc6, #f1e8d2 30%, #ece2ca);
  box-shadow: inset 0 3px 6px rgba(0,0,0,.5), inset 0 -1px 2px rgba(0,0,0,.25), 0 1px 0 rgba(255,255,255,.1);
}
.tk-window::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(40,25,15,.75), transparent 16%, transparent 90%, rgba(40,25,15,.5)),
    linear-gradient(rgba(255,255,255,.28), transparent 42%);
  pointer-events: none;
}
.tk-tape {
  position: absolute;
  right: 24%;
  top: 0;
  height: 100%;
  white-space: pre;
  font: 21px/41px "Special Elite", "Courier New", monospace;
  color: #2a2420;
  will-change: transform;
}
.tk-tape span { display: inline-block; min-width: .5em; transition: opacity .6s; }
.tk-tape span.done { opacity: .3; }
.tk-tape span.struck { text-decoration: line-through; text-decoration-color: var(--verm); text-decoration-thickness: 2px; }
.tk-tape span.nl { color: var(--verm); margin: 0 .3em; }
.tk-ghost {
  position: absolute; left: 0; right: 24%; top: 0; padding-right: 14px; text-align: right;
  font: italic 15px/38px "Shippori Mincho", serif; letter-spacing: .08em; color: rgba(60,45,30,.5);
  transition: opacity .4s;
}
.tk-ghost.off { opacity: 0; }
.tk-head { position: absolute; right: 24%; top: 5px; bottom: 5px; width: 1.5px; background: var(--verm); opacity: .75; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .15; } }

/* ───────────── paper ───────────── */

#sheet-wrap { position: absolute; left: 490px; top: 150px; width: 620px; height: 820px; z-index: 1; isolation: isolate; }

.sheet {
  position: absolute;
  inset: 0;
  background: #f3ecdb;
  transform-origin: 0 0;
  box-shadow: 1px 2px 3px rgba(0,0,0,.28), 14px 24px 44px rgba(0,0,0,.42);
  transition: transform .95s cubic-bezier(.3,.7,.2,1), opacity .5s;
  cursor: text;
}
.sheet canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sheet canvas.wet { mix-blend-mode: multiply; }
.sheet.incoming { transform: translate(40px, -960px) rotate(4deg); }
.sheet.done { cursor: default; box-shadow: 2px 4px 10px rgba(0,0,0,.4); z-index: 0; }

#bunchin {
  position: absolute;
  left: 120px; top: 16px; width: 380px; height: 16px;
  border-radius: 3px;
  background: linear-gradient(#f3dc9a, #b98f3a 48%, #7c5c1e);
  box-shadow: 3px 7px 9px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.55);
  z-index: 60;
  transition: transform .5s cubic-bezier(.3,.7,.2,1), opacity .4s;
  pointer-events: none;
}
#bunchin i {
  position: absolute; left: 50%; top: 50%; width: 24px; height: 24px; margin: -12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fdeebb, #b98f3a 60%, #6b4d15);
  box-shadow: 2px 3px 4px rgba(0,0,0,.35);
}
#bunchin.up { transform: translateY(-50px) scale(1.04); opacity: 0; }

/* ───────────── pen in hand ───────────── */

.ink-fill { fill: var(--ink); }

#pen-top {
  --lift: 1;
  position: absolute;
  left: 470px;
  top: 110px;
  transform-origin: 20px 40px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s;
  will-change: transform;
  z-index: 6;
  overflow: visible;
  filter: drop-shadow(calc(3px + 12px * var(--lift)) calc(.5px + 2px * var(--lift)) calc(2px + 5px * var(--lift)) rgba(0, 0, 0, .42));
}
body[data-mode="writing"] #pen-top { opacity: 1; }
body[data-mode="writing"] #pen-top { pointer-events: visiblePainted; cursor: grab; touch-action: none; }
body[data-mode="handling"] #pen-top { opacity: 1; pointer-events: visiblePainted; cursor: grabbing; }
#pen-top:focus-visible { outline: 1px solid var(--gold); outline-offset: 8px; }
#d-pen-cap { touch-action: none; }
body[data-mode="writing"] #d-pen-cap { cursor: grab; }
#stage.recapping #d-pen-cap { opacity: 0; transition: none; }
#cap-top {
  position: absolute; left: 1194px; top: 210px; width: 72px; height: 216px;
  transform-origin: 36px 204px; z-index: 8; overflow: visible;
  opacity: 0; pointer-events: none;
  filter: drop-shadow(6px 10px 6px rgba(0,0,0,.38));
}
#stage.recapping #cap-top { opacity: 1; }
#stage.cap-near #cap-top { filter: drop-shadow(0 0 5px rgba(241,209,138,.8)) drop-shadow(6px 10px 6px rgba(0,0,0,.38)); }
#stage.pen-held { cursor: grabbing; }

#hanko-fly {
  position: absolute; left: 0; top: 0; width: 54px; height: 54px; margin: -27px;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #f0d49c, #c79f62 60%, #8f6b38);
  box-shadow: 10px 16px 18px rgba(0,0,0,.45);
  opacity: 0; pointer-events: none; z-index: 7;
  transition: transform .5s cubic-bezier(.4,0,.2,1), opacity .25s, box-shadow .2s;
}
#hanko-fly.press { box-shadow: 1px 2px 3px rgba(0,0,0,.5); }

/* ───────────── light ───────────── */

#light { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#light .pool {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 75% 85% at 26% 16%, rgba(255, 214, 150, .2), transparent 62%),
    radial-gradient(ellipse 120% 120% at 45% 40%, transparent 48%, rgba(10, 5, 2, .6) 100%);
}
#light svg { position: absolute; inset: 0; width: 100%; height: 100%; mix-blend-mode: multiply; }
.lattice { fill: #3a2412; opacity: .22; filter: blur(16px); transform: rotate(-13deg) skewX(-14deg); transform-origin: 50% 50%; }
.leaves { fill: #1c1707; opacity: .2; filter: blur(7px); transform-origin: 100% 0; animation: sway 9s ease-in-out infinite alternate; }
@keyframes sway {
  from { transform: rotate(-1.4deg); }
  to { transform: rotate(1.7deg) translate(-8px, 6px); }
}

/* ───────────── the pen, up close ───────────── */

#ritual {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: rgba(14, 8, 5, .62);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  opacity: 0; pointer-events: none;
  transition: opacity .6s;
}
#ritual.open { opacity: 1; pointer-events: auto; }
.r-panel {
  position: relative;
  width: min(1040px, 94vw, calc(78vh * 10 / 7));
  aspect-ratio: 10 / 7;
  margin-bottom: 40px;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08);
  transform: translateY(16px) scale(.985);
  transition: transform .8s cubic-bezier(.2,.7,.2,1);
  touch-action: none;
}
#ritual.open .r-panel { transform: none; }
#r-svg { display: block; width: 100%; height: 100%; }
.r-part { cursor: default; }
.r-part.target { cursor: pointer; }
.r-part.closable { cursor: pointer; }
.r-part.closable:hover { filter: drop-shadow(0 0 5px rgba(181,141,59,.7)); }
.r-part:focus-visible { outline: 2px solid var(--gold); outline-offset: 6px; }
.r-lk { font-family: "Shippori Mincho", serif; font-weight: 700; font-size: 14px; fill: var(--ink); }
.r-lr { font-family: "Shippori Mincho", serif; font-size: 7.5px; letter-spacing: .22em; fill: #6d5f48; }
.ink-bub circle { fill: rgba(255,255,255,.5); }

.r-title {
  position: absolute; left: 6%; top: 6%;
  color: #4a3b2a; font-size: clamp(16px, 2.4vw, 26px); letter-spacing: .02em;
  pointer-events: none;
}
.r-title small { display: block; font-size: .5em; letter-spacing: .06em; opacity: .65; margin-top: 7px; }
.r-cap-note { position: absolute; left: 10%; bottom: 7%; font-size: clamp(10px, 1.2vw, 12px); letter-spacing: .03em; color: #66523b; opacity: 0; pointer-events: none; transition: opacity .3s; }
.r-cap-note.on { opacity: 1; }

.r-swatches { position: absolute; left: 6%; top: 18%; display: flex; gap: 10px; transition: opacity .5s; }
.r-swatches.locked { opacity: .0; pointer-events: none; }
.r-swatches button {
  all: unset; cursor: pointer;
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  font: 500 10px "Shippori Mincho", serif; color: #f3ecdb;
  background: var(--c);
  box-shadow: 0 3px 8px rgba(40,25,10,.35), inset 0 2px 3px rgba(255,255,255,.25), inset 0 -3px 5px rgba(0,0,0,.3);
  transition: transform .25s, box-shadow .25s;
}
.r-swatches button.two { font-size: 11px; }
.r-swatches button:hover { transform: translateY(-2px); }
.r-swatches button.on { box-shadow: 0 0 0 2px #ece2cc, 0 0 0 3.5px var(--c), 0 3px 8px rgba(40,25,10,.35), inset 0 2px 3px rgba(255,255,255,.25); }

.r-skip {
  all: unset; cursor: pointer;
  position: absolute; right: 2.4%; top: 3.4%;
  font-size: 12px; letter-spacing: .14em; color: rgba(74,59,42,.6);
  padding: 6px 8px; transition: color .2s;
}
.r-skip:hover { color: #4a3b2a; }

.r-meter {
  position: absolute; left: 50%; top: 6%; width: 180px; height: 3px; margin-left: -90px;
  background: rgba(74,59,42,.18); border-radius: 2px; overflow: hidden;
  opacity: 0; transition: opacity .4s;
}
.r-meter.on { opacity: 1; }
.r-meter i { display: block; height: 100%; width: 0; background: var(--ink); }

/* ───────────── hint ───────────── */

#hint {
  position: fixed; left: 50%; bottom: 58px; z-index: 40;
  transform: translateX(-50%) translateY(8px);
  display: flex; align-items: center; gap: 12px;
  padding: 8px 22px 8px 9px;
  border-radius: 999px;
  background: rgba(22, 13, 9, .82);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.09);
  font-size: 16px; letter-spacing: .05em; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .5s, transform .5s;
}
#hint.on { opacity: 1; transform: translateX(-50%); }
#hint.nudge { animation: nudge .4s; }
@keyframes nudge { 30% { transform: translateX(calc(-50% - 7px)); } 65% { transform: translateX(calc(-50% + 5px)); } }
#hint b {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--verm); color: #fbf3e2; font-weight: 500; font-size: 15px;
}
#hint b:empty { display: none; }
#hint b:empty + span { padding-left: 13px; }

/* ───────────── quiet controls ───────────── */

#bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px 14px;
  font-size: 13px; letter-spacing: .09em;
  background: linear-gradient(transparent, rgba(10, 5, 3, .55));
}
#bar button {
  all: unset; cursor: pointer;
  color: rgba(239, 230, 210, .6);
  margin-right: 22px;
  transition: color .2s, opacity .2s;
}
#bar button b { color: rgba(239, 230, 210, .92); font-weight: 500; font-size: 14px; margin-right: 5px; }
#bar button:hover { color: #fff; }
#bar button:disabled { cursor: default; }
#bar button:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }
#bar button[aria-pressed="false"] { opacity: .42; }
#bar .bar-left { transition: opacity .6s; }
body:not([data-mode="writing"]) #bar .bar-left { opacity: 0; pointer-events: none; }
.bar-right { display: flex; align-items: center; }

#inkstat { display: inline-flex; align-items: center; gap: 8px; color: rgba(239,230,210,.7); transition: opacity .6s; }
body[data-mode="idle"] #inkstat { opacity: 0; }
#inkstat b { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px rgba(239,230,210,.35); }
#inkstat i { width: 74px; height: 5px; border-radius: 3px; background: rgba(239,230,210,.16); overflow: hidden; }
#inkstat u { display: block; height: 100%; width: 0; background: var(--inkstat, var(--cream)); transition: width .4s; }
#inkstat.dry { animation: blink 1s steps(2) infinite; }

#input {
  position: fixed; left: 0; bottom: 0; width: 2px; height: 2px;
  opacity: 0; border: 0; padding: 0; resize: none; font-size: 16px;
  pointer-events: none;
}

@media (max-width: 1020px) {
  #bar { padding: 12px 14px 10px; }
  #bar button { font-size: 12px; margin-right: 14px; }
  #inkstat i { width: 54px; }
  #hint { font-size: 14px; bottom: 50px; max-width: calc(100vw - 28px); white-space: normal; }
  #hint b { flex-shrink: 0; }
  #title { left: 490px; top: 0; gap: 2px; }
  #title h1 { font-size: 30px; }
  #title small { font-size: 14px; }
  #title .maker-credit { position: absolute; left: 370px; top: 15px; white-space: nowrap; font-size: 16px; }
  #ticker { top: 85px; height: 48px; }
}

@media (max-width: 650px) {
  #bar { flex-wrap: wrap; justify-content: center; gap: 10px; }
  #bar .bar-left { display: flex; justify-content: center; width: 100%; }
  #bar button { font-size: 11px; margin: 0 7px; letter-spacing: .02em; padding: 4px 0; }
  #hint { bottom: 88px; font-size: 12px; padding-right: 14px; }
  .r-swatches { gap: 7px; }
  .r-swatches button { width: 32px; height: 32px; font-size: 8px; }
  .r-skip { font-size: 10px; letter-spacing: .03em; }
}

/* A quiet, readable note behind the name. */
#about {
  width: min(500px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 48px 42px 30px;
  border: 1px solid #d7c6a6;
  border-radius: 4px;
  background: #f3ecdb;
  color: #493a2c;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
  font-size: 15px;
  line-height: 1.85;
  user-select: text;
  -webkit-user-select: text;
}
#about::backdrop { background: rgba(19,12,8,.65); backdrop-filter: blur(5px); }
#about h2 { margin: 14px 0 24px; font-size: 32px; line-height: 1.3; font-weight: 500; letter-spacing: -.02em; }
#about p { margin: 0 0 18px; }
#about .about-kicker { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: #937153; }
#about .about-signoff { color: #8a4934; font-style: italic; margin-top: 26px; }
#about .about-seal { border-top: 1px solid #d7c6a6; padding-top: 16px; margin-bottom: 0; font-size: 12px; color: #80654c; }
#about .about-maker { margin: 14px 0 0; font-size: 12px; color: #80654c; }
#about .about-maker a { color: #8a4934; text-underline-offset: 3px; }
#about-close { all: unset; position: absolute; top: 14px; right: 20px; cursor: pointer; font-size: 12px; color: #80654c; }
#about-close:focus-visible { outline: 1px solid #937153; outline-offset: 4px; }
@media (max-width: 650px) { #about { padding: 42px 26px 22px; font-size: 14px; } #about h2 { font-size: 28px; } }
