:root {
  --bg: #04060d;
  --ink: #0a1024;
  --navy: #192847;
  --blue: #1881e4;
  --bright: #26aff7;
  --pale: #96dbfa;
  --white: #eaf8ff;
  --title: #1273e6;
  --font: 'Montserrat', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--white); font-family: var(--font); overflow: hidden; overscroll-behavior: none; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

#grain, #vignette, #fade { position: fixed; inset: 0; pointer-events: none; }
#grain { opacity: 0; mix-blend-mode: overlay; background-size: 220px 220px; transition: opacity .8s; animation: grain .5s steps(4) infinite; inset: -120px; }
#vignette { opacity: 0; transition: opacity .8s; background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(4, 6, 13, .55) 100%); }
body.in-world #grain { opacity: .34; }
body.in-world #vignette { opacity: 1; }
@keyframes grain { 0% { transform: translate(0, 0); } 25% { transform: translate(-60px, 40px); } 50% { transform: translate(50px, -70px); } 75% { transform: translate(-30px, -40px); } 100% { transform: translate(0, 0); } }
#fade { background: var(--blue); opacity: 0; transition: opacity .55s ease; z-index: 30; }
#fade.on { opacity: 1; }

#top { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px; z-index: 10; pointer-events: none; transition: opacity .5s; }
#top > * { pointer-events: auto; }
.brand { text-decoration: none; color: var(--white); display: flex; flex-direction: column; line-height: 1; }
.brand b { font-weight: 900; font-size: 20px; letter-spacing: .02em; color: var(--bright); }
.brand span { font-style: italic; font-weight: 800; font-size: 12px; opacity: .8; margin-top: 3px; }
.top-right { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip { appearance: none; border: 1px solid rgba(150, 219, 250, .35); background: rgba(10, 16, 36, .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: var(--white); border-radius: 999px; padding: 8px 14px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-decoration: none; text-transform: uppercase; transition: background .2s, border-color .2s, color .2s; white-space: nowrap; }
.chip:hover, .chip:focus-visible { background: rgba(24, 129, 228, .55); border-color: var(--pale); outline: none; }
.chip.on, .chip[aria-pressed="true"] { background: var(--white); color: var(--ink); border-color: var(--white); }

#bottom { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 20px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 10; pointer-events: none; }
#bottom > * { pointer-events: auto; }
#modes { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(10, 16, 36, .6); border: 1px solid rgba(150, 219, 250, .28); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
#modes button { appearance: none; border: 0; background: transparent; border-radius: 999px; padding: 10px 18px; font-weight: 800; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--pale); transition: background .25s, color .25s; }
#modes button:hover { color: var(--white); }
#modes button.on { background: var(--bright); color: var(--ink); }
#modes button[disabled] { opacity: .45; cursor: progress; }
#depthwrap { display: flex; align-items: center; gap: 10px; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--pale); width: min(520px, 86vw); transition: opacity .4s; }
#depthwrap input { flex: 1; accent-color: var(--bright); height: 22px; }
body.in-world #depthwrap { opacity: 0; pointer-events: none; height: 0; margin: -5px 0; overflow: hidden; }
#hint { margin: 0; font-size: 11px; font-weight: 500; letter-spacing: .04em; color: rgba(234, 248, 255, .72); text-align: center; min-height: 1.3em; text-shadow: 0 1px 8px rgba(4, 6, 13, .8); }

#angles { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; width: min(900px, 96vw); z-index: 10; opacity: 0; pointer-events: none; transition: opacity .5s; }
body.in-world #angles { opacity: 1; pointer-events: auto; }

#layerlist { position: fixed; right: 16px; top: 50%; transform: translate(20px, -50%); width: 232px; max-height: 76vh; overflow: auto; padding: 14px 12px 10px; border-radius: 14px; background: rgba(10, 16, 36, .62); border: 1px solid rgba(150, 219, 250, .25); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 9; opacity: 0; pointer-events: none; transition: opacity .45s, transform .45s; }
body.show-layers #layerlist { opacity: 1; pointer-events: auto; transform: translate(0, -50%); }
#layerlist h2 { margin: 0 4px 8px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--pale); display: flex; justify-content: space-between; align-items: baseline; }
#layerlist h2 small { font-weight: 500; letter-spacing: .02em; text-transform: none; opacity: .8; }
#layerlist ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#layerlist li button { width: 100%; display: grid; grid-template-columns: 34px 1fr; gap: 9px; align-items: center; text-align: left; background: transparent; border: 0; border-radius: 9px; padding: 5px 6px; }
#layerlist li button:hover, #layerlist li button:focus-visible { background: rgba(38, 175, 247, .22); outline: none; }
#layerlist li.off { opacity: .38; }
#layerlist .thumb { width: 34px; height: 34px; border-radius: 6px; background: #0a1024 center/cover no-repeat; border: 1px solid rgba(150, 219, 250, .3); }
#layerlist .t { display: block; font-size: 12px; font-weight: 700; line-height: 1.2; }
#layerlist .n { display: block; font-size: 10px; font-weight: 500; color: rgba(150, 219, 250, .85); font-variant-numeric: tabular-nums; }
#layerlist .tip { margin: 8px 4px 0; font-size: 10px; color: rgba(234, 248, 255, .55); }

#caption { position: fixed; left: 24px; bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 9; display: flex; flex-direction: column; gap: 2px; opacity: 0; transform: translateY(8px); transition: opacity .35s, transform .35s; pointer-events: none; text-shadow: 0 2px 14px rgba(4, 6, 13, .9); }
#caption.on { opacity: 1; transform: none; }
#caption .num { font-size: 11px; font-weight: 700; letter-spacing: .2em; color: var(--pale); }
#caption .name { font-size: clamp(26px, 5vw, 54px); font-weight: 900; letter-spacing: .01em; line-height: 1; text-transform: uppercase; }
#caption .meta { font-size: 12px; font-weight: 500; color: rgba(234, 248, 255, .8); font-variant-numeric: tabular-nums; }

#loader { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: radial-gradient(90% 70% at 50% 60%, #12296b 0%, #070d22 55%, var(--bg) 100%); transition: opacity .9s ease, visibility .9s; }
body:not(.is-loading) #loader { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-in { width: min(520px, 88vw); text-align: center; }
#loader h1 { margin: 0; font-weight: 900; font-size: clamp(44px, 12vw, 96px); letter-spacing: .01em; line-height: .95; color: var(--bright); text-shadow: 0 0 40px rgba(38, 175, 247, .35); }
#loader .sub { margin: 12px 0 22px; font-size: 13px; font-weight: 500; color: var(--pale); line-height: 1.5; }
#loader .sub b { color: var(--white); font-variant-numeric: tabular-nums; }
#lp-list { list-style: none; margin: 0 auto 16px; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px 18px; text-align: left; font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; color: rgba(150, 219, 250, .45); max-width: 400px; }
#lp-list li { display: flex; justify-content: space-between; gap: 8px; transition: color .3s; }
#lp-list li.now { color: var(--white); }
#lp-list li.done { color: var(--bright); }
.bar { height: 3px; border-radius: 3px; background: rgba(150, 219, 250, .18); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0%; background: var(--bright); transition: width .35s ease; }
#enter { margin-top: 22px; appearance: none; border: 0; border-radius: 999px; padding: 15px 34px; font-weight: 900; font-size: 14px; letter-spacing: .14em; text-transform: uppercase; background: var(--white); color: var(--ink); transition: transform .2s, background .2s, opacity .2s; }
#enter:not([disabled]):hover { transform: translateY(-2px); background: var(--bright); }
#enter[disabled] { opacity: .4; cursor: progress; background: transparent; color: var(--pale); border: 1px solid rgba(150, 219, 250, .35); }
#loader .fine { margin: 14px 0 0; font-size: 10px; letter-spacing: .06em; color: rgba(150, 219, 250, .6); }

#toast { position: fixed; top: 74px; left: 50%; transform: translate(-50%, -12px); z-index: 20; padding: 9px 16px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgba(10, 16, 36, .8); border: 1px solid rgba(150, 219, 250, .35); opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

body.is-loading #top, body.is-loading #bottom, body.is-loading #angles, body.is-loading #layerlist { opacity: 0; pointer-events: none; }

@media (max-width: 760px) {
  #layerlist { right: 8px; width: 178px; padding: 10px 8px; max-height: 52vh; top: 44%; }
  #layerlist .thumb { width: 26px; height: 26px; }
  #layerlist li button { grid-template-columns: 26px 1fr; gap: 7px; }
  #modes button { padding: 9px 12px; font-size: 11px; letter-spacing: .05em; }
  #angles { bottom: calc(92px + env(safe-area-inset-bottom)); flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding: 0 12px; width: 100vw; scrollbar-width: none; }
  #angles::-webkit-scrollbar { display: none; }
  #caption { left: 16px; bottom: calc(142px + env(safe-area-inset-bottom)); }
  .brand b { font-size: 17px; }
  .chip { padding: 7px 11px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  #grain { animation: none; }
}
