:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --ink: #132238;
  --muted: #5b6b7f;
  --line: #d7e0ea;
  --blue: #2563eb;
  --blue-deep: #1d4ed8;
  --blue-soft: #dbeafe;
  --ok: #16a34a;
  --shadow: 0 18px 48px rgba(19, 34, 56, 0.12);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: #111827;
}

/* 动态 meme 拼贴背景 */
.meme-bg {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 0;
  overflow: hidden;
  background: #111827;
  pointer-events: none;
}

.meme-grid {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
}

.meme-cell {
  position: relative;
  width: 50%;
  height: 25%;
  overflow: hidden;
  background: #1f2937;
  border: 1px solid rgba(0, 0, 0, 0.55);
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

.meme-cell img {
  position: absolute;
  left: -8%;
  top: -8%;
  width: 116%;
  height: 116%;
  border: 0;
  display: block;
  object-fit: cover;
  -webkit-transform: translate3d(0, 0, 0) scale(1);
  transform: translate3d(0, 0, 0) scale(1);
  -webkit-animation: memeKen 9s ease-in-out infinite alternate;
  animation: memeKen 9s ease-in-out infinite alternate;
  will-change: transform;
}

.meme-cell:nth-child(1) img { -webkit-animation-delay: 0s; animation-delay: 0s; }
.meme-cell:nth-child(2) img { -webkit-animation-delay: -1.2s; animation-delay: -1.2s; }
.meme-cell:nth-child(3) img { -webkit-animation-delay: -2.4s; animation-delay: -2.4s; }
.meme-cell:nth-child(4) img { -webkit-animation-delay: -3.1s; animation-delay: -3.1s; }
.meme-cell:nth-child(5) img { -webkit-animation-delay: -4.2s; animation-delay: -4.2s; }
.meme-cell:nth-child(6) img { -webkit-animation-delay: -5s; animation-delay: -5s; }
.meme-cell:nth-child(7) img { -webkit-animation-delay: -6.3s; animation-delay: -6.3s; }
.meme-cell:nth-child(8) img { -webkit-animation-delay: -7.1s; animation-delay: -7.1s; }

.meme-cell.is-pop img {
  -webkit-animation: memePop 0.55s ease;
  animation: memePop 0.55s ease;
}

@-webkit-keyframes memeKen {
  0% { -webkit-transform: translate3d(0, 0, 0) scale(1); transform: translate3d(0, 0, 0) scale(1); }
  100% { -webkit-transform: translate3d(-4%, -3%, 0) scale(1.12); transform: translate3d(-4%, -3%, 0) scale(1.12); }
}
@keyframes memeKen {
  0% { -webkit-transform: translate3d(0, 0, 0) scale(1); transform: translate3d(0, 0, 0) scale(1); }
  100% { -webkit-transform: translate3d(-4%, -3%, 0) scale(1.12); transform: translate3d(-4%, -3%, 0) scale(1.12); }
}

@-webkit-keyframes memePop {
  0% { -webkit-transform: scale(1); transform: scale(1); }
  40% { -webkit-transform: scale(1.18); transform: scale(1.18); }
  100% { -webkit-transform: scale(1.06); transform: scale(1.06); }
}
@keyframes memePop {
  0% { -webkit-transform: scale(1); transform: scale(1); }
  40% { -webkit-transform: scale(1.18); transform: scale(1.18); }
  100% { -webkit-transform: scale(1.06); transform: scale(1.06); }
}

/* 漂浮反应表情，增强“表情包动态感” */
.meme-float {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 1;
}

.meme-emoji {
  position: absolute;
  bottom: -10%;
  font-size: 28px;
  line-height: 1;
  opacity: 0;
  -webkit-animation: memeRise 5.5s linear forwards;
  animation: memeRise 5.5s linear forwards;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

@-webkit-keyframes memeRise {
  0% { opacity: 0; -webkit-transform: translate3d(0, 0, 0) scale(0.7) rotate(-8deg); }
  12% { opacity: 0.92; }
  100% { opacity: 0; -webkit-transform: translate3d(12px, -120vh, 0) scale(1.15) rotate(12deg); }
}
@keyframes memeRise {
  0% { opacity: 0; transform: translate3d(0, 0, 0) scale(0.7) rotate(-8deg); }
  12% { opacity: 0.92; }
  100% { opacity: 0; transform: translate3d(12px, -120vh, 0) scale(1.15) rotate(12deg); }
}

.meme-bg:after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 2;
  background: rgba(7, 12, 24, 0.22);
}

@media (prefers-reduced-motion: reduce) {
  .meme-cell img,
  .meme-emoji {
    -webkit-animation: none !important;
    animation: none !important;
  }
}

.page {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 10;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
  padding: 16px;
  padding-top: 16px;
  padding-bottom: 20px;
  background: transparent;
}

@supports (padding: max(0px)) {
  .page {
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}

.lang-switcher {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  inset-inline-end: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(19, 34, 56, 0.06);
}

.lang-label {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
}

.lang-select {
  appearance: none;
  border: 0;
  background:
    linear-gradient(145deg, var(--blue), var(--blue-deep)) padding-box;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  padding: 7px 28px 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 148px;
  background-image:
    linear-gradient(145deg, var(--blue), var(--blue-deep)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position: 0 0, right 10px center;
  background-size: 100% 100%, 12px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.lang-select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.shell {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: calc(100vh - 36px);
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding-top: 36px;
}

.shell > * + * {
  margin-top: 18px;
}

.brand {
  text-align: center;
}

.shield {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.35));
}

.shield svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-kicker {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(37, 99, 235, 0.2);
  color: var(--blue-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.brand h1 {
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: #ffffff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}

.brand-sub {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.92rem;
  line-height: 1.5;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  padding: 18px 16px 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
  flex: none;
  animation: pulse 1.6s ease-in-out infinite;
}

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

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.card-tip {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.slider {
  --x: 0px;
  --thumb-size: 52px;
  position: relative;
  height: var(--thumb-size);
  border-radius: 14px;
  background: #f3f6fa;
  border: 1px solid #c9d5e3;
  box-shadow: inset 0 1px 3px rgba(19, 34, 56, 0.05);
  overflow: hidden;
  touch-action: none;
}

.slider-progress {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--x) + var(--thumb-size));
  background: linear-gradient(90deg, #93c5fd, #2563eb 70%, #1d4ed8);
  opacity: 0.95;
  transition: width 0.18s ease;
}

.slider-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-left: calc(var(--thumb-size) * 0.55);
  color: #4b6280;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.slider-thumb {
  position: absolute;
  left: var(--x);
  top: 0;
  width: var(--thumb-size);
  height: var(--thumb-size);
  border: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(160deg, #3b82f6, #1d4ed8);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
  cursor: grab;
  z-index: 2;
  transition: left 0.18s ease, transform 0.12s ease;
}

.slider-thumb:active {
  cursor: grabbing;
  transform: scale(0.97);
}

.thumb-arrow {
  width: 42%;
  height: 42%;
  pointer-events: none;
}

.slider.dragging .slider-thumb,
.slider.dragging .slider-progress {
  transition: none;
}

.slider.done .slider-text {
  opacity: 0;
}

.slider.done .slider-thumb {
  background: linear-gradient(160deg, #22c55e, #15803d);
  box-shadow: 0 8px 18px rgba(22, 163, 74, 0.32);
  font-size: 1.2rem;
  font-weight: 800;
}

.robot-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #334155;
  font-size: 0.88rem;
  font-weight: 600;
}

.robot-box {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 2px solid #94a3b8;
  background: #fff;
  display: grid;
  place-items: center;
  flex: none;
}

.robot-check {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: transparent;
  transform: scale(0);
  transition: transform 0.2s ease, background 0.2s ease;
}

.robot-row.is-checked .robot-box {
  border-color: var(--ok);
  background: #f0fdf4;
}

.robot-row.is-checked .robot-check {
  background: var(--ok);
  transform: scale(1);
  clip-path: polygon(14% 44%, 0 65%, 40% 100%, 100% 22%, 82% 5%, 38% 68%);
}

.robot-badge {
  margin-left: auto;
  display: grid;
  line-height: 1.05;
  text-align: right;
  color: #64748b;
  font-weight: 500;
}

.robot-badge strong {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #475569;
}

.robot-badge small {
  font-size: 0.62rem;
}

.countdown,
.routing {
  display: none;
  margin-top: 14px;
  padding: 18px 12px;
  border-radius: 14px;
  text-align: center;
  background: linear-gradient(180deg, #eff6ff, #f8fafc);
  border: 1px solid #dbe7f5;
}

.countdown.show,
.routing.show {
  display: block;
  animation: fadeUp 0.35s ease both;
}

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

.countdown-number {
  font-size: clamp(1.8rem, 8vw, 2.35rem);
  font-weight: 800;
  color: var(--blue-deep);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.countdown-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.routing-spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid rgba(37, 99, 235, 0.18);
  border-top-color: var(--blue);
  animation: spin 0.85s linear infinite;
}

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

.routing-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.routing-subtitle {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.share-panel {
  text-align: center;
}

.share-text {
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 10px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

.share-btn {
  appearance: none;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

.share-btn svg {
  width: 18px;
  height: 18px;
}

.share-btn:active {
  transform: translateY(1px);
}

.foot-note {
  margin-top: 10px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
}

.meta {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
  text-align: center;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.78);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
  padding-bottom: 4px;
}

.meta > * + * {
  margin-top: 4px;
}

.meta-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}

@media (prefers-reduced-motion: reduce) {
  .status-dot,
  .routing-spinner,
  .countdown.show,
  .routing.show {
    animation: none !important;
  }
}
