@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --color-bg-dark: #06060c;
  --color-bg-panel: rgba(10, 10, 20, 0.7);
  --color-border: rgba(255, 255, 255, 0.08);
  --color-accent-blue: #3b82f6;
  --color-accent-purple: #8b5cf6;
  --color-accent-cyan: #06b6d4;
  --color-accent-glow: rgba(139, 92, 246, 0.15);
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--color-bg-dark);
  color: #f3f4f6;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

h1, h2, h3, h4, .font-display {
  font-family: 'Space Grotesk', sans-serif;
}

/* Glassmorphism Panel */
.glass-panel {
  background: var(--color-bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-border);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

.bg-gradient-cyber {
  background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 50%, #8b5cf6 100%);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

/* Tab active */
.tab-active {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--color-accent-cyan);
  color: #fff;
}

/* ==================== 模态框 ==================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 1rem;
}

.modal-container {
  background: rgba(10, 10, 20, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.5rem;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  justify-content: flex-end;
}

.modal-close {
  cursor: pointer;
  color: #6b7280;
  transition: color 0.2s;
}
.modal-close:hover { color: #fff; }

/* ==================== 日历 ==================== */

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.calendar-day-header {
  padding: 0.4rem 0;
  text-align: center;
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  font-size: 14px;
  color: #cbd5e1;
  min-width: 40px;
  min-height: 40px;
}

.calendar-day:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.calendar-day.empty {
  cursor: default;
  color: transparent;
}

.calendar-day.today {
  border: 2px solid rgba(6, 182, 212, 0.5);
  color: #06b6d4;
  font-weight: 600;
}

.calendar-day.has-dream {
  background: rgba(139, 92, 246, 0.2);
}

.calendar-day.has-dream:hover {
  background: rgba(139, 92, 246, 0.35);
}

.dream-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #06b6d4;
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.6);
}

/* ==================== 登录弹窗 ==================== */

.login-tab {
  border: none;
  cursor: pointer;
  font-weight: 500;
}

.login-tab.active {
  background: rgba(6, 182, 212, 0.2);
  color: #06b6d4;
}

/* ==================== 模拟进度条 ==================== */

.sim-progress {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.sim-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #06b6d4, #8b5cf6);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ==================== 事件日志 ==================== */

.event-log {
  max-height: 200px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ==================== 统计卡片 ==================== */

.stat-card {
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #06b6d4;
  font-family: 'Space Grotesk', sans-serif;
}

.stat-label {
  font-size: 10px;
  color: #9ca3af;
}

/* ==================== 通知Toast ==================== */

#notification-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}

.notification-toast {
  animation: slideIn 0.3s ease;
  transition: opacity 0.3s, transform 0.3s;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ==================== 梦境卡片 ==================== */

.dream-card {
  transition: all 0.2s;
}

.dream-card:hover {
  border-color: rgba(6, 182, 212, 0.3) !important;
  transform: translateY(-1px);
}

/* ==================== 输入框 ==================== */

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: rgba(6, 182, 212, 0.5) !important;
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.15);
}

/* ==================== 按钮 ==================== */

.btn-primary {
  background: linear-gradient(135deg, #06b6d4 0%, #8b5cf6 100%);
  color: white;
  padding: 0.5rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: opacity 0.2s;
  border: none;
  cursor: pointer;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #d1d5db;
  padding: 0.5rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  padding: 0.5rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* ==================== 按钮小组 ==================== */

.btn-group {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}

/* ==================== 响应式 ==================== */

/* 安全区域适配 */
.pb-safe {
  padding-bottom: env(safe-area-inset-bottom, 8px);
}

@media (max-width: 768px) {
  .modal-container {
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .modal-body {
    padding: 1rem;
  }

  .calendar-day {
    font-size: 11px;
  }

  .btn-group {
    flex-wrap: wrap;
  }

  #notification-container {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }

  * {
    -webkit-tap-highlight-color: transparent !important;
  }

  button, a, span, div {
    -webkit-tap-highlight-color: transparent !important;
  }

  input, textarea, select {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-user-select: text !important;
    user-select: text !important;
  }
}

/* ==================== 动画 ==================== */

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.05); opacity: 0.6; }
}

.dream-glow-ring {
  animation: pulseGlow 4s infinite ease-in-out;
}

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

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ==================== 首页微动态 ==================== */

/* 浮动粒子 */
.home-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.hp-dot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  background: var(--c);
  border-radius: 50%;
  box-shadow: 0 0 calc(var(--s) * 3) var(--c), 0 0 calc(var(--s) * 6) var(--c);
  animation: hpFloat var(--d) ease-in-out infinite;
  animation-delay: calc(var(--d) * -0.5);
}

@keyframes hpFloat {
  0%, 100% {
    transform: translateY(0) translateX(0) scale(1);
    opacity: 0.3;
  }
  25% {
    transform: translateY(-30px) translateX(15px) scale(1.4);
    opacity: 0.8;
  }
  50% {
    transform: translateY(-15px) translateX(-10px) scale(0.9);
    opacity: 0.4;
  }
  75% {
    transform: translateY(-40px) translateX(5px) scale(1.3);
    opacity: 0.7;
  }
}

/* 扫描光线 */
.home-scanline {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(6, 182, 212, 0) 30%,
    rgba(6, 182, 212, 0.5) 50%,
    rgba(6, 182, 212, 0) 70%,
    transparent 100%
  );
  animation: scanlineMove 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
}

@keyframes scanlineMove {
  0% { top: -2px; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* 光晕环 */
.home-glow-ring {
  border: 2px solid rgba(6, 182, 212, 0.15);
  animation: glowRingPulse 3s ease-in-out infinite;
}

.home-glow-ring-2 {
  border: 1.5px solid rgba(139, 92, 246, 0.12);
  animation: glowRingPulse 3s ease-in-out infinite 0.5s;
}

@keyframes glowRingPulse {
  0%, 100% {
    transform: scale(1);
    border-color: rgba(6, 182, 212, 0.15);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.05);
  }
  50% {
    transform: scale(1.12);
    border-color: rgba(6, 182, 212, 0.35);
    box-shadow: 0 0 30px rgba(6, 182, 212, 0.15), 0 0 60px rgba(139, 92, 246, 0.08);
  }
}

.home-glow-ring-2 {
  animation-name: glowRingPulse2;
}

@keyframes glowRingPulse2 {
  0%, 100% {
    transform: scale(1);
    border-color: rgba(139, 92, 246, 0.1);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.04);
  }
  50% {
    transform: scale(1.15);
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 0 35px rgba(139, 92, 246, 0.12), 0 0 70px rgba(6, 182, 212, 0.06);
  }
}

/* 星星图标微动 */
.home-sparkle-icon {
  animation: sparkleTwinkle 2.5s ease-in-out infinite;
}

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

/* 标题文字 */
.home-subtitle {
  opacity: 0.6;
}

/* 按钮呼吸感 + 悬停光效 */
.home-enter-btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  animation: btnBreathe 3s ease-in-out infinite;
}

.home-enter-btn::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

@keyframes btnBreathe {
  0%, 100% {
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.2), 0 0 30px rgba(139, 92, 246, 0.1);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 25px rgba(6, 182, 212, 0.4), 0 0 50px rgba(139, 92, 246, 0.25), 0 0 80px rgba(6, 182, 212, 0.1);
    transform: scale(1.03);
  }
}

.home-enter-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 30px rgba(6, 182, 212, 0.5), 0 4px 15px rgba(139, 92, 246, 0.35), 0 0 60px rgba(6, 182, 212, 0.2);
  animation: none;
}

.home-enter-btn:hover::after {
  opacity: 1;
  animation: btnShine 1s ease-in-out infinite;
}

@keyframes btnShine {
  0% { transform: translate(-30%, -30%) rotate(0deg); }
  100% { transform: translate(30%, 30%) rotate(180deg); }
}

/* ==================== 梦境空状态 ==================== */

/* 浮动提示文字 */
.dream-empty-text {
  color: rgba(255, 255, 255, 0.45);
  font-size: 14px;
  font-weight: 400;
  animation: emptyTextFloat 3s ease-in-out infinite;
}

@keyframes emptyTextFloat {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  50% {
    transform: translateY(-8px);
    opacity: 0.6;
  }
}

/* ==================== 实体浮动工具栏 ==================== */

#entity-toolbar.show {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.entity-tb-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #d1d5db;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 44px;
}

.entity-tb-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(6, 182, 212, 0.4);
  color: #fff;
}

.entity-tb-btn.active {
  background: rgba(6, 182, 212, 0.2);
  border-color: rgba(6, 182, 212, 0.5);
  color: #06b6d4;
}

/* ==================== Canvas 容器 ==================== */

#dream-canvas-container {
  min-height: 400px;
  position: relative;
}

#dream-canvas-container canvas {
  display: block !important;
}

/* 隐藏工具类 */
.hidden {
  display: none !important;
}

/* ==================== 调试：确保按钮可点击 ==================== */
#panel-entity button,
#panel-role button,
#panel-effects button,
#panel-rules button,
#panel-sim button {
  pointer-events: auto !important;
  position: relative;
  z-index: 10;
}

#panel-entity,
#panel-role,
#panel-effects,
#panel-rules,
#panel-sim {
  pointer-events: auto !important;
}

#panel-entity > *,
#panel-role > *,
#panel-effects > *,
#panel-rules > *,
#panel-sim > * {
  pointer-events: auto !important;
}

/* ==================== 确保3D画布不干扰面板点击 ==================== */
#dream-canvas-container {
  z-index: 1 !important;
  pointer-events: auto;
}

#dream-canvas-container canvas {
  pointer-events: auto;
}

/* ==================== 浮动按钮和面板层级 ==================== */
.floating-tool-btn {
  pointer-events: auto !important;
  z-index: 60 !important;
  position: relative;
}

#panel-entity,
#panel-role,
#panel-effects,
#panel-rules,
#panel-sim {
  z-index: 70 !important;
  pointer-events: auto !important;
}

.flex {
  display: flex !important;
}

/* Lucide图标加载前隐藏，防止闪烁 */
i[data-lucide] {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

i[data-lucide].lucide-icon {
  opacity: 1;
  visibility: visible;
}

/* ==================== 启动界面动画 ==================== */

#startup-overlay {
  animation: fadeIn 0.5s ease;
}

#startup-overlay.fade-out {
  animation: fadeOut 0.5s ease forwards;
}

#homepage-overlay {
  animation: fadeIn 0.5s ease;
}

#homepage-overlay.fade-out {
  animation: fadeOut 0.5s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.dream-card-mini img {
  transition: transform 0.3s ease;
}

.dream-card-mini:hover img {
  transform: scale(1.05);
}

/* ==================== 角色选择 ==================== */

.role-model-item {
  aspect-ratio: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  text-align: center;
}

.role-model-item:hover {
  border-color: rgba(6, 182, 212, 0.5);
  background: rgba(6, 182, 212, 0.1);
}

.role-model-item.selected {
  border-color: #06b6d4;
  background: rgba(6, 182, 212, 0.15);
  box-shadow: 0 0 0 1px rgba(6, 182, 212, 0.3);
}

.role-model-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

.role-model-name {
  font-size: 8px;
  color: rgba(255,255,255,0.7);
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.tool-btn {
  transition: all 0.2s ease;
  cursor: pointer;
}

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

/* ==================== 竖屏布局样式 ==================== */

.floating-tool-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  cursor: pointer;
}

.role-list-item {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: background 0.2s ease;
}

.role-list-item:hover {
  background: rgba(255,255,255,0.05);
}

.role-list-item.selected {
  background: rgba(6,182,212,0.12);
  border-left: 3px solid rgba(6,182,212,0.6);
}

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

/* ==================== 确认对话框 ==================== */

#modal-confirm .modal-container {
  animation: confirmSlideIn 0.25s ease-out;
}

@keyframes confirmSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ==================== 草图工具栏 ==================== */

.sketch-tool-btn {
  cursor: pointer;
  transition: all 0.2s;
}
.sketch-tool-btn:hover {
  opacity: 0.85;
}

.sketch-tab {
  cursor: pointer;
  transition: all 0.2s;
  font-size: 11px;
}
.sketch-tab:hover {
  background: rgba(255,255,255,0.08);
}
.sketch-tab.active {
  background: rgba(139,92,246,0.2);
  border-color: rgba(139,92,246,0.5);
  color: #a78bfa;
}

.sketch-thumb {
  cursor: pointer;
  transition: all 0.2s;
}
.sketch-thumb:hover {
  border-color: rgba(139,92,246,0.4);
  transform: scale(1.02);
}
