:root {
  color-scheme: dark;
  --ink: #070914;
  --night: #0c1023;
  --blue: #1d2857;
  --violet: #74619c;
  --gold: #deb86f;
  --gold-soft: #f0d6a0;
  --ivory: #fff8ed;
  --muted: rgba(239, 232, 223, .55);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: #03040a; }
body { color: var(--ivory); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif; overflow: hidden; }
button, a { font: inherit; -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app {
  position: relative;
  width: min(100%, 430px);
  height: 100dvh;
  min-height: 680px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--ink);
  box-shadow: 0 0 80px rgba(0,0,0,.55);
  isolation: isolate;
}

.screen { position: absolute; inset: 0; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .42s ease, visibility .42s; }
.screen.is-active { opacity: 1; visibility: visible; pointer-events: auto; }

.home-screen { background: radial-gradient(circle at 45% 5%, #273363 0%, #12162f 38%, #080a18 72%, #05060d 100%); }
.cosmos { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.cosmos::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(circle, rgba(244,219,161,.58) 0 1px, transparent 1.6px); background-size: 54px 61px; opacity: .18; transform: rotate(11deg) scale(1.2); }
.nebula { position: absolute; width: 130%; height: 34%; border-radius: 50%; filter: blur(48px); opacity: .16; }
.nebula-a { left: -60%; top: 10%; background: #6378dc; transform: rotate(16deg); animation: driftA 13s ease-in-out infinite alternate; }
.nebula-b { right: -75%; top: 43%; background: #a05e9b; transform: rotate(-20deg); animation: driftB 16s ease-in-out infinite alternate; }
.dust { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--gold-soft); box-shadow: 0 0 18px var(--gold), 0 0 36px rgba(224,180,103,.6); animation: twinkle 3.4s ease-in-out infinite; }
.dust-a { left: 12%; top: 22%; }.dust-b { right: 11%; top: 33%; animation-delay: -1.4s; }.dust-c { left: 18%; bottom: 28%; animation-delay: -2.4s; }

.home-header { position: relative; z-index: 3; height: calc(74px + env(safe-area-inset-top)); padding: calc(22px + env(safe-area-inset-top)) 22px 0; display: flex; align-items: flex-start; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ivory); text-decoration: none; font-family: "Songti SC", STSong, serif; letter-spacing: .18em; font-size: 14px; }
.brand > span { width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid rgba(222,184,111,.48); border-radius: 50%; color: var(--gold-soft); font-size: 12px; }
.token-state { display: flex; align-items: center; gap: 7px; height: 29px; padding: 0 11px; border: 1px solid rgba(255,255,255,.08); border-radius: 99px; background: rgba(6,8,18,.24); backdrop-filter: blur(12px); color: rgba(255,248,237,.58); font-size: 10px; letter-spacing: .08em; }
.token-state i { width: 6px; height: 6px; border-radius: 50%; background: #dbb96e; box-shadow: 0 0 10px #dbb96e; }

.home-scroll { position: relative; z-index: 2; height: calc(100% - 145px - env(safe-area-inset-top)); overflow: auto; scrollbar-width: none; padding: 18px 22px 30px; }
.home-scroll::-webkit-scrollbar { display: none; }
.hero { text-align: center; }
.eyebrow { margin: 2px 0 15px; color: var(--gold); font-size: 10px; letter-spacing: .28em; }
.hero h1 { margin: 0; font-family: "Songti SC", STSong, serif; font-size: clamp(34px, 10vw, 44px); line-height: 1.25; font-weight: 400; letter-spacing: .06em; text-shadow: 0 4px 30px rgba(0,0,0,.2); }
.hero-copy { max-width: 315px; margin: 17px auto 0; color: var(--muted); font-size: 12px; line-height: 1.8; }

.signal-entry { position: relative; width: 220px; height: 190px; margin: 16px auto 0; padding: 0; border: 0; background: transparent; color: var(--ivory); }
.signal-core { position: absolute; left: 50%; top: 57px; width: 68px; height: 68px; margin-left: -34px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 38% 30%, #fff6d2 0 5%, #d9b66e 9%, #6e542e 43%, #1b1920 73%); box-shadow: 0 0 24px rgba(224,184,104,.5), 0 0 70px rgba(103,90,158,.25), inset 0 0 0 1px rgba(255,244,213,.45); transition: transform .25s ease; }
.signal-core b { width: 13px; height: 13px; border-radius: 50%; background: var(--ivory); box-shadow: 0 0 16px var(--gold-soft); }
.signal-entry:active .signal-core { transform: scale(.92); }
.signal-wave { position: absolute; left: 50%; top: 91px; width: 90px; height: 54px; margin: -27px 0 0 -45px; border: 1px solid rgba(231,196,128,.34); border-left-color: transparent; border-right-color: transparent; border-radius: 50%; animation: broadcast 2.7s ease-out infinite; }
.wave-two { animation-delay: -.9s; }.wave-three { animation-delay: -1.8s; }
.signal-label { position: absolute; left: 0; right: 0; bottom: 7px; color: rgba(255,247,235,.66); font-size: 11px; letter-spacing: .18em; }

.memory-section { margin-top: 6px; text-align: left; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 13px; }
.section-heading p { margin: 0 0 6px; color: rgba(222,184,111,.62); font-size: 8px; letter-spacing: .2em; }
.section-heading h2 { margin: 0; font-size: 17px; font-weight: 500; }
.section-heading > span { color: rgba(238,232,224,.4); font-size: 9px; }

.memory-card { position: relative; width: 100%; min-height: 94px; margin-bottom: 10px; padding: 15px 16px; overflow: hidden; display: grid; grid-template-columns: 34px 1fr 46px; align-items: center; gap: 12px; border: 1px solid rgba(255,255,255,.09); border-radius: 22px; background: linear-gradient(135deg, rgba(35,41,76,.72), rgba(12,15,31,.76)); box-shadow: 0 12px 34px rgba(0,0,0,.16); text-align: left; backdrop-filter: blur(15px); }
.memory-card-primary { border-color: rgba(225,188,112,.17); }
.card-glow { position: absolute; right: -30px; top: -55px; width: 150px; height: 150px; border-radius: 50%; background: #c89c54; opacity: .13; filter: blur(24px); }
.card-glow-violet { background: #9474c3; }
.card-index { position: relative; color: rgba(237,213,161,.42); font: 10px/1 ui-monospace, monospace; }
.card-content { position: relative; display: block; }
.card-content small, .card-content strong, .card-content em { display: block; }
.card-content small { margin-bottom: 7px; color: rgba(239,232,223,.4); font-size: 9px; font-weight: 400; letter-spacing: .05em; }
.card-content strong { font-family: "Songti SC", STSong, serif; font-size: 17px; font-weight: 400; letter-spacing: .05em; }
.card-content em { margin-top: 6px; color: rgba(239,232,223,.38); font-size: 9px; font-style: normal; }
.card-signal { position: relative; height: 35px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.card-signal i { width: 2px; height: 12px; border-radius: 99px; background: #d9b676; opacity: .55; }
.card-signal i:nth-child(2) { height: 28px; }.card-signal i:nth-child(3) { height: 18px; }

.home-nav { position: absolute; z-index: 5; left: 18px; right: 18px; bottom: calc(14px + env(safe-area-inset-bottom)); height: 66px; display: flex; justify-content: space-around; align-items: center; border: 1px solid rgba(255,255,255,.08); border-radius: 24px; background: rgba(12,15,31,.8); backdrop-filter: blur(20px); box-shadow: 0 12px 36px rgba(0,0,0,.25); }
.home-nav button { width: 72px; height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 0; background: transparent; color: rgba(240,234,225,.36); font-size: 9px; }
.home-nav button.is-active { color: var(--gold-soft); }
.nav-icon { position: relative; width: 18px; height: 18px; display: block; }
.nav-home::before { content: ""; position: absolute; left: 3px; top: 6px; width: 11px; height: 9px; border: 1.5px solid currentColor; border-top: 0; border-radius: 2px; }
.nav-home::after { content: ""; position: absolute; left: 4px; top: 2px; width: 9px; height: 9px; border-left: 1.5px solid currentColor; border-top: 1.5px solid currentColor; transform: rotate(45deg); }
.nav-voice::before, .nav-voice::after { content: ""; position: absolute; top: 1px; bottom: 1px; border: 1.5px solid currentColor; border-top-color: transparent; border-bottom-color: transparent; border-radius: 50%; }
.nav-voice::before { left: 3px; right: 3px; }.nav-voice::after { left: 7px; right: 7px; }
.nav-profile::before { content: ""; position: absolute; left: 6px; top: 1px; width: 6px; height: 6px; border: 1.5px solid currentColor; border-radius: 50%; }
.nav-profile::after { content: ""; position: absolute; left: 3px; right: 3px; bottom: 1px; height: 7px; border: 1.5px solid currentColor; border-radius: 9px 9px 3px 3px; }

.tunnel-screen { z-index: 20; background: #000; }
.tunnel-screen video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-vignette { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.06), transparent 70%, rgba(2,3,9,.16)); pointer-events: none; }
.video-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; background: #060711; transition: opacity .4s ease; }
.video-loading.is-hidden { opacity: 0; pointer-events: none; }
.video-loading span { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-soft); box-shadow: 0 0 16px var(--gold), 0 0 45px rgba(212,174,103,.7); animation: beacon 1.4s ease-in-out infinite; }
.video-loading p { margin: 0; color: rgba(245,237,225,.55); font-size: 10px; letter-spacing: .22em; }
.tap-to-start { position: absolute; inset: 0; border: 0; background: rgba(4,5,12,.7); color: var(--ivory); backdrop-filter: blur(10px); }
.tap-to-start span { display: inline-grid; place-items: center; width: 118px; height: 118px; border: 1px solid rgba(231,193,117,.42); border-radius: 50%; box-shadow: 0 0 55px rgba(222,180,105,.17); letter-spacing: .18em; font-size: 11px; }

.player-screen { z-index: 30; background: var(--ink); }
.tail-static, .tail-dynamic { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; }
.tail-static { z-index: 1; opacity: 1; transition: opacity .55s ease; }
.tail-dynamic { z-index: 2; opacity: 0; transition: opacity .55s ease; pointer-events: none; }
.player-screen.is-live .tail-static { opacity: 0; }
.player-screen.is-live .tail-dynamic { opacity: 1; }
.player-shade { position: absolute; z-index: 3; inset: 0; background: linear-gradient(180deg, rgba(5,6,16,.04) 0%, transparent 37%, rgba(5,6,16,.08) 70%, rgba(5,6,16,.26) 100%); pointer-events: none; }
.back-button { position: absolute; z-index: 8; left: 12px; top: calc(12px + env(safe-area-inset-top)); width: 48px; height: 48px; border: 0; border-radius: 50%; background: rgba(8,10,22,.28); backdrop-filter: blur(10px); opacity: 0; transform: translateY(-8px); transition: opacity .5s .7s ease, transform .5s .7s ease; }
.back-button span::before, .back-button span::after { content: ""; position: absolute; left: 17px; width: 14px; height: 1.5px; background: rgba(255,246,232,.72); transform-origin: left center; }
.back-button span::before { top: 20px; transform: rotate(-42deg); }.back-button span::after { top: 20px; transform: rotate(42deg); }
.player-screen.is-copy-visible .back-button { opacity: 1; transform: none; }

.pendant-control { position: absolute; z-index: 7; left: 50%; top: 32.3%; width: 27%; aspect-ratio: 1; transform: translate(-50%,-50%); border: 0; border-radius: 50%; background: transparent; }
.pause-mark { position: absolute; inset: 31%; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 50%; background: rgba(10,11,24,.76); opacity: 0; transform: scale(.75); transition: opacity .25s ease, transform .25s ease; box-shadow: 0 0 25px rgba(222,184,111,.38); }
.pause-mark i { width: 5px; height: 26px; border-radius: 99px; background: #fff2ca; }
.player-screen.is-playing .pause-mark { opacity: 1; transform: scale(1); }

.memory-copy { position: absolute; z-index: 6; top: 44%; left: 24px; right: 24px; text-align: center; opacity: 0; transform: translateY(16px); transition: opacity .7s ease, transform .7s ease; }
.player-screen.is-copy-visible .memory-copy { opacity: 1; transform: none; }
.memory-kicker { margin: 0 0 10px; color: var(--gold); font-size: 9px; letter-spacing: .22em; }
.memory-copy h2 { margin: 0; font-family: "Songti SC", STSong, serif; font-size: clamp(28px, 8vw, 36px); font-weight: 400; letter-spacing: .08em; }
.memory-copy > p:last-child { margin: 9px 0 0; color: rgba(239,232,223,.5); font-size: 10px; letter-spacing: .08em; }
.playback-meta { position: absolute; z-index: 6; top: 62%; left: 15.5%; right: 15.5%; display: flex; justify-content: space-between; color: rgba(239,232,223,.42); font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; opacity: 0; transition: opacity .7s .15s ease; }
.memory-quote { position: absolute; z-index: 6; top: 69.5%; left: 20px; right: 20px; margin: 0; text-align: center; color: rgba(242,234,225,.62); font-family: "Songti SC", STSong, serif; font-size: 12px; letter-spacing: .14em; opacity: 0; transition: opacity .7s .2s ease; }
.player-hint { position: absolute; z-index: 6; left: 0; right: 0; bottom: calc(24px + env(safe-area-inset-bottom)); margin: 0; text-align: center; color: rgba(239,232,223,.34); font-size: 9px; letter-spacing: .16em; opacity: 0; transition: opacity .7s .3s ease; }
.player-screen.is-copy-visible .playback-meta, .player-screen.is-copy-visible .memory-quote, .player-screen.is-copy-visible .player-hint { opacity: 1; }
.player-screen.is-playing .player-hint { color: rgba(222,184,111,.58); }

@keyframes driftA { to { transform: translate(110px, 60px) rotate(6deg) scale(1.15); } }
@keyframes driftB { to { transform: translate(-90px, -55px) rotate(-8deg) scale(1.12); } }
@keyframes twinkle { 50% { opacity: .95; transform: scale(1.8); } }
@keyframes broadcast { 0% { transform: scale(.35); opacity: 0; } 35% { opacity: .6; } 100% { transform: scale(2.1); opacity: 0; } }
@keyframes beacon { 50% { transform: scale(1.8); box-shadow: 0 0 28px var(--gold), 0 0 70px rgba(212,174,103,.8); } }

@media (min-width: 700px) {
  body { display: grid; place-items: center; padding: 18px; }
  .app { height: min(920px, calc(100dvh - 36px)); min-height: 700px; border-radius: 42px; }
}

@media (max-height: 740px) {
  .home-scroll { padding-top: 6px; }
  .hero h1 { font-size: 32px; }
  .hero-copy { margin-top: 10px; }
  .signal-entry { height: 160px; margin-top: 4px; }
  .signal-core { top: 43px; }
  .signal-wave { top: 77px; }
  .memory-section { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
