:root {
  --paper: #f4eedf;
  --ink: #23201b;
  --ink2: #5b5348;
  --blue: #1b2b6b;
  --red: #b8231f;
  --hand: "LXGW WenKai", "Kaiti SC", "STKaiti", serif;
  --serif: "Noto Serif SC", "Songti SC", serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0c10; color: #f3efe6; font-family: var(--serif); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; background: transparent; }
body.dragging #gl { cursor: grabbing; }
body.hovering #gl { cursor: pointer; }

/* film look */
#grain { position: fixed; inset: -50%; pointer-events: none; opacity: .16; mix-blend-mode: overlay; z-index: 2;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 0.9s steps(6) infinite; }
@keyframes grain { 0% { transform: translate(0, 0) } 20% { transform: translate(-4%, 3%) } 40% { transform: translate(3%, -2%) } 60% { transform: translate(-2%, -4%) } 80% { transform: translate(4%, 2%) } 100% { transform: translate(0, 0) } }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 2; background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 55%, rgba(0,0,0,.42) 100%); }

/* intro */
#intro { position: fixed; inset: 0; z-index: 20; background: #07080b; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; cursor: pointer; transition: opacity 1.6s ease; text-align: center; padding: 24px; }
#intro .place { font-family: var(--hand); font-size: clamp(22px, 3.2vw, 34px); letter-spacing: .3em; margin: 0; color: #efe7d4; }
#intro .line { font-family: var(--hand); font-size: 18px; color: #b8ae9c; margin: 0; }
#intro .hint { position: absolute; bottom: 9vh; margin: 0; font-size: 13px; letter-spacing: .25em; color: #8f877a; }
#intro .hint span::before { content: ""; display: inline-block; width: 22px; height: 1px; background: currentColor; vertical-align: middle; margin-right: 10px; }
#intro .loading { position: absolute; bottom: 9vh; margin: 0; font-size: 13px; color: #6f685e; letter-spacing: .2em; }
body:not([data-state="loading"]) #intro .loading { display: none; }
body[data-state="loading"] #intro .hint { display: none; }
#intro::after { content: ""; position: absolute; left: 50%; bottom: 30vh; width: 120px; height: 2px; transform: translateX(-50%); background: #ffd6a0; filter: blur(3px); opacity: .55; box-shadow: 0 0 30px 6px rgba(255,200,140,.35); }
body:not([data-state="intro"]):not([data-state="loading"]) #intro { opacity: 0; pointer-events: none; }

/* hover label: a hairline + handwriting */
#label { position: fixed; z-index: 6; pointer-events: none; opacity: 0; transition: opacity .15s; font-family: var(--hand); font-size: 16px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8), 0 0 12px rgba(0,0,0,.5); white-space: nowrap; display: flex; align-items: center; gap: 8px; }
#label i { width: 26px; height: 1px; background: #fff; box-shadow: 0 0 3px rgba(0,0,0,.8); }
#label span small { font-size: 13px; opacity: .78; margin-left: 6px; }
body.hovering #label { opacity: 1; }

#guide { position: fixed; left: 22px; bottom: 18px; margin: 0; z-index: 5; font-size: 12px; letter-spacing: .08em; color: rgba(255,255,255,.62); text-shadow: 0 1px 2px rgba(0,0,0,.7); pointer-events: none; transition: opacity .6s; }
#timeLine { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); margin: 0; z-index: 5; font-family: var(--hand); font-size: 15px; color: rgba(255,245,225,.85); text-shadow: 0 1px 3px rgba(0,0,0,.8); pointer-events: none; opacity: 0; transition: opacity 1s; }
#timeLine.show { opacity: 1; }
body[data-state="loading"] #guide, body[data-state="intro"] #guide, body.focused #guide { opacity: 0; }

/* HUD */
#hud { position: fixed; top: 0; left: 0; right: 0; z-index: 8; display: flex; justify-content: space-between; align-items: flex-start; padding: 16px 22px; pointer-events: none; transition: opacity .6s; }
body[data-state="loading"] #hud, body[data-state="intro"] #hud { opacity: 0; }
#hud > * { pointer-events: auto; }
#hud .title { font-family: var(--hand); font-size: 18px; letter-spacing: .2em; color: rgba(255,248,232,.9); text-shadow: 0 1px 3px rgba(0,0,0,.7); }
#hud nav { display: flex; gap: 18px; align-items: center; font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
#hud nav a, #hud nav button { color: rgba(255,255,255,.78); text-decoration: none; }
#hud nav a:hover, #hud nav button:hover { color: #fff; }
#hud .times { display: flex; gap: 10px; }
#hud .times button { opacity: .55; position: relative; }
#hud .times button[aria-pressed="true"] { opacity: 1; }
#hud .times button[aria-pressed="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px; background: #fff; }
#hud b { font-weight: 600; color: #ffd98a; }

#back { position: fixed; top: 54px; left: 22px; z-index: 9; font-size: 14px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
#back:hover { text-decoration: underline; text-underline-offset: 4px; }

/* story card: a sheet of paper */
#panel { position: fixed; right: 26px; top: 50%; transform: translateY(-50%) rotate(.4deg); width: min(380px, calc(100vw - 40px)); max-height: calc(100vh - 140px); overflow: auto; z-index: 10;
  background: var(--paper); color: var(--ink); padding: 26px 26px 22px; box-shadow: 0 18px 50px rgba(0,0,0,.45), 0 2px 0 rgba(0,0,0,.05); border-radius: 2px;
  background-image: repeating-linear-gradient(transparent 0 29px, rgba(27,43,107,.09) 29px 30px); background-position: 0 14px; animation: paperIn .45s cubic-bezier(.2,.8,.2,1); }
@keyframes paperIn { from { opacity: 0; transform: translateY(-46%) rotate(2deg); } }
#panel .x { position: absolute; right: 12px; top: 8px; font-size: 22px; color: var(--ink2); }
#panel h2 { font-family: var(--hand); font-weight: 400; font-size: 24px; margin: 0 0 12px; color: var(--blue); }
#panel .body { font-size: 15px; line-height: 30px; }
#panel .body p { margin: 0 0 10px; }
#panel .src { font-size: 12px; color: var(--ink2); line-height: 1.6; }
#panel .keys { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0 10px; }
#panel kbd { font-family: var(--serif); display: inline-block; min-width: 24px; text-align: center; border: 1px solid #9a907f; border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; margin-right: 4px; font-size: 13px; line-height: 22px; background: #fffaf0; }
#panel .links { display: flex; flex-wrap: wrap; gap: 8px 18px; }
#panel a { color: var(--red); }
#panel .rps { display: flex; gap: 10px; margin: 8px 0; }
#panel .btn, #sheet .btn, #modal .btn { font-family: var(--hand); font-size: 17px; color: var(--blue); border-bottom: 1px solid currentColor; line-height: 1.4; }
#panel .btn:hover, #sheet .btn:hover, #modal .btn:hover { color: var(--red); }
#panel .rps .btn { border: 1px solid #b9ae98; padding: 4px 14px; border-radius: 3px; background: #fffaf0; }
#panel img.flyer { width: 100%; display: block; margin: 8px 0; box-shadow: 0 4px 14px rgba(0,0,0,.2); transform: rotate(-1deg); }
#panel .count { font-family: var(--hand); color: var(--red); }

/* memory sheets */
#sheet { position: fixed; right: 26px; top: 86px; bottom: 26px; width: min(460px, calc(100vw - 40px)); z-index: 10; overflow: auto; background: var(--paper); color: var(--ink); padding: 24px; box-shadow: 0 18px 50px rgba(0,0,0,.45); border-radius: 2px; animation: paperIn2 .45s cubic-bezier(.2,.8,.2,1); }
@keyframes paperIn2 { from { opacity: 0; transform: translateX(30px); } }
#sheet h2 { font-family: var(--hand); font-weight: 400; font-size: 26px; margin: 0 0 6px; color: var(--blue); }
#sheet .lead { font-size: 14px; line-height: 1.8; color: var(--ink2); margin: 0 0 16px; }
#sheet .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 14px 0; }
#sheet .tiny { font-size: 12px; color: var(--ink2); }
#sheet .empty { font-family: var(--hand); font-size: 18px; color: var(--ink2); padding: 24px 0; text-align: center; }
/* cassette spines */
.spines { display: flex; flex-direction: column; gap: 6px; }
.spine { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 10px; background: #2b2d31; color: #1b2b6b; padding: 4px; border-radius: 2px; text-align: left; box-shadow: 0 2px 4px rgba(0,0,0,.25); transition: transform .15s; }
.spine:hover { transform: translateX(-6px); }
.spine .lab { background: #f3ecd8; border-top: 4px solid var(--c); border-bottom: 4px solid var(--c); padding: 6px 10px; font-family: var(--hand); font-size: 17px; display: flex; justify-content: space-between; gap: 12px; grid-column: 1 / 4; }
.spine .lab small { font-size: 13px; color: #5b5348; }
.spine .sample { font-family: var(--serif); font-size: 11px; color: #b8231f; }
/* J-card (one show) */
.jcard { background: #f7f1e1; border: 1px solid #d7ccb4; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.jcard .band { background: var(--c); color: var(--t, #fff); padding: 14px 16px; box-shadow: inset 0 -1px 0 rgba(0,0,0,.12); }
.jcard .band .tour { font-family: var(--hand); font-size: 22px; }
.jcard .band .when { font-size: 13px; opacity: .9; margin-top: 2px; }
.jcard .in { padding: 14px 16px; font-size: 14px; line-height: 1.8; }
.jcard dl { display: grid; grid-template-columns: 70px 1fr; gap: 4px 10px; margin: 0 0 10px; }
.jcard dt { color: #8a7f6d; font-size: 12px; padding-top: 3px; }
.jcard dd { margin: 0; }
.jcard ol { margin: 0; padding-left: 22px; font-family: var(--hand); font-size: 17px; line-height: 1.7; }
.jcard .notes { font-family: var(--hand); font-size: 17px; color: var(--blue); white-space: pre-wrap; border-top: 1px dashed #cbbf a6; border-top: 1px dashed #cbbfa6; padding-top: 10px; margin-top: 8px; }
.jcard img { width: 100%; display: block; margin-top: 10px; }
.reel { display: flex; justify-content: center; gap: 40px; padding: 10px 0 4px; }
.reel span { width: 34px; height: 34px; border-radius: 50%; border: 6px dotted #6b6f75; background: #2b2d31; }
.playing .reel span { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* stub grid */
.stubs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stubs figure { margin: 0; }
.stubs img { width: 100%; display: block; box-shadow: 0 3px 8px rgba(0,0,0,.2); }
.stubs figcaption { font-size: 12px; color: var(--ink2); margin-top: 4px; display: flex; justify-content: space-between; }
/* polaroids */
.polas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.polas figure { margin: 0; background: #fff; padding: 8px 8px 10px; box-shadow: 0 3px 10px rgba(0,0,0,.18); }
.polas figure:nth-child(odd) { transform: rotate(-1.5deg); } .polas figure:nth-child(even) { transform: rotate(1.2deg); }
.polas img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.polas figcaption { font-family: var(--hand); font-size: 14px; color: var(--blue); margin-top: 6px; line-height: 1.3; }
.polas figcaption small { display: block; font-family: var(--serif); font-size: 11px; color: var(--ink2); }
/* notebook */
.notes-list { list-style: none; margin: 0; padding: 0; }
.notes-list li { border-bottom: 1px solid rgba(27,43,107,.15); padding: 10px 0; }
.notes-list .d { font-size: 12px; color: var(--ink2); display: flex; justify-content: space-between; }
.notes-list .t { font-family: var(--hand); font-size: 18px; color: var(--blue); line-height: 1.6; white-space: pre-wrap; }
.big-count { font-family: var(--hand); font-size: 64px; color: var(--red); line-height: 1; }
.bands { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.bands span { width: 26px; height: 26px; border-radius: 50%; border: 5px solid var(--c); }
.del { font-size: 12px; color: #9a3a2a; text-decoration: underline; }

/* forms */
#modal { position: fixed; inset: 0; z-index: 30; background: rgba(5,6,10,.55); display: flex; align-items: center; justify-content: center; padding: 20px; }
#modal form { background: var(--paper); color: var(--ink); width: min(520px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 24px; border-radius: 2px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
#modal h3 { font-family: var(--hand); font-weight: 400; font-size: 24px; margin: 0 0 14px; color: var(--blue); }
#modal label { display: block; font-size: 12px; color: var(--ink2); margin: 10px 0 0; }
#modal input, #modal textarea, #modal select { display: block; width: 100%; margin-top: 4px; font: 16px var(--hand); color: var(--blue); background: transparent; border: 0; border-bottom: 1px solid #b9ae98; padding: 4px 2px; border-radius: 0; }
#modal textarea { border: 1px solid #cdc2aa; min-height: 90px; padding: 6px 8px; background: repeating-linear-gradient(transparent 0 27px, rgba(27,43,107,.08) 27px 28px); line-height: 28px; }
#modal input:focus, #modal textarea:focus, #modal select:focus { outline: none; border-color: var(--blue); }
#modal .two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
#modal .swatches { display: flex; gap: 8px; margin-top: 6px; }
#modal .swatches label { margin: 0; }
#modal .swatches input { display: none; }
#modal .swatches span { display: block; width: 26px; height: 26px; border-radius: 50%; background: var(--c); border: 2px solid #fff; box-shadow: 0 0 0 1px #b9ae98; cursor: pointer; }
#modal .swatches input:checked + span { box-shadow: 0 0 0 2px var(--ink); }
#modal .actions { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
#modal .hint { font-size: 12px; color: var(--ink2); margin-top: 4px; }
#modal .cancel { font-size: 14px; color: var(--ink2); }

/* 任意門 */
#door { position: fixed; inset: 0; z-index: 25; background: #02040c; animation: doorIn 1.8s ease; }
@keyframes doorIn { from { background-color: #5b72e2; opacity: 0; } 25% { background-color: #5b72e2; opacity: 1; } }
#door canvas { position: absolute; inset: 0; width: 100%; height: 100%; animation: fadeIn 2.6s ease; }
#door .doorText, #door .doorList { animation: fadeIn 3.2s ease; }
@keyframes fadeIn { 0%, 30% { opacity: 0; } }
#door .doorText { position: absolute; left: 0; right: 0; top: 9vh; text-align: center; font-family: var(--hand); color: #e8eeff; text-shadow: 0 0 20px rgba(80,120,255,.6); padding: 0 20px; }
#door .doorText .big { font-size: clamp(26px, 4vw, 44px); letter-spacing: .08em; }
#door .doorText .sub { font-size: 16px; opacity: .8; margin-top: 10px; font-family: var(--serif); }
#door .doorList { position: absolute; right: 24px; top: 50%; transform: translateY(-50%); list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; font-size: 13px; color: rgba(220,230,255,.75); text-align: right; }
#door .doorList li { padding: 4px 0; cursor: pointer; }
#door .doorList li:hover, #door .doorList li.on { color: #fff; }
#door .doorList b { font-family: var(--hand); font-weight: 400; font-size: 16px; margin-left: 8px; }
#door .doorTip { position: absolute; pointer-events: none; transform: translate(-50%, -130%); font-family: var(--hand); font-size: 16px; color: #fff; text-align: center; text-shadow: 0 0 8px #000; white-space: nowrap; }
#door .doorClose { position: absolute; left: 50%; bottom: 6vh; transform: translateX(-50%); font-size: 14px; color: rgba(230,236,255,.8); letter-spacing: .15em; }
#door .doorClose:hover { color: #fff; }

#toast { position: fixed; left: 50%; top: 70px; transform: translate(-50%, -10px); z-index: 40; font-family: var(--hand); font-size: 17px; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.9); opacity: 0; transition: all .35s; pointer-events: none; text-align: center; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* the YouTube player lives behind the transparent canvas, placed on the TV screen in the room */
#css3d { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
body.tvfocus #css3d { z-index: 3; }
body.tvfocus #tvScreen { pointer-events: auto; }
#css3d .cam { position: absolute; left: 0; top: 0; transform-style: preserve-3d; }
#tvScreen { position: absolute; left: 0; top: 0; width: 400px; height: 300px; background: #000; backface-visibility: hidden; }
#tvScreen iframe, #tvScreen #ytp { display: block; width: 400px; height: 300px; border: 0; }
#gl { z-index: 1; }
/* music control in the top bar */
#musicCtl { display: flex; gap: 8px; align-items: center; }
#musicCtl span { font-family: var(--hand); font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
#musicCtl i { font-style: normal; font-size: 11px; margin-right: 2px; }
.songsH { font-weight: 600; font-size: 12px; color: var(--ink2); margin: 18px 0 2px; letter-spacing: .05em; }
/* song list */
.songs { list-style: none; margin: 0; padding: 0; }
.songs li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(27,43,107,.12); padding: 8px 0; }
.songs li button.play { font-family: var(--hand); font-size: 19px; color: var(--blue); text-align: left; }
.songs li.on button.play { color: var(--red); } .songs li.on button.play::before { content: "♪ "; }
.songs li small { font-size: 11px; color: var(--ink2); }
.songs h4 { font-weight: 600; font-size: 12px; color: var(--ink2); margin: 16px 0 4px; letter-spacing: .05em; }

/* egg list */
.eggs { list-style: none; padding: 0; margin: 8px 0 0; columns: 2; }
.eggs li { font-family: var(--hand); font-size: 17px; line-height: 1.9; color: var(--blue); }
.eggs li.no { color: #b9ae98; }

@media (max-width: 760px) {
  #hud { padding: 12px 14px; flex-direction: column; gap: 6px; }
  #hud nav { gap: 12px; flex-wrap: wrap; font-size: 12px; }
  #panel { right: 10px; left: 10px; width: auto; top: auto; bottom: 10px; transform: none; max-height: 52vh; padding: 20px; }
  @keyframes paperIn { from { opacity: 0; transform: translateY(20px); } }
  #sheet { left: 10px; right: 10px; width: auto; top: 46vh; bottom: 10px; padding: 18px; }
  #guide { left: 14px; right: 14px; bottom: 12px; text-align: center; }
  #timeLine { bottom: 40px; width: 90vw; text-align: center; }
  #back { top: 76px; left: 14px; }
  #door .doorList { right: 12px; left: 12px; top: calc(9vh + 120px); bottom: auto; transform: none; max-height: 16vh; text-align: center; }
  #intro .place { font-size: 20px; letter-spacing: .14em; white-space: nowrap; }
  .polas { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { #grain { animation: none; } }
