[hidden] { display: none !important; }
:root { --bg: #16161a; --ui: #fff; --ui-bg: rgba(18, 18, 22, .55); font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
:root.light-bg { --ui: #1b1b20; --ui-bg: rgba(255, 255, 255, .6); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); -webkit-tap-highlight-color: transparent; }

#bg { position: fixed; inset: 0; background: var(--bg) center / cover no-repeat; transition: background-color .4s; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 45%, rgba(0, 0, 0, .28) 100%); }

/* ---- the book ---------------------------------------------------------- */
#stage { position: fixed; inset: 0; perspective: 2600px; perspective-origin: 50% 45%; overflow: hidden; user-select: none; -webkit-user-select: none; }
.book { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; transform-origin: 0 0; }
.sheet { position: absolute; left: 0; top: calc(var(--ph) / -2); width: var(--pw); height: var(--ph); transform-origin: 0 50%; transform-style: preserve-3d; }
.strip { position: absolute; top: 0; left: 0; width: var(--sw); height: 100%; transform-origin: 0 50%; transform-style: preserve-3d; }
.face { position: absolute; top: 0; bottom: 0; left: 0; right: -1.5px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #f3efe6; }
.face.back { transform: rotateY(180deg); }
.face.blank { background: #ece6d8; }
.face img { position: absolute; top: 0; width: var(--pw); height: var(--ph); max-width: none; object-fit: cover; pointer-events: none; }
.gutter { position: absolute; inset: 0; pointer-events: none;
  /* spine shadow, soft glossy sheen, paper grain (all share the strip's background-position so slices line up) */
  background-image: linear-gradient(var(--dir), rgba(0, 0, 0, .4), rgba(0, 0, 0, .11) 4%, transparent 12%),
    linear-gradient(var(--odir), rgba(0, 0, 0, .22), transparent 2.2%),
    linear-gradient(118deg, rgba(255, 255, 255, .09) 0%, rgba(255, 255, 255, .015) 30%, rgba(255, 255, 255, .06) 52%, rgba(255, 255, 255, 0) 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .27 0 0 0 0 .2 0 0 0 .42 -.08'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat, no-repeat, repeat;
  background-size: var(--pw) 100%, var(--pw) 100%, var(--pw) 100%, 220px 220px; }
.shade { position: absolute; inset: 0; pointer-events: none; }
.shade::before, .shade::after { content: ""; position: absolute; inset: 0; }
.shade::before { background: linear-gradient(to right, rgba(0, 0, 0, var(--d0, 0)), rgba(0, 0, 0, var(--d1, 0))); }
.shade::after { background: linear-gradient(to right, rgba(255, 255, 255, var(--h0, 0)), rgba(255, 255, 255, var(--h1, 0))); }
.face.back .shade::before { background: linear-gradient(to left, rgba(0, 0, 0, var(--d0, 0)), rgba(0, 0, 0, var(--d1, 0))); }
.face.back .shade::after { background: linear-gradient(to left, rgba(255, 255, 255, var(--h0, 0)), rgba(255, 255, 255, var(--h1, 0))); }

.book-shadow { position: absolute; pointer-events: none; transform: translateZ(-12px); border-radius: 3px; box-shadow: 0 40px 80px rgba(0, 0, 0, .7), 0 14px 28px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .3); }
.backing { position: absolute; pointer-events: none; transform: translateZ(-8px); background: #121216; }
.spine { position: absolute; width: 8px; left: -4px; pointer-events: none; opacity: 0; background: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, .55) 30%, rgba(0, 0, 0, .9) 50%, rgba(0, 0, 0, .55) 70%, rgba(0, 0, 0, 0)); }
.cast { position: absolute; pointer-events: none; opacity: 0; }

.zone { position: absolute; z-index: 5; touch-action: none; cursor: grab; }
.zone-body { z-index: 4; cursor: move; }
.zone.grabbing { cursor: grabbing; }
body.preview #controls, body.preview #sticker, body.preview #hint { display: none !important; }

/* ---- sticker ----------------------------------------------------------- */
.sticker { position: fixed; top: 16px; left: 16px; z-index: 20; opacity: .2; transition: opacity .35s ease; }
.sticker:hover, .sticker:focus-within, .sticker.open { opacity: 1; }
.sticker[hidden] { display: none; }
.disc { position: relative; width: 128px; height: 128px; cursor: pointer;
  filter: url(#worn) drop-shadow(0 4px 6px rgba(0, 0, 0, .45)); transform: rotate(-9deg); transition: transform .35s cubic-bezier(.2, .8, .2, 1);
  --mx: 30%; --my: 25%; --ang: 40deg; --gx: 0px; --gy: 0px; }
.sticker:hover .disc, .sticker.open .disc { transform: rotate(-3deg) scale(1.06); }
.disc .layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; clip-path: polygon(50.00% 8.50%, 61.46% 36.22%, 91.37% 38.56%, 68.55% 58.03%, 75.57% 87.19%, 50.00% 71.50%, 24.43% 87.19%, 31.45% 58.03%, 8.63% 38.56%, 38.54% 36.22%); }
.disc .outline { clip-path: polygon(50.00% 2.00%, 63.52% 33.39%, 97.55% 36.55%, 71.87% 59.11%, 79.39% 92.45%, 50.00% 75.00%, 20.61% 92.45%, 28.13% 59.11%, 2.45% 36.55%, 36.48% 33.39%); background: #fff3fa; }
.disc .base { background: radial-gradient(circle at 36% 30%, #ffe3f2 0, #ff7cc4 24%, #ff2fa0 52%, #e0107f 82%, #b00a62 100%); }
.disc .holo { mix-blend-mode: soft-light; opacity: .6;
  background: conic-gradient(from var(--ang) at var(--mx) var(--my), #ff7ac6, #ffd27a, #8affb4, #7ad0ff, #b08aff, #ff7ac6); }
.disc .glitter { mix-blend-mode: screen; animation: twinkle 2.2s ease-in-out infinite alternate;
  background-image:
    radial-gradient(circle, #fff 0 .8px, transparent 1.6px),
    radial-gradient(circle, #fff 0 .6px, transparent 1.2px),
    radial-gradient(circle, #ffe9ff 0 1px, transparent 1.9px),
    radial-gradient(circle, #e9ffff 0 .7px, transparent 1.4px);
  background-size: 12px 14px, 8px 10px, 18px 20px, 24px 22px;
  background-position: calc(var(--gx) * 1) calc(var(--gy) * 1), calc(var(--gx) * -.6) 3px, 5px calc(var(--gy) * .8), calc(var(--gx) * .4) calc(var(--gy) * -.5); }
@keyframes twinkle { from { opacity: .55; filter: hue-rotate(0deg); } to { opacity: 1; filter: hue-rotate(40deg); } }
.disc .art { width: 100%; height: 100%; mix-blend-mode: multiply; }
.disc .scratch { opacity: .5;
  background:
    linear-gradient(112deg, transparent 38%, rgba(255, 255, 255, .85) 38.4%, transparent 39.2%),
    linear-gradient(64deg, transparent 61%, rgba(80, 50, 0, .45) 61.3%, transparent 62%),
    linear-gradient(151deg, transparent 22%, rgba(255, 255, 255, .7) 22.3%, transparent 23%),
    linear-gradient(97deg, transparent 72%, rgba(255, 255, 255, .8) 72.3%, transparent 73%); }


/* links are little holographic stickers too; the padding-top bridges the gap so hover never drops */
.menu { position: absolute; left: 10px; top: 100%; padding-top: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 9px;
  opacity: 0; transform: translateY(-6px); pointer-events: none; transition: .25s ease; }
.sticker:hover .menu, .sticker:focus-within .menu, .sticker.open .menu { opacity: 1; transform: none; pointer-events: auto; }
.tag { position: relative; display: flex; gap: 8px; align-items: center; white-space: nowrap; padding: 9px 18px; font: 700 14px/1 "Trebuchet MS", system-ui, sans-serif; letter-spacing: .02em; text-decoration: none;
  color: #3d0125; background: linear-gradient(115deg, #ffb3dc, #ff5db4 40%, #ff2fa0 72%, #ff8ccb); border: 3px solid rgba(255, 245, 251, .95); border-radius: 999px;
  filter: url(#worn-lite) drop-shadow(0 3px 5px rgba(0, 0, 0, .4)); transform: rotate(-2deg); transition: transform .25s cubic-bezier(.2, .8, .2, 1); isolation: isolate; --hx: 0%; }
.tag + .tag { transform: rotate(1.6deg); margin-left: 12px; }
.tag::before, .tag::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.tag::before { background: linear-gradient(105deg, transparent 15%, rgba(255, 110, 200, .55) 35%, rgba(110, 220, 255, .6) 50%, rgba(140, 255, 170, .55) 65%, transparent 85%);
  background-size: 260% 100%; background-position: var(--hx) 0; mix-blend-mode: soft-light; transition: background-position .6s ease; }
.tag::after { opacity: .7; mix-blend-mode: screen;
  background-image: radial-gradient(circle, #fff 0 .7px, transparent 1.4px), radial-gradient(circle, #fff 0 .5px, transparent 1.1px);
  background-size: 10px 12px, 7px 9px; background-position: 2px 3px, 5px 1px; }
.tag:hover { transform: rotate(0deg) scale(1.07); --hx: 100%; }
.tag.off { opacity: .5; pointer-events: none; }
.tag .arr { font-weight: 900; font-size: 16px; }

/* ---- controls ---------------------------------------------------------- */
#controls { position: fixed; right: 18px; bottom: 18px; z-index: 20; display: flex; gap: 8px; align-items: flex-end; }
#controls > button { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer; color: var(--ui); background: var(--ui-bg); backdrop-filter: blur(8px); opacity: .5; transition: opacity .2s, transform .2s; }
#controls > button:hover { opacity: 1; transform: translateY(-2px); }
#soundBtn .slash { display: none; }
#soundBtn.muted .slash { display: block; }
#soundBtn.muted .waves { display: none; }

#hint { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); margin: 0; color: var(--ui); font-size: 12px; letter-spacing: .08em; text-transform: lowercase; opacity: .55; transition: opacity .6s; pointer-events: none; text-align: center; padding: 0 70px; }
#hint.gone { opacity: 0; }
#empty { position: fixed; inset: 0; display: grid; place-items: center; color: var(--ui); }
#empty a { color: inherit; }

/* resting pages are drawn as one flat piece: no seams, crisper, cheaper */
.sheet.flat > .strip { width: var(--pw); }
.sheet.flat > .strip > .strip { display: none; }
.sheet.flat > .strip > .face.back img { left: 0 !important; }
.sheet.flat > .strip > .face.back .gutter { background-position: 0 0 !important; }


/* the 1.5px seam overlap must not stick out past the page edge */
.sheet.flat > .strip > .face, .strip:not(:has(> .strip)) > .face { right: 0; }

canvas.gl { position: absolute; inset: 0; pointer-events: none; }

/* ---- comment wall (under the sticker + its links; hover to open) -------- */
.wall { position: fixed; top: 272px; left: 16px; z-index: 19; width: 330px; opacity: .2; transition: opacity .35s ease; }
.wall:hover, .wall:focus-within, .wall.open { opacity: 1; }
.wall-tab { display: inline-block; padding: 8px 16px; border: 3px solid rgba(255, 245, 251, .95); border-radius: 999px; cursor: pointer;
  font: 700 13px/1 "Trebuchet MS", system-ui, sans-serif; letter-spacing: .03em; color: #3d0125; transform: rotate(-2deg);
  background: linear-gradient(115deg, #ffb3dc, #ff5db4 40%, #ff2fa0 72%, #ff8ccb); filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .4)); }
.wall-panel { display: none; flex-direction: column; margin-top: 8px; max-height: calc(100vh - 272px - 64px); padding: 16px 14px 12px; border-radius: 18px;
  color: #f4eaf0; background: rgba(22, 16, 24, .86); backdrop-filter: blur(14px); box-shadow: 0 14px 40px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 79, 176, .35); }
.wall:hover .wall-panel, .wall:focus-within .wall-panel, .wall.open .wall-panel { display: flex; }
.wall-head h2 { margin: 0 0 4px; font: 800 21px/1.1 "Trebuchet MS", system-ui, sans-serif; color: #ff3fa8; letter-spacing: .01em; text-shadow: 0 0 14px rgba(255, 63, 168, .35); }
.wall-head p { margin: 0 0 12px; font-size: 12px; line-height: 1.4; color: rgba(244, 234, 240, .68); }
.wall form { display: grid; gap: 8px; margin-bottom: 12px; }
.wall textarea, .wall-row input { width: 100%; padding: 9px 10px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 10px; background: rgba(255, 255, 255, .07); color: inherit; font: 13px/1.4 system-ui, sans-serif; resize: vertical; min-height: 0; }
.wall textarea { min-height: 62px; max-height: 160px; }
.wall textarea:focus, .wall-row input:focus { outline: none; border-color: #ff3fa8; background: rgba(255, 255, 255, .1); }
.wall-row { display: flex; gap: 8px; }
.wall-row input { flex: 1; }
.wall-row button { padding: 0 16px; border: 0; border-radius: 10px; cursor: pointer; font: 700 13px system-ui, sans-serif; color: #3d0125; background: linear-gradient(115deg, #ff8ccb, #ff2fa0); }
.wall-row button:disabled { opacity: .5; }
.wall-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
#wallMsg { margin: 0; min-height: 1em; font-size: 12px; } #wallMsg.ok { color: #ff8ccb; } #wallMsg.bad { color: #ff9b9b; }
.wall-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 10px; align-content: start; padding-right: 6px;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .22) transparent; }
.wall-list::-webkit-scrollbar { width: 5px; }
.wall-list::-webkit-scrollbar-track { background: transparent; }
.wall-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .2); border-radius: 4px; }
.wall-list::-webkit-scrollbar-thumb:hover { background: rgba(255, 63, 168, .6); }
.wall-item { padding: 9px 10px; border-radius: 12px; background: rgba(255, 255, 255, .06); }
.wall-item header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 3px; }
.wall-item b { font-size: 13px; color: #ffd0ea; overflow-wrap: anywhere; }
.wall-item time { font-size: 11px; color: rgba(244, 234, 240, .45); white-space: nowrap; }
.wall-item p { margin: 0; font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.wall-reply { margin-top: 8px; padding: 7px 9px; border-left: 3px solid #ff2fa0; border-radius: 4px 10px 10px 4px; background: rgba(255, 47, 160, .12); }
.wall-reply span { display: block; margin-bottom: 2px; font: 700 10px/1 system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #ff3fa8; }
.wall-empty { margin: 0; font-size: 12px; color: rgba(244, 234, 240, .5); }
body.preview #wall { display: none !important; }

.wall { pointer-events: none; }
.wall-tab, .wall-panel { pointer-events: auto; }
