* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: #100b07;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

button {
  font-family: inherit;
  touch-action: none;
}

img,
canvas {
  -webkit-user-drag: none;
}

.noise,
#body::after,
#deck::after,
#wall::after,
#desk::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

#stage {
  position: fixed;
  left: 0;
  top: 0;
  width: 1440px;
  height: 880px;
  transform-origin: 0 0;
  overflow: visible;
  touch-action: none;
}

#stage.panning {
  cursor: grabbing;
}

body.pannable #hint {
  top: 818px;
}

#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 100% at 50% 42%, transparent 55%, rgba(5, 3, 2, 0.55) 100%);
  pointer-events: none;
  z-index: 95;
}

#wall {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(120% 90% at 52% -8%, #3a2d20 0%, #241b13 34%, #171009 68%, #100b07 100%);
}

#wall::after {
  opacity: 0.16;
}

#glow {
  position: absolute;
  left: 200px;
  top: -260px;
  width: 1100px;
  height: 760px;
  z-index: 2;
  background: radial-gradient(closest-side, rgba(255, 198, 130, 0.2), rgba(255, 190, 120, 0.07) 46%, transparent 72%);
  filter: blur(6px);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: breathe 9s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.82; }
  38% { opacity: 1; }
  52% { opacity: 0.9; }
  74% { opacity: 1; }
}

#beam,
#beam-core {
  position: absolute;
  top: -160px;
  z-index: 2;
  pointer-events: none;
  mix-blend-mode: screen;
  transform-origin: top center;
}

#beam {
  left: 330px;
  width: 440px;
  height: 1060px;
  transform: rotate(17deg);
  background: linear-gradient(90deg, transparent, rgba(255, 208, 150, 0.12) 30%, rgba(255, 214, 160, 0.2) 50%, rgba(255, 208, 150, 0.12) 70%, transparent);
  filter: blur(22px);
  animation: beamsway 14s ease-in-out infinite;
}

@keyframes beamsway {
  0%, 100% { transform: rotate(16.6deg); opacity: 0.9; }
  50% { transform: rotate(17.4deg); opacity: 1; }
}

#beam-core {
  left: 480px;
  width: 150px;
  height: 1010px;
  transform: rotate(17deg);
  background: linear-gradient(90deg, transparent, rgba(255, 220, 170, 0.17) 50%, transparent);
  filter: blur(13px);
}

#desk {
  position: absolute;
  left: 0;
  right: 0;
  top: 620px;
  bottom: 0;
  z-index: 3;
  background:
    radial-gradient(70% 90% at 53% 0%, rgba(255, 196, 130, 0.15), transparent 60%),
    repeating-linear-gradient(180deg, transparent 0 44px, rgba(0, 0, 0, 0.2) 44px 46px),
    linear-gradient(180deg, #63452d 0%, #4d3421 22%, #3a2718 55%, #2a1b10 100%);
  box-shadow: inset 0 2px 0 rgba(255, 210, 150, 0.2);
}

#desk::after {
  opacity: 0.22;
}

#machine-shadow {
  position: absolute;
  left: 330px;
  top: 756px;
  width: 860px;
  height: 54px;
  z-index: 4;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.5), transparent);
  filter: blur(10px);
  pointer-events: none;
}

#machine {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  transition: transform 0.07s ease-out;
}

#platen,
#bail,
#scale,
.knob,
#return-lever,
#lf-lever,
#paper,
#ribbon-lever {
  pointer-events: auto;
}

#rail {
  position: absolute;
  left: 380px;
  top: 298px;
  width: 760px;
  height: 18px;
  z-index: 4;
  border-radius: 9px;
  background: linear-gradient(#565b52, #23261f 60%, #171a14);
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.tower {
  position: absolute;
  top: 252px;
  width: 52px;
  height: 172px;
  z-index: 5;
  border-radius: 18px 18px 6px 6px;
  background: linear-gradient(160deg, #39423a, #1c221c 60%, #121712);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.08), inset 0 -10px 16px rgba(0, 0, 0, 0.45), 0 8px 14px rgba(0, 0, 0, 0.3);
}

#tower-l { left: 420px; }
#tower-r { left: 1048px; }

#body {
  position: absolute;
  left: 420px;
  top: 330px;
  width: 680px;
  height: 440px;
  z-index: 5;
  border-radius: 26px 26px 14px 14px;
  background: linear-gradient(160deg, #333d34, #1d241e 55%, #141a15);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.07), inset 0 -16px 26px rgba(0, 0, 0, 0.5), 0 18px 30px rgba(0, 0, 0, 0.35);
}

#body::after {
  opacity: 0.13;
  border-radius: inherit;
}

#brand-plate {
  position: absolute;
  left: 50%;
  top: 388px;
  width: 172px;
  transform: translateX(-50%);
  z-index: 6;
  text-align: center;
  padding: 9px 0 8px;
  background: linear-gradient(#3a332a, #201c16);
  border: 1px solid #55492f;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 230, 170, 0.16), 0 4px 8px rgba(0, 0, 0, 0.4);
}

.bp-name {
  display: block;
  font-family: TypeFace, "American Typewriter", "Courier New", monospace;
  font-weight: 700;
  font-size: 27px;
  letter-spacing: 11px;
  padding-left: 11px;
  color: #c8a765;
  text-shadow: 0 1px 0 #000, 0 -1px 0 rgba(255, 230, 170, 0.25);
}

.bp-no {
  display: block;
  margin-top: 2px;
  font-family: TypeFace, "American Typewriter", "Courier New", monospace;
  font-size: 10px;
  letter-spacing: 5px;
  padding-left: 5px;
  color: #93805a;
}

#carriage {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  transition: transform 0.06s cubic-bezier(0.2, 0.9, 0.3, 1);
}

#carriage.notrans {
  transition: none !important;
}

#paper-window {
  position: absolute;
  left: 640px;
  top: -820px;
  width: 660px;
  height: 1164px;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

#paper-wrap {
  position: absolute;
  transition: transform 0.13s ease-out;
  transform-origin: 50% 40%;
}

#paper-wrap.notrans {
  transition: none !important;
}

#paper {
  display: block;
  box-shadow: 2px 5px 10px rgba(0, 0, 0, 0.3);
  cursor: grab;
}

#paper:active {
  cursor: grabbing;
}

#platen {
  position: absolute;
  left: 460px;
  top: 280px;
  width: 600px;
  height: 58px;
  z-index: 2;
  border-radius: 29px;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 4px),
    linear-gradient(180deg, #4a4642 0%, #26231f 30%, #171512 55%, #2c2925 88%, #3d3934 100%);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.45), inset 0 2px 3px rgba(255, 255, 255, 0.1);
  cursor: grab;
}

#bail {
  position: absolute;
  left: 560px;
  top: 262px;
  width: 400px;
  height: 22px;
  z-index: 3;
  cursor: pointer;
}

#bail-bar {
  position: absolute;
  left: 0;
  right: 0;
  top: 9px;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(#a29c8b, #55503f);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s ease;
  transform-origin: left center;
}

.bail-roller {
  position: absolute;
  top: 5px;
  width: 28px;
  height: 13px;
  border-radius: 7px;
  background: linear-gradient(#48433d, #1c1a16 60%, #33302a);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.12);
  transition: transform 0.2s ease;
}

.bail-roller.r1 { left: 74px; }
.bail-roller.r2 { right: 74px; }

#bail.lift #bail-bar {
  transform: rotate(-5deg) translateY(-7px);
}

#bail.lift .bail-roller {
  transform: translateY(-6px);
}

#scale {
  position: absolute;
  z-index: 2;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  cursor: grab;
}

.knob {
  position: absolute;
  top: 279px;
  width: 60px;
  height: 60px;
  z-index: 3;
  border-radius: 50%;
  background: repeating-conic-gradient(#3c3833 0 6deg, #211e1a 6deg 12deg);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5), inset 0 0 0 3px #17150f;
  cursor: grab;
}

#knob-l { left: 405px; }
#knob-r { left: 1055px; }

.knob-face {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6b655b, #2e2b25 70%);
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.45s cubic-bezier(0.3, 0.8, 0.3, 1);
}

.knob-face::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  width: 2px;
  height: 11px;
  background: #c8bfa8;
  transform: translateX(-50%);
  border-radius: 1px;
}

#return-lever {
  position: absolute;
  left: 352px;
  top: 288px;
  width: 106px;
  height: 13px;
  z-index: 4;
  border: 0;
  border-radius: 7px;
  background: linear-gradient(#948d7c, #4c473c);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
  transform: rotate(-7deg);
  transform-origin: right center;
  transition: transform 0.12s ease;
  cursor: pointer;
}

#return-lever:active {
  transform: rotate(-17deg);
}

.lever-ball {
  position: absolute;
  left: -9px;
  top: -4px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3a3733, #16140f);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.2), 0 2px 3px rgba(0, 0, 0, 0.5);
}

.lever-ball.small {
  width: 17px;
  height: 17px;
  left: -3px;
  top: auto;
  bottom: -7px;
}

#lf-lever {
  position: absolute;
  left: 448px;
  top: 340px;
  width: 12px;
  height: 44px;
  z-index: 4;
  border: 0;
  border-radius: 7px;
  background: linear-gradient(90deg, #8d8676, #46413a);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
  transform: rotate(15deg);
  transform-origin: top center;
  transition: transform 0.12s ease;
  cursor: pointer;
}

#lf-lever:active {
  transform: rotate(28deg);
}

#pointer-pin {
  position: absolute;
  left: 754px;
  top: 331px;
  width: 12px;
  height: 13px;
  z-index: 50;
  background: #c03a2e;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
  pointer-events: none;
}

#bell-icon {
  position: absolute;
  left: 792px;
  top: 330px;
  z-index: 50;
  opacity: 0.85;
  transform-origin: 50% 0;
  pointer-events: none;
}

#bell-icon.ring {
  animation: bellring 0.55s ease-out;
}

@keyframes bellring {
  0% { transform: rotate(0); }
  15% { transform: rotate(16deg); }
  35% { transform: rotate(-13deg); }
  55% { transform: rotate(9deg); }
  75% { transform: rotate(-5deg); }
  100% { transform: rotate(0); }
}

#basket {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

#basket .segment {
  fill: url(#seggrad);
  stroke: #0c0f0b;
  stroke-width: 1.5;
}

#basket .bar line {
  stroke: #cfcbc0;
  stroke-width: 3;
  stroke-linecap: round;
}

#basket .bar rect {
  fill: #b9b4a4;
  stroke: #6e6a5c;
  stroke-width: 1;
}

#ribbon-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.spool-outer {
  fill: #20232a;
  stroke: #43474f;
  stroke-width: 2;
}

.spool-wound {
  fill: #1d1d1f;
  transition: fill 0.2s;
}

.spool-spin line {
  stroke: #565b66;
  stroke-width: 2;
}

.spool-hub {
  fill: #b08d4f;
  stroke: #6e5a33;
  stroke-width: 1;
}

.inkpath {
  fill: none;
  stroke: #1d1d1f;
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke 0.2s, opacity 0.2s;
}

.inkfill {
  transition: fill 0.2s, opacity 0.2s;
}

.vibrator {
  transition: transform 0.06s ease;
}

.vibrator.up {
  transform: translateY(-9px);
}

.vibfork {
  fill: #3a3d42;
}

.guideprong {
  fill: #23262b;
}

#ribbon-layer.mode-red .inkpath { stroke: #7f1d16; }
#ribbon-layer.mode-red .inkfill { fill: #7f1d16; }

#ribbon-layer.mode-off .vibrator { transform: translateY(16px); }
#ribbon-layer.mode-off .vibrator.up { transform: translateY(8px); }
#ribbon-layer.mode-off .inkpath { opacity: 0.45; }
#ribbon-layer.mode-off .spool-wound { opacity: 0.55; }

#ribbon-lever {
  position: absolute;
  left: 1078px;
  top: 368px;
  width: 26px;
  height: 74px;
  z-index: 55;
  border: 1px solid #4c463a;
  border-radius: 8px;
  background: linear-gradient(#34312b, #191713);
  box-shadow: 0 4px 7px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.rl-knob {
  position: absolute;
  left: 4px;
  top: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d8b877, #8a6d3a);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5);
  transition: top 0.16s ease;
}

#ribbon-lever[data-mode="black"] .rl-knob { top: 6px; }
#ribbon-lever[data-mode="off"] .rl-knob { top: 28px; }
#ribbon-lever[data-mode="red"] .rl-knob { top: 50px; }

.rl-label {
  position: absolute;
  top: 79px;
  left: -7px;
  width: 40px;
  text-align: center;
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 1.8px;
  color: #9b8f74;
}

#deck {
  position: absolute;
  left: 390px;
  top: 455px;
  width: 740px;
  height: 293px;
  z-index: 40;
  clip-path: polygon(4% 0, 96% 0, 100% 100%, 0 100%);
  background: linear-gradient(#2c352d, #1a211b 70%, #131a15);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.06);
}

#deck::after {
  opacity: 0.12;
}

#serial {
  position: absolute;
  bottom: 7px;
  width: 100%;
  text-align: center;
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 2.6px;
  color: #8d8672;
}

#keys {
  position: absolute;
  inset: 0;
  z-index: 45;
  pointer-events: none;
}

.key {
  position: absolute;
  pointer-events: auto;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.key:focus-visible {
  outline: 2px solid #d9b878;
  outline-offset: 3px;
  border-radius: 50%;
}

.key.round {
  width: 46px;
  height: 46px;
}

.cap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, #f4ecd8, #ddd2b4 58%, #b6a982);
  box-shadow:
    0 0 0 3px #2b2a26,
    0 0 0 4.5px #57544a,
    0 5px 6px rgba(0, 0, 0, 0.55),
    inset 0 -3px 4px rgba(90, 75, 45, 0.35);
  color: #26241f;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.cap i {
  font-family: TypeFace, "American Typewriter", "Courier New", monospace;
  font-style: normal;
  font-weight: 400;
  font-size: 9px;
  line-height: 1;
  opacity: 0.8;
  transform: translateY(3px);
}

.cap b {
  font-family: TypeFace, "American Typewriter", "Courier New", monospace;
  font-weight: 700;
  font-size: 15.5px;
  line-height: 0.95;
}

.key.down .cap {
  transform: translateY(5px);
  box-shadow:
    0 0 0 3px #2b2a26,
    0 0 0 4.5px #57544a,
    0 1px 2px rgba(0, 0, 0, 0.5),
    inset 0 -1px 2px rgba(90, 75, 45, 0.4),
    inset 0 3px 5px rgba(70, 58, 35, 0.35);
}

.key.blocked .cap {
  animation: blocked 0.13s ease-out;
}

@keyframes blocked {
  30% { transform: translateY(2px); }
  60% { transform: translateY(4.5px); }
  100% { transform: translateY(0); }
}

.key.wide {
  height: 40px;
}

.klabel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(160deg, #efe7d2, #cfc2a2 70%, #b3a684);
  box-shadow:
    0 0 0 2.5px #2b2a26,
    0 0 0 4px #57544a,
    0 5px 6px rgba(0, 0, 0, 0.55),
    inset 0 -3px 4px rgba(90, 75, 45, 0.35);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: #26241f;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}

.key.wide.down .klabel {
  transform: translateY(5px);
  box-shadow:
    0 0 0 2.5px #2b2a26,
    0 0 0 4px #57544a,
    0 1px 2px rgba(0, 0, 0, 0.5),
    inset 0 3px 5px rgba(70, 58, 35, 0.35);
}

.key.latch.latched .klabel {
  transform: translateY(4px);
  background: linear-gradient(160deg, #d8cfb6, #b6a988 70%, #9c9070);
  box-shadow:
    0 0 0 2.5px #2b2a26,
    0 0 0 4px #57544a,
    0 1px 2px rgba(0, 0, 0, 0.5),
    inset 0 3px 6px rgba(70, 58, 35, 0.45);
}

.key.wide.space {
  height: 34px;
  margin-top: 3px;
}

.key.wide.space .klabel {
  border-radius: 9px;
  background: linear-gradient(180deg, #efe7d2 0%, #d9cdae 45%, #c0b391 100%);
}

#paper-box {
  position: absolute;
  left: 80px;
  top: 660px;
  width: 220px;
  height: 140px;
  z-index: 12;
  cursor: pointer;
  transition: transform 0.18s ease;
}

#paper-box:hover {
  transform: translateY(-3px);
}

.box-sheets {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 8px;
  height: 56px;
}

.box-sheets i {
  position: absolute;
  left: 0;
  right: 0;
  height: 46px;
  border-radius: 2px;
  background: linear-gradient(160deg, #f6f0df, #e2d9c2);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.6) inset, 0 2px 3px rgba(0, 0, 0, 0.25);
  transition: opacity 0.3s;
}

.box-sheets i:nth-child(1) { top: 10px; transform: rotate(-1.4deg); }
.box-sheets i:nth-child(2) { top: 7px; transform: rotate(0.8deg); }
.box-sheets i:nth-child(3) { top: 4px; transform: rotate(-0.5deg); }
.box-sheets i:nth-child(4) { top: 0; transform: rotate(1.1deg); }

#paper-box.empty .box-sheets i {
  opacity: 0.12;
}

.box-front {
  position: absolute;
  left: 0;
  right: 0;
  top: 48px;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 6px;
  background: linear-gradient(#6b4a2e, #43291a);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.12), 0 8px 14px rgba(0, 0, 0, 0.4);
}

.box-title {
  font-family: TypeFace, "American Typewriter", "Courier New", monospace;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 3.5px;
  color: #d9c49a;
}

.box-count {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2.2px;
  color: #a98d63;
}

.box-count b {
  color: #e8d3a8;
}

.fly-sheet {
  position: absolute;
  width: 400px;
  height: 110px;
  z-index: 15;
  border-radius: 2px;
  background: linear-gradient(#f6f0df, #e7dfc9);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: left 0.42s cubic-bezier(0.3, 0.7, 0.3, 1), top 0.42s cubic-bezier(0.3, 0.7, 0.3, 1), opacity 0.42s;
}

#done-stack {
  position: absolute;
  left: 1160px;
  top: 640px;
  width: 240px;
  height: 170px;
  z-index: 12;
}

#done-stack.has-pages {
  cursor: pointer;
}

.stack-empty {
  position: absolute;
  inset: 26px 34px 16px 44px;
  padding-top: 36px;
  text-align: center;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.5px;
  color: rgba(214, 194, 154, 0.38);
  border: 1.5px dashed rgba(214, 194, 154, 0.22);
  border-radius: 6px;
}

#done-stack.has-pages .stack-empty {
  display: none;
}

.page-sheet {
  position: absolute;
  left: 48px;
  bottom: 16px;
  width: 96px;
  height: 124px;
  border-radius: 2px;
  background: linear-gradient(#f6f0df, #e9e1cb);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.35);
  transform: rotate(var(--r, 0deg)) translateY(calc(var(--i, 0) * -3.5px));
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.page-sheet.drop {
  animation: pagedrop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes pagedrop {
  0% {
    transform: rotate(calc(var(--r, 0deg) + 9deg)) translateY(calc(var(--i, 0) * -3.5px - 70px));
    opacity: 0;
  }
  60% { opacity: 1; }
  100% {
    transform: rotate(var(--r, 0deg)) translateY(calc(var(--i, 0) * -3.5px));
  }
}

.page-sheet::before {
  content: "";
  position: absolute;
  inset: 10px 9px;
  background: repeating-linear-gradient(180deg, rgba(60, 50, 30, 0.16) 0 1.5px, transparent 1.5px 7px);
}

#done-stack:hover .page-sheet:last-of-type {
  transform: rotate(var(--r, 0deg)) translateY(calc(var(--i, 0) * -3.5px - 8px));
  box-shadow: 0 10px 16px rgba(0, 0, 0, 0.4);
}

.stack-badge {
  position: absolute;
  right: 24px;
  top: 4px;
  min-width: 30px;
  height: 30px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 15px;
  background: radial-gradient(circle at 35% 30%, #d8b877, #7c6134);
  color: #241c0d;
  font-family: TypeFace, "American Typewriter", "Courier New", monospace;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

#specimen {
  position: absolute;
  left: 1075px;
  top: 745px;
  z-index: 13;
  padding: 12px 12px 10px;
  border-radius: 2px;
  background: linear-gradient(160deg, #f4eedd, #e6ddc6);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  transform: rotate(-3deg);
}

#specimen-canvas {
  display: block;
}

.specimen-pin {
  position: absolute;
  top: -5px;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c9a86a, #6e5630);
  transform: translateX(-50%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
}

#dust {
  position: absolute;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  mix-blend-mode: screen;
}

#title-plate {
  position: absolute;
  left: 36px;
  top: 28px;
  z-index: 96;
  padding: 12px 20px 11px;
  background: linear-gradient(150deg, #241d15, #120e09);
  border: 1px solid #4c3d28;
  border-radius: 6px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 220, 160, 0.12);
}

.tp-name {
  display: block;
  font-family: TypeFace, "American Typewriter", "Courier New", monospace;
  font-weight: 700;
  font-size: 21px;
  letter-spacing: 6px;
  color: #d9b878;
  text-shadow: 0 1px 0 #000;
}

.tp-sub {
  display: block;
  margin-top: 5px;
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 2.6px;
  color: #8f7f5f;
}

#hud {
  position: absolute;
  left: 36px;
  top: 806px;
  z-index: 96;
  padding: 10px 16px 9px;
  background: linear-gradient(#5d4a2e, #33271a);
  border: 1px solid #77603c;
  border-radius: 8px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 235, 190, 0.25);
  color: #f0ddb4;
  font-family: TypeFace, "American Typewriter", "Courier New", monospace;
  font-size: 11px;
  letter-spacing: 1.6px;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.hud-row.dim {
  margin-top: 3px;
  font-size: 9.5px;
  opacity: 0.65;
}

.hud-row b {
  font-weight: 700;
  color: #ffe9bd;
}

.hud-sep {
  opacity: 0.4;
}

#margin-lamp {
  width: 9px;
  height: 9px;
  margin-left: 6px;
  border-radius: 50%;
  background: #4a1512;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.6);
  transition: background 0.15s, box-shadow 0.15s;
}

#margin-lamp.lit {
  background: #e04434;
  box-shadow: 0 0 8px 2px rgba(224, 68, 52, 0.55);
  animation: lamppulse 1.1s ease-in-out infinite;
}

@keyframes lamppulse {
  0%, 100% { box-shadow: 0 0 6px 1px rgba(224, 68, 52, 0.45); }
  50% { box-shadow: 0 0 12px 4px rgba(224, 68, 52, 0.75); }
}

@media (hover: hover) {
  .key.round:hover .cap {
    filter: brightness(1.05);
    transform: translateY(-1px);
  }
  .key.round.down:hover .cap {
    filter: none;
    transform: translateY(5px);
  }
  #paper-box:hover .box-front {
    filter: brightness(1.08);
  }
  #done-stack.has-pages:hover .stack-badge {
    transform: scale(1.08);
  }
}

#hint {
  position: absolute;
  left: 50%;
  top: 843px;
  z-index: 96;
  max-width: 86%;
  transform: translateX(-50%) translateY(6px);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 15px;
  letter-spacing: 0.3px;
  color: #e6d3a8;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

#hint.show {
  opacity: 0.92;
  transform: translateX(-50%) translateY(0);
}

#strike-flash {
  position: absolute;
  left: 745px;
  top: 251px;
  width: 30px;
  height: 30px;
  z-index: 25;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 244, 214, 0.9), rgba(255, 214, 140, 0.35) 45%, transparent 70%);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

#reader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 7, 4, 0.86);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#reader.open {
  opacity: 1;
  pointer-events: auto;
}

.reader-sheet {
  margin: 0;
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.6));
  transform: scale(0.94) translateY(10px);
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}

#reader.open .reader-sheet {
  transform: scale(1) translateY(0);
}

#reader-img {
  display: block;
  max-height: 76vh;
  max-width: 82vw;
  border-radius: 3px;
  background: #f4eedd;
}

#reader-cap {
  margin-top: 16px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 3px;
  color: #c8b48c;
}

.reader-btn {
  position: fixed;
  top: 50%;
  width: 52px;
  height: 52px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #f0e8d2, #c4b795);
  box-shadow: 0 0 0 3px #2b2a26, 0 6px 12px rgba(0, 0, 0, 0.5);
  font-family: Georgia, serif;
  font-weight: 700;
  font-size: 26px;
  line-height: 1;
  color: #26241f;
  transition: filter 0.15s, transform 0.15s;
}

.reader-btn:hover {
  filter: brightness(1.07);
}

#reader-prev { left: 26px; }
#reader-next { right: 26px; }

#reader-close {
  top: 26px;
  right: 26px;
  width: 44px;
  height: 44px;
  transform: none;
  font-size: 22px;
}

.reader-btn.disabled {
  opacity: 0.3;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  #glow,
  #beam,
  #beam-core,
  #bell-icon.ring {
    animation: none;
  }
  #machine,
  .cap,
  .klabel,
  #carriage {
    transition-duration: 0s;
  }
}
