:root {
  --bg: #07080b;
  --panel: rgba(18, 22, 34, 0.78);
  --panel-solid: #161b28;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f6fb;
  --muted: #8d96ad;
  --accent: #60a5fa;
  --accent-2: #3b82f6;
  --ok: #3dd68c;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

button:focus,
button:focus-visible,
input:focus,
input:focus-visible {
  outline: none;
  box-shadow: none;
}

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: none;
}

.gl-ready #gl {
  opacity: 1;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
}

.hero {
  text-align: center;
  padding: 4px 0 12px;
  flex-shrink: 0;
}

.hero h1 {
  font-size: clamp(24px, 6.5vw, 30px);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.15;
}

.form-card {
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 13, 22, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

.field {
  position: relative;
  margin-bottom: 14px;
}

.field-last {
  margin-bottom: 0;
}

.panel-token {
  z-index: 30;
}

.label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.token-trigger,
.input-box {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(18, 22, 34, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease), transform 0.25s var(--ease);
}

.token-trigger {
  cursor: pointer;
  text-align: left;
}

.token-trigger:hover,
.input-box:focus-within {
  border-color: rgba(94, 236, 210, 0.35);
  box-shadow: 0 0 0 3px rgba(94, 236, 210, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.token-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, #34d399, #0f766e);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.35);
}

.token-logo.usdc {
  background: linear-gradient(145deg, #60a5fa, #1d4ed8);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.35);
}
.token-logo.eth {
  background: linear-gradient(145deg, #a5b4fc, #4f46e5);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}
.token-logo.btc {
  background: linear-gradient(145deg, #fbbf24, #d97706);
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.35);
}

.token-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.token-meta strong {
  font-size: 15px;
  font-weight: 600;
}

.token-meta small {
  color: var(--muted);
  font-size: 12px;
}

.chev {
  color: var(--muted);
  transition: transform 0.25s var(--ease);
}

.token-trigger[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

.token-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 50;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #151b28;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.75);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top center;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease), visibility 0.22s;
  isolation: isolate;
}

.token-menu.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.token-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: #151b28;
  color: var(--text);
  cursor: pointer;
  transition: background 0.18s ease;
}

.token-menu button:hover,
.token-menu button:active {
  background: #222a3d;
}

.chains-scroll {
  margin: 0 -6px;
  padding: 2px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
}

.chains-scroll::-webkit-scrollbar {
  display: none;
}

.chains {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  width: max-content;
  padding-right: 8px;
}

.chain-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px 8px 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease), transform 0.2s var(--ease), box-shadow 0.25s var(--ease);
}

.chain-btn:focus,
.chain-btn:focus-visible,
.chain-btn:active {
  outline: none;
  box-shadow: none;
}

.chain-btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.chain-btn.active {
  color: #0b1220;
  background: #ffffff;
  border-color: #ffffff;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.chain-btn.active:focus,
.chain-btn.active:focus-visible {
  outline: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.chain-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
}

.chain-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.chain-icon.tron { background: #ef0027; }
.chain-icon.matic { background: #8247e5; }
.chain-icon.bsc { background: #f0b90b; color: #0b1220; }
.chain-icon.sol { background: linear-gradient(135deg, #9945ff, #14f195); }
.chain-icon.eth { background: #627eea; }
.chain-icon.eos { background: #000; border: 1px solid rgba(255,255,255,0.15); }

.chain-btn.active .chain-icon.eos {
  border-color: rgba(0, 0, 0, 0.2);
}

.input-box input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
  letter-spacing: 0.01em;
}

.input-box input::placeholder {
  color: #667085;
}

.icon-action {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: rgba(96, 165, 250, 0.1);
  color: var(--accent);
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: 0.2s var(--ease);
}

.icon-action:hover {
  background: rgba(96, 165, 250, 0.18);
}

.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.72);
  display: grid;
  place-items: end center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.qr-modal[hidden] {
  display: none !important;
}

.qr-sheet {
  width: min(100%, 420px);
  background: #121722;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.qr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.qr-head strong {
  font-size: 15px;
}

.qr-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.qr-reader {
  width: 100%;
  overflow: hidden;
  border-radius: 14px;
  background: #000;
  min-height: 260px;
}

.qr-reader video {
  border-radius: 14px !important;
}

.qr-tip {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.scan-area {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex: 0 0 auto;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
  transition: color 0.25s ease;
  position: relative;
  z-index: 2;
  order: 2;
}

.hint.scanning {
  color: var(--accent);
}

.start-wrap {
  position: relative;
  width: 184px;
  height: 184px;
  display: grid;
  place-items: center;
  order: 1;
}

.start-btn {
  position: relative;
  z-index: 3;
  width: 136px;
  height: 136px;
  border-radius: 50%;
  border: none;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.25s var(--ease);
}

.start-btn:hover:not(:disabled) {
  transform: scale(1.03);
}

.start-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.start-btn:disabled {
  cursor: wait;
}

/* 清晰 DOM 文字，贴在金属球中心 */
.ball-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 76px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(8, 12, 22, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.ball-label strong {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  line-height: 1.1;
  color: #f8fafc;
  -webkit-font-smoothing: antialiased;
}

.ball-label small {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #bfdbfe;
  line-height: 1.2;
}

.ball-label small[hidden] {
  display: none;
}

.start-wrap.scanning .ball-label {
  background: rgba(8, 16, 36, 0.36);
  border-color: rgba(147, 197, 253, 0.22);
}

.progress-text {
  font-size: 12px;
  color: var(--accent);
  min-height: 18px;
  letter-spacing: 0.02em;
  opacity: 0;
  transform: translateY(4px);
  transition: 0.3s var(--ease);
  order: 3;
}

.progress-text.show {
  opacity: 1;
  transform: translateY(0);
}

.reveal {
  animation: rise 0.55s var(--ease) both;
  animation-delay: var(--d, 0s);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  background: rgba(18, 22, 34, 0.96);
  border: 1px solid var(--line-strong);
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: 0.28s var(--ease);
  z-index: 120;
  max-width: 86vw;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.hero,
.scan-area {
  position: relative;
  z-index: 2;
}

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

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

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

@keyframes pulse {
  0%,
  100% {
    opacity: 0.7;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes glow-drift {
  from {
    transform: translateY(0) scale(1);
  }
  to {
    transform: translateY(18px) scale(1.05);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
}
