:root {
  --splash-accent: #c30000;
  --splash-accent-soft: rgba(195, 0, 0, 0.12);
  --splash-accent-glow: rgba(195, 0, 0, 0.35);
  --splash-bg: #eef1f6;
  --splash-bg-mesh:
    radial-gradient(ellipse 80% 55% at 12% 8%, rgba(195, 0, 0, 0.09), transparent 55%),
    radial-gradient(ellipse 65% 50% at 88% 92%, rgba(195, 0, 0, 0.07), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(255, 255, 255, 0.9), transparent),
    linear-gradient(160deg, #f8f9fc 0%, #eef1f6 42%, #f5ecec 100%);
  --splash-card-bg: rgba(255, 255, 255, 0.82);
  --splash-card-border: rgba(255, 255, 255, 0.95);
  --splash-card-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.04),
    0 4px 6px -2px rgba(15, 23, 42, 0.05),
    0 24px 48px -12px rgba(15, 23, 42, 0.12),
    0 0 80px -20px var(--splash-accent-glow);
  --splash-title: #0f172a;
  --splash-subtitle: #64748b;
  --splash-text: #475569;
  --splash-muted: #94a3b8;
  --splash-chip-bg: #f8fafc;
  --splash-chip-border: #e2e8f0;
  --splash-chip-text: #334155;
  --splash-progress-bg: #e2e8f0;
  --splash-progress-fill: linear-gradient(90deg, #e85c5c, #c30000 55%, #a80000);
  --splash-grid: rgba(15, 23, 42, 0.035);
}

html.app-dark {
  --splash-accent: #ef4444;
  --splash-accent-soft: rgba(239, 68, 68, 0.14);
  --splash-accent-glow: rgba(239, 68, 68, 0.25);
  --splash-bg: #0b1220;
  --splash-bg-mesh:
    radial-gradient(ellipse 70% 50% at 15% 10%, rgba(239, 68, 68, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 45% at 85% 90%, rgba(239, 68, 68, 0.08), transparent 50%),
    linear-gradient(165deg, #0b1220 0%, #111827 50%, #0f172a 100%);
  --splash-card-bg: rgba(15, 23, 42, 0.72);
  --splash-card-border: rgba(51, 65, 85, 0.65);
  --splash-card-shadow:
    0 0 0 1px rgba(148, 163, 184, 0.08),
    0 24px 48px -12px rgba(0, 0, 0, 0.45),
    0 0 60px -16px var(--splash-accent-glow);
  --splash-title: #f1f5f9;
  --splash-subtitle: #94a3b8;
  --splash-text: #cbd5e1;
  --splash-muted: #64748b;
  --splash-chip-bg: rgba(30, 41, 59, 0.8);
  --splash-chip-border: #334155;
  --splash-chip-text: #e2e8f0;
  --splash-progress-bg: #334155;
  --splash-progress-fill: linear-gradient(90deg, #f87171, #ef4444 55%, #dc2626);
  --splash-grid: rgba(148, 163, 184, 0.06);
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--splash-bg);
}

html.app-dark,
html.app-dark body {
  background: #0b1220;
}

#app-splash {
  position: fixed;
  inset: 0;
  z-index: 2147483646;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  box-sizing: border-box;
  background: var(--splash-bg-mesh);
  background-size: 200% 200%;
  animation: app-splash-bg-shift 18s ease-in-out infinite alternate;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.5s;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

#app-splash::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--splash-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--splash-grid) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, black 20%, transparent 75%);
  pointer-events: none;
  animation: app-splash-grid-drift 24s linear infinite;
}

.app-splash__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(64px);
  pointer-events: none;
  opacity: 0.6;
  will-change: transform;
}

.app-splash__orb--1 {
  width: 300px;
  height: 300px;
  top: -90px;
  right: -70px;
  background: var(--splash-accent-soft);
  animation: app-splash-float-a 10s ease-in-out infinite;
}

.app-splash__orb--2 {
  width: 240px;
  height: 240px;
  bottom: -50px;
  left: -60px;
  background: rgba(148, 163, 184, 0.18);
  animation: app-splash-float-b 13s ease-in-out infinite;
}

.app-splash__orb--3 {
  width: 160px;
  height: 160px;
  top: 42%;
  left: 58%;
  background: var(--splash-accent-glow);
  opacity: 0.25;
  animation: app-splash-float-c 8s ease-in-out infinite;
}

body.app-bootstrapped #app-splash {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.app-bootstrapped #app-splash .app-splash__shell {
  transform: scale(0.94) translateY(8px);
  opacity: 0;
  filter: blur(6px);
  transition:
    transform 0.45s cubic-bezier(0.4, 0, 1, 1),
    opacity 0.4s ease,
    filter 0.45s ease;
}

.app-splash__progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--splash-progress-bg);
  overflow: hidden;
  z-index: 2;
}

.app-splash__progress-bar {
  position: relative;
  height: 100%;
  width: 42%;
  background: var(--splash-progress-fill);
  box-shadow: 0 0 16px var(--splash-accent-glow);
  animation: app-splash-progress-top 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.app-splash__progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 48%,
    transparent 100%
  );
  animation: app-splash-shimmer 1.2s ease-in-out infinite;
}

.app-splash__shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: min(100%, 26rem);
  animation: app-splash-shell-enter 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform 0.45s ease, opacity 0.4s ease, filter 0.45s ease;
}

.app-splash__shell > .app-splash__reveal {
  animation: app-splash-reveal 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.72s;
}

.app-splash__card {
  width: 100%;
  padding: 2rem 1.75rem 1.5rem;
  border-radius: 1.25rem;
  background: var(--splash-card-bg);
  border: 1px solid var(--splash-card-border);
  box-shadow: var(--splash-card-shadow);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  text-align: center;
  box-sizing: border-box;
  animation:
    app-splash-card-enter 0.75s cubic-bezier(0.22, 1, 0.36, 1) both,
    app-splash-card-glow 3.5s ease-in-out 0.75s infinite;
}

.app-splash__card > .app-splash__reveal {
  animation: app-splash-reveal 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.app-splash__card > .app-splash__reveal:nth-child(1) { animation-delay: 0.08s; }
.app-splash__card > .app-splash__reveal:nth-child(2) { animation-delay: 0.16s; }
.app-splash__card > .app-splash__reveal:nth-child(3) { animation-delay: 0.24s; }
.app-splash__card > .app-splash__reveal:nth-child(4) { animation-delay: 0.32s; }
.app-splash__card > .app-splash__reveal:nth-child(5) { animation-delay: 0.4s; }
.app-splash__card > .app-splash__reveal:nth-child(6) { animation-delay: 0.48s; }
.app-splash__card > .app-splash__reveal:nth-child(7) { animation-delay: 0.56s; }

.app-splash__brand {
  margin: 0 auto 0.875rem;
}

.app-splash__logo {
  display: block;
  width: 6.5rem;
  height: auto;
  max-height: 2.5rem;
  margin: 0 auto;
  object-fit: contain;
}

.app-splash__logo:not([src]) {
  visibility: hidden;
}

.app-splash__title {
  margin: 0 0 0.25rem;
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--splash-title);
  line-height: 1.2;
}

.app-splash__subtitle {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--splash-subtitle);
  line-height: 1.45;
}

.app-splash__modules {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.app-splash__modules:empty {
  display: none;
  margin: 0;
}

.app-splash__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--splash-chip-text);
  background: var(--splash-chip-bg);
  border: 1px solid var(--splash-chip-border);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.app-splash__modules .app-splash__chip:nth-child(1) {
  animation: app-splash-chip-pop 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) 0.55s both;
}

.app-splash__modules .app-splash__chip:nth-child(2) {
  animation: app-splash-chip-pop 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) 0.68s both;
}

.app-splash__chip svg {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
  opacity: 0.85;
}

.app-splash__track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--splash-progress-bg);
  overflow: hidden;
  margin-bottom: 0.875rem;
}

.app-splash__track-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 42%;
  border-radius: inherit;
  background: var(--splash-progress-fill);
  box-shadow: 0 0 12px var(--splash-accent-glow);
  animation: app-splash-track-slide 2.1s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

.app-splash__track-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    105deg,
    transparent 20%,
    rgba(255, 255, 255, 0.5) 50%,
    transparent 80%
  );
  animation: app-splash-shimmer 1.4s ease-in-out infinite;
}

.app-splash__text {
  margin: 0 0 0.35rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--splash-text);
  letter-spacing: 0.01em;
}

.app-splash__status-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
}

.app-splash__status {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--splash-muted);
  min-height: 1.25em;
  transition:
    opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-splash__status.is-exit {
  opacity: 0;
  transform: translateY(-6px);
}

.app-splash__status.is-enter {
  opacity: 0;
  transform: translateY(8px);
}

.app-splash__dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.app-splash__dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--splash-accent);
  opacity: 0.35;
  animation: app-splash-dot-bounce 1.2s ease-in-out infinite;
}

.app-splash__dots span:nth-child(1) { animation-delay: 0s; }
.app-splash__dots span:nth-child(2) { animation-delay: 0.15s; }
.app-splash__dots span:nth-child(3) { animation-delay: 0.3s; }

.app-splash__footer {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--splash-muted);
  letter-spacing: 0.02em;
}

.app-splash__footer strong {
  color: var(--splash-subtitle);
  font-weight: 600;
}

@keyframes app-splash-bg-shift {
  0% { background-position: 0% 40%; }
  100% { background-position: 100% 60%; }
}

@keyframes app-splash-grid-drift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(40px, 40px); }
}

@keyframes app-splash-shell-enter {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes app-splash-card-enter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes app-splash-card-glow {
  0%, 100% {
    box-shadow: var(--splash-card-shadow);
  }
  50% {
    box-shadow:
      var(--splash-card-shadow),
      0 0 0 1px rgba(195, 0, 0, 0.06),
      0 0 40px -8px var(--splash-accent-glow);
  }
}

@keyframes app-splash-reveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes app-splash-progress-top {
  0% {
    transform: translateX(-105%);
  }
  100% {
    transform: translateX(320%);
  }
}

@keyframes app-splash-track-slide {
  0% {
    left: -45%;
    width: 38%;
  }
  50% {
    width: 48%;
  }
  100% {
    left: 105%;
    width: 38%;
  }
}

@keyframes app-splash-shimmer {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

@keyframes app-splash-float-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-14px, 18px) scale(1.05); }
  66% { transform: translate(10px, -12px) scale(0.96); }
}

@keyframes app-splash-float-b {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(16px, -20px) scale(1.08); }
}

@keyframes app-splash-float-c {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(calc(-50% + 20px), calc(-50% - 14px)) scale(1.15); }
}

@keyframes app-splash-chip-pop {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes app-splash-dot-bounce {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0) scale(0.85);
  }
  40% {
    opacity: 1;
    transform: translateY(-5px) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  #app-splash,
  #app-splash::before,
  .app-splash__progress-bar,
  .app-splash__progress-bar::after,
  .app-splash__track-fill,
  .app-splash__track-fill::after,
  .app-splash__orb,
  .app-splash__card,
  .app-splash__card > .app-splash__reveal,
  .app-splash__modules .app-splash__chip,
  .app-splash__dots span {
    animation: none;
  }

  .app-splash__track-fill {
    left: 20%;
    width: 60%;
  }

  .app-splash__progress-bar {
    width: 50%;
    transform: none;
  }

  body.app-bootstrapped #app-splash .app-splash__shell {
    filter: none;
  }
}

@media (max-width: 380px) {
  .app-splash__card {
    padding: 1.5rem 1.25rem 1.25rem;
  }

  .app-splash__modules {
    flex-direction: column;
    align-items: stretch;
  }
}
