/* YOKAIFIED 妖怪化 · a specimen scroll at night: Prussian blue, sumi, washi, vermilion, a little gold */
:root {
  --night: #0b1026; --prussian: #1d3563; --sumi: #0a0a0f; --washi: #efe4cf; --washi-dim: #cdbf9f;
  --vermilion: #c7372f; --gold: #c8a24a; --ink-soft: rgba(239, 228, 207, 0.72);
  --display: "Shippori Mincho B1", "Hiragino Mincho ProN", serif;
  --ui: "Zen Kaku Gothic New", "Hiragino Sans", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--washi); font: 500 16px/1.45 var(--ui); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; }
html:lang(ja), html:lang(ko) { word-break: keep-all; overflow-wrap: anywhere; } /* break between words, never inside one */
#grain { position: fixed; inset: 0; pointer-events: none; opacity: .16; mix-blend-mode: overlay; z-index: 5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 .95  0 0 0 0 .85  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }
body::before { content: ""; position: fixed; inset: 0; background: radial-gradient(120% 80% at 50% 0%, #22306a 0%, var(--night) 55%, #05070f 100%); z-index: -1; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: calc(18px + var(--safe-t)) 18px calc(18px + var(--safe-b)); overflow-y: auto; animation: in .5s ease both; }
.screen[hidden] { display: none; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* the hook */
.brand { display: flex; flex-direction: column; align-items: center; margin-top: 4px; }
.brand .kanji { font: 800 clamp(44px, 14vw, 64px)/1 var(--display); letter-spacing: .06em; color: var(--washi); text-shadow: 0 0 22px rgba(200, 162, 74, .35); }
.brand .latin { font: 700 12px var(--ui); letter-spacing: .5em; color: var(--gold); margin-top: 6px; padding-left: .5em; }
.parade { width: 100vw; overflow: hidden; margin-top: 8px; mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.parade-track { display: flex; gap: 10px; width: max-content; animation: parade 48s linear infinite; }
.parade-track img { width: 150px; height: 225px; object-fit: cover; border-radius: 6px; border: 1px solid rgba(200, 162, 74, .35); box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
@keyframes parade { to { transform: translateX(-50%); } }
.parade-note { margin: -4px 0 0; font-size: 11px; letter-spacing: .08em; color: var(--washi-dim); opacity: .7; }
.hook-line { margin: 6px 0 0; text-align: center; font: 800 clamp(24px, 7.4vw, 34px)/1.25 var(--display); max-width: 15em; }
.langs { display: flex; gap: 8px; margin-top: auto; }
.langs button { background: none; border: 1px solid rgba(239, 228, 207, .25); border-radius: 999px; padding: 4px 12px; font-size: 12px; opacity: .75; cursor: pointer; }
.langs button[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); opacity: 1; }

/* buttons */
.stack { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; }
.btn { width: 100%; max-width: 360px; min-height: 52px; border-radius: 14px; border: 0; cursor: pointer; font: 700 17px var(--ui); display: grid; place-items: center; }
.btn.primary { background: linear-gradient(180deg, #d9453b, var(--vermilion)); color: #fff7ea; box-shadow: 0 8px 26px rgba(199, 55, 47, .45); }
.btn.primary:disabled { opacity: .4; box-shadow: none; }
.btn.ghost { background: rgba(239, 228, 207, .08); border: 1px solid rgba(239, 228, 207, .28); }
.btn.text { background: none; min-height: 40px; font-size: 14px; opacity: .75; }
.btn:active { transform: scale(.98); }

/* consent */
.title { margin: 24px 0 6px; font: 800 26px/1.3 var(--display); text-align: center; }
.check { display: flex; gap: 12px; align-items: flex-start; max-width: 360px; padding: 14px; border-radius: 14px; background: rgba(239, 228, 207, .06); border: 1px solid rgba(239, 228, 207, .18); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--vermilion); flex: none; margin-top: 2px; }
.truth { max-width: 360px; font-size: 13px; color: var(--ink-soft); text-align: center; margin: 4px 0 8px; }

/* the two doors */
.path { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.path[hidden], .or[hidden], .region-note[hidden] { display: none; }
.region-note { max-width: 360px; margin: 6px 0 0; text-align: center; font: 600 15px/1.4 var(--ui); color: var(--washi); }
.or { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 360px; font-size: 12px; letter-spacing: .14em; color: var(--washi-dim); text-transform: uppercase; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: rgba(239, 228, 207, .2); }
.mask-door { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 360px; padding: 12px 14px; border-radius: 14px; cursor: pointer; text-align: left;
  background: rgba(239, 228, 207, .06); border: 1px solid rgba(200, 162, 74, .45); }
.mask-door.only { background: linear-gradient(180deg, #d9453b, var(--vermilion)); border-color: transparent; box-shadow: 0 8px 26px rgba(199, 55, 47, .45); }
.mask-k { flex: none; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 10px; border: 2px solid var(--vermilion); color: var(--washi); font: 800 26px var(--display); background: rgba(10, 10, 15, .35); }
.mask-door.only .mask-k { border-color: #fff7ea; }
.mask-txt { display: flex; flex-direction: column; gap: 2px; }
.mask-txt b { font: 700 16px var(--ui); }
.mask-txt small { font-size: 12px; color: var(--ink-soft); }
.mask-door.only .mask-txt small { color: #ffe9dc; }

/* Mask mode: the builder */
.doll-frame { flex: none; width: min(36vw, 140px); aspect-ratio: 4 / 5; border-radius: 4px; overflow: hidden; border: 5px solid #2a2016;
  box-shadow: 0 0 0 1px var(--gold), 0 12px 32px rgba(0, 0, 0, .55); background: radial-gradient(circle at 50% 40%, #f3ead8, #d9c9a6); }
.doll-frame #doll, .doll-frame svg { width: 100%; height: 100%; display: block; }
.builder { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.row-l { margin: 4px 0 0; text-align: center; font: 700 10px var(--ui); letter-spacing: .18em; text-transform: uppercase; color: var(--washi-dim); }
.row button { cursor: pointer; border: 2px solid rgba(239, 228, 207, .2); background: rgba(29, 53, 99, .45); padding: 0; }
.row button[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(200, 162, 74, .35); }
.row.chips button { padding: 7px 16px; border-radius: 999px; font: 700 14px var(--ui); }
.row.chips button[aria-pressed="true"] { background: rgba(200, 162, 74, .22); }
.row.heads button { width: 50px; height: 53px; border-radius: 12px; background: radial-gradient(circle at 50% 40%, #f3ead8, #d9c9a6); overflow: hidden; }
.row.heads button svg { width: 100%; height: 100%; display: block; }
.row.swatches button { width: 34px; height: 34px; border-radius: 50%; border-color: rgba(239, 228, 207, .35); }
.row.swatches button[aria-pressed="true"] { border-color: var(--washi); box-shadow: 0 0 0 3px var(--gold); }
[data-screen="mask"] .stack { position: sticky; bottom: calc(-18px - var(--safe-b)); padding: 14px 0 calc(8px + var(--safe-b)); background: linear-gradient(180deg, transparent, var(--night) 35%); }
[data-screen="mask"] .title { margin-top: 8px; }

/* camera */
.viewfinder { position: relative; width: min(88vw, 360px); aspect-ratio: 3 / 4; border-radius: 22px; overflow: hidden; margin-top: 18px; border: 1px solid rgba(200, 162, 74, .4); background: #000; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.oval { position: absolute; inset: 12% 18% 20%; border: 2px dashed rgba(239, 228, 207, .55); border-radius: 50%; }
.hint { font-size: 13px; color: var(--ink-soft); }
.shutter { width: 76px; height: 76px; border-radius: 50%; border: 4px solid var(--washi); background: var(--vermilion); cursor: pointer; margin-top: 4px; box-shadow: 0 0 0 6px rgba(199, 55, 47, .25); }

/* preview + Trial */
.scroll-frame { position: relative; width: min(56vw, 230px); aspect-ratio: 4 / 5; margin-top: 6px; border-radius: 4px; overflow: hidden;
  border: 6px solid #2a2016; box-shadow: 0 0 0 1px var(--gold), 0 14px 40px rgba(0, 0, 0, .6); background: var(--washi); }
.scroll-frame canvas { width: 100%; height: 100%; display: block; }
.ink-veil { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, transparent 0%, transparent 30%, var(--washi) 31%); animation: spread 2.4s ease-out forwards; }
@keyframes spread { from { background-size: 100% 100%; opacity: 1; } to { background-size: 400% 400%; opacity: 0; } }
.taking-shape { margin: 0; font: 600 14px var(--display); color: var(--gold); letter-spacing: .08em; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .45; } }
.trial { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
.dots { display: flex; gap: 8px; justify-content: center; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(239, 228, 207, .22); }
.dots i.on { background: var(--gold); }
.ask { margin: 2px 0 2px; text-align: center; font: 800 clamp(20px, 6vw, 26px)/1.3 var(--display); }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.answers button { min-height: 64px; padding: 10px; border-radius: 14px; border: 1px solid rgba(239, 228, 207, .22); background: rgba(29, 53, 99, .55); cursor: pointer; font: 600 14px/1.3 var(--ui); text-align: left; }
.answers button:active, .answers button.picked { border-color: var(--gold); background: rgba(200, 162, 74, .22); }
.morrow-line { min-height: 2.6em; margin: 0; text-align: center; font: 600 14px/1.35 var(--ui); color: #ff8f86; }
.morrow-line:not(:empty)::before { content: "MORROW  "; font-size: 10px; letter-spacing: .2em; color: var(--vermilion); }

/* reveal */
.plate-wrap { position: relative; width: min(92vw, 400px); aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; flex: none;
  border: 1px solid rgba(200, 162, 74, .55); box-shadow: 0 18px 50px rgba(0, 0, 0, .6); background: #120d08; }
.plate { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.03); }
.unroll { position: absolute; inset: 0; background: linear-gradient(180deg, #2a2016, #120d08); transform-origin: top; animation: unroll 1.6s cubic-bezier(.6, 0, .2, 1) .2s forwards; }
@keyframes unroll { to { transform: scaleY(0); } }
.ai-label { position: absolute; left: 8px; bottom: 8px; font: 700 10px var(--ui); letter-spacing: .12em; padding: 3px 7px; border-radius: 6px; background: rgba(10, 10, 15, .7); color: var(--washi-dim); }
.mock-note { max-width: 380px; margin: -4px 0 0; padding: 8px 10px; border-radius: 10px; background: rgba(199, 55, 47, .15); border: 1px dashed rgba(199, 55, 47, .6); font-size: 12px; text-align: center; }
.entry { width: 100%; max-width: 400px; padding: 16px; border-radius: 14px; background: linear-gradient(180deg, rgba(239, 228, 207, .96), rgba(214, 199, 166, .96)); color: #1b1410; animation: in .6s ease 1.7s both; }
.entry-no { margin: 0; font: 700 11px var(--ui); letter-spacing: .22em; color: #7a5a2a; }
.entry-name { margin: 4px 0 10px; font: 800 22px/1.25 var(--display); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0; font-size: 14px; }
.fields div { min-width: 0; }
.fields dt { font: 700 10px var(--ui); letter-spacing: .14em; text-transform: uppercase; color: #7a5a2a; }
.fields dd { margin: 2px 0 0; font: 600 15px/1.3 var(--display); }
.fields div.wide { grid-column: span 2; }
.rarity { margin: 10px 0 0; font-size: 13px; }
.rarity b { color: var(--vermilion); letter-spacing: .12em; }
.morrow-says { cursor: pointer; margin: 10px 0 0; padding: 10px 12px; border-left: 4px solid var(--vermilion); background: rgba(199, 55, 47, .08); font: 600 15px/1.4 var(--display); }
.morrow-says::after { content: " ◂))"; font: 700 12px var(--ui); color: var(--vermilion); opacity: .7; }
.fiction { margin: 10px 0 0; font-size: 11px; color: #6b5a44; }
.door { display: flex; align-items: center; gap: 10px; max-width: 400px; width: 100%; margin: 4px 0 8px; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(200, 162, 74, .45); color: var(--washi); text-decoration: none; font-size: 14px; }
.door-k { font: 800 26px var(--display); color: var(--gold); }

/* the share formats */
.formats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.formats .btn { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; padding: 0 8px; }
.fmt-k { color: var(--gold); font-size: 14px; }
.parade-go { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: inherit; }
#clip.ready { border-color: var(--gold); background: rgba(200, 162, 74, .2); }

/* a friend picks */
.pick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; max-width: 400px; }
.pick-grid button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: none; cursor: pointer; aspect-ratio: 1; }
.pick-grid button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-grid button.picked { border-color: var(--gold); }

/* the friend loop */
.pick-grid button { position: relative; }
.pick-grid button span { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 3px 4px; font: 700 9px/1.15 var(--ui); color: var(--washi); background: linear-gradient(transparent, rgba(5, 7, 15, .9)); }
.picked-by { margin: 8px 0 0; font: 700 11px var(--ui); letter-spacing: .08em; color: var(--vermilion); }
.picked-by[hidden] { display: none; }
.new-drop { display: inline-flex; align-items: center; gap: 8px; margin: 10px 0 0; padding: 5px 12px 5px 6px; border-radius: 8px; background: var(--vermilion); color: #efe4cf; font: 800 12px var(--ui); letter-spacing: .12em; }
.new-drop b { font: 800 16px/1 "Shippori Mincho B1", serif; padding: 3px 6px; border: 1.5px solid #efe4cf; border-radius: 5px; }
.new-drop[hidden] { display: none; }
.next-wrap { width: min(66vw, 270px); aspect-ratio: 1; margin-top: 18px; }
.next-plate { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.85) brightness(.8); }
[data-screen="pick"] .btn[hidden] { display: none; }
/* 巻物 · the group's scroll: one row per person, the next row is the empty place waiting for you */
[data-screen="scroll"] .brand .kanji { font-size: clamp(34px, 10vw, 46px); }
[data-screen="scroll"] .title { margin-top: 10px; }
.scroll-list { list-style: none; margin: 4px 0 0; padding: 0; width: 100%; max-width: 380px; display: grid; gap: 8px; }
.scroll-list li { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; min-width: 0; padding: 6px 10px 6px 6px; border-radius: 12px; background: rgba(239, 228, 207, .06); border: 1px solid rgba(239, 228, 207, .16); }
.scroll-list li img, .scroll-list li i { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; display: block; }
.scroll-list li i { display: grid; place-items: center; font: 800 26px/1 var(--display); font-style: normal; color: var(--gold); border: 1.5px dashed rgba(200, 162, 74, .6); }
.scroll-list li span { min-width: 0; }
.scroll-list li b { display: block; font: 700 16px/1.3 var(--ui); overflow-wrap: anywhere; }
.scroll-list li small { display: block; font-size: 12.5px; line-height: 1.35; color: var(--ink-soft); }
.scroll-list li.me { border-color: var(--gold); }
.scroll-list li.you { border-style: dashed; animation: scrollYou 1.8s ease-in-out infinite; }
@keyframes scrollYou { 50% { background: rgba(200, 162, 74, .14); } }
@media (prefers-reduced-motion: reduce) { .scroll-list li.you { animation: none; } }
.scroll-name { display: grid; gap: 6px; width: 100%; max-width: 360px; font: 700 12px var(--ui); letter-spacing: .06em; color: var(--ink-soft); }
.scroll-name input { min-height: 48px; border-radius: 12px; border: 1px solid rgba(239, 228, 207, .3); background: rgba(239, 228, 207, .08); color: var(--washi); font: 700 17px var(--ui); padding: 0 14px; }
.scroll-name[hidden], [data-screen="scroll"] .btn[hidden] { display: none; }

/* the door to the app */
#doorSheet { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 18px; background: rgba(5, 7, 15, .9); backdrop-filter: blur(6px); animation: in .35s ease both; }
#doorSheet[hidden], .door-carry[hidden] { display: none; }
.door-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.door-art { position: relative; width: min(64vw, 250px); aspect-ratio: 1; }
.door-art img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid rgba(200, 162, 74, .6); box-shadow: 0 18px 44px rgba(0, 0, 0, .6); }
.door-seal { position: absolute; right: -10px; top: -12px; padding: 6px 9px; border-radius: 8px; background: var(--vermilion); border: 2px solid var(--washi); font: 800 26px/1 var(--display); color: var(--washi); transform: rotate(5deg); }
.door-title { margin: 6px 0 0; font: 800 22px/1.3 var(--display); }
.door-sub { margin: 0 0 6px; font-size: 14px; color: var(--ink-soft); }
.door-code-l { margin: 0; font: 700 10px var(--ui); letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.door-code { display: flex; gap: 10px; align-items: center; justify-content: center; }
.door-code b { font: 700 28px ui-monospace, monospace; letter-spacing: .22em; color: var(--washi); }
.door-code .btn { width: auto; min-height: 40px; padding: 0 14px; font-size: 14px; }
#getApp, #openApp { text-decoration: none; }
#openApp { color: var(--gold); min-height: 36px; font-size: 13px; }

/* the parade figure: cutting your yokai out */
#figureWait { position: fixed; inset: 0; z-index: 21; display: grid; place-items: center; background: rgba(5, 7, 15, .9); backdrop-filter: blur(6px); }
#figureWait[hidden] { display: none; }
.fw-card { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px; text-align: center; }
.fw-k { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 12px; background: var(--vermilion); border: 2px solid var(--washi); font: 800 34px var(--display); color: var(--washi); animation: breathe 1.4s ease-in-out infinite; }
.fw-card p { margin: 0; font: 700 15px/1.4 var(--ui); color: var(--washi); max-width: 280px; }

/* the save sheet */
#saveSheet { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 18px; background: rgba(5, 7, 15, .88); backdrop-filter: blur(6px); }
#saveSheet[hidden] { display: none; }
.save-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.save-media img, .save-media video { display: block; max-width: 100%; max-height: 62vh; border-radius: 10px; border: 1px solid rgba(200, 162, 74, .5); -webkit-touch-callout: default; }
.save-hint { margin: 0; text-align: center; font: 600 14px/1.4 var(--ui); color: var(--washi); }
.save-dl { text-decoration: none; }
.save-dl[hidden] { display: none; }

#toast { position: fixed; left: 50%; bottom: calc(26px + var(--safe-b)); transform: translateX(-50%); padding: 9px 16px; border-radius: 12px; background: rgba(10, 10, 15, .85); font-size: 13px; z-index: 10; }
@media (prefers-reduced-motion: reduce) { .parade-track, .unroll, .ink-veil, .taking-shape { animation: none; } .unroll { display: none; } }

/* the cold open (10-02): three paintings, crossfading, slowly pushing in */
.cold { position: fixed; inset: 0; z-index: 90; background: #05060c; cursor: pointer; transition: opacity .45s; animation: coldSafety 0s linear 8s forwards; }
@keyframes coldSafety { to { visibility: hidden; pointer-events: none; } } /* if the script never runs, the page still opens */
.cold.out { opacity: 0; }
.cold img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.06); transition: opacity .6s ease, transform 2.4s ease-out; }
.cold img.on { opacity: 1; transform: scale(1); }

/* the painted scroll above the roster (10-02) */
.scroll-head { width: 100%; max-width: 420px; height: auto; aspect-ratio: 3 / 2; border-radius: 12px; display: block; margin: 2px auto 0; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.scroll-head[hidden] { display: none; }
