:root {
  color-scheme: light;
  --app-bg: #f7f3ff;
  --surface: rgba(255,255,255,0.86);
  --surface-strong: #ffffff;
  --surface-soft: rgba(255,255,255,0.64);
  --shadow-soft: 0 14px 34px rgba(47,35,86,0.10);
  --shadow-deep: 0 22px 54px rgba(47,35,86,0.18);
  --radius-card: 20px;
  --radius-control: 14px;
  --focus-ring: 0 0 0 4px rgba(142,85,255,0.16);
  --nav-height: 74px;
  --cosmic-mouse-x: 50%;
  --cosmic-mouse-y: 42%;
  --cosmic-parallax-x: 0px;
  --cosmic-parallax-y: 0px;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(ellipse at 18% 18%, rgba(118,69,255,0.32), transparent 28rem),
    radial-gradient(ellipse at 84% 26%, rgba(255,184,92,0.18), transparent 24rem),
    radial-gradient(ellipse at 48% 86%, rgba(30,207,184,0.12), transparent 24rem),
    linear-gradient(140deg, #070711 0%, #15102b 42%, #241347 66%, #0b0a17 100%) !important;
  color: var(--ink, #151226);
  font-feature-settings: "liga" 1, "kern" 1;
  isolation: isolate;
}

body.page-transition {
  opacity: 0;
  transform: translateY(10px) scale(0.992);
  filter: blur(2px);
}

body.page-ready {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
  transition:
    opacity 0.34s ease,
    transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.34s ease;
}

body.page-leaving {
  opacity: 0;
  transform: translateY(-8px) scale(0.994);
  filter: blur(2px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    filter 0.2s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(circle at 8% 12%, rgba(255,255,255,0.82) 0 1px, transparent 1.8px),
    radial-gradient(circle at 24% 74%, rgba(255,255,255,0.5) 0 1px, transparent 1.7px),
    radial-gradient(circle at 42% 22%, rgba(255,255,255,0.7) 0 1px, transparent 1.7px),
    radial-gradient(circle at 68% 38%, rgba(255,255,255,0.56) 0 1px, transparent 1.8px),
    radial-gradient(circle at 86% 78%, rgba(255,255,255,0.72) 0 1px, transparent 1.8px),
    radial-gradient(circle at 55% 66%, rgba(255,222,164,0.72) 0 1px, transparent 1.8px);
  background-size: 170px 170px, 230px 230px, 190px 190px, 260px 260px, 210px 210px, 280px 280px;
  animation: cosmicStarDrift 96s linear infinite;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 22% 42%, rgba(178,108,255,0.3), transparent 25rem),
    radial-gradient(ellipse at 76% 56%, rgba(255,166,82,0.16), transparent 23rem),
    radial-gradient(ellipse at 48% 28%, rgba(74,222,217,0.1), transparent 21rem),
    linear-gradient(115deg, transparent 0 28%, rgba(255,255,255,0.11) 44%, transparent 62%);
  filter: blur(2px) saturate(1.18);
  opacity: 0.88;
  animation: cosmicNebulaBreath 36s ease-in-out infinite alternate;
}

.cosmic-space-field {
  position: fixed;
  inset: -8%;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.72;
}

.cosmic-space-field::before,
.cosmic-space-field::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,0.85) 0 1px, transparent 1.7px),
    radial-gradient(circle at 32% 64%, rgba(222,208,255,0.68) 0 1px, transparent 1.8px),
    radial-gradient(circle at 54% 32%, rgba(255,237,198,0.76) 0 1.2px, transparent 2px),
    radial-gradient(circle at 78% 18%, rgba(255,255,255,0.72) 0 1px, transparent 1.8px),
    radial-gradient(circle at 88% 72%, rgba(205,241,255,0.62) 0 1px, transparent 1.8px);
  background-size: 210px 210px, 270px 270px, 320px 320px, 240px 240px, 300px 300px;
  animation: cosmicStarDrift 120s linear infinite, cosmicTwinkle 12s ease-in-out infinite alternate;
}

.cosmic-space-field::after {
  filter: blur(0.5px);
  opacity: 0.5;
  transform: scale(1.2);
  animation-duration: 160s, 14s;
  animation-direction: reverse, alternate;
}

.cosmic-particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  border-radius: 999px;
  background: rgba(255,255,255,0.86);
  box-shadow:
    0 0 10px rgba(185,145,255,0.58),
    0 0 20px rgba(255,201,129,0.18);
  opacity: var(--opacity);
  transform: translate3d(0, 0, 0);
  animation: cosmicParticleFloat var(--duration) ease-in-out infinite alternate;
  animation-delay: var(--delay);
}

a, button, input, select, textarea {
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
  font-family: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

body.theme-dark {
  color-scheme: dark;
  --primary: #b18cff;
  --primary2: #d1bdff;
  --secondary: #ffbd72;
  --accent: #d8c3ff;
  --gold: #ffbf62;
  --ink: #f7f2ff;
  --ink2: #e5dcff;
  --paper: #15101f;
  --muted: #beb3cf;
  --line: rgba(255,255,255,0.12);
  --soft: rgba(177,140,255,0.18);
  --dark: #0f0b18;
  --dark2: #181123;
  --glass: rgba(255,255,255,0.075);
  --glass-border: rgba(255,255,255,0.14);
  --text: #f7f2ff;
  --text-dim: #beb3cf;
  --app-bg: #0f0b18;
  --surface: rgba(255,255,255,0.078);
  --surface-strong: rgba(255,255,255,0.105);
  --surface-soft: rgba(255,255,255,0.052);
  --shadow-soft: 0 16px 40px rgba(0,0,0,0.28);
  --shadow-deep: 0 24px 60px rgba(0,0,0,0.38);
  background:
    radial-gradient(ellipse at 18% 18%, rgba(118,69,255,0.26), transparent 28rem),
    radial-gradient(ellipse at 84% 26%, rgba(255,191,98,0.14), transparent 24rem),
    radial-gradient(ellipse at 48% 86%, rgba(30,207,184,0.09), transparent 24rem),
    linear-gradient(140deg, #05050d 0%, #100b21 42%, #1c0f37 66%, #080711 100%) !important;
  color: #f7f2ff !important;
}

body.theme-dark .bg {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(177,140,255,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(255,191,98,0.07) 0%, transparent 50%) !important;
}

body.theme-dark .app-card,
body.theme-dark .card,
body.theme-dark .feature,
body.theme-dark .usage-card,
body.theme-dark .wide-card,
body.theme-dark .panel,
body.theme-dark .form-card,
body.theme-dark .payment-card,
body.theme-dark .result-card,
body.theme-dark .question-card,
body.theme-dark .premium-card,
body.theme-dark .plan-card,
body.theme-dark .history-item,
body.theme-dark .lucky-item {
  background: linear-gradient(180deg, rgba(255,255,255,0.092), rgba(255,255,255,0.052)) !important;
  border-color: rgba(255,255,255,0.14) !important;
  color: #f7f2ff !important;
  box-shadow: 0 16px 40px rgba(0,0,0,0.24) !important;
}

body.theme-dark .result-body,
body.theme-dark .message,
body.theme-dark .reading,
body.theme-dark .analysis,
body.theme-dark .face-result,
body.theme-dark .sacred-meta,
body.theme-dark .sacred-place p,
body.theme-dark .history-item,
body.theme-dark .lottery-box,
body.theme-dark #dashboardAnalysis,
body.theme-dark #lotteryAnalysis,
body.theme-dark #lotterySource,
body.theme-dark #lucky2Desc {
  color: #f4efff !important;
}

body.theme-dark .result-header,
body.theme-dark .result-header .info h2,
body.theme-dark .card-title,
body.theme-dark .history-item .type,
body.theme-dark .lucky-item strong,
body.theme-dark .premium-card h3,
body.theme-dark .feature-card h3 {
  color: #ffffff !important;
}

body.theme-dark .result-header p,
body.theme-dark .premium-insight p,
body.theme-dark .feature-card p,
body.theme-dark .wide-card p,
body.theme-dark .card p,
body.theme-dark .status-card span,
body.theme-dark .section-title,
body.theme-dark .history-item .date,
body.theme-dark .lucky-item .label,
body.theme-dark .score-item .label,
body.theme-dark .sacred-tags span,
body.theme-dark .muted {
  color: #d8d0e8 !important;
}

body.theme-dark .premium-insight,
body.theme-dark .face-result,
body.theme-dark .sacred-place,
body.theme-dark .score-item,
body.theme-dark .lottery-box {
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.075)) !important;
  border-color: rgba(255,255,255,0.18) !important;
}

body.theme-dark .premium-insight h4,
body.theme-dark .feature-icon,
body.theme-dark .score-item .val,
body.theme-dark .sacred-map {
  color: #e7d9ff !important;
}

body.theme-dark .tarot-card .card-name,
body.theme-dark .tarot-card .card-meaning,
body.theme-dark .count-btn .label,
body.theme-dark .zodiac-btn .name,
body.theme-dark .nav-item span {
  color: #eee7ff !important;
}

body.theme-dark .count-btn,
body.theme-dark .zodiac-btn,
body.theme-dark .tarot-card {
  color: #ffffff !important;
}

body.theme-dark .nav-item:not(.active) {
  color: #d0c7dc !important;
}

.app,
.container,
.wrap {
  width: min(100%, 520px);
}

.topbar,
.top,
.header,
.app-header {
  position: relative;
}

.header h1,
.title strong,
.hello strong,
h1, h2, h3 {
  letter-spacing: 0;
}

.hero {
  border-radius: 22px !important;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: var(--shadow-deep) !important;
}

.hero h1 {
  text-wrap: balance;
}

.hero p,
.wide-card p,
.muted,
.result-body,
.message {
  text-wrap: pretty;
}

.card,
.feature,
.usage-card,
.wide-card,
.status-card,
.zodiac-btn,
.count-btn,
.loading,
.result-card,
.step,
.upload,
.qr-panel,
.receiver,
.history-item,
.lucky-item,
.item,
.form-control,
.gender-item,
.lottery-box {
  border-radius: var(--radius-card) !important;
  border-color: var(--line, rgba(40,30,70,0.09)) !important;
  box-shadow: var(--shadow-soft) !important;
}

.card,
.feature,
.usage-card,
.wide-card,
.status-card,
.zodiac-btn,
.count-btn,
.loading,
.result-card,
.item {
  background: var(--surface) !important;
  backdrop-filter: blur(18px);
}

.usage-card.premium {
  background: linear-gradient(135deg, var(--primary, #8e55ff), var(--gold, #f5ad42)) !important;
  color: #ffffff !important;
}

.usage-card.premium small,
.usage-card.premium strong {
  color: #ffffff !important;
}

.usage-card.premium small {
  opacity: 0.82;
}

.feature,
.zodiac-btn,
.count-btn,
.wide-card,
.nav-item,
button,
.theme-action {
  transition:
    transform 0.2s cubic-bezier(0.18, 0.9, 0.24, 1),
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    color 0.2s ease,
    filter 0.2s ease;
}

.feature:hover,
.zodiac-btn:hover,
.count-btn:hover,
.wide-card:hover,
button:hover {
  transform: translateY(-2px);
  filter: saturate(1.04);
}

.feature,
.wide-card,
.count-btn,
.zodiac-btn,
.result-card,
.usage-card,
.status-card {
  position: relative;
  overflow: hidden;
}

.feature::before,
.wide-card::before,
.count-btn::before,
.zodiac-btn::before,
.usage-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 0 34%, rgba(255,255,255,0.34) 45%, transparent 56%);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-120%);
  transition: opacity 0.2s ease, transform 0.64s ease;
}

.feature:hover::before,
.wide-card:hover::before,
.count-btn:hover::before,
.zodiac-btn:hover::before,
.usage-card:hover::before {
  opacity: 1;
  transform: translateX(120%);
}

.feature .icon,
.result-icon,
.header-icon,
.nav-icon,
.avatar,
.premium-mark,
.step-num {
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.34), 0 10px 24px rgba(91,61,153,0.15);
}

@keyframes fortuneIconFloat {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  45% { transform: translateY(-3px) rotate(-2deg) scale(1.03); }
  70% { transform: translateY(1px) rotate(1deg) scale(0.99); }
}

@keyframes fortuneIconPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.14) rotate(-4deg); }
  100% { transform: scale(1.04) rotate(0deg); }
}

@keyframes fortuneActivePulse {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(142,85,255,0)); transform: translateY(0) scale(1); }
  50% { filter: drop-shadow(0 5px 12px rgba(142,85,255,0.28)); transform: translateY(-1px) scale(1.06); }
}

@keyframes cosmicNebulaBreath {
  from {
    opacity: 0.58;
    filter: blur(2px) saturate(1.08);
  }
  to {
    opacity: 0.76;
    filter: blur(2.5px) saturate(1.16);
  }
}

@keyframes cosmicStarDrift {
  from { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
  to { background-position: 42px -42px, -56px 56px, 48px 48px, -62px -62px, 52px -52px, -68px 68px; }
}

@keyframes cosmicTwinkle {
  from { opacity: 0.5; }
  to { opacity: 0.72; }
}

@keyframes cosmicParticleFloat {
  from {
    transform: translate3d(0, 0, 0) scale(0.85);
    filter: blur(0);
  }
  to {
    transform: translate3d(var(--drift-x), var(--drift-y), 0) scale(1.06);
    filter: blur(0.4px);
  }
}

.feature .icon,
.result-icon,
.header-icon,
.premium-mark,
.step-num {
  transform-origin: center;
  animation: fortuneIconFloat 4.2s ease-in-out infinite;
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  transform-origin: center;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.feature:hover .icon,
.feature:focus-visible .icon,
.wide-card:hover .icon,
.count-btn:hover .num,
.zodiac-btn:hover .emoji,
.theme-action:hover,
.nav-item:hover .nav-icon {
  animation: fortuneIconPop 0.46s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.nav-item.active .nav-icon,
.count-btn.active .num,
.zodiac-btn.active .emoji {
  animation: fortuneActivePulse 2.2s ease-in-out infinite;
}

button:active,
.feature:active,
.wide-card:active,
.nav-item:active,
.theme-action:active {
  transform: translateY(0) scale(0.98);
}

.feature-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.feature {
  min-height: 92px !important;
  padding: 10px 6px;
}

.feature span,
.nav-item,
.zodiac-btn .name,
.count-btn .label {
  line-height: 1.25;
}

.wide-card {
  grid-template-columns: 86px 1fr !important;
  gap: 14px !important;
  padding: 14px !important;
}

.wide-card img {
  width: 86px !important;
  height: 104px !important;
  border-radius: 16px !important;
  box-shadow: 0 12px 24px rgba(32,24,58,0.16);
}

.badge,
.pill,
.status,
.premium-badge {
  border-radius: 999px !important;
  letter-spacing: 0;
}

.primary-btn,
.btn-action,
.save-btn,
button:not(.theme-action):not(.zodiac-btn):not(.count-btn) {
  border-radius: 16px !important;
}

.primary-btn,
.btn-action,
.save-btn {
  min-height: 48px;
}

.bottom-nav,
.nav-bar {
  min-height: var(--nav-height);
  padding: 10px 14px max(12px, env(safe-area-inset-bottom)) !important;
  background: rgba(255,255,255,0.74) !important;
  border-top: 1px solid rgba(40,30,70,0.09) !important;
  box-shadow: 0 -12px 34px rgba(47,35,86,0.08);
  backdrop-filter: blur(18px);
}

.bottom-inner,
.nav-bar {
  max-width: 480px;
  margin: 0 auto;
}

.nav-item {
  min-height: 48px;
  border-radius: 16px !important;
  padding-inline: 10px !important;
}

.nav-item.active {
  color: var(--primary2, #5f39cc) !important;
  background: rgba(142,85,255,0.13) !important;
}

body.theme-dark .nav-item.active {
  background: rgba(177,140,255,0.17) !important;
}

input,
textarea,
select,
.form-control {
  min-height: 48px;
  border-radius: 16px !important;
  padding: 12px 18px !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
.form-control:focus {
  transform: translateY(-1px);
  box-shadow: var(--focus-ring), 0 14px 30px rgba(47,35,86,0.1) !important;
}

select.form-control {
  padding-right: 44px !important;
}

.theme-toggle {
  display: none !important;
}

body.theme-dark input,
body.theme-dark textarea,
body.theme-dark select,
body.theme-dark .form-control,
body.theme-dark .sacred-search input,
body.theme-dark .premium-question textarea {
  background: rgba(255,255,255,0.08) !important;
  border-color: rgba(255,255,255,0.16) !important;
  color: #f7f2ff !important;
}

body.theme-dark select.form-control option {
  background-color: #241b31;
  color: #f7f2ff;
}

body.theme-dark select.form-control option:checked {
  background-color: #8e55ff;
  color: #ffffff;
}

body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder,
body.theme-dark .form-control::placeholder,
body.theme-dark .sacred-search input::placeholder,
body.theme-dark .premium-question textarea::placeholder {
  color: #c5bad7 !important;
  opacity: 0.82;
}

body.theme-dark p,
body.theme-dark small,
body.theme-dark label,
body.theme-dark .muted,
body.theme-dark .subtitle,
body.theme-dark .desc,
body.theme-dark .date,
body.theme-dark .label {
  color: #beb3cf;
}

body.theme-dark .bottom-nav,
body.theme-dark .nav-bar {
  background: rgba(15,11,24,0.9) !important;
  border-color: rgba(255,255,255,0.12) !important;
}

body.theme-dark .nav-item {
  color: #beb3cf;
}

body.theme-dark .nav-item.active {
  color: #d8c3ff;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  body.page-transition,
  body.page-ready,
  body.page-leaving {
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
  }

  .feature .icon,
  .result-icon,
  .header-icon,
  .premium-mark,
  .step-num,
  .nav-item.active .nav-icon,
  .count-btn.active .num,
  .zodiac-btn.active .emoji,
  .cosmic-space-field,
  .cosmic-space-field::before,
  .cosmic-space-field::after,
  .cosmic-particle,
  body::before,
  body::after {
    animation: none !important;
  }
}

.theme-actions {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  z-index: 60;
  width: min(520px, calc(100% - 24px));
  transform: translateX(-50%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.theme-action {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(40,30,70,0.11);
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.82);
  color: #151226;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  cursor: pointer;
  font: 700 18px/1 "Prompt", sans-serif;
  text-decoration: none;
  pointer-events: auto;
}

.theme-action:hover {
  transform: translateY(-1px);
}

.theme-action[hidden] {
  display: none;
}

body.theme-dark .theme-action {
  background: rgba(24,17,35,0.86);
  border-color: rgba(255,255,255,0.16);
  color: #f7f2ff;
  box-shadow: 0 14px 34px rgba(0,0,0,0.34);
}

body.has-theme-actions .app,
body.has-theme-actions .container,
body.has-theme-actions .wrap {
  padding-top: max(74px, calc(env(safe-area-inset-top) + 64px));
}

body.has-theme-actions .back,
body.has-theme-actions .back-btn {
  visibility: hidden;
  pointer-events: none;
}

@media (min-width: 720px) {
  .theme-actions {
    top: 18px;
  }

  .app,
  .container,
  .wrap {
    max-width: 560px !important;
  }
}

@media (max-width: 380px) {
  .feature-grid,
  .zodiac-grid,
  .lucky-grid {
    gap: 8px !important;
  }

  .feature {
    min-height: 84px !important;
  }

  .feature .icon {
    width: 38px !important;
    height: 38px !important;
  }

  .wide-card {
    grid-template-columns: 76px 1fr !important;
  }

  .wide-card img {
    width: 76px !important;
    height: 94px !important;
  }
}
