/* ═══════════════════════════════════════════════════════════
   沪深300 炒股训练游戏 - 全局样式 & 暗色行情主题
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── CSS 设计令牌 ── */
:root {
  /* 背景层次 */
  --bg-base:        #0a0c0f;
  --bg-surface:     #0f1318;
  --bg-panel:       #141920;
  --bg-card:        #1a2030;
  --bg-hover:       #1f2840;
  --bg-active:      #243050;
  --bg-input:       #0d1117;

  /* 边框 */
  --border-subtle:  #1e2535;
  --border-default: #253045;
  --border-strong:  #2e3d5a;
  --border-accent:  #3d5480;

  /* 文字 */
  --text-primary:   #e8edf5;
  --text-secondary: #8a9bb5;
  --text-muted:     #4a5870;
  --text-accent:    #5ba4f5;

  /* 行情色彩（A股：涨红跌绿） */
  --color-rise:     #f5515f;
  --color-rise-dim: #8b1a24;
  --color-rise-bg:  rgba(245, 81, 95, 0.08);
  --color-fall:     #00c076;
  --color-fall-dim: #0a5a38;
  --color-fall-bg:  rgba(0, 192, 118, 0.08);
  --color-flat:     #8a9bb5;

  /* 强调色 */
  --accent-blue:    #3d7ef5;
  --accent-blue-dim:#1a3a7a;
  --accent-cyan:    #00d4ff;
  --accent-gold:    #f5c842;
  --accent-purple:  #8b5cf6;

  /* 均线颜色 */
  --ma5-color:      #00c076;
  --ma10-color:     #f5c842;
  --ma20-color:     #f5913a;
  --ma60-color:     #8b5cf6;

  /* MACD 颜色 */
  --macd-dif:       #3d7ef5;
  --macd-dea:       #f5913a;

  /* 字体 */
  --font-sans:      'Inter', -apple-system, 'PingFang SC', sans-serif;
  --font-mono:      'JetBrains Mono', 'Courier New', monospace;

  /* 间距 */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 24px;

  /* 圆角 */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  /* 阴影 */
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow-blue: 0 0 20px rgba(61,126,245,0.15);
  --shadow-glow-gold: 0 0 20px rgba(245,200,66,0.12);

  /* 动画 */
  --transition-fast:   0.12s ease;
  --transition-normal: 0.22s ease;
  --transition-slow:   0.38s ease;
}

/* ── 重置 ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-accent); }

/* ── 数字字体工具类 ── */
.mono { font-family: var(--font-mono); }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── 颜色工具类 ── */
.rise  { color: var(--color-rise) !important; }
.fall  { color: var(--color-fall) !important; }
.flat  { color: var(--color-flat) !important; }
.muted { color: var(--text-muted) !important; }
.accent{ color: var(--text-accent) !important; }

/* ── 按钮基础样式 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  outline: none;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-accent);
  color: var(--text-accent);
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}
.btn-primary:hover {
  background: #2f6ae0;
  border-color: #2f6ae0;
  color: #fff;
  box-shadow: var(--shadow-glow-blue);
}

.btn-rise {
  background: var(--color-rise);
  border-color: var(--color-rise);
  color: #fff;
  font-weight: 600;
}
.btn-rise:hover {
  background: #e04050;
  color: #fff;
}

.btn-fall {
  background: var(--color-fall);
  border-color: var(--color-fall);
  color: #000;
  font-weight: 600;
}
.btn-fall:hover {
  background: #00a865;
  color: #000;
}

.btn-icon {
  padding: 6px 8px;
  min-width: 32px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── 输入框 ── */
.input {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 5px 8px;
  outline: none;
  transition: border-color var(--transition-fast);
  width: 100%;
}
.input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(61,126,245,0.15);
}
.input::-webkit-inner-spin-button,
.input::-webkit-outer-spin-button { opacity: 0.5; }

/* ── select ── */
.select {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 5px 24px 5px 8px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a9bb5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--transition-fast);
}
.select:focus { border-color: var(--accent-blue); }

/* ── 标签 ── */
.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.tag-rise { background: var(--color-rise-bg); color: var(--color-rise); border: 1px solid var(--color-rise-dim); }
.tag-fall { background: var(--color-fall-bg); color: var(--color-fall); border: 1px solid var(--color-fall-dim); }
.tag-blue { background: rgba(61,126,245,0.12); color: var(--accent-blue); border: 1px solid var(--accent-blue-dim); }
.tag-gold { background: rgba(245,200,66,0.1); color: var(--accent-gold); border: 1px solid rgba(245,200,66,0.3); }

/* ── 分割线 ── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-sm) 0;
}
.divider-v {
  width: 1px;
  background: var(--border-subtle);
  align-self: stretch;
}

/* ── 面板标题 ── */
.panel-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel-title .icon { font-size: 13px; }

/* ── Toast 通知 ── */
#toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  animation: toastIn 0.25s ease forwards;
  pointer-events: auto;
}
.toast.toast-buy  { background: rgba(245,81,95,0.9); color: #fff; border: 1px solid var(--color-rise); }
.toast.toast-sell { background: rgba(0,192,118,0.9); color: #000; border: 1px solid var(--color-fall); }
.toast.toast-info { background: rgba(61,126,245,0.9); color: #fff; border: 1px solid var(--accent-blue); }
.toast.toast-warn { background: rgba(245,200,66,0.9); color: #000; border: 1px solid var(--accent-gold); }
.toast.toast-out  { animation: toastOut 0.25s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ── 加载遮罩 ── */
#loading-overlay {
  position: fixed; inset: 0;
  background: var(--bg-base);
  z-index: 8888;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  transition: opacity 0.4s ease;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loading-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.loading-sub   { font-size: 12px; color: var(--text-secondary); }
.progress-bar-track {
  width: 280px; height: 3px;
  background: var(--border-subtle);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  border-radius: 99px;
  transition: width 0.1s linear;
  width: 0%;
}

/* ── 脉冲动画 ── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.pulse { animation: pulse 1.5s ease-in-out infinite; }

/* ── 闪烁（价格变化）── */
@keyframes flashRise {
  0%   { background: var(--color-rise-bg); }
  100% { background: transparent; }
}
@keyframes flashFall {
  0%   { background: var(--color-fall-bg); }
  100% { background: transparent; }
}
.flash-rise { animation: flashRise 0.6s ease forwards; }
.flash-fall { animation: flashFall 0.6s ease forwards; }

/* ── 模态框 ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 7000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: var(--sp-xl);
  min-width: 360px;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.93) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: var(--sp-lg);
  color: var(--text-primary);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-sm);
  margin-top: var(--sp-xl);
}

.btn-safe {
  background: var(--color-fall-dim) !important;
  border-color: var(--color-fall) !important;
  color: #fff !important;
}
.btn-safe:hover {
  background: var(--color-fall) !important;
  color: #000 !important;
}
.btn-warning {
  background: #cfa830 !important;
  border-color: var(--accent-gold) !important;
  color: #000 !important;
}
.btn-warning:hover {
  background: var(--accent-gold) !important;
  color: #000 !important;
}
