:root {
  color-scheme: dark;
  --bg: #071014;
  --bg-deep: #04080c;
  --text: #f7fafc;
  --muted: rgba(247, 250, 252, 0.72);
  --line: rgba(255, 255, 255, 0.12);
  --surface: rgba(255, 255, 255, 0.08);
  --surface-strong: rgba(255, 255, 255, 0.12);
  --brand-green: #29c28a;
  --brand-cyan: #65d7f7;
  --brand-gold: rgba(255, 220, 160, 0.22);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg-deep); }
body {
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
img, video { display: block; max-width: 100%; }
button { font: inherit; }
.hidden { display: none !important; }

.viewer-app {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 15% 10%, rgba(101, 215, 247, 0.16), transparent 24%),
    radial-gradient(circle at 85% 18%, rgba(41, 194, 138, 0.18), transparent 22%),
    radial-gradient(circle at 50% 100%, rgba(255, 220, 160, 0.08), transparent 28%),
    linear-gradient(180deg, #0a1419 0%, #071014 42%, #04080c 100%);
}

.viewer-app::before,
.viewer-app::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.viewer-app::before {
  background:
    linear-gradient(130deg, rgba(255,255,255,0.04), transparent 20%, transparent 80%, rgba(255,255,255,0.03)),
    radial-gradient(circle at 50% 20%, rgba(255,255,255,0.04), transparent 34%);
  mix-blend-mode: screen;
  opacity: 0.65;
}

.viewer-app::after {
  inset: 1px;
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 0;
}

.brand-frame {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.brand-top {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top));
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  width: min(38vw, 156px);
  height: auto;
  opacity: 0.96;
  filter: drop-shadow(0 14px 30px rgba(0, 0, 0, 0.35));
}

.brand-chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(16px);
  color: rgba(247,250,252,0.78);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-bottom-glow {
  position: absolute;
  left: 50%;
  bottom: -80px;
  width: min(86vw, 460px);
  height: 180px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: radial-gradient(circle, rgba(41, 194, 138, 0.18) 0%, rgba(101, 215, 247, 0.12) 32%, rgba(255,255,255,0) 72%);
  filter: blur(34px);
  opacity: 0.9;
  animation: pulseGlow 7s ease-in-out infinite;
}

.ambient {
  position: fixed;
  border-radius: 999px;
  filter: blur(78px);
  pointer-events: none;
  opacity: 0.34;
  animation: floatOrb 12s ease-in-out infinite;
}

.ambient-a {
  width: 240px;
  height: 240px;
  top: -54px;
  right: -56px;
  background: rgba(41, 194, 138, 0.24);
}

.ambient-b {
  width: 220px;
  height: 220px;
  left: -64px;
  bottom: -40px;
  background: rgba(101, 215, 247, 0.22);
  animation-delay: -3s;
}

.leaf-float {
  position: fixed;
  width: min(54vw, 280px);
  opacity: 0.11;
  pointer-events: none;
  filter: saturate(1.08) blur(0.1px);
  transform-origin: center;
}

.leaf-left {
  left: -10vw;
  top: 16vh;
  transform: rotate(-18deg);
  animation: driftLeafLeft 20s ease-in-out infinite;
}

.leaf-right {
  right: -12vw;
  bottom: 18vh;
  transform: rotate(162deg) scaleX(-1);
  animation: driftLeafRight 24s ease-in-out infinite;
}

.stage {
  position: relative;
  min-height: 100vh;
  width: 100%;
}

.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(4,8,12,0.08) 0%, rgba(4,8,12,0.16) 18%, rgba(4,8,12,0.5) 100%);
}

.stage-loading,
.stage-error {
  display: grid;
  place-items: center;
  padding: 32px 24px;
}

.loading-shell,
.error-shell {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
}

.loading-shell {
  gap: 24px;
}

.loading-logo {
  width: min(42vw, 132px);
  height: auto;
  opacity: 0.96;
  filter: drop-shadow(0 18px 42px rgba(0, 0, 0, 0.28));
  animation: logoBreath 6s ease-in-out infinite;
}

.loading-line {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.stage-cover,
.stage-video {
  display: flex;
  flex-direction: column;
}

.cover-media-wrap,
.stage-video video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cover-image,
.stage-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.cover-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top, rgba(41, 194, 138, 0.16), transparent 30%),
    radial-gradient(circle at 70% 30%, rgba(101, 215, 247, 0.14), transparent 26%),
    linear-gradient(180deg, rgba(12, 19, 24, 0.96) 0%, rgba(4, 8, 12, 0.98) 100%);
}

.cover-fallback-leaf {
  position: absolute;
  right: -10vw;
  top: 14vh;
  width: min(54vw, 290px);
  opacity: 0.12;
  transform: rotate(-16deg);
  animation: driftLeafRight 24s ease-in-out infinite;
}

.cover-fallback-logo {
  width: min(46vw, 182px);
  opacity: 0.95;
  filter: drop-shadow(0 18px 42px rgba(0, 0, 0, 0.36));
}

.cover-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 8, 12, 0.12) 0%, rgba(4, 8, 12, 0.22) 30%, rgba(4, 8, 12, 0.78) 72%, rgba(4, 8, 12, 0.95) 100%),
    radial-gradient(circle at bottom, rgba(255,220,160,0.08), transparent 26%);
}

.cover-copy {
  position: relative;
  z-index: 2;
  margin-top: auto;
  padding: 0 24px 138px;
}

.cover-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(14px);
  color: rgba(247,250,252,0.8);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.cover-eyebrow-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--brand-green), var(--brand-cyan));
  box-shadow: 0 0 14px rgba(101,215,247,0.56);
}

.cover-title {
  margin: 0;
  font-size: clamp(30px, 7vw, 56px);
  line-height: 1.02;
  font-weight: 700;
  letter-spacing: -0.045em;
  text-wrap: balance;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
}

.cover-subtitle {
  margin: 12px 0 0;
  max-width: 34ch;
  color: var(--muted);
  font-size: clamp(14px, 3.6vw, 18px);
  line-height: 1.45;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
}

.play-button {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-width: 142px;
  height: 62px;
  padding: 0 24px 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.08)),
    linear-gradient(90deg, rgba(41,194,138,0.18), rgba(101,215,247,0.18));
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(255,255,255,0.02) inset;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.play-button:active {
  transform: translateX(-50%) scale(0.985);
}

.play-button-icon {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.24), rgba(255,255,255,0.12));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}

.play-button-icon svg {
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

.video-stage-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(4,8,12,0.18) 0%, rgba(4,8,12,0.04) 30%, rgba(4,8,12,0.32) 100%);
}

.video-overlay {
  position: absolute;
  z-index: 2;
  inset: auto 16px calc(22px + env(safe-area-inset-bottom)) 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(4, 8, 12, 0.62);
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  backdrop-filter: blur(16px);
}

.stage-error {
  background:
    radial-gradient(circle at 50% 14%, rgba(101, 215, 247, 0.08), transparent 30%),
    radial-gradient(circle at 50% 86%, rgba(41, 194, 138, 0.1), transparent 28%);
}

.error-shell {
  gap: 18px;
  width: min(100%, 420px);
}

.error-logo {
  width: min(34vw, 120px);
  opacity: 0.92;
  filter: drop-shadow(0 16px 36px rgba(0,0,0,0.3));
}

.error-headline {
  margin: 0;
  font-size: clamp(30px, 7vw, 50px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.045em;
  text-align: center;
  text-wrap: balance;
  max-width: 11ch;
  text-shadow: 0 12px 30px rgba(0,0,0,0.34);
}

.error-text {
  font-size: clamp(12px, 3vw, 14px);
  line-height: 1.45;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--muted);
  text-wrap: balance;
  max-width: 28ch;
}

@keyframes pulseGlow {
  0%, 100% { transform: translateX(-50%) scale(0.96); opacity: 0.75; }
  50% { transform: translateX(-50%) scale(1.06); opacity: 1; }
}

@keyframes floatOrb {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(0, 16px, 0) scale(1.06); }
}

@keyframes driftLeafLeft {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-18deg); }
  50% { transform: translate3d(18px, -12px, 0) rotate(-12deg); }
}

@keyframes driftLeafRight {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(162deg) scaleX(-1); }
  50% { transform: translate3d(-16px, 12px, 0) rotate(168deg) scaleX(-1); }
}

@keyframes logoBreath {
  0%, 100% { transform: scale(1); opacity: 0.94; }
  50% { transform: scale(1.02); opacity: 1; }
}

@media (min-width: 768px) {
  .viewer-app {
    max-width: 540px;
    margin: 0 auto;
    min-height: 100vh;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06), 0 36px 120px rgba(0,0,0,0.48);
  }

  .viewer-app::after {
    border-radius: 28px;
  }

  .brand-frame,
  .ambient,
  .leaf-float {
    max-width: 540px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0 auto;
  }

  .brand-top {
    max-width: 500px;
    margin: 0 auto;
    left: 20px;
    right: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ambient,
  .leaf-float,
  .brand-bottom-glow,
  .loading-logo,
  .cover-fallback-leaf {
    animation: none !important;
  }
}

.log-panel {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 7;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(8,14,20,0.78), rgba(8,14,20,0.56));
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.28);
  max-height: min(22vh, 180px);
  overflow: hidden;
}

.log-panel-title {
  margin-bottom: 8px;
  color: rgba(247,250,252,0.72);
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.log-lines {
  display: grid;
  gap: 6px;
  overflow: auto;
  max-height: calc(min(22vh, 180px) - 34px);
  padding-right: 4px;
}

.log-lines::-webkit-scrollbar {
  width: 4px;
}

.log-lines::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
}

.log-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  font-size: 11px;
  line-height: 1.35;
}

.log-time {
  color: rgba(101, 215, 247, 0.88);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.log-message {
  color: rgba(247,250,252,0.84);
}

.stage-video + .log-panel,
.stage-cover + .log-panel,
.stage-error + .log-panel,
.stage-loading + .log-panel {
  pointer-events: none;
}

@media (min-width: 768px) {
  .log-panel {
    left: auto;
    width: min(420px, calc(100vw - 32px));
    right: 20px;
    bottom: 20px;
  }
}
