:root {
  color-scheme: dark;
  --bg: #120f1f; --bg2: #1b1730; --card: rgba(255,255,255,.06); --card2: rgba(255,255,255,.1);
  --line: rgba(255,255,255,.12); --ink: #f6f2ff; --ink2: #c9c1e0; --muted: #918aa8;
  --accent: #ff7aa8; --accent2: #8f7bff; --accent-ink: #1a0f1f; --good: #63e6a4; --bad: #ff8a8a;
  --display: 'Unbounded', system-ui, sans-serif; --body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 18px; --shadow: 0 10px 40px rgba(0,0,0,.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f7f3fb; --bg2: #efe8f7; --card: rgba(40,20,80,.05); --card2: rgba(40,20,80,.09);
    --line: rgba(40,20,80,.12); --ink: #1d1530; --ink2: #4a4060; --muted: #7a7090;
    --accent: #e0457c; --accent2: #6a55e0; --accent-ink: #ffffff; --shadow: 0 10px 30px rgba(60,30,100,.12);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--body); }
body { overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input { font: inherit; color: var(--ink); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; line-height: 1.2; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.screen { min-height: 100dvh; padding: 18px 16px calc(96px + var(--safe-b)); max-width: 720px; margin: 0 auto; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px; border-radius: 999px;
  background: var(--card2); color: var(--ink); font-weight: 700; font-size: 16px; transition: transform .15s, opacity .15s, background .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; box-shadow: 0 8px 26px rgba(255,90,150,.35); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .4; box-shadow: none; cursor: default; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.link { color: var(--ink2); text-decoration: underline; text-underline-offset: 3px; font-size: 15px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  font-size: 14.5px; white-space: nowrap; transition: background .15s, transform .15s, border-color .15s; }
.chip:active { transform: scale(.96); }
.chip.on { background: color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); }
.chip small { color: var(--muted); font-size: 12px; }

/* living background of the first screens */
.sky { position: fixed; inset: 0; z-index: -1; background: radial-gradient(900px 600px at 80% -10%, rgba(143,123,255,.35), transparent 60%),
  radial-gradient(700px 500px at -10% 30%, rgba(255,122,168,.22), transparent 60%), linear-gradient(180deg, #1c1640, var(--bg) 70%); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .sky { background: radial-gradient(900px 600px at 80% -10%, rgba(143,123,255,.25), transparent 60%), radial-gradient(700px 500px at -10% 30%, rgba(255,122,168,.18), transparent 60%), var(--bg); } }
.sky i { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; opacity: .5; animation: drift 14s linear infinite; }
@keyframes drift { from { transform: translateY(20px); opacity: 0; } 20% { opacity: .6; } to { transform: translateY(-120px); opacity: 0; } }

/* the storyteller */
.teller { display: flex; gap: 12px; align-items: flex-end; margin: 6px 0 18px; }
.avatar { flex: 0 0 64px; width: 64px; height: 64px; border-radius: 50%; position: relative; background: linear-gradient(160deg, #ffc2d9, #8f7bff);
  box-shadow: 0 0 0 3px rgba(255,255,255,.12), 0 8px 30px rgba(143,123,255,.45); animation: breathe 4s ease-in-out infinite; overflow: hidden; }
.avatar svg { position: absolute; inset: 0; width: 100%; height: 100%; }
@keyframes breathe { 50% { transform: translateY(-2px) scale(1.02); } }
.bubble { position: relative; background: var(--card2); border: 1px solid var(--line); border-radius: 20px 20px 20px 6px; padding: 12px 16px; font-size: 16.5px;
  min-height: 48px; backdrop-filter: blur(8px); flex: 1; }
.bubble .name { display: block; font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .04em; margin-bottom: 2px; }

/* taste picker */
.search { position: relative; margin-bottom: 14px; }
.search input { width: 100%; height: 50px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); padding: 0 16px 0 44px; font-size: 16px; outline: none; }
.search input:focus { border-color: var(--accent2); }
.search::before { content: '⌕'; position: absolute; left: 16px; top: 11px; font-size: 20px; color: var(--muted); }
.results { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.results button { text-align: left; padding: 11px 14px; border-radius: 12px; background: var(--card); }
.results button small { color: var(--muted); margin-left: 6px; }
.shelf { margin: 0 -16px 14px; }
.shelf h3 { font-family: var(--body); font-size: 14px; font-weight: 700; color: var(--ink2); padding: 0 16px 8px; display: flex; align-items: center; gap: 6px; }
.shelf .row { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 4px; scrollbar-width: none; }
.shelf .row::-webkit-scrollbar { display: none; }
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 12px 16px calc(14px + var(--safe-b));
  background: linear-gradient(180deg, transparent, var(--bg) 16px); }
.dock .inner { max-width: 720px; margin: 0 auto; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.slot { min-height: 46px; border-radius: 14px; border: 1.5px dashed var(--line); display: flex; align-items: center; justify-content: center; padding: 4px 8px;
  font-size: 13px; color: var(--muted); text-align: center; line-height: 1.2; transition: all .25s; }
.slot.filled { border-style: solid; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--ink); font-weight: 600; animation: pop .3s; }
@keyframes pop { 0% { transform: scale(.8); } 70% { transform: scale(1.05); } }
.moods { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.mood { min-height: 74px; border-radius: 16px; padding: 12px; display: flex; align-items: flex-end; font-weight: 700; text-align: left; border: 2px solid transparent; }
.mood.on { border-color: #fff; }

/* phrase */
.field { width: 100%; min-height: 54px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); padding: 14px 16px; font-size: 16px; outline: none; }
.field:focus { border-color: var(--accent2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 2px 0; }
.label { font-weight: 700; margin: 18px 0 8px; font-size: 15px; }
.toggle { display: inline-flex; background: var(--card); border-radius: 999px; padding: 3px; border: 1px solid var(--line); }
.toggle button { padding: 9px 18px; border-radius: 999px; color: var(--ink2); font-weight: 600; }
.toggle button.on { background: var(--card2); color: var(--ink); }
.namebox { display: flex; gap: 8px; align-items: center; }
.namebox input { flex: 1; }
.round { width: 52px; height: 52px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-size: 20px; flex: 0 0 52px; }

/* assemble */
.tropes { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.trope { padding: 14px 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); font-weight: 600; opacity: 0; transform: translateX(-24px); animation: slidein .5s forwards; }
@keyframes slidein { to { opacity: 1; transform: none; } }
.archcard { border-radius: 24px; padding: 22px 20px; margin: 18px 0; background: linear-gradient(150deg, rgba(255,122,168,.35), rgba(143,123,255,.35)), var(--bg2);
  border: 1px solid rgba(255,255,255,.18); box-shadow: var(--shadow); opacity: 0; animation: slidein .6s forwards; transform: translateY(16px); }
.archcard .k { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink2); }
.archcard h2 { font-size: 24px; margin: 6px 0 10px; }
.writing { display: flex; align-items: center; gap: 12px; color: var(--ink2); margin: 18px 0; }
.quill { width: 30px; height: 30px; display: inline-block; animation: write 1.2s ease-in-out infinite; }
@keyframes write { 50% { transform: translate(6px, -2px) rotate(-8deg); } }

/* reader */
.reader { position: fixed; inset: 0; background: #000; overflow: hidden; user-select: none; color: #fff; }
.reader .bg { position: absolute; inset: -4%; background-size: cover; background-position: center; transition: opacity .5s; animation: parallax 30s ease-in-out infinite alternate; }
@keyframes parallax { to { transform: translate(-1.5%, -1%) scale(1.03); } }
.reader .bg.fade { opacity: 0; }
.reader .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.45) 0%, transparent 18%, transparent 45%, rgba(0,0,0,.65) 100%); pointer-events: none; }
.reader .top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 8px; z-index: 6; }
.reader .top button { width: 42px; height: 42px; border-radius: 50%; background: rgba(0,0,0,.35); backdrop-filter: blur(6px); font-size: 18px; flex: 0 0 42px; position: relative; }
.reader .top button .count { position: absolute; top: -3px; right: -3px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 18px; height: 18px; line-height: 18px; }
.reader .progress { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,.2); overflow: hidden; }
.reader .progress i { display: block; height: 100%; background: #fff; transition: width .4s; }
.portraits { position: absolute; left: 0; right: 0; bottom: 30%; height: 62%; pointer-events: none; z-index: 2; }
.portrait { position: absolute; bottom: 0; height: 100%; width: min(86vw, 560px); transition: all .4s; filter: drop-shadow(0 10px 30px rgba(0,0,0,.5)); }
.portrait img, .portrait svg { width: 100%; height: 100%; display: block; object-fit: contain; object-position: center bottom; }
.portrait.left { left: -14%; } .portrait.right { right: -14%; } .portrait.center { left: 50%; transform: translateX(-50%); }
@media (min-width: 700px) { .portrait.left { left: 4%; } .portrait.right { right: 4%; } }
.portrait.dim { filter: brightness(.55) drop-shadow(0 10px 30px rgba(0,0,0,.5)); }
.portrait.enter { opacity: 0; transform: translateY(20px); }
.portrait.center.enter { transform: translate(-50%, 20px); }
.item { position: absolute; bottom: 33%; width: 74px; height: 74px; z-index: 4; transform: translateX(-50%); border-radius: 50%;
  filter: drop-shadow(0 0 14px rgba(255,220,140,.9)); animation: bob 2.4s ease-in-out infinite, glint 4s ease-in-out infinite; pointer-events: auto; }
.item img, .item svg { width: 100%; height: 100%; object-fit: contain; }
.item.fg_left { left: 32%; } .item.fg_center { left: 50%; } .item.fg_right { left: 68%; }
.item.take { animation: take .6s forwards; }
@keyframes bob { 50% { margin-bottom: 8px; } }
@keyframes glint { 0%, 80%, 100% { filter: drop-shadow(0 0 12px rgba(255,220,140,.8)); } 90% { filter: drop-shadow(0 0 26px rgba(255,255,220,1)); } }
@keyframes take { to { left: 88%; bottom: 92%; width: 20px; height: 20px; opacity: 0; } }
.box { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 0 12px calc(14px + var(--safe-b)); }
.box .inner { max-width: 760px; margin: 0 auto; background: rgba(14,10,28,.82); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.14);
  border-radius: 22px; padding: 16px 18px 18px; min-height: 140px; }
.box .who { font-family: var(--display); font-size: 13px; letter-spacing: .06em; color: var(--accent); margin-bottom: 6px; min-height: 18px; }
.box .text { font-size: 18.5px; line-height: 1.55; min-height: 58px; }
.box .text.narr { color: #e9e4ff; font-style: italic; }
.box .next { position: absolute; right: 30px; bottom: calc(24px + var(--safe-b)); font-size: 14px; opacity: .6; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .15; } }
.choices { display: flex; flex-direction: column; gap: 10px; max-width: 760px; margin: 0 auto 10px; }
.choices .q { text-align: center; font-weight: 700; text-shadow: 0 2px 10px #000; margin-bottom: 2px; }
.choice { text-align: left; padding: 15px 18px; border-radius: 18px; background: rgba(255,255,255,.92); color: #1a1230; font-weight: 700; font-size: 16.5px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); animation: slidein .35s forwards; opacity: 0; transform: translateY(10px); }
.choice:disabled { background: rgba(255,255,255,.45); color: #3b3352; }
.choice small { display: block; font-weight: 600; font-size: 12.5px; opacity: .7; margin-top: 2px; }
.choice .pct { float: right; font-size: 13px; opacity: .7; }
.major { text-align: center; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.wait { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 8; background: rgba(0,0,0,.55); text-align: center; padding: 24px; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 70%; overflow: auto; z-index: 9; background: rgba(14,10,28,.96); border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(18px + var(--safe-b)); border-top: 1px solid rgba(255,255,255,.14); animation: up .25s; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { font-size: 15px; margin-bottom: 10px; }
.sheet .logline { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 15px; }
.sheet .logline b { color: var(--accent); font-weight: 700; margin-right: 6px; }
.inv { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.inv .ic { width: 52px; height: 52px; flex: 0 0 52px; }

/* a big picture (cg) over the whole screen: no portraits, a lighter shade; 👁 hides the text to look at it */
.reader .box, .reader .shade, .portraits { transition: opacity .3s; }
.reader.cg .bg { inset: 0; animation: none; }
.reader.cg .portraits { opacity: 0; }
.reader.cg .shade { background: linear-gradient(180deg, rgba(0,0,0,.35) 0%, transparent 14%, transparent 70%, rgba(0,0,0,.55) 100%); }
.reader.peek .box, .reader.peek .shade { opacity: 0; pointer-events: none; }

/* big screens (phones untouched): sprites stand from the bottom edge as in a visual novel, the text box takes the room */
@media (min-width: 1000px) and (min-aspect-ratio: 5/4) {
  .portraits { bottom: 0; height: 94%; }
  .portrait { width: min(46vw, 94vh); }
  .portrait.left { left: 3%; } .portrait.right { right: 3%; }
  .box { padding: 0 28px 22px; }
  .box .inner { max-width: min(1240px, 82vw); padding: 22px 30px 26px; min-height: 180px; }
  .box .who { font-size: 15px; }
  .box .text { font-size: 22px; line-height: 1.6; min-height: 88px; }
  .choices { max-width: min(1000px, 70vw); }
  .choice { font-size: 18px; padding: 17px 22px; }
}

/* chapter end */
.end { text-align: center; padding-top: 8vh; }
.end .cliff { font-family: var(--display); font-size: 22px; line-height: 1.35; margin: 14px 0 22px; }
.end .stack { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel .t { font-weight: 700; margin-bottom: 6px; }
.thumbs { display: flex; gap: 10px; }
.thumbs button { flex: 1; min-height: 52px; border-radius: 14px; background: var(--card2); font-size: 22px; }
.thumbs button.on { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.countdown { font-family: var(--display); font-size: 26px; margin: 4px 0; }

/* lists */
.head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 16px; gap: 10px; }
.head h1 { font-size: 22px; }
.seg { display: inline-flex; background: var(--card); border-radius: 999px; padding: 3px; }
.seg button { padding: 7px 14px; border-radius: 999px; font-size: 14px; color: var(--ink2); font-weight: 600; }
.seg button.on { background: var(--card2); color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card { border-radius: var(--radius); overflow: hidden; background: var(--card); border: 1px solid var(--line); display: flex; flex-direction: column; text-align: left; color: var(--ink); }
.card .cover { aspect-ratio: 4 / 5; background-size: cover; background-position: center; position: relative; }
.card .cover .ttl { position: absolute; left: 0; right: 0; bottom: 0; padding: 30px 12px 10px; font-family: var(--display); font-size: 15px; line-height: 1.25; color: #fff;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.75)); }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .hook { font-size: 13.5px; color: var(--ink2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { font-size: 12px; color: var(--muted); margin-top: auto; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--card2); color: var(--ink2); }
.empty { text-align: center; padding: 40px 10px; color: var(--ink2); }
.hero-card { border-radius: 24px; overflow: hidden; position: relative; min-height: 280px; background-size: cover; background-position: center; display: flex; align-items: flex-end; margin-bottom: 16px; }
.hero-card .in { padding: 60px 18px 18px; width: 100%; background: linear-gradient(180deg, transparent, rgba(0,0,0,.8)); color: #fff; }
.hero-card h1 { font-size: 26px; margin-bottom: 8px; }
.chap { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.chap .st { font-size: 13px; color: var(--muted); text-align: right; }
.row2 { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.small { font-size: 13px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around; padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--muted); font-size: 12px; font-weight: 600; padding: 4px 18px; min-width: 64px; }
.tabbar a span { font-size: 20px; line-height: 1.2; }
.tabbar a.on { color: var(--ink); }
.toast { pointer-events: none; position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 18px;
  border-radius: 14px; font-size: 14.5px; font-weight: 600; max-width: 90vw; text-align: center; }
.cookie { position: fixed; left: 8px; right: 8px; top: calc(8px + env(safe-area-inset-top, 0px)); z-index: 40; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; font-size: 13px; color: var(--ink2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; max-width: 720px; margin: 0 auto; }
.cookie button { margin-left: auto; padding: 6px 12px; border-radius: 999px; background: var(--card2); font-weight: 700; font-size: 13px; }
.footer { text-align: center; font-size: 12px; color: var(--muted); margin: 30px 0 10px; }

body.reading .cookie, body.reading .toast { display: none; }
body.reading .toast.keep { display: block; top: calc(64px + env(safe-area-inset-top, 0px)); bottom: auto; }
@media (min-width: 700px) { .shelf .row { flex-wrap: wrap; overflow: visible; } }
