:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #1a1a2e;
  --bg-card: rgba(26, 26, 46, 0.8);
  --accent-cyan: #00f0ff;
  --accent-gold: #ffd700;
  --accent-pink: #ff00a0;
  --text-primary: #e0e0e0;
  --text-secondary: #8a8a9a;
  --success: #00ff88;
  --danger: #ff4757;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.app-container {
  min-height: 100vh;
  padding-bottom: 80px;
  position: relative;
}

/* 三层纵深背景 */
.space-background {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  perspective: 1000px;
  overflow: hidden;
  z-index: 0;
}

.layer-3 {
  position: absolute;
  width: 120%; height: 120%;
  top: -10%; left: -10%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(107, 78, 230, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 240, 255, 0.1) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 80%, rgba(255, 0, 160, 0.08) 0%, transparent 50%);
  transform: translateZ(-100px) scale(1.5);
  animation: stars-twinkle 4s ease-in-out infinite;
}

.layer-2 {
  position: absolute;
  width: 110%; height: 110%;
  top: -5%; left: -5%;
  background: linear-gradient(180deg, transparent 0%, rgba(26, 26, 46, 0.3) 100%);
  transform: translateZ(-50px) scale(1.2);
}

.layer-1 {
  position: absolute;
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at 50% 100%, rgba(26, 26, 46, 0.8) 0%, transparent 70%);
  transform: translateZ(0);
}

@keyframes stars-twinkle {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

/* 洞府主体 */
.cave-container {
  position: relative;
  z-index: 1;
  padding: 20px;
  min-height: 100vh;
}

/* 状态栏 */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(10, 10, 15, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 240, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.stat-icon { font-size: 16px; }

.stat-value {
  font-weight: 600;
  color: var(--accent-gold);
}

/* 功能物体网格 */
.objects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 20px;
  padding-bottom: 100px;
}

/* 功能物体卡片 */
.object-card {
  width: 64px; height: 64px;
  min-width: 44px; min-height: 44px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), rgba(255, 0, 160, 0.03));
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  transition: all 0.3s ease;
  cursor: pointer;
  margin: 0 auto;
}

.object-card::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.object-card:hover, .object-card:focus {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(255, 0, 160, 0.08));
  border-color: rgba(0, 240, 255, 0.5);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.object-card:active {
  transform: scale(0.95) translateY(0);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 底部3物体上移 */
.object-card:nth-last-child(-n+3) {
  transform: translateY(-20px);
}

.object-card:nth-last-child(-n+3):hover,
.object-card:nth-last-child(-n+3):focus {
  transform: translateY(-22px);
}

.object-card:nth-last-child(-n+3):active {
  transform: translateY(-20px) scale(0.95);
}

/* 物体图标 */
.object-icon {
  font-size: 24px;
  line-height: 1;
  filter: drop-shadow(0 0 4px rgba(0, 240, 255, 0.4));
  transition: all 0.3s ease;
}

.object-card:hover .object-icon {
  filter: drop-shadow(0 0 8px rgba(0, 240, 255, 0.8));
  transform: scale(1.1);
}

.object-card:active .object-icon {
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.8));
}

/* 物体标签 */
.object-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

/* 角标 */
.object-badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 18px; height: 18px;
  background: var(--danger);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(255, 71, 87, 0.5);
}

/* 有新内容状态 */
.object-card.has-reward {
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    border-color: rgba(255, 215, 0, 0.4);
  }
  50% {
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
    border-color: rgba(255, 215, 0, 0.8);
  }
}

/* 触摸反馈区域扩展 */
.object-card::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 20px;
}

/* 底部导航 */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: linear-gradient(180deg, rgba(10, 10, 15, 0) 0%, rgba(10, 10, 15, 0.95) 20%);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0, 240, 255, 0.1);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 1000;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 64px; height: 48px;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-icon {
  font-size: 24px;
  line-height: 1;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.tab-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.tab-item.active .tab-icon {
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 8px rgba(0, 240, 255, 0.6));
}

.tab-item.active .tab-label {
  color: var(--accent-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
}

.tab-item:active { transform: scale(0.92); }

/* 页面容器 */
.page-container {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 200;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 页面推进动画 */
.page-enter {
  animation: page-push 300ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes page-push {
  0% { transform: translateX(100%) scale(0.9); opacity: 0; filter: blur(10px); }
  100% { transform: translateX(0) scale(1); opacity: 1; filter: blur(0); }
}

/* 页面退回动画 */
.page-exit {
  animation: page-pop 200ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes page-pop {
  0% { transform: translateX(0) scale(1); opacity: 1; }
  100% { transform: translateX(100%) scale(0.9); opacity: 0; filter: blur(10px); }
}

/* Tab页面切换动画 */
.tab-page-enter {
  animation: tab-fade 200ms ease-out;
}

@keyframes tab-fade {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* 返回按钮 */
.back-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.back-button:active { transform: scale(0.95); }

/* 页面标题 */
.page-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  padding: 16px;
  color: var(--text-primary);
}

/* 卡片组件 */
.card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 16px;
  margin: 12px 16px;
  border: 1px solid rgba(0, 240, 255, 0.1);
  backdrop-filter: blur(10px);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--accent-cyan);
}

/* 列表项 */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0, 240, 255, 0.1);
}

.list-item:last-child { border-bottom: none; }

/* 按钮组件 */
.btn {
  padding: 12px 24px;
  border-radius: 24px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-pink));
  color: var(--bg-primary);
}

.btn-primary:active { transform: scale(0.95); }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-secondary:active { background: rgba(0, 240, 255, 0.1); }

/* 信号卡片 */
.signal-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 16px;
  margin: 12px 16px;
  border: 1px solid rgba(0, 240, 255, 0.15);
  position: relative;
  overflow: hidden;
}

.signal-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-pink));
}

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

.signal-type {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.signal-type.fish-head { background: rgba(0, 255, 136, 0.2); color: var(--success); }
.signal-type.fish-body { background: rgba(0, 240, 255, 0.2); color: var(--accent-cyan); }
.signal-type.fish-tail { background: rgba(255, 0, 160, 0.2); color: var(--accent-pink); }

.signal-symbol {
  font-size: 18px;
  font-weight: 700;
}

.signal-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.info-item { text-align: center; }
.info-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.info-value { font-size: 16px; font-weight: 600; }

/* 探测按钮 */
.detect-button {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-pink));
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 24px auto;
  cursor: pointer;
  position: relative;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
  animation: detect-pulse 2s ease-in-out infinite;
}

@keyframes detect-pulse {
  0%, 100% { box-shadow: 0 0 30px rgba(0, 240, 255, 0.3); transform: scale(1); }
  50% { box-shadow: 0 0 50px rgba(0, 240, 255, 0.5); transform: scale(1.02); }
}

.detect-button:active { transform: scale(0.95); animation: none; }

.detect-icon { font-size: 36px; }
.detect-text { font-size: 14px; font-weight: 700; color: var(--bg-primary); }
.detect-cost { font-size: 12px; color: rgba(10, 10, 15, 0.8); }

/* 灵力条 */
.spirit-bar {
  width: 100%;
  height: 8px;
  background: rgba(0, 240, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.spirit-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-gold));
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* 修为进度 */
.realm-progress {
  text-align: center;
  padding: 24px 16px;
}

.realm-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 8px;
}

.realm-stars { font-size: 20px; margin-bottom: 16px; }

.progress-ring {
  width: 120px; height: 120px;
  margin: 0 auto 16px;
  position: relative;
}

.progress-ring svg { transform: rotate(-90deg); }
.progress-ring-bg { fill: none; stroke: rgba(0, 240, 255, 0.1); stroke-width: 8; }
.progress-ring-fill { fill: none; stroke: url(#progress-gradient); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.3s ease; }

.progress-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: 600;
}

/* 任务列表 */
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0, 240, 255, 0.1);
}

.task-item:last-child { border-bottom: none; }

.task-checkbox {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.task-checkbox.completed { background: var(--accent-cyan); }

.task-info { flex: 1; }
.task-name { font-size: 14px; font-weight: 500; }
.task-reward { font-size: 12px; color: var(--accent-gold); }

/* 昼夜光影 */
.dawn-theme { --bg-primary: #1a1020; --bg-secondary: #2a2040; }
.day-theme { --bg-primary: #1a1a3e; --bg-secondary: #2a2a4e; }
.dusk-theme { --bg-primary: #2a1a30; --bg-secondary: #1a1020; }
.night-theme { --bg-primary: #0a0a0f; --bg-secondary: #1a1a2e; }

/* 粒子效果 */
.particle {
  position: absolute;
  width: 4px; height: 4px;
  background: var(--accent-cyan);
  border-radius: 50%;
  pointer-events: none;
  animation: particle-rise 3s ease-out forwards;
}

@keyframes particle-rise {
  0% { transform: translateY(0) scale(1); opacity: 0.8; }
  100% { transform: translateY(-100px) scale(0); opacity: 0; }
}

/* 加载动画 */
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(0, 240, 255, 0.1);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 24px auto;
}

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

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* 响应式 */
@media (min-width: 768px) {
  .app-container { max-width: 414px; margin: 0 auto; }
}
