:root {
  --ink: #6b4334;
  --ink-soft: #a07a66;
  --cream: #fff6ea;
  --paper: #fffaf1;
  --wood: #b87a52;
  --wood-dark: #8c5638;
  --wood-light: #d79d70;
  --capoo: #b5dcef;
  --capoo-line: #46606f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  background: #7a4a34;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

html.has-hand, html.has-hand * { cursor: none !important; }

button { font: inherit; color: inherit; }

/* =================================================================
   Capoo (shared by every cat on the page)
   ================================================================= */
.capoo { display: block; width: 100%; height: auto; overflow: visible; }
.capoo .body, .capoo .leg {
  fill: var(--capoo);
  stroke: var(--capoo-line);
  stroke-width: 2.4;
  stroke-linejoin: round;
}
.capoo .ear-in { fill: #d8eef8; }
.capoo .blush { fill: #f6a7b6; opacity: 0.75; }
.capoo .eye { fill: #2f3d47; }
.capoo .shine { fill: #fff; }
.capoo .line { fill: none; stroke: #2f3d47; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.capoo .line.thick { stroke-width: 2.8; }
.capoo .mouth { fill: #e7798a; stroke: #2f3d47; stroke-width: 1.8; stroke-linejoin: round; }
.capoo .tear { fill: #cdeeff; stroke: #79b6d6; stroke-width: 1.2; }
.capoo .snot { fill: rgba(214, 240, 255, 0.75); stroke: #8fc3dc; stroke-width: 1.2; transform-box: fill-box; transform-origin: 0 50%; animation: snot 3.2s ease-in-out infinite; }
.capoo .face { display: none; }
.capoo .eye { transform-box: fill-box; transform-origin: center; transition: transform 0.08s; }

[data-pose="sit"] .capoo .down, [data-pose="sleep"] .capoo .up { display: none; }
[data-face="open"] .capoo .f-open,
[data-face="teary"] .capoo .f-teary,
[data-face="happy"] .capoo .f-happy,
[data-face="sleep"] .capoo .f-sleep { display: inline; }

[data-face="teary"] .capoo .up { animation: tremble 0.32s linear infinite; }
[data-face="teary"] .capoo .tear { animation: tear 1.2s ease-in infinite; }
.blink .capoo .f-open .eye { transform: scaleY(0.12); }

@keyframes snot { 50% { transform: scale(1.7); } }
@keyframes tremble { 25% { transform: translateX(0.5px); } 75% { transform: translateX(-0.5px); } }
@keyframes tear { 0% { transform: translateY(-3px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(6px); opacity: 0; } }

/* =================================================================
   Front door
   ================================================================= */
.door {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 45%, #fff8ec, #f6cfaa 60%, #d69670);
  transition: opacity 0.8s ease, visibility 0.8s;
  outline: none;
}
.door.gone { opacity: 0; visibility: hidden; }
.door-card { text-align: center; animation: bob 2.8s ease-in-out infinite; }
.door-cat { width: 150px; margin: 0 auto 14px; }
.door-title {
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: clamp(2rem, 6vw, 2.8rem);
  color: #8a4b3a;
}
.door-hint { margin-top: 8px; color: #a8705a; font-weight: 700; animation: pulse 2.4s ease-in-out infinite; }

@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes pulse { 50% { opacity: 0.45; } }

/* =================================================================
   Room stage (fixed design size, scaled with JS)
   ================================================================= */
.viewport { position: fixed; inset: 0; overflow: hidden; }

.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: 50% 50%;
  opacity: 0;
  transition: opacity 0.9s ease 0.15s;
}
body.entered .stage { opacity: 1; }
body.is-reading .viewport,
body.is-reading .dust,
body.is-reading .vignette { display: none; }

/* wall + floor extend far past the stage so any screen shape is filled */
.wall, .floor { position: absolute; left: -3000px; right: -3000px; }
.wall {
  top: -3000px;
  bottom: calc(100% - var(--floor));
  background:
    radial-gradient(circle at 50% calc(100% - var(--glow-y)), rgba(255, 226, 180, 0.95), rgba(255, 210, 160, 0) 620px),
    radial-gradient(circle, rgba(255, 255, 255, 0.16) 1.6px, transparent 2.2px) 0 0 / 34px 34px,
    linear-gradient(#b9785e, #e2a982 calc(100% - 700px), #edbb92);
}
.floor {
  top: var(--floor);
  bottom: -3000px;
  background:
    linear-gradient(rgba(70, 30, 10, 0.35), transparent 120px),
    repeating-linear-gradient(90deg, rgba(90, 45, 20, 0.22) 0 2px, transparent 2px 140px),
    linear-gradient(#c4865c, #a86a46 400px);
}
.baseboard {
  position: absolute;
  left: -3000px;
  right: -3000px;
  top: calc(var(--floor) - 18px);
  height: 22px;
  background: linear-gradient(#fbe7cf, #e9c7a4);
  box-shadow: 0 4px 10px rgba(80, 40, 20, 0.25);
}

.stage.land { --floor: 640px; --glow-y: 300px; }
.stage.port { --floor: 790px; --glow-y: 400px; }

/* --- fairy lights --- */
.fairy { position: absolute; z-index: 2; height: 64px; }
.fairy svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.fairy path { fill: none; stroke: #6d4a3b; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.fairy span {
  position: absolute;
  width: 11px;
  height: 14px;
  margin: -2px 0 0 -5.5px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: var(--c);
  box-shadow: 0 0 10px 3px var(--c), 0 0 26px 6px color-mix(in srgb, var(--c) 50%, transparent);
  animation: glow 2.6s ease-in-out infinite alternate;
}
.fairy span::before {
  content: "";
  position: absolute;
  left: 3px;
  top: -4px;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: #6d4a3b;
}
@keyframes glow { from { opacity: 0.55; } to { opacity: 1; } }
.land .fairy { left: 120px; top: 28px; width: 1360px; }
.port .fairy { left: 16px; top: 18px; width: 508px; height: 46px; }

/* --- window --- */
.window { position: absolute; z-index: 2; }
.land .window { left: 150px; top: 150px; width: 300px; height: 250px; }
.port .window { left: 30px; top: 92px; width: 170px; height: 150px; }

.win-sky {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 10px solid #fff1df;
  border-radius: 16px 16px 6px 6px;
  background: linear-gradient(#27306a, #4b4b8e 55%, #8f6fa6);
  box-shadow: inset 0 0 30px rgba(10, 10, 40, 0.5), 0 10px 20px rgba(90, 45, 25, 0.3);
}
.win-sky::before, .win-sky::after {
  content: "";
  position: absolute;
  z-index: 4;
  background: #fff1df;
}
.win-sky::before { left: 50%; top: 0; bottom: 0; width: 8px; transform: translateX(-50%); }
.win-sky::after { top: 50%; left: 0; right: 0; height: 8px; transform: translateY(-50%); }

.moon {
  position: absolute;
  top: 14%;
  right: 18%;
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 38%, #fffdf0, #fbecbf);
  box-shadow: 0 0 24px 6px rgba(255, 244, 205, 0.45);
}
.wstars span {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff8e0;
  animation: twinkle 3.6s ease-in-out infinite;
}
@keyframes twinkle { 50% { opacity: 0.2; } }
.hills { position: absolute; left: 0; bottom: 0; width: 100%; height: 38%; }
.hills .h2 { fill: #5e4f8f; }
.hills .h1 { fill: #47407a; }
.rain { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; }
.pane {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.12) 0 16%, transparent 16% 34%, rgba(255, 255, 255, 0.06) 34% 38%, transparent 38%);
}

.rod {
  position: absolute;
  z-index: 5;
  left: -30px;
  right: -30px;
  top: -18px;
  height: 9px;
  border-radius: 9px;
  background: linear-gradient(#a8704f, #7d4b31);
}
.rod::before, .rod::after {
  content: "";
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #8a5638;
}
.rod::before { left: -6px; }
.rod::after { right: -6px; }

.curtain {
  position: absolute;
  z-index: 6;
  top: -14px;
  width: 30%;
  height: calc(100% + 36px);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 8px, rgba(190, 90, 110, 0.12) 8px 16px),
    #f3b9c4;
  box-shadow: 0 6px 14px rgba(120, 50, 50, 0.25);
}
.curtain.left { left: -26px; border-radius: 4px 4px 60% 8px; transform-origin: top left; animation: sway 7s ease-in-out infinite; }
.curtain.right { right: -26px; border-radius: 4px 4px 8px 60%; transform-origin: top right; animation: sway 7s ease-in-out -3.5s infinite reverse; }
.curtain::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 58%;
  height: 8px;
  border-radius: 8px;
  background: #fff1df;
}
@keyframes sway { 50% { transform: skewX(1.5deg); } }

.sill {
  position: absolute;
  z-index: 7;
  left: -22px;
  right: -22px;
  bottom: -14px;
  height: 16px;
  border-radius: 6px;
  background: linear-gradient(#fff3e2, #ecccab);
  box-shadow: 0 6px 10px rgba(90, 45, 25, 0.25);
}
.sill-pot {
  position: absolute;
  bottom: 14px;
  left: 18%;
  width: 26px;
  height: 22px;
  border-radius: 3px 3px 9px 9px;
  background: #f0a98f;
}
.sill-pot::before {
  content: "";
  position: absolute;
  bottom: 18px;
  left: 1px;
  width: 24px;
  height: 22px;
  border-radius: 50% 50% 40% 40%;
  background:
    radial-gradient(circle at 30% 60%, #8cc79a 6px, transparent 7px),
    radial-gradient(circle at 70% 55%, #7bbb8b 6px, transparent 7px),
    radial-gradient(circle at 50% 30%, #9ad3a6 7px, transparent 8px);
}

/* --- picture frames + clock --- */
.frame {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 7px solid #fff1df;
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(90, 45, 25, 0.3);
  font-family: "Fredoka", sans-serif;
  color: #fff;
}
.frame.f1 { background: linear-gradient(#ffd3dc, #f6a9ba); }
.frame.f2 { background: linear-gradient(#d4ecdc, #a9d6b7); border-radius: 50%; }
.frame.f3 { background: linear-gradient(#cfe3ff, #a8c6f0); }
.land .frame.f1 { left: 1160px; top: 170px; width: 96px; height: 120px; font-size: 44px; transform: rotate(-3deg); }
.land .frame.f2 { left: 1280px; top: 200px; width: 82px; height: 82px; font-size: 34px; }
.land .frame.f3 { left: 1150px; top: 318px; width: 120px; height: 84px; font-size: 38px; transform: rotate(2deg); }
.port .frame.f1 { left: 330px; top: 100px; width: 74px; height: 92px; font-size: 34px; transform: rotate(-3deg); }
.port .frame.f2 { left: 422px; top: 118px; width: 64px; height: 64px; font-size: 26px; }
.port .frame.f3 { display: none; }

.clock {
  position: absolute;
  z-index: 2;
  border-radius: 50%;
  background: radial-gradient(circle, #fffaf0 60%, #f6e0c5 62%);
  border: 6px solid #e59c86;
  box-shadow: 0 6px 14px rgba(90, 45, 25, 0.3);
}
.land .clock { left: 1408px; top: 110px; width: 74px; height: 74px; }
.port .clock { display: none; }
.clock span { position: absolute; left: 50%; bottom: 50%; width: 4px; margin-left: -2px; border-radius: 4px; background: #6b4334; transform-origin: bottom center; }
.clock .hh { height: 18px; transform: rotate(-60deg); }
.clock .mm { height: 25px; animation: spin 60s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- floor lamp --- */
.lamp { position: absolute; z-index: 3; }
.land .lamp { left: 1330px; top: 300px; width: 140px; height: 440px; }
.port .lamp { display: none; }
.lamp-glow {
  position: absolute;
  left: 50%;
  top: 70px;
  width: 900px;
  height: 900px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 160, 0.55), rgba(255, 200, 140, 0.18) 35%, transparent 65%);
  pointer-events: none;
  animation: flick 6s ease-in-out infinite;
}
@keyframes flick { 50% { opacity: 0.85; } }
.lamp-shade {
  position: absolute;
  left: 10px;
  top: 0;
  width: 120px;
  height: 84px;
  clip-path: polygon(22% 0, 78% 0, 100% 100%, 0 100%);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.25) 0 6px, transparent 6px 14px),
    linear-gradient(#fff3cf, #ffd99a);
  filter: drop-shadow(0 0 18px rgba(255, 210, 140, 0.9));
}
.lamp-pole {
  position: absolute;
  left: 67px;
  top: 84px;
  width: 7px;
  height: 330px;
  border-radius: 4px;
  background: linear-gradient(90deg, #8a5638, #c08460, #8a5638);
}
.lamp-base {
  position: absolute;
  left: 34px;
  bottom: 12px;
  width: 72px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(#a8704f, #7d4b31);
  box-shadow: 0 8px 12px rgba(60, 25, 10, 0.35);
}

/* --- monstera --- */
.monstera { position: absolute; z-index: 4; }
.land .monstera { left: 300px; top: 470px; width: 170px; height: 280px; }
.port .monstera { display: none; }
.monstera .pot {
  position: absolute;
  left: 38px;
  bottom: 0;
  width: 94px;
  height: 92px;
  border-radius: 8px 8px 30px 30px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.08), transparent 30%, rgba(255, 255, 255, 0.2) 50%, transparent 70%, rgba(0, 0, 0, 0.08)),
    #f6dcc4;
  box-shadow: inset 0 10px 0 #ecc8a6, 0 10px 16px rgba(60, 25, 10, 0.3);
}
.monstera .leaf {
  position: absolute;
  width: 86px;
  height: 86px;
  border-radius: 0 100% 0 100%;
  background:
    linear-gradient(135deg, transparent 49%, rgba(40, 95, 55, 0.4) 49.5% 50.5%, transparent 51%),
    radial-gradient(circle at 30% 30%, #b0e0ae, #74b37a 75%);
  box-shadow: inset -4px -4px 0 rgba(40, 95, 55, 0.15);
  transform-origin: 50% 100%;
  animation: leaf 6s ease-in-out infinite;
}
.monstera .l1 { left: 4px; top: 76px; rotate: -95deg; }
.monstera .l2 { left: 42px; top: 4px; rotate: -45deg; animation-delay: -1s; }
.monstera .l3 { left: 86px; top: 50px; rotate: -5deg; animation-delay: -2s; }
.monstera .l4 { left: 26px; top: 96px; width: 68px; height: 68px; rotate: -70deg; animation-delay: -3s; }
.monstera .l5 { left: 82px; top: 104px; width: 68px; height: 68px; rotate: 10deg; animation-delay: -4s; }
@keyframes leaf { 50% { transform: translateY(-3px) rotate(2deg); } }

/* =================================================================
   Bookshelf
   ================================================================= */
.shelf-wrap {
  position: absolute;
  z-index: 5;
  left: 50%;
  width: 520px;
  margin-left: -260px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.land .shelf-wrap { top: 84px; }
.port .shelf-wrap { top: 236px; }

.sign { text-align: center; margin-bottom: 86px; }
.sign h1 {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 54px;
  line-height: 1;
  color: #fff8ee;
  letter-spacing: 0.01em;
  text-shadow: 0 3px 0 #c97f63, 0 6px 18px rgba(120, 50, 30, 0.35);
}
.sign p {
  margin-top: 10px;
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 19px;
  color: #7a4636;
}

.bookcase { position: relative; width: 470px; }

.case-top {
  position: relative;
  height: 24px;
  margin: 0 -12px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(var(--wood-light), var(--wood) 70%, var(--wood-dark));
  box-shadow: 0 4px 0 rgba(80, 40, 20, 0.3), inset 0 2px 0 rgba(255, 230, 200, 0.4);
}
.jar {
  position: absolute;
  left: 30px;
  bottom: 100%;
  width: 34px;
  height: 40px;
  border-radius: 8px 8px 12px 12px;
  background:
    radial-gradient(circle at 30% 70%, #ffd166 3px, transparent 4px),
    radial-gradient(circle at 65% 55%, #f78fa7 3px, transparent 4px),
    radial-gradient(circle at 45% 40%, #8fd3c9 3px, transparent 4px),
    radial-gradient(circle at 70% 80%, #c5a3ff 3px, transparent 4px),
    rgba(255, 255, 255, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.8);
}
.jar::before {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: -9px;
  height: 8px;
  border-radius: 3px;
  background: #e59c86;
}
.mini-plant {
  position: absolute;
  left: 80px;
  bottom: 100%;
  width: 30px;
  height: 24px;
  border-radius: 3px 3px 9px 9px;
  background: #fff1df;
}
.mini-plant i {
  position: absolute;
  bottom: 18px;
  width: 12px;
  height: 22px;
  border-radius: 50%;
  background: #85c494;
  transform-origin: 50% 100%;
}
.mini-plant i:nth-child(1) { left: 2px; transform: rotate(-30deg); }
.mini-plant i:nth-child(2) { left: 9px; height: 28px; background: #9ad3a6; }
.mini-plant i:nth-child(3) { left: 16px; transform: rotate(30deg); }

.case-body {
  position: relative;
  padding: 0 14px;
  background:
    linear-gradient(90deg, var(--wood-dark), var(--wood) 4px, var(--wood) 10px, var(--wood-dark) 14px, transparent 14px calc(100% - 14px), var(--wood-dark) calc(100% - 14px), var(--wood) calc(100% - 10px), var(--wood) calc(100% - 4px), var(--wood-dark)),
    radial-gradient(ellipse at 50% 10%, #8e5a3e, #6a3e28 75%);
}

.shelf {
  position: relative;
  height: 206px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  padding: 0 10px 16px;
  box-shadow: inset 0 16px 18px -8px rgba(40, 15, 5, 0.55);
}
.shelf::after {
  content: "";
  position: absolute;
  left: -14px;
  right: -14px;
  bottom: 0;
  height: 16px;
  background: linear-gradient(var(--wood-light), var(--wood) 50%, var(--wood-dark));
  box-shadow: 0 3px 4px rgba(40, 15, 5, 0.4);
  z-index: 2;
}

.case-feet { display: flex; justify-content: space-between; padding: 0 10px; }
.case-feet span { width: 26px; height: 16px; border-radius: 0 0 8px 8px; background: var(--wood-dark); }
.bookcase::after {
  content: "";
  position: absolute;
  left: -30px;
  right: -30px;
  bottom: -14px;
  height: 30px;
  border-radius: 50%;
  background: rgba(60, 25, 10, 0.35);
  filter: blur(8px);
  z-index: -1;
}

/* --- shelf decorations --- */
.decor { position: relative; flex-shrink: 0; z-index: 1; }
.bookend {
  width: 26px;
  height: 46px;
  border-radius: 13px 13px 3px 3px;
  background: linear-gradient(90deg, #f4b6c2, #fbd3db 40%, #f4b6c2);
  box-shadow: inset 0 -6px 0 rgba(200, 110, 130, 0.25);
}
.bookend::after { content: "♡"; position: absolute; top: 9px; left: 0; right: 0; text-align: center; color: #fff; font-size: 14px; font-weight: 800; }
.candle {
  width: 30px;
  height: 32px;
  border-radius: 6px 6px 8px 8px;
  background: linear-gradient(rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.35)), #f6d18d;
  border: 2px solid rgba(255, 255, 255, 0.7);
}
.candle i {
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 9px;
  height: 15px;
  margin-left: -4.5px;
  border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
  background: radial-gradient(circle at 50% 70%, #fff6c8, #ffbf47 60%, #ff8f3d);
  box-shadow: 0 0 12px 4px rgba(255, 190, 90, 0.6), 0 0 40px 14px rgba(255, 190, 90, 0.25);
  transform-origin: 50% 100%;
  animation: flame 1.6s ease-in-out infinite;
}
@keyframes flame { 25% { transform: scale(0.92, 1.06) rotate(-3deg); } 60% { transform: scale(1.05, 0.95) rotate(2deg); } }
.lying { width: 60px; height: 30px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.lying i { display: block; height: 14px; border-radius: 3px; box-shadow: inset -6px 0 0 #fff3df; }
.lying i:nth-child(1) { width: 52px; margin-left: 4px; background: #9bc7e8; }
.lying i:nth-child(2) { width: 60px; background: #f2b38f; }
.globe {
  width: 34px;
  height: 24px;
  border-radius: 3px 3px 10px 10px;
  background: #f0a98f;
}
.globe::before {
  content: "";
  position: absolute;
  left: 4px;
  bottom: 18px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 20%, #ffd6e0 3px, transparent 4px),
    repeating-conic-gradient(from 0deg at 50% 100%, #8ccb98 0 12deg, #77ba86 12deg 24deg);
}

/* --- books --- */
.books { display: flex; align-items: flex-end; gap: 5px; position: relative; z-index: 1; }

.book {
  position: relative;
  display: block;
  width: 50px;
  height: calc(var(--h) * 158px);
  flex-shrink: 0;
  text-decoration: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.book-in {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-origin: 50% 100%;
  transition:
    transform 0.55s cubic-bezier(0.25, 1.35, 0.4, 1),
    filter 0.4s ease;
}
.book.out .book-in { transform: translateY(-16px) scale(1.07); filter: drop-shadow(0 14px 12px rgba(50, 20, 5, 0.4)); }
.book.picked .book-in { transform: translateY(-34px) scale(1.14); transition-duration: 0.45s; }
.book.lean-l .book-in { transform: rotate(-2.2deg); transform-origin: 0% 100%; }
.book.lean-r .book-in { transform: rotate(2.2deg); transform-origin: 100% 100%; }

.spine {
  position: absolute;
  inset: 0;
  border-radius: 9px 9px 4px 4px;
  background:
    linear-gradient(90deg, rgba(90, 40, 20, 0.18), rgba(255, 255, 255, 0.32) 20%, rgba(255, 255, 255, 0.06) 46%, rgba(90, 40, 20, 0.06) 78%, rgba(90, 40, 20, 0.22)),
    var(--c);
  box-shadow: inset 0 0 0 2px rgba(90, 40, 20, 0.12), inset 0 -10px 12px -8px rgba(90, 40, 20, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 0;
  overflow: hidden;
  transition: box-shadow 0.4s;
}
.book.out .spine { box-shadow: inset 0 0 0 2px rgba(90, 40, 20, 0.12), 0 0 0 3px rgba(255, 246, 225, 0.7), 0 0 22px rgba(255, 220, 160, 0.55); }
.spine .band { width: 100%; height: 5px; flex-shrink: 0; background: rgba(255, 248, 232, 0.75); }
.spine .band.low { position: absolute; bottom: 12px; }
.sticker {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: 9px 0 8px;
  border-radius: 50%;
  background: #fff8ec;
  box-shadow: 0 2px 0 rgba(90, 40, 20, 0.15);
}
.sticker svg { width: 18px; height: 18px; fill: var(--c); stroke: var(--c); stroke-width: 0.6; filter: saturate(1.3) brightness(0.85); }
.spine .title {
  writing-mode: vertical-rl;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: #fffaf2;
  text-shadow: 0 1px 0 rgba(90, 40, 20, 0.25);
}
.top-pages {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 2px;
  height: 0;
  border-radius: 4px 4px 0 0;
  background: repeating-linear-gradient(90deg, #fffaf0 0 2px, #ead8bd 2px 3px);
  transform: translateY(-100%);
  transition: height 0.5s cubic-bezier(0.25, 1.35, 0.4, 1);
}
.book.out .top-pages, .book.picked .top-pages { height: 8px; }
.ribbon {
  position: absolute;
  top: -12px;
  left: 62%;
  width: 7px;
  height: 20px;
  background: var(--r);
  clip-path: polygon(0 0, 50% 22%, 100% 0, 100% 100%, 0 100%);
}
.book:focus-visible .spine { outline: 3px solid #fff3dc; outline-offset: 3px; }

/* --- bookshelf Capoo --- */
.buddy {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 20;
  width: 0;
  height: 0;
  pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.45, 0, 0.3, 1);
}
.buddy-hop { position: absolute; left: -34px; bottom: -3px; width: 68px; transform-origin: 50% 100%; }
.buddy-hop.hopping { animation: hop 0.45s cubic-bezier(0.3, 0, 0.4, 1); }
.buddy-body { animation: breathe 2.6s ease-in-out infinite; transform-origin: 50% 100%; }
.buddy.flip .buddy-body .capoo { transform: scaleX(-1); }
.buddy.wiggle .buddy-body { animation: wiggle 0.6s ease-in-out; }

@keyframes hop {
  0% { transform: translateY(0) scale(1, 1); }
  15% { transform: translateY(0) scale(1.12, 0.86); }
  50% { transform: translateY(-44px) scale(0.94, 1.08); }
  82% { transform: translateY(0) scale(1.14, 0.84); }
  100% { transform: translateY(0) scale(1, 1); }
}
@keyframes breathe { 50% { transform: scale(1.02, 0.97); } }
@keyframes wiggle {
  0%, 100% { transform: rotate(0) translateY(0); }
  20% { transform: rotate(-9deg) translateY(-6px); }
  45% { transform: rotate(8deg) translateY(-10px); }
  70% { transform: rotate(-5deg) translateY(-3px); }
}

.bubble {
  position: absolute;
  left: 50%;
  bottom: 64px;
  padding: 6px 13px;
  border-radius: 16px;
  background: #fffaf1;
  border: 2.5px solid #eccab0;
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 16px;
  color: #7a4636;
  white-space: nowrap;
  box-shadow: 0 4px 0 rgba(120, 60, 30, 0.12);
  opacity: 0;
  transform: translateX(-50%) translateY(6px) scale(0.7);
  transform-origin: 50% 100%;
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background: #fffaf1;
  border-right: 2.5px solid #eccab0;
  border-bottom: 2.5px solid #eccab0;
  transform: rotate(45deg);
}
.bubble.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

.hint {
  position: absolute;
  z-index: 8;
  left: 0;
  right: 0;
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 18px;
  color: #fff3e3;
  text-shadow: 0 2px 6px rgba(80, 35, 15, 0.5);
}
.land .hint { top: 838px; }
.port .hint { top: 1018px; }

.foot {
  position: absolute;
  z-index: 8;
  left: 0;
  right: 0;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: rgba(255, 240, 225, 0.7);
}
.land .foot { top: 868px; }
.port .foot { top: 1040px; }

/* =================================================================
   Rug + sleeping Capoo + floor things
   ================================================================= */
.rug-area { position: absolute; z-index: 6; }
.land .rug-area { left: 410px; top: 726px; width: 780px; height: 104px; }
.port .rug-area { left: 20px; top: 868px; width: 500px; height: 120px; }
.rug {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-radial-gradient(ellipse at center, #f7d4d9 0 14px, #fbe6e0 14px 28px);
  box-shadow: 0 0 0 6px #f1bcc6, 0 10px 24px rgba(70, 30, 10, 0.3);
}
.sleeper { position: absolute; cursor: pointer; }
.land .sleeper { left: 520px; top: -6px; width: 156px; }
.port .sleeper { left: 290px; top: -4px; width: 130px; }
.sleeper-body { animation: snooze 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
.sleeper.poked .sleeper-body { animation: poke 0.5s ease-in-out, snooze 3.2s ease-in-out 0.5s infinite; }
@keyframes snooze { 50% { transform: scale(1.03, 1.06); } }
@keyframes poke { 30% { transform: scale(1.1, 0.85); } 60% { transform: scale(0.95, 1.1) translateY(-6px); } }
.sleeper::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -6px;
  height: 14px;
  border-radius: 50%;
  background: rgba(150, 70, 70, 0.25);
  z-index: -1;
}
.zzz { position: absolute; right: 18%; top: 18%; width: 50px; height: 60px; pointer-events: none; }
.zzz span {
  position: absolute;
  left: 0;
  bottom: 0;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  color: #6f9fbd;
  -webkit-text-stroke: 1px #fff8ee;
  paint-order: stroke fill;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6);
  opacity: 0;
  animation: zzz 3.6s ease-in-out infinite;
}
.zzz span:nth-child(1) { font-size: 20px; }
.zzz span:nth-child(2) { font-size: 26px; animation-delay: 1.2s; }
.zzz span:nth-child(3) { font-size: 33px; animation-delay: 2.4s; }
@keyframes zzz {
  0% { transform: translate(0, 0) rotate(-10deg); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(34px, -58px) rotate(12deg); opacity: 0; }
}

.floor-stuff { position: absolute; z-index: 7; width: 240px; height: 90px; }
.land .floor-stuff { left: 470px; top: 750px; }
.port .floor-stuff { left: 36px; top: 902px; transform: scale(0.85); transform-origin: left top; }
.cushion {
  position: absolute;
  left: 0;
  bottom: 6px;
  width: 120px;
  height: 52px;
  border-radius: 40px 40px 26px 26px;
  background:
    radial-gradient(circle at 50% 46%, #f4b9a6 4px, transparent 5px),
    linear-gradient(#ffe0b8, #f6c690);
  box-shadow: inset 0 -8px 0 rgba(200, 120, 60, 0.18), 0 8px 12px rgba(70, 30, 10, 0.25);
}
.mug {
  position: absolute;
  left: 134px;
  bottom: 8px;
  width: 34px;
  height: 36px;
  border-radius: 5px 5px 12px 12px;
  background: linear-gradient(90deg, #ffffff, #f4ece4);
  box-shadow: inset 0 6px 0 #a76b4d, 0 4px 6px rgba(70, 30, 10, 0.25);
}
.mug::before {
  content: "";
  position: absolute;
  right: -11px;
  top: 9px;
  width: 12px;
  height: 15px;
  border: 4px solid #f4ece4;
  border-left: none;
  border-radius: 0 10px 10px 0;
}
.mug::after { content: "♡"; position: absolute; inset: 12px 0 0; text-align: center; color: #f3a3b4; font-size: 14px; font-weight: 800; }
.steam {
  position: absolute;
  left: 50%;
  bottom: 38px;
  width: 8px;
  height: 22px;
  border-left: 2.5px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  opacity: 0;
  animation: steam 3.4s ease-in-out infinite;
}
.steam:nth-child(2) { margin-left: -9px; animation-delay: 1.7s; }
@keyframes steam {
  0% { transform: translateY(6px) scaleX(1); opacity: 0; }
  30% { opacity: 0.9; }
  100% { transform: translateY(-22px) scaleX(-1); opacity: 0; }
}
.pile { position: absolute; left: 186px; bottom: 8px; width: 50px; display: flex; flex-direction: column; gap: 2px; }
.pile span { height: 12px; border-radius: 3px; box-shadow: inset -6px 0 0 #fff3df; }
.pile span:nth-child(1) { width: 40px; margin-left: 6px; background: #c4a7e6; }
.pile span:nth-child(2) { width: 46px; margin-left: 1px; background: #90cdaa; }
.pile span:nth-child(3) { width: 50px; background: #f2c46e; }

/* =================================================================
   Overlays
   ================================================================= */
.dust { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 9; pointer-events: none; mix-blend-mode: screen; }
.vignette {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background: radial-gradient(ellipse 75% 70% at 50% 45%, transparent 55%, rgba(70, 28, 10, 0.45));
}

.sound-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2.5px solid #f0c9a8;
  background: #fff6ea;
  box-shadow: 0 4px 0 #e3b48f;
  font-size: 1.15rem;
  cursor: pointer;
  transition: transform 0.15s;
}
.sound-toggle:hover { transform: translateY(-2px); }

/* Page transition: a warm circle grows from the book, Capoo bounces inside */
.wipe {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  visibility: hidden;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, #fff7ea, #f7d2b2 70%);
  clip-path: circle(0 at var(--x, 50%) var(--y, 50%));
}
.wipe.on { visibility: visible; clip-path: circle(150% at var(--x, 50%) var(--y, 50%)); transition: clip-path 0.55s cubic-bezier(0.65, 0, 0.35, 1); }
.wipe.on.out { clip-path: circle(0 at 50% 50%); transition: clip-path 0.48s cubic-bezier(0.65, 0, 0.35, 1); }
.wipe-cat { width: 110px; animation: bob 0.6s ease-in-out infinite; }

/* =================================================================
   Reading page (one per book)
   ================================================================= */
.reading {
  position: relative;
  z-index: 20;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 26px 20px 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(255, 236, 205, 0.9), transparent 70%),
    radial-gradient(circle, rgba(255, 255, 255, 0.14) 1.6px, transparent 2.2px) 0 0 / 34px 34px,
    linear-gradient(#e7ad85, #c98a62);
}
.reading[hidden] { display: none; }

.reading-top, .flip-nav { width: min(1000px, 100%); display: flex; gap: 12px; }
.reading-top { justify-content: flex-start; margin-bottom: 22px; }
.flip-nav { justify-content: space-between; margin-top: 24px; }

.pill {
  padding: 10px 20px;
  border-radius: 999px;
  border: 2.5px solid #f0c9a8;
  background: #fff6ea;
  color: #7a4636;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 17px;
  box-shadow: 0 4px 0 #e3b48f;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.pill:hover, .pill:focus-visible { transform: translateY(-2px); box-shadow: 0 6px 0 #e3b48f; outline: none; }
.pill:active { transform: translateY(2px); box-shadow: 0 2px 0 #e3b48f; }
.pill.small { font-size: 15px; padding: 8px 16px; }

.open-book {
  position: relative;
  width: min(1000px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  padding: 14px;
  border-radius: 22px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.12), transparent 4%, transparent 96%, rgba(0, 0, 0, 0.12)),
    var(--c);
  box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 70%, #5a3020), 0 30px 60px rgba(90, 40, 20, 0.35);
  perspective: 2000px;
  animation: bookIn 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}
@keyframes bookIn { from { opacity: 0; transform: translateY(30px) scale(0.94); } }

.bk-page {
  position: relative;
  min-height: 520px;
  padding: 38px 40px 54px;
  background:
    repeating-linear-gradient(transparent 0 33px, rgba(214, 170, 130, 0.18) 33px 34px),
    var(--paper);
  font-size: 17px;
  line-height: 1.65;
}
.bk-page.left {
  border-radius: 14px 4px 4px 14px;
  box-shadow: inset -26px 0 30px -24px rgba(120, 70, 30, 0.45);
  transform-origin: 100% 50%;
  animation: openLeft 0.85s cubic-bezier(0.2, 0.8, 0.25, 1) 0.1s both;
}
.bk-page.right {
  border-radius: 4px 14px 14px 4px;
  box-shadow: inset 26px 0 30px -24px rgba(120, 70, 30, 0.45);
}
@keyframes openLeft { from { transform: rotateY(-95deg); filter: brightness(0.8); } }
.open-book.turn .bk-page { animation: turn 0.5s ease both; }
@keyframes turn { 0% { opacity: 1; } 40% { opacity: 0; transform: translateX(-8px); } 41% { transform: translateX(8px); } 100% { opacity: 1; transform: none; } }

.pg-sticker {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 70%, #5a3020);
  margin-bottom: 14px;
}
.pg-sticker svg { width: 26px; height: 26px; fill: #fffaf2; stroke: #fffaf2; stroke-width: 0.6; }

.bk-page h2 { font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 40px; line-height: 1.1; color: #5e3628; }
.bk-page h3 { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 24px; color: #5e3628; margin-bottom: 12px; }
.bk-page p + p { margin-top: 12px; }
.bk-page .intro { color: var(--ink-soft); margin: 6px 0 20px; font-weight: 700; }

.pg-num {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: "Fredoka", sans-serif;
  color: #c9a68c;
  font-size: 14px;
}

.tag {
  flex-shrink: 0;
  padding: 3px 12px;
  border-radius: 999px;
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  color: #fffaf2;
  background: color-mix(in srgb, var(--c) 80%, #5a3020);
}

.entries { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.entries li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--c) 14%, #fffaf1);
  border: 2px solid color-mix(in srgb, var(--c) 30%, #fffaf1);
}
.entries strong { display: block; font-weight: 800; }
.entries small { display: block; color: var(--ink-soft); font-size: 14px; line-height: 1.4; }

.facts { display: flex; flex-direction: column; gap: 8px; }
.fact {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--c) 14%, #fffaf1);
}
.fact dt { color: var(--ink-soft); font-weight: 700; }
.fact dd { font-weight: 800; text-align: right; }

.review {
  padding: 14px 16px;
  margin-bottom: 12px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--c) 14%, #fffaf1);
  border: 2px solid color-mix(in srgb, var(--c) 30%, #fffaf1);
}
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.review-head strong { font-weight: 800; }
.rating { font-size: 19px; letter-spacing: 2px; color: #ecd9c6; }
.rating .on { color: #f5b942; }
.review p { font-size: 15px; color: #8a6352; }

.favs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fav {
  padding: 14px;
  border-radius: 16px;
  text-align: center;
  background: color-mix(in srgb, var(--c) 16%, #fffaf1);
  border: 2px dashed color-mix(in srgb, var(--c) 45%, #fffaf1);
}
.fav small { display: block; color: var(--ink-soft); font-weight: 700; font-size: 13px; }
.fav strong { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 19px; }

.qa { margin-bottom: 14px; }
.qa .q, .qa .a { width: fit-content; max-width: 90%; padding: 9px 15px; border-radius: 18px; }
.qa .q { background: #f3e6d6; border-bottom-left-radius: 4px; font-weight: 800; }
.qa .a { margin: 6px 0 0 auto; background: color-mix(in srgb, var(--c) 85%, #5a3020); color: #fffaf2; border-bottom-right-radius: 4px; text-align: right; }
.bk-page .qa p + p { margin-top: 6px; }

.links { display: flex; flex-direction: column; gap: 12px; margin-top: 40px; }
.link-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 18px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  background: #fffaf1;
  border: 2.5px solid color-mix(in srgb, var(--c) 45%, #fffaf1);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 45%, #fffaf1);
  transition: transform 0.15s, box-shadow 0.15s;
}
.link-card:hover, .link-card:focus-visible { transform: translateY(-3px); box-shadow: 0 7px 0 color-mix(in srgb, var(--c) 45%, #fffaf1); outline: none; }
.link-card .ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.link-card svg { width: 20px; height: 20px; fill: #fffaf2; }
.link-card .lbl { flex: 1; }
.link-card .arrow { color: var(--ink-soft); }

.blank {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 50px 10px;
  border: 2.5px dashed #ecd2bb;
  border-radius: 18px;
  color: var(--ink-soft);
  font-family: "Fredoka", sans-serif;
  font-size: 20px;
}
.blank small { font-family: "Nunito", sans-serif; font-weight: 700; font-size: 14px; }

.doodle { display: grid; place-items: center; height: 100%; min-height: 300px; align-content: center; gap: 8px; opacity: 0.9; }
.doodle .capoo { width: 170px; }
.doodle p { font-family: "Fredoka", sans-serif; color: var(--ink-soft); font-size: 18px; }

/* =================================================================
   Sweater-sleeve hand cursor (desktop only)
   ================================================================= */
.hand {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transform-origin: 30px 9px;
  transition: opacity 0.2s;
  will-change: transform;
}
.hand.on { opacity: 1; }
.hand .hi { transform-origin: 30px 9px; transition: transform 0.2s cubic-bezier(0.3, 1.5, 0.5, 1); }
.hand.point .hi { transform: rotate(-6deg) translateY(1px); }
.hand.down .hi { transform: scale(0.9) translateY(3px); }
.hand svg { display: block; overflow: visible; filter: drop-shadow(0 6px 6px rgba(70, 30, 10, 0.3)); }
.hand .o { fill: #c98f7a; stroke: #c98f7a; stroke-width: 6; stroke-linejoin: round; }
.hand .f { fill: #ffe3d2; }
.hand .knuckle { stroke: #f1c3ad; stroke-width: 2; stroke-linecap: round; fill: none; }
.hand .nail { fill: #fff6f1; }
.hand .cheek { fill: #ffb3a7; opacity: 0.55; }
.hand .sleeve { fill: #f7c6d3; stroke: #c98f9d; stroke-width: 3; }
.hand .stripes rect { fill: #fde6ec; }
.hand .cuff { fill: #f3b3c4; stroke: #c98f9d; stroke-width: 3; }
.hand .ribs path { stroke: rgba(255, 255, 255, 0.55); stroke-width: 2; stroke-linecap: round; }

/* =================================================================
   Small screens (reading page)
   ================================================================= */
@media (max-width: 760px) {
  .reading { padding: 16px 12px 90px; }
  .open-book { grid-template-columns: minmax(0, 1fr); padding: 10px; border-radius: 18px; }
  .bk-page { min-height: 0; padding: 28px 22px 44px; font-size: 16px; }
  .bk-page.left { border-radius: 12px 12px 4px 4px; box-shadow: inset 0 -24px 30px -26px rgba(120, 70, 30, 0.45); transform-origin: 50% 0%; animation-name: openTop; }
  .bk-page.right { border-radius: 4px 4px 12px 12px; box-shadow: none; }
  .bk-page h2 { font-size: 32px; }
  .links { margin-top: 0; }
  .doodle { min-height: 200px; }
  .doodle .capoo { width: 130px; }
  .flip-nav .pill { max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@keyframes openTop { from { transform: rotateX(70deg); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
