:root {
  --bg-dark: #05030c;
  --text-main: rgba(255, 255, 255, 0.96);
  --text-soft: rgba(244, 242, 255, 0.76);
  --text-dim: rgba(244, 242, 255, 0.52);

  --purple: #9b6bff;
  --blue: #42c8ff;
  --gold: #ffe6a6;
  --pink: #f0b6ff;

  --glass: rgba(12, 10, 28, 0.58);
  --glass-strong: rgba(12, 10, 28, 0.78);
  --border: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,

body {

  margin: 0;

  padding: 0;

  min-height: 100%;

  background: var(--bg-dark);

  color: var(--text-main);

  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",

    "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;

  scroll-behavior: smooth;

}

body {

  overflow-x: hidden;

  overflow-y: auto;

  -webkit-overflow-scrolling: touch;

  overscroll-behavior-y: contain;

}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.world-home {

  position: relative;

  min-height: 100svh;

  overflow-x: hidden;

  overflow-y: visible;

  touch-action: pan-y;

  background: #05030c;

  padding-bottom: calc(128px + env(safe-area-inset-bottom));

}

.world-bg {
  position: fixed;
  inset: 0;
  background-image: url("magic-gate.webp");
  background-size: cover;
  background-position: center center;
  transform: scale(1.08);
  filter: brightness(0.5) saturate(1.18) contrast(1.08);
  transition: background-image 0.45s ease, filter 0.45s ease;
  z-index: 0;
}

.world-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(circle at 50% 30%, rgba(155, 107, 255, 0.18), transparent 30%),
    radial-gradient(circle at 70% 68%, rgba(66, 200, 255, 0.12), transparent 28%),
    linear-gradient(to bottom, rgba(3, 2, 10, 0.38), rgba(3, 2, 10, 0.78));
}

.star-field {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.75) 1px, transparent 1px),
    radial-gradient(circle, rgba(255,230,166,0.45) 1px, transparent 1px);
  background-size: 42px 42px, 76px 76px;
  background-position: 0 0, 20px 30px;
  opacity: 0.18;
  animation: starsDrift 18s linear infinite;
}

@keyframes starsDrift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-42px);
  }
}

.energy-ring {
  position: fixed;
  z-index: 2;
  border-radius: 50%;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 40px rgba(155, 107, 255, 0.16),
    inset 0 0 40px rgba(66, 200, 255, 0.08);
}

.ring-a {
  width: 390px;
  height: 390px;
  left: 50%;
  top: 43%;
  transform: translate(-50%, -50%);
  animation: ringRotateA 28s linear infinite;
}

.ring-b {
  width: 520px;
  height: 520px;
  left: 50%;
  top: 43%;
  transform: translate(-50%, -50%);
  animation: ringRotateB 34s linear infinite reverse;
}

@keyframes ringRotateA {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes ringRotateB {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Top */
.home-topbar {
  position: relative;
  z-index: 10;
  padding: calc(16px + env(safe-area-inset-top)) 18px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.back-btn,
.icon-btn {
  width: 58px;
  height: 58px;
  border-radius: 22px;
  border: 1px solid var(--border);
  color: #ffffff;
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.14), transparent 34%),
    rgba(9, 10, 24, 0.46);
  backdrop-filter: blur(18px) saturate(1.16);
  -webkit-backdrop-filter: blur(18px) saturate(1.16);
  box-shadow:
    0 12px 34px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  font-size: 24px;
  flex: 0 0 auto;
}

.top-title {
  flex: 1;
  text-align: center;
  padding-top: 2px;
}

.top-english {
  margin: 0;
  font-family: "Allura", cursive;
  font-size: 26px;
  line-height: 0.9;
  color: rgba(255, 230, 166, 0.86);
  text-shadow: 0 0 16px rgba(255, 230, 166, 0.24);
}

.top-title h1 {
  margin: 4px 0 0;
  font-family: "Long Cang", cursive;
  font-weight: 400;
  font-size: clamp(34px, 9vw, 52px);
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 12px rgba(255, 255, 255, 0.22),
    0 0 30px rgba(155, 107, 255, 0.28);
}

.top-actions {
  position: relative;
}

.menu-panel {
  position: absolute;
  top: 70px;
  right: 0;
  width: 178px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.03)),
    rgba(12, 10, 28, 0.78);
  border: 1px solid var(--border);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  box-shadow:
    0 18px 56px rgba(0, 0, 0, 0.42),
    0 0 30px rgba(155, 107, 255, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px) scale(0.96);
  transition: 0.22s ease;
}

.menu-panel.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.menu-panel button {
  width: 100%;
  border: 0;
  border-radius: 17px;
  padding: 12px 14px;
  text-align: left;
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.07);
}

.menu-panel .danger {
  color: #ffb7c5;
}

/* Search */
.search-zone {
  position: relative;
  z-index: 8;
  padding: 14px 20px 0;
}

.page-subtitle {
  margin: 0 auto 14px;
  max-width: 420px;
  text-align: center;
  font-family: "Long Cang", cursive;
  font-size: clamp(24px, 7vw, 38px);
  line-height: 1.05;
  color: var(--gold);
  text-shadow:
    0 0 8px rgba(255, 230, 166, 0.38),
    0 0 24px rgba(155, 107, 255, 0.2);
}

.search-box {
  width: min(100%, 520px);
  min-height: 58px;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
    rgba(12, 10, 28, 0.52);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  box-shadow:
    0 12px 38px rgba(0,0,0,0.26),
    0 0 30px rgba(155,107,255,0.12);
}

.search-box span {
  color: rgba(255, 230, 166, 0.86);
  font-size: 22px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: none;
  color: #fff;
  background: transparent;
  font-size: 15px;
}

.search-box input::placeholder {
  color: rgba(255,255,255,0.52);
}

/* Main portal */
.portal-stage {
  position: relative;
  z-index: 6;
  width: 100%;
  min-height: 430px;
  padding: 34px 26px 8px;
  display: grid;
  place-items: center;
}

.main-gate {
  position: relative;
  width: min(78vw, 360px);
  aspect-ratio: 4 / 5;
  border-radius: 46% 46% 32px 32px;
  overflow: hidden;
  transform-style: preserve-3d;
  box-shadow:
    0 20px 80px rgba(0,0,0,0.52),
    0 0 38px rgba(155,107,255,0.4),
    0 0 80px rgba(66,200,255,0.16);
  transition:
    transform 0.4s ease,
    box-shadow 0.4s ease;
}

.main-gate:active {
  transform: scale(0.985);
}

.gate-image {
  position: absolute;
  inset: 0;
  background-image: url("magic-gate.webp");
  background-size: cover;
  background-position: center;
  transition: background-image 0.45s ease, transform 0.45s ease;
}

.main-gate.change .gate-image {
  transform: scale(1.08);
}

.gate-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(2, 2, 10, 0.68), transparent 52%),
    radial-gradient(circle at 50% 20%, rgba(255,255,255,0.12), transparent 28%);
}

.gate-shine {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      120deg,
      transparent 0%,
      transparent 38%,
      rgba(255,255,255,0.32) 48%,
      transparent 58%,
      transparent 100%
    );
  transform: translateX(-130%) skewX(-18deg);
  animation: gateSweep 4.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes gateSweep {
  0% {
    transform: translateX(-140%) skewX(-18deg);
  }
  54% {
    transform: translateX(140%) skewX(-18deg);
  }
  100% {
    transform: translateX(140%) skewX(-18deg);
  }
}

.gate-border {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow:
    inset 0 0 24px rgba(255,255,255,0.12),
    inset 0 -30px 50px rgba(0,0,0,0.24);
  pointer-events: none;
}

.gate-content {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
}

.gate-content p {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: rgba(255,230,166,0.86);
  text-shadow: 0 0 12px rgba(255,230,166,0.34);
}

.gate-content h2 {
  margin: 0;
  font-family: "Long Cang", cursive;
  font-size: clamp(48px, 14vw, 74px);
  font-weight: 400;
  line-height: 0.9;
  color: #fff;
  text-shadow:
    0 0 10px rgba(255,255,255,0.32),
    0 0 26px rgba(155,107,255,0.38);
}

.nav-arrow {
  position: absolute;
  z-index: 8;
  top: 50%;
  transform: translateY(-50%);
  width: 54px;
  height: 76px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 28px;
  color: #fff;
  font-size: 42px;
  line-height: 1;
  background: rgba(12,10,28,0.42);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.nav-left {
  left: 12px;
}

.nav-right {
  right: 12px;
}

/* Action */
.gate-action-zone {
  position: relative;
  z-index: 8;
  padding: 0 22px;
  text-align: center;
}

.enter-gate-btn {
  width: min(100%, 420px);
  min-height: 64px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 15px 18px 15px 26px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.06em;
  background:
    linear-gradient(90deg, rgba(155,107,255,0.92), rgba(66,200,255,0.76));
  box-shadow:
    0 0 24px rgba(155,107,255,0.36),
    0 0 50px rgba(66,200,255,0.18),
    0 14px 38px rgba(0,0,0,0.32);
}

.enter-gate-btn i {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 24px;
  background: rgba(255,255,255,0.16);
}

.selected-note {
  margin: 12px 0 0;
  color: rgba(255,255,255,0.68);
  font-size: 13px;
}

/* Orbit strip */
.orbit-zone {
  position: relative;
  z-index: 9;
  padding: 24px 0 0;
}

.orbit-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 0 18px 12px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.orbit-strip::-webkit-scrollbar {
  display: none;
}

.orbit-item {
  position: relative;
  flex: 0 0 92px;
  height: 124px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 28px;
  overflow: hidden;
  scroll-snap-align: center;
  background: rgba(255,255,255,0.06);
  opacity: 0.68;
  transform: scale(0.94);
  transition: 0.24s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
}

.orbit-item.active {
  opacity: 1;
  transform: scale(1);
  border-color: rgba(255,230,166,0.46);
  box-shadow:
    0 0 20px rgba(255,230,166,0.22),
    0 0 34px rgba(155,107,255,0.22),
    0 12px 34px rgba(0,0,0,0.34);
}

.orbit-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: brightness(0.72) saturate(1.08);
}

.orbit-item.active img {
  filter: brightness(0.92) saturate(1.12);
}

.orbit-item span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  right: 8px;
  font-family: "Long Cang", cursive;
  font-size: 25px;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 8px rgba(0,0,0,0.6),
    0 0 16px rgba(155,107,255,0.36);
}

/* Modal */
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 2, 10, 0.58);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transition: 0.22s ease;
}

.modal-layer.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(100%, 430px);
  max-height: 82svh;
  overflow-y: auto;
  border-radius: 30px;
  padding: 24px;
  position: relative;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
    rgba(12,10,28,0.82);
  border: 1px solid rgba(255,255,255,0.16);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  box-shadow:
    0 20px 70px rgba(0,0,0,0.52),
    0 0 36px rgba(155,107,255,0.2);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  background: rgba(255,255,255,0.1);
}

.modal-eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,230,166,0.82);
}

.modal-card h2 {
  margin: 0 0 18px;
  font-size: 24px;
}

.modal-option,
.modal-action {
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 14px 16px;
  margin-top: 10px;
  text-align: left;
  color: #fff;
  font-weight: 800;
  background: rgba(255,255,255,0.08);
}

.modal-option.active {
  background: linear-gradient(90deg, rgba(155,107,255,0.75), rgba(66,200,255,0.5));
}

.modal-textarea {
  width: 100%;
  min-height: 130px;
  resize: none;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 20px;
  padding: 14px;
  color: #fff;
  outline: none;
  background: rgba(255,255,255,0.08);
}

.modal-note {
  margin: 12px 0 0;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  line-height: 1.6;
}

.modal-danger {
  color: #ffb7c5;
}

.modal-action.primary {
  text-align: center;
  background: linear-gradient(90deg, rgba(155,107,255,0.9), rgba(66,200,255,0.72));
}

.modal-action.danger {
  text-align: center;
  background: rgba(255,92,125,0.22);
  color: #ffb7c5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(112px + env(safe-area-inset-bottom));
  z-index: 80;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  max-width: 82vw;
  padding: 12px 18px;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  background: rgba(12,10,28,0.78);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: 0.22s ease;
}

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

/* Search empty */
.empty-result {
  position: relative;
  z-index: 10;
  margin: 20px auto 0;
  width: min(100% - 40px, 420px);
  padding: 18px;
  border-radius: 22px;
  text-align: center;
  color: rgba(255,255,255,0.74);
  background: rgba(12,10,28,0.46);
  border: 1px solid rgba(255,255,255,0.12);
}

/* Mobile */
@media (max-width: 640px) {
  .portal-stage {
    min-height: 395px;
    padding-top: 30px;
  }

  .main-gate {
    width: min(74vw, 330px);
  }

  .nav-arrow {
    width: 46px;
    height: 68px;
    font-size: 36px;
  }

  .nav-left {
    left: 8px;
  }

  .nav-right {
    right: 8px;
  }

  .orbit-item {
    flex-basis: 86px;
    height: 116px;
    border-radius: 25px;
  }

  .ring-a {
    width: 350px;
    height: 350px;
  }

  .ring-b {
    width: 460px;
    height: 460px;
  }
}

@media (max-height: 720px) {
  .page-subtitle {
    font-size: clamp(22px, 6vw, 32px);
    margin-bottom: 10px;
  }

  .portal-stage {
    min-height: 350px;
    padding-top: 22px;
  }

  .main-gate {
    width: min(64vw, 280px);
  }

  .gate-action-zone {
    margin-top: -4px;
  }

  .enter-gate-btn {
    min-height: 58px;
  }
}

/* ===== Safety Fixes / Mobile Compatibility ===== */

/* 防止 iPhone Safari 默认按钮和搜索框样式影响设计 */
button,
input,
textarea {
  -webkit-appearance: none;
  appearance: none;
}

/* 搜索框在 iPhone 上更稳定 */
.search-box input[type="search"]::-webkit-search-decoration,
.search-box input[type="search"]::-webkit-search-cancel-button,
.search-box input[type="search"]::-webkit-search-results-button,
.search-box input[type="search"]::-webkit-search-results-decoration {
  display: none;
}

/* 图片没加载出来时，至少显示高级暗色底，不会空白 */
.world-bg,
.gate-image {
  background-color: #090415;
}

/* 底部横向世界入口滑动更顺 */
.orbit-strip {
  -webkit-overflow-scrolling: touch;
}

/* 避免点击按钮时文字被选中 */
button,
.floating-dock,
.orbit-item,
.main-gate {
  user-select: none;
  -webkit-user-select: none;
}

/* 让菜单和弹窗在小屏幕不会被挤出 */
.menu-panel {
  max-width: calc(100vw - 36px);
}

.modal-card {
  overscroll-behavior: contain;
}

/* 如果 14 张图区域为空，提示文字不会被压成很窄 */
.empty-result {
  flex: 0 0 calc(100vw - 40px);
}

/* 进入按钮和顶部按钮触摸反馈 */
.back-btn:active,
.icon-btn:active,
.nav-arrow:active,
.enter-gate-btn:active,
.orbit-item:active,
.floating-orb:active {
  transform: scale(0.97);
}

/* 修正 nav-arrow 原本已有 translateY，点击时不要完全丢失位置 */
.nav-arrow:active {
  transform: translateY(-50%) scale(0.97);
}

/* 如果用户系统开了减少动态，自动降低动画，提升流畅度 */
@media (prefers-reduced-motion: reduce) {
  .star-field,
  .ring-a,
  .ring-b,
  .gate-shine {
    animation: none !important;
  }

  * {
    scroll-behavior: auto !important;
  }
}

.modal-option strong {
  display: block;
  font-size: 16px;
  letter-spacing: 0.08em;
}

.modal-option-desc {
  display: block;
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
  line-height: 1.55;
}