:root {
  --bg: #11163a;
  --panel: rgba(28, 34, 72, 0.78);
  --panel-strong: rgba(24, 29, 64, 0.9);
  --text: #f5f7ff;
  --muted: #c5cbee;
  --line: rgba(127, 219, 255, 0.34);
  --accent: #7fdbff;
  --accent-2: #ff6ec7;
  --accent-3: #d9ff66;
  --accent-4: #7cffcb;
  --card-glow: rgba(127, 219, 255, 0.36);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 110, 199, 0.3), transparent 24rem),
    radial-gradient(circle at 86% 18%, rgba(127, 219, 255, 0.28), transparent 23rem),
    radial-gradient(circle at 55% 78%, rgba(217, 255, 102, 0.12), transparent 24rem),
    linear-gradient(180deg, #18205a 0%, #111846 45%, #151137 100%);
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(127, 219, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 110, 199, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 88%);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px 24px;
  overflow: hidden;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 220px;
  height: 220px;
  border: 1px solid rgba(127, 219, 255, 0.38);
  transform: rotate(18deg);
  opacity: 0.72;
  filter: blur(0.2px);
  animation: drift 12s ease-in-out infinite alternate;
}

.ambient-one {
  top: 56px;
  right: -120px;
  box-shadow: 0 0 44px rgba(127, 219, 255, 0.28), 0 0 60px rgba(217, 255, 102, 0.12);
}

.ambient-two {
  bottom: 120px;
  left: -150px;
  border-color: rgba(255, 110, 199, 0.34);
  box-shadow: 0 0 44px rgba(255, 110, 199, 0.24), 0 0 60px rgba(124, 255, 203, 0.1);
  animation-delay: -4s;
}

.scanline {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.12;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 6px);
  mix-blend-mode: screen;
}

.screen {
  display: none;
  min-height: calc(100vh - 108px);
  animation: screenIn 280ms ease both;
}

.screen-active {
  display: block;
}

.home-screen {
  display: none;
  flex-direction: column;
  justify-content: center;
  padding: 40px 0 24px;
}

.home-screen.screen-active {
  display: flex;
}

.brand-mark,
.eyebrow {
  color: var(--accent-3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(217, 255, 102, 0.58);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  position: relative;
  margin-top: 14px;
  font-size: clamp(48px, 16vw, 74px);
  line-height: 0.98;
  letter-spacing: 0;
  background: linear-gradient(94deg, #ffffff 0%, var(--accent) 36%, var(--accent-3) 62%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(127, 219, 255, 0.34);
}

.glitch::before,
.glitch::after {
  position: absolute;
  inset: 0;
  content: attr(data-text);
  opacity: 0.32;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.glitch::before {
  transform: translate(2px, -1px);
  background-image: linear-gradient(90deg, #ff6ec7, transparent);
}

.glitch::after {
  transform: translate(-2px, 1px);
  background-image: linear-gradient(90deg, transparent, #7fdbff);
}

.home-subtitle {
  margin: 22px 0 34px;
  color: #eef2ff;
  font-size: 17px;
  line-height: 1.75;
}

.tiny-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.number-lab {
  margin-top: 28px;
  padding: 16px;
  border: 1px solid rgba(217, 255, 102, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(217, 255, 102, 0.12), transparent 42%),
    rgba(17, 24, 70, 0.7);
  box-shadow: 0 0 28px rgba(217, 255, 102, 0.1), 0 0 22px rgba(127, 219, 255, 0.1) inset;
}

.number-lab-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.number-lab h2 {
  margin-top: 6px;
  font-size: 22px;
  color: #ffffff;
}

.number-lab-badge {
  padding: 5px 7px;
  border: 1px solid rgba(217, 255, 102, 0.5);
  border-radius: 4px;
  color: var(--accent-3);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.number-lab > p {
  margin: 10px 0 14px;
  color: #eef2ff;
  font-size: 13px;
  line-height: 1.65;
}

.number-mode-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.number-mode-button {
  min-height: 40px;
  padding: 7px 8px;
  border: 1px solid rgba(235, 239, 255, 0.24);
  border-radius: 8px;
  color: rgba(245, 247, 255, 0.8);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  font-weight: 800;
}

.number-mode-button.is-active {
  border-color: rgba(217, 255, 102, 0.72);
  color: #091123;
  background: linear-gradient(110deg, #d9ff66, #7fdbff);
  box-shadow: 0 0 16px rgba(217, 255, 102, 0.22);
}

.number-result {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(7, 13, 42, 0.44);
}

.number-result[hidden] {
  display: none;
}

.number-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.number-row > span {
  flex: 0 0 52px;
  color: rgba(238, 242, 255, 0.76);
  font-size: 11px;
  font-weight: 800;
}

.number-balls {
  display: flex;
  flex: 1;
  justify-content: flex-end;
  gap: 6px;
}

.number-ball {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: #071127;
  font-size: 12px;
  font-weight: 1000;
  animation: numberPop 280ms ease both;
}

.number-ball-main {
  background: linear-gradient(135deg, #d9ff66, #8df3cb);
  box-shadow: 0 0 12px rgba(217, 255, 102, 0.38);
}

.number-ball-bonus {
  color: #ffffff;
  background: linear-gradient(135deg, #7fdbff, #6d4aff);
  box-shadow: 0 0 12px rgba(127, 219, 255, 0.4);
}

.number-button {
  width: 100%;
  min-height: 42px;
  margin-top: 12px;
  border: 1px solid rgba(217, 255, 102, 0.64);
  border-radius: 8px;
  color: #f8ffe4;
  background: rgba(217, 255, 102, 0.12);
  font-size: 13px;
  font-weight: 900;
}

.number-lab small {
  display: block;
  margin-top: 10px;
  color: rgba(235, 239, 255, 0.66);
  font-size: 10px;
  line-height: 1.5;
}

.section-header {
  padding: 18px 0 16px;
}

.section-header h2 {
  margin-top: 8px;
  font-size: 28px;
}

.input-panel,
.result-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(36, 43, 91, 0.82), rgba(20, 24, 62, 0.86));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 0 34px rgba(127, 219, 255, 0.16), 0 18px 48px rgba(0, 0, 0, 0.22);
}

.input-panel {
  padding: 16px;
}

.field-block {
  display: block;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.field-block > span,
.field-block legend {
  display: block;
  margin-bottom: 10px;
  color: #f7f8ff;
  font-size: 14px;
  font-weight: 800;
}

input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(127, 219, 255, 0.42);
  border-radius: 8px;
  outline: 0;
  color: var(--text);
  background: rgba(13, 18, 48, 0.66);
  box-shadow: 0 0 18px rgba(127, 219, 255, 0.08) inset;
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(127, 219, 255, 0.16), 0 0 20px rgba(127, 219, 255, 0.12) inset;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.choice-grid label {
  position: relative;
  min-height: 42px;
}

.choice-grid input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-grid span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid rgba(197, 203, 238, 0.28);
  border-radius: 8px;
  color: #eef2ff;
  background: rgba(255, 255, 255, 0.075);
  font-size: 13px;
  line-height: 1.28;
  text-align: center;
}

.choice-grid input:checked + span {
  border-color: var(--accent);
  color: #ffffff;
  background: linear-gradient(135deg, rgba(127, 219, 255, 0.28), rgba(255, 110, 199, 0.2), rgba(217, 255, 102, 0.13));
  box-shadow: 0 0 20px rgba(127, 219, 255, 0.2);
}

.primary-button,
.ghost-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  border: 1px solid rgba(255, 255, 255, 0.32);
  color: #05101b;
  background: linear-gradient(92deg, var(--accent), var(--accent-3) 52%, var(--accent-2));
  box-shadow: 0 0 22px rgba(127, 219, 255, 0.32), 0 0 24px rgba(255, 110, 199, 0.24);
}

.ghost-button {
  border: 1px solid rgba(127, 219, 255, 0.42);
  color: var(--text);
  background: rgba(29, 36, 78, 0.74);
}

.full-button {
  width: 100%;
  margin-top: 4px;
}

.loading-screen.screen-active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  color: #dbe1ff;
  text-align: center;
}

.loader-ring {
  width: 82px;
  height: 82px;
  border: 2px solid rgba(127, 219, 255, 0.22);
  border-top-color: var(--accent);
  border-right-color: var(--accent-2);
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(127, 219, 255, 0.28);
  animation: spin 900ms linear infinite;
}

.result-screen {
  padding: 14px 0 22px;
}

.result-card {
  padding: 16px;
  overflow: hidden;
  border-color: var(--theme-main, var(--accent));
  box-shadow: 0 0 26px var(--theme-glow, var(--card-glow)), 0 0 18px var(--theme-aux-soft, rgba(255, 79, 216, 0.12));
}

.result-card::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(90deg, transparent, var(--theme-soft, rgba(87, 231, 255, 0.08)), transparent),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 38%);
}

.card-topline,
.profile-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.result-card h2 {
  position: relative;
  margin-top: 10px;
  font-size: 24px;
  background: linear-gradient(90deg, #fff, var(--theme-main, var(--accent)), var(--theme-aux, var(--accent-2)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.profile-row {
  margin-top: 12px;
  color: #eaf0ff;
  font-weight: 800;
}

.core-result {
  position: relative;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.core-result span,
.score-grid span,
.result-list span,
.share-copy span {
  display: block;
  color: var(--theme-main, var(--accent));
  font-size: 12px;
  font-weight: 900;
}

.core-result strong {
  display: block;
  margin-top: 6px;
  font-size: 23px;
}

.score-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.score-grid div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.065);
}

.score-grid strong {
  display: block;
  margin-top: 7px;
  font-size: 25px;
}

.result-list,
.share-copy {
  position: relative;
  margin-top: 14px;
}

.result-list div {
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.result-list p,
.share-copy p {
  margin-top: 6px;
  color: #eef2ff;
  font-size: 14px;
  line-height: 1.65;
}

.share-copy {
  padding: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.result-card footer {
  position: relative;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.11);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.action-grid .primary-button {
  grid-column: span 2;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 5;
  width: max-content;
  max-width: calc(100% - 36px);
  padding: 10px 14px;
  border: 1px solid rgba(127, 219, 255, 0.42);
  border-radius: 8px;
  color: #ffffff;
  background: rgba(24, 29, 64, 0.94);
  box-shadow: 0 0 24px rgba(127, 219, 255, 0.22);
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sound-toggle {
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 74px;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  color: #08101f;
  background: linear-gradient(135deg, #d9ff66, #7fdbff 52%, #ff6ec7);
  box-shadow: 0 0 22px rgba(127, 219, 255, 0.34), 0 0 26px rgba(255, 110, 199, 0.22);
  font-size: 12px;
  font-weight: 1000;
}

.sound-toggle::after {
  position: absolute;
  inset: -5px;
  z-index: -1;
  border: 1px solid rgba(217, 255, 102, 0.34);
  border-radius: inherit;
  content: "";
  animation: pulseGlow 1600ms ease-in-out infinite;
}

.sound-toggle[aria-pressed="true"] {
  color: #ffffff;
  background: linear-gradient(135deg, #1b1f4a, #6d4aff 48%, #ff4fd8);
}

.sound-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(8, 16, 31, 0.76);
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.22);
}

.share-qr {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  margin: 4px auto 0;
  padding: 0 18px;
}

.share-qr-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(127, 219, 255, 0.25);
  border-radius: 18px;
  background: rgba(10, 20, 42, 0.62);
  box-shadow: 0 0 24px rgba(127, 219, 255, 0.12);
  backdrop-filter: blur(14px);
}

.share-qr img {
  display: block;
  width: 96px;
  height: 96px;
  flex: 0 0 auto;
  padding: 8px;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 0 18px rgba(217, 255, 102, 0.18);
}

.share-qr strong,
.share-qr span {
  display: block;
}

.share-qr strong {
  margin-bottom: 6px;
  color: #ffffff;
  font-size: 15px;
}

.share-qr span {
  color: rgba(235, 239, 255, 0.72);
  font-size: 12px;
}

.disclaimer {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 12px 108px calc(18px + env(safe-area-inset-bottom)) 18px;
  color: rgba(235, 239, 255, 0.78);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

.disclaimer p {
  margin: 0 0 6px;
}

.disclaimer a {
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
}

.disclaimer a:hover {
  color: #ffffff;
}

@keyframes drift {
  from {
    transform: translateY(0) rotate(18deg);
  }
  to {
    transform: translateY(22px) rotate(28deg);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes numberPop {
  from {
    opacity: 0;
    transform: scale(0.65);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(1);
  }
  50% {
    opacity: 0.95;
    transform: scale(1.08);
  }
}

@media (min-width: 560px) {
  .app-shell {
    padding-top: 30px;
  }

  .home-screen {
    min-height: 720px;
  }
}

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