:root {
  --bg-warm: #0b1020;
  --bg-peach: #0f1a33;
  --bg-sky: #101f3a;
  --bg-ice: #0c162c;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --accent: #00f5d4;
  --accent-deep: #00c2a8;
  --accent-soft: #142c3d;
  --accent-hot: #ff7a9a;
  --panel: rgba(10, 16, 30, 0.78);
  --shadow: 0 32px 90px rgba(5, 8, 18, 0.55);
  --font-title: "Bahnschrift", "Segoe UI", "Arial", sans-serif;
  --font-body: "Segoe UI", "Microsoft YaHei", "Helvetica", sans-serif;
  --font-accent: "Consolas", "Lucida Console", "Monaco", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--font-body);
  color: var(--ink);
  background: radial-gradient(circle at 18% 14%, rgba(0, 245, 212, 0.22) 0%, transparent 45%),
    radial-gradient(circle at 82% 18%, rgba(255, 122, 154, 0.2) 0%, transparent 40%),
    radial-gradient(circle at 70% 85%, rgba(59, 130, 246, 0.18) 0%, transparent 45%),
    linear-gradient(145deg, var(--bg-warm), var(--bg-peach) 45%, var(--bg-sky));
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(
      130deg,
      rgba(255, 255, 255, 0.08),
      rgba(255, 255, 255, 0) 60%
    ),
    radial-gradient(circle at 30% 80%, rgba(0, 245, 212, 0.18), transparent 55%);
  opacity: 0.9;
  animation: ambientShift 12s ease-in-out infinite;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.06) 0,
    rgba(255, 255, 255, 0.06) 1px,
    transparent 1px,
    transparent 5px
  );
  opacity: 0.18;
  animation: scanMove 10s linear infinite;
}

.bg-orbit {
  position: fixed;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(0, 245, 212, 0.25),
    rgba(0, 0, 0, 0)
  );
  filter: blur(1px);
  opacity: 0.65;
  z-index: -1;
  animation: float 16s ease-in-out infinite;
}

.bg-orbit--one {
  top: -80px;
  left: -60px;
}

.bg-orbit--two {
  bottom: -120px;
  right: -80px;
  animation-delay: 2s;
}

.bg-orbit--three {
  top: 20%;
  right: 30%;
  width: 240px;
  height: 240px;
  animation-delay: 4s;
}

main {
  padding: calc(36px + env(safe-area-inset-top)) 6vw
    calc(36px + env(safe-area-inset-bottom));
  min-height: 100svh;
}

.hidden {
  display: none;
}

.gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.card {
  background: var(--panel);
  border-radius: 28px;
  padding: 42px 48px;
  box-shadow: var(--shadow);
  max-width: 520px;
  width: min(90vw, 520px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  animation: fadeIn 0.9s ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    140deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0) 60%
  );
  opacity: 0.8;
  z-index: 0;
}

.card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 6px;
  width: 100%;
  background: linear-gradient(
    90deg,
    var(--accent),
    var(--accent-hot) 45%,
    #ffd166
  );
  opacity: 0.95;
  z-index: 1;
}

.card > * {
  position: relative;
  z-index: 2;
}

.card h1 {
  font-family: var(--font-title);
  font-size: 2.6rem;
  margin: 12px 0 6px;
  letter-spacing: 0.04em;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 6px 12px;
  background: rgba(0, 245, 212, 0.12);
  color: var(--accent);
  font-family: var(--font-accent);
  border-radius: 999px;
  border: 1px solid rgba(0, 245, 212, 0.35);
}

.subtitle {
  color: var(--muted);
  margin-top: 4px;
}

.input-row {
  margin-top: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
}

.input-row input {
  flex: 1;
  padding: 14px 16px;
  font-size: 1rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(10, 16, 30, 0.85);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(0, 245, 212, 0.12);
  height: 48px;
}

.input-row input::placeholder {
  color: rgba(226, 232, 240, 0.6);
}

.input-row .btn {
  height: 48px;
}

.msg {
  min-height: 22px;
  color: #d04545;
  margin-top: 10px;
}

.micro {
  color: var(--muted);
  font-size: 0.85rem;
}

.micro span {
  font-weight: 700;
  color: var(--accent-deep);
}

.footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 10px 4vw calc(12px + env(safe-area-inset-bottom));
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  pointer-events: none;
}

.helper {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.btn {
  border: none;
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 1rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hot));
  color: white;
  box-shadow: 0 18px 36px rgba(0, 245, 212, 0.35),
    0 12px 22px rgba(255, 122, 154, 0.3);
  letter-spacing: 0.08em;
}

.btn-primary:hover {
  box-shadow: 0 22px 44px rgba(0, 245, 212, 0.4),
    0 16px 28px rgba(255, 122, 154, 0.35);
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 20%,
    rgba(255, 255, 255, 0.35) 40%,
    transparent 60%
  );
  transform: translateX(-120%);
  animation: shimmer 3.6s ease-in-out infinite;
}

.btn-large {
  width: 100%;
  padding: 16px 24px;
  font-size: 1.1rem;
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(0, 245, 212, 0.35);
  color: var(--accent);
}

.lottery {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.lottery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.lottery-header h2 {
  font-family: var(--font-title);
  font-size: 2.2rem;
  margin: 8px 0 6px;
}

.tag {
  font-size: 0.78rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat {
  background: var(--panel);
  padding: 12px 18px;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(28, 26, 23, 0.12);
  min-width: 120px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.lottery-body {
  display: grid;
  grid-template-columns: minmax(260px, 520px) minmax(240px, 340px);
  gap: 36px;
  align-items: center;
  flex: 1;
}

.wheel-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  perspective: 900px;
  animation: floatWheel 6s ease-in-out infinite;
}

.wheel-wrap canvas {
  border-radius: 50%;
  background: #0b1426;
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.08),
    0 26px 55px rgba(0, 0, 0, 0.45);
  max-width: 100%;
  transform: rotateX(10deg);
}

.glow {
  position: absolute;
  width: 120%;
  height: 120%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(0, 245, 212, 0.35) 0%,
    rgba(0, 0, 0, 0) 70%
  );
  filter: blur(6px);
  z-index: -1;
  animation: pulseGlow 5s ease-in-out infinite;
}

.pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-bottom: 32px solid var(--accent);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6));
  animation: pointerPulse 2.4s ease-in-out infinite;
}

.pointer span {
  position: absolute;
  top: 6px;
  left: -11px;
  font-size: 0.75rem;
  color: #04121a;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.panel {
  background: var(--panel);
  padding: 28px;
  border-radius: 26px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.complete-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.complete-actions.hidden {
  display: none;
}

.complete-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.5;
}

.result-card {
  background: rgba(10, 16, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px 18px;
}

.result-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 6px;
}

.result-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
  color: var(--accent);
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
}

.prize-title {
  font-size: 0.9rem;
  margin: 0 0 10px;
  color: var(--muted);
}

.prize-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prize-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(10, 16, 30, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
}

.prize-pill.active {
  background: var(--accent-soft);
  border-color: rgba(0, 245, 212, 0.45);
  color: var(--accent);
  font-weight: 700;
}

.lottery.completed #spinBtn,
.lottery.completed .panel-actions,
.lottery.completed .prize-list,
.lottery.completed .hint {
  display: none;
}

.lottery.completed .complete-actions {
  display: flex;
}

@media (max-width: 900px) {
  main {
    padding: 32px 5vw;
  }

  .lottery-body {
    grid-template-columns: 1fr;
  }

  .panel {
    order: 2;
  }

  .wheel-wrap {
    order: 1;
  }
}

@media (max-width: 600px) {
  main {
    padding: calc(22px + env(safe-area-inset-top)) 4vw
      calc(26px + env(safe-area-inset-bottom));
  }

  .card {
    padding: 28px 24px;
  }

  .card h1 {
    font-size: 2rem;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .input-row .btn {
    width: 100%;
  }

  .lottery-header {
    gap: 16px;
    margin-bottom: 22px;
  }

  .lottery-header h2 {
    font-size: 1.8rem;
  }

  .stats {
    width: 100%;
  }

  .stat {
    flex: 1;
    min-width: 0;
  }

  .lottery-body {
    gap: 24px;
    align-items: start;
  }

  .pointer {
    top: -10px;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 26px solid var(--accent);
  }

  .pointer span {
    top: 4px;
    left: -9px;
    font-size: 0.7rem;
  }

  .panel {
    padding: 22px;
  }

  .result-value {
    font-size: 1.4rem;
  }
}

@media (max-width: 430px) {
  .card {
    padding: 24px 20px;
    border-radius: 24px;
  }

  .card h1 {
    font-size: 1.9rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  .lottery-header h2 {
    font-size: 1.6rem;
  }

  .stats {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat {
    padding: 10px 12px;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .panel {
    padding: 18px;
  }

  .result-value {
    font-size: 1.25rem;
  }
}

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

@keyframes float {
  0%,
  100% {
    transform: translateY(0) translateX(0);
  }
  50% {
    transform: translateY(20px) translateX(-10px);
  }
}

@keyframes ambientShift {
  0%,
  100% {
    opacity: 0.8;
  }
  50% {
    opacity: 1;
  }
}

@keyframes scanMove {
  0% {
    transform: translateY(-10%);
  }
  100% {
    transform: translateY(10%);
  }
}

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

@keyframes pulseGlow {
  0%,
  100% {
    opacity: 0.65;
    transform: scale(0.98);
  }
  50% {
    opacity: 0.95;
    transform: scale(1.02);
  }
}

@keyframes pointerPulse {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }
  50% {
    transform: translateX(-50%) scale(1.06);
  }
}

@keyframes floatWheel {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}
