/* ============================================================
   崩坏：星穹铁道 — 行动轴排顺模拟器
   太空科幻风格 UI (v1.0)
   ============================================================ */

/* ----- CSS 变量 ----- */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #0c1220;
  --bg-card: #111a2e;
  --bg-card-hover: #141f38;
  --border-color: #1a2a4a;
  --border-glow: #00f0ff33;
  --text-primary: #c8d6e5;
  --text-secondary: #8899aa;
  --text-muted: #556677;
  --accent: #00f0ff;
  --accent-dim: #00aabb;
  --gold: #f0c060;
  --gold-dim: #b8860b;
  --warning: #ffcc00;
  --warning-bg: #ffcc0022;
  --btn-bg: linear-gradient(135deg, #0066ff, #00bbff);
  --btn-hover: linear-gradient(135deg, #0077ff, #00ccff);
  --shadow-glow: 0 0 20px #00f0ff22;
  --shadow-btn: 0 0 30px #00f0ff44;
  --font-main: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --timeline-line: #1e3050;
}

/* ----- 全局重置 ----- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  overflow-x: hidden;
}

/* 背景星点纹理 */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.15), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.10), transparent),
    radial-gradient(1.5px 1.5px at 50% 10%, rgba(255,255,255,0.20), transparent),
    radial-gradient(1px 1px at 70% 80%, rgba(255,255,255,0.12), transparent),
    radial-gradient(1.5px 1.5px at 90% 40%, rgba(255,255,255,0.18), transparent),
    radial-gradient(1px 1px at 15% 85%, rgba(255,255,255,0.08), transparent),
    radial-gradient(1px 1px at 85% 15%, rgba(255,255,255,0.10), transparent);
  pointer-events: none;
  z-index: 0;
}

.app-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* ----- 头部标题 ----- */
.app-header {
  text-align: center;
  padding: 30px 0 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 32px;
  position: relative;
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.app-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 2px;
}

.header-icon {
  color: var(--gold);
  margin-right: 8px;
  font-size: 24px;
}

.header-sub {
  display: block;
  font-size: 16px;
  font-weight: 400;
  color: var(--accent);
  margin-top: 4px;
  letter-spacing: 4px;
}

.header-desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 8px;
  letter-spacing: 1px;
}

/* ----- 区域标题 ----- */
.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}

.title-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 400;
  color: var(--gold);
  background: var(--gold-dim);
  padding: 2px 10px;
  border-radius: 10px;
  margin-left: 10px;
  vertical-align: middle;
}

.config-section,
.result-section {
  margin-bottom: 36px;
}

/* ============================================================
   角色配置 — 2×2 网格 + 左立绘右输入布局
   ============================================================ */

.cards-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 700px) {
  .cards-container {
    grid-template-columns: 1fr;
  }
}

/* ----- 角色卡片（水平双栏布局） ----- */
.char-card {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.char-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
  border-color: var(--accent-dim);
}

/* ----- 左侧立绘占位区 / CDN 头像 ----- */
.char-portrait {
  flex-shrink: 0;
  width: 100px;
  height: 100px;
  background: linear-gradient(180deg, #0d1428, #0a1020);
  border-right: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.char-portrait::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px dashed #1a2a4a;
  border-radius: 6px;
  pointer-events: none;
}

.char-portrait.has-avatar::before {
  display: none;
}

/* CDN 头像图片 */
.char-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* 文字兜底（纯色圆形背景 + 首字） */
.portrait-placeholder {
  font-size: 28px;
  font-weight: 700;
  color: #1a2a4a;
  letter-spacing: 2px;
  user-select: none;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  position: relative;
  z-index: 1;
}

/* ----- 右侧配置区 ----- */
.char-config {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-header {
  background: linear-gradient(135deg, #0f1a30, #152040);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
}

.card-number {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
}

.card-body {
  padding: 12px 14px 14px;
  flex-grow: 1;
}

/* ----- 输入组 ----- */
.input-group {
  margin-bottom: 10px;
}

.input-group:last-child {
  margin-bottom: 0;
}

.input-group label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ----- 输入框与下拉框共用样式 ----- */
.input-group input,
.input-group select {
  width: 100%;
  padding: 7px 10px;
  background: #0d1424;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-main);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-group input::placeholder {
  color: var(--text-muted);
  font-size: 12px;
}

.input-group input:focus,
.input-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--border-glow);
}

/* ----- Select 下拉框专用样式 ----- */
.input-group select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2300f0ff' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 6px;
}

.input-group select option,
.input-group select optgroup {
  background: #0d1424;
  color: var(--text-primary);
}

.input-group select optgroup {
  color: var(--gold);
  font-weight: 600;
}

/* 去除 number 输入框的默认箭头 */
.input-group input[type="number"]::-webkit-inner-spin-button,
.input-group input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-group input[type="number"] {
  appearance: textfield;
  -webkit-appearance: textfield;
  -moz-appearance: textfield;
}

/* ----- 操作按钮 ----- */
.action-bar {
  text-align: center;
  margin-top: 8px;
}

.btn-start {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 48px;
  background: var(--btn-bg);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-main);
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  box-shadow: var(--shadow-btn);
}

.btn-start:hover {
  background: var(--btn-hover);
  box-shadow: 0 0 40px #00f0ff66;
  transform: translateY(-1px);
}

.btn-start:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 0 20px #00f0ff44;
}

.btn-icon {
  font-size: 14px;
}

/* ----- 时间轴容器 ----- */
.timeline-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px 20px;
  min-height: 200px;
}

.timeline-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 48px 0;
  letter-spacing: 1px;
}

/* ----- 时间轴列表 ----- */
.timeline-list {
  position: relative;
  padding-left: 24px;
}

/* 时间轴竖线 */
.timeline-list::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--timeline-line);
  border-radius: 1px;
}

/* ----- 轮次分隔 ----- */
.round-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 3px;
  margin: 16px 0 8px;
  padding: 4px 0 4px 12px;
  border-bottom: 1px dashed #2a3a5a;
}

.round-header:first-child {
  margin-top: 0;
}

/* ----- 行动节点 ----- */
.timeline-node {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 8px 4px;
  position: relative;
  transition: background 0.15s ease;
  border-radius: 4px;
}

.timeline-node:hover {
  background: rgba(0, 240, 255, 0.04);
}

/* 节点圆点 */
.timeline-dot {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--border-glow);
  position: relative;
  z-index: 1;
  transition: box-shadow 0.3s ease;
}

.timeline-node:hover .timeline-dot {
  box-shadow: 0 0 14px #00f0ff66;
}

/* 角色名称 */
.timeline-label {
  flex-grow: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

/* AV 时间值 */
.timeline-value {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  padding: 2px 10px;
  background: rgba(0, 240, 255, 0.06);
  border-radius: 4px;
  border: 1px solid rgba(0, 240, 255, 0.08);
}

/* ----- 乱速警示 (clash-warning) ----- */
.timeline-node.clash-warning {
  background: var(--warning-bg);
  border-radius: 6px;
  padding: 8px 12px 8px 4px;
  margin: 2px 0;
  animation: clash-pulse 1.5s ease-in-out infinite;
}

.timeline-node.clash-warning .timeline-dot {
  background: var(--warning);
  box-shadow: 0 0 12px #ffcc0088;
}

.timeline-node.clash-warning .timeline-value {
  color: var(--warning);
  background: rgba(255, 204, 0, 0.08);
  border-color: rgba(255, 204, 0, 0.15);
}

.timeline-node.clash-warning .timeline-label {
  color: var(--warning);
}

@keyframes clash-pulse {
  0%, 100% {
    box-shadow: inset 0 0 0 0 rgba(255, 204, 0, 0);
  }
  50% {
    box-shadow: inset 0 0 12px 2px rgba(255, 204, 0, 0.10);
  }
}

/* ----- 页脚 ----- */
.app-footer {
  text-align: center;
  padding: 24px 0 8px;
  border-top: 1px solid var(--border-color);
  margin-top: 20px;
}

.app-footer p {
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 1px;
}

.footer-note {
  margin-top: 4px;
  font-size: 11px;
  color: #3a4a5a;
}

/* ----- 滚动条美化 ----- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dim);
}