:root {
  --bg: #05060a;
  --ink: #eef1f7;
  --ink2: #a4abbd;
  --ink3: #6b7285;
  --glass: rgba(14, 17, 26, 0.72);
  --line: rgba(255, 255, 255, 0.09);
  --accent: #1ed760;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: "Space Grotesk", system-ui, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; }
.label-layer { position: absolute; inset: 0; pointer-events: none; }

.glass { background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 14px; }

#top { position: fixed; top: 16px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; z-index: 5; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 18px var(--accent); }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.brand p { margin: 2px 0 0; color: var(--ink2); font-size: 12px; font-family: var(--mono); }
#scene-desc { max-width: 380px; text-align: right; color: var(--ink2); font-size: 13px; line-height: 1.45; }
#scene-desc b { color: var(--ink); display: block; font-size: 15px; margin-bottom: 2px; }

#panel { position: fixed; top: 76px; left: 16px; bottom: 96px; width: 360px; z-index: 6; display: flex; flex-direction: column; transition: transform .4s cubic-bezier(.2,.8,.2,1); }
#panel.closed { transform: translateX(-390px); }
#panel-toggle { position: fixed; left: 384px; top: 86px; z-index: 7; width: 26px; height: 38px; border-radius: 0 8px 8px 0; background: var(--glass); border: 1px solid var(--line); border-left: 0; transition: left .4s cubic-bezier(.2,.8,.2,1); }
#panel-toggle.closed { left: 0; }
#tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; border-bottom: 1px solid var(--line); }
#tabs button { background: none; border: 0; padding: 5px 9px; border-radius: 999px; color: var(--ink2); font-size: 12.5px; }
#tabs button.on, #tabs button:hover { background: rgba(255,255,255,.08); color: var(--ink); }
#tab-body { overflow-y: auto; padding: 12px 14px 18px; flex: 1; scrollbar-width: thin; scrollbar-color: #333 transparent; }

.big-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.035); border: 1px solid var(--line); }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11.5px; color: var(--ink2); margin-top: 2px; }
.stat.hero { grid-column: span 2; }
.stat.hero .v { font-size: 40px; color: var(--accent); }
h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink3); margin: 18px 0 8px; font-weight: 500; }
.story { font-size: 13.5px; line-height: 1.55; color: var(--ink2); }
.story b { color: var(--ink); font-weight: 500; }

input.search { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.3); color: var(--ink); font: inherit; font-size: 13px; margin-bottom: 8px; outline: none; }
input.search:focus { border-color: rgba(255,255,255,.25); }

.row { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 6px 6px; border-radius: 8px; cursor: pointer; position: relative; }
.row:hover { background: rgba(255,255,255,.06); }
.row .rk { font-family: var(--mono); font-size: 11px; color: var(--ink3); text-align: right; }
.row .nm { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .nm small { display: block; color: var(--ink3); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .val { font-family: var(--mono); font-size: 11.5px; color: var(--ink2); text-align: right; }
.row .bar { grid-column: 2 / 4; height: 3px; border-radius: 2px; background: rgba(255,255,255,.06); overflow: hidden; margin-top: -2px; }
.row .bar i { display: block; height: 100%; border-radius: 2px; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

.genre-row { padding: 8px; border-radius: 10px; cursor: pointer; }
.genre-row:hover, .genre-row.on { background: rgba(255,255,255,.06); }
.genre-row .top { display: flex; justify-content: space-between; font-size: 14px; }
.genre-row .top span:last-child { font-family: var(--mono); font-size: 12px; color: var(--ink2); }
.genre-row .gb { height: 6px; border-radius: 3px; margin: 6px 0 4px; }
.genre-row .who { font-size: 11.5px; color: var(--ink3); }
.note { font-size: 11.5px; color: var(--ink3); line-height: 1.5; margin-top: 12px; }

.year-card { padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid var(--line); margin-bottom: 8px; }
.year-card .yh { display: flex; justify-content: space-between; align-items: baseline; }
.year-card .yh b { font-size: 20px; }
.year-card .yh span { font-family: var(--mono); font-size: 12px; color: var(--ink2); }
.year-card .gstrip { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin: 6px 0; gap: 1px; }
.year-card p { margin: 3px 0; font-size: 12.5px; color: var(--ink2); }
.year-card p b { color: var(--ink); font-weight: 500; }

.heat { display: grid; grid-template-columns: 28px repeat(24, 1fr); gap: 2px; font-size: 9.5px; font-family: var(--mono); color: var(--ink3); }
.heat div.c { aspect-ratio: 1; border-radius: 2px; }
.heat .hl { text-align: right; padding-right: 3px; line-height: 1; align-self: center; }
.hbar { display: grid; grid-template-columns: 90px 1fr 54px; gap: 8px; align-items: center; font-size: 12.5px; margin: 5px 0; }
.hbar .t { height: 6px; border-radius: 3px; background: rgba(255,255,255,.06); }
.hbar .t i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.hbar .n { font-family: var(--mono); font-size: 11.5px; color: var(--ink2); text-align: right; }

#detail { position: fixed; top: 96px; right: 16px; width: 340px; max-height: calc(100vh - 200px); overflow-y: auto; z-index: 6; padding: 16px; transition: opacity .3s, transform .3s; scrollbar-width: thin; }
#detail.hidden { opacity: 0; transform: translateX(20px); pointer-events: none; }
#detail .close { position: absolute; top: 8px; right: 10px; background: none; border: 0; font-size: 22px; color: var(--ink2); }
#detail h2 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.02em; line-height: 1.1; padding-right: 20px; }
.chip { display: inline-flex; align-items: center; font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.07); color: var(--ink2); }
.mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; }
.mini .stat { padding: 8px; }
.mini .stat .v { font-size: 17px; }
svg.spark text { fill: var(--ink3); font-family: var(--mono); font-size: 9px; }

#scenes { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 5px; z-index: 6; }
#scenes button { background: none; border: 0; padding: 8px 16px; border-radius: 10px; text-align: left; color: var(--ink2); }
#scenes button b { display: block; font-size: 14px; font-weight: 500; }
#scenes button span { font-size: 11px; color: var(--ink3); }
#scenes button.on { background: rgba(255,255,255,.1); color: var(--ink); }
#scenes button:hover { color: var(--ink); }

#legend { position: fixed; right: 16px; bottom: 18px; z-index: 5; display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; font-size: 11.5px; color: var(--ink2); }
#legend div { display: flex; align-items: center; cursor: pointer; padding: 1px 4px; border-radius: 4px; }
#legend div:hover, #legend div.on { color: var(--ink); background: rgba(255,255,255,.06); }

#tip { position: fixed; z-index: 20; pointer-events: none; padding: 8px 11px; font-size: 12.5px; line-height: 1.45; max-width: 280px; transform: translate(14px, 14px); }
#tip.hidden { display: none; }
#tip b { font-size: 13.5px; }
#tip .m { font-family: var(--mono); font-size: 11.5px; color: var(--ink2); }

#tunnel-hud { position: fixed; left: 50%; bottom: 122px; transform: translateX(-50%); z-index: 6; text-align: center; padding: 12px 18px; width: 520px; }
#tunnel-hud.hidden, #records-hud.hidden { display: none; }
#tunnel-hud .date { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
#tunnel-hud .sub { color: var(--ink2); font-size: 13px; min-height: 18px; }
#tunnel-hud .ctrl { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
#tunnel-hud .ctrl button, #tunnel-hud select { background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; color: var(--ink); font: inherit; font-size: 12px; }
#tunnel-hud input[type=range] { flex: 1; accent-color: var(--accent); }
#tunnel-hud .clock-legend { font-size: 11px; color: var(--ink3); margin-top: 6px; }
#records-hud { position: fixed; left: 50%; bottom: 122px; transform: translateX(-50%); z-index: 6; padding: 4px; display: flex; gap: 4px; }
#records-hud button { background: none; border: 0; padding: 7px 14px; border-radius: 9px; color: var(--ink2); font-size: 13px; }
#records-hud button.on { background: rgba(255,255,255,.1); color: var(--ink); }

.lbl { font-size: 12px; color: var(--ink); text-shadow: 0 0 6px #000, 0 0 2px #000; white-space: nowrap; pointer-events: none; transform: translateY(-14px); letter-spacing: .01em; }
.lbl.big { font-size: 15px; font-weight: 700; }
.lbl.dim { color: var(--ink2); font-size: 11px; }
.lbl.year { font-size: 22px; font-weight: 700; color: rgba(255,255,255,.75); }
.lbl.col { text-align: center; transform: translateY(-8px); line-height: 1.3; }
.lbl.col b { font-size: 16px; display: block; }
.lbl.col span { color: var(--ink2); font-size: 11px; }
.lbl.core { text-align: center; font-size: 12px; color: var(--ink2); transform: none; }
.lbl.core b { display: block; font-size: 30px; color: #fff; letter-spacing: -0.02em; }
.lbl.moon { font-size: 11px; color: var(--ink2); transform: translate(10px, 0); }

#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .35s; z-index: 15; }
#fade.on { opacity: 1; }
#loader { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; transition: opacity .8s; color: var(--ink2); font-family: var(--mono); font-size: 13px; }
#loader.gone { opacity: 0; pointer-events: none; }
#loader .ring { width: 54px; height: 54px; border-radius: 50%; border: 2px solid rgba(255,255,255,.08); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  #panel { width: calc(100vw - 32px); bottom: auto; height: 40vh; }
  #panel-toggle { display: none; }
  #scenes { overflow-x: auto; max-width: calc(100vw - 20px); }
  #scenes button span { display: none; }
  #legend { display: none; }
  #detail { width: calc(100vw - 32px); }
  #tunnel-hud { width: calc(100vw - 32px); }
}
