/* ===== Apple 极简风格主题 ===== */

:root {
  --cr-bg: #f5f5f7;
  --cr-bg-card: #ffffff;
  --cr-text: #1d1d1f;
  --cr-text-secondary: #86868b;
  --cr-text-muted: #aeaeb2;
  --cr-gold: #f5a623;
  --cr-gold-light: #f9d371;
  --cr-primary: #1d1d1f;
  --cr-primary-light: #333336;
  --cr-accent: #0071e3;
  --cr-accent-light: #2997ff;
  --cr-border: #e5e5e7;
  --cr-glow-gold: none;
  --cr-glow-purple: 0 2px 12px rgba(0,0,0,0.06);
  --cr-glow-rare: 0 2px 8px rgba(0,0,0,0.04);
  --cr-radius: 18px;
  --cr-radius-sm: 12px;
  --cr-rare: #0071e3;
  --cr-epic: #f5a623;
  --cr-success: #30c452;
  --cr-danger: #ff372a;
}

/* ===== 导航根容器 ===== */
#cr-nav-root { min-height: 56px; }

/* ===== 导航左侧（Logo + 链接） ===== */
.cr-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cr-header-logo {
  font-size: 22px;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  transition: all 0.2s;
  overflow: hidden;
  flex-shrink: 0;
}
.cr-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}
.cr-header-logo:hover {
  background: rgba(0,0,0,0.04);
  transform: scale(1.1);
}

/* ===== 导航链接 ===== */
.cr-nav-link {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(0,0,0,0.6);
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.cr-nav-link:hover {
  background: rgba(0,0,0,0.04);
  color: #1d1d1f;
}
.cr-nav-link.active {
  background: rgba(0,0,0,0.06);
  color: #0071e3;
}

/* ===== 面包屑 ===== */
.cr-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  flex-shrink: 0;
  overflow: hidden;
}
.cr-breadcrumb-item {
  font-size: 12px;
  font-weight: 600;
  color: rgba(0,0,0,0.4);
  white-space: nowrap;
}
.cr-breadcrumb-sep {
  font-size: 14px;
  color: rgba(0,0,0,0.4);
  opacity: 0.4;
  font-weight: 700;
}

/* ===== 用户信息 ===== */
.cr-user-info {
  font-size: 13px;
  color: rgba(0,0,0,0.7);
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

/* ===== 移动端汉堡菜单 ===== */
.cr-nav-toggle {
  display: none;
  width: 32px;
  height: 32px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,0.04);
  color: rgba(0,0,0,0.6);
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
  line-height: 1;
}
.cr-nav-toggle:hover {
  background: rgba(0,0,0,0.08);
  color: #1d1d1f;
}

/* ===== Header 更新（让左中右三段布局撑开） ===== */
.cr-header {
  gap: 8px;
}

/* ===== 移动端响应式 ===== */
@media (max-width: 768px) {
  .cr-nav-toggle {
    display: none;
  }

  /* 移动端导航链接缩小但始终可见 */
  .cr-header-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
  }
  .cr-header-nav .cr-nav-link {
    padding: 3px 8px;
    font-size: 11px;
  }

  /* 移动端面包屑隐藏 */
  .cr-breadcrumb { display: none; }

  /* 移动端用户信息缩写 */
  .cr-user-info {
    max-width: 60px;
    font-size: 11px;
  }

  /* 移动端按钮缩小 */
  .cr-btn-icon { width: 28px; height: 28px; font-size: 14px; }
  .cr-btn-sm { padding: 3px 8px; font-size: 11px; }

  /* 紧凑导航 */
  .cr-header-compact .cr-header-right { gap: 2px; }
}

/* ===== 基础 ===== */
html {
  scrollbar-gutter: stable;
}
body {
  margin: 0;
  font-family: 'Nunito', -apple-system, sans-serif;
  background: var(--cr-bg);
  min-height: 100vh;
  color: var(--cr-text);
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

/* ===== Header ===== */
.cr-header {
  background: rgba(255,255,255,0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid #e5e5e7;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 10;
  box-shadow: none;
}

.cr-header-title {
  font-size: 20px;
  font-weight: 800;
  color: #1d1d1f;
  letter-spacing: -0.5px;
}

.cr-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== 卡片系统 ===== */
.cr-card {
  background: var(--cr-bg-card);
  border-radius: var(--cr-radius);
  border: 1px solid #e5e5e7;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.cr-card::before {
  display: none;
}

.cr-card-rare {
  border-color: #e5e5e7;
  box-shadow: var(--cr-glow-rare);
}
.cr-card-rare::before {
  display: none;
}

.cr-card-epic {
  border-color: #e5e5e7;
  box-shadow: var(--cr-glow-gold);
}
.cr-card-epic::before {
  display: none;
}

.cr-card-gold {
  border-color: #e5e5e7;
  box-shadow: var(--cr-glow-gold);
}
.cr-card-gold::before {
  display: none;
}

/* ===== 按钮 ===== */
.cr-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--cr-radius-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.cr-btn:hover {
  transform: translateY(-2px);
}

.cr-btn:active {
  transform: scale(0.96);
}

.cr-btn-primary {
  background: #0071e3;
  color: white;
  box-shadow: none;
}

.cr-btn-primary:hover {
  background: #0077ed;
}

.cr-btn-gold {
  background: #f5a623;
  color: white;
  box-shadow: none;
}

.cr-btn-gold:hover {
  background: #f7b840;
}

.cr-btn-ghost {
  background: transparent;
  color: var(--cr-text);
  border: 1px solid #d2d2d7;
}

.cr-btn-ghost:hover {
  background: rgba(0,0,0,0.04);
}

.cr-btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: 8px;
}

.cr-btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #1d1d1f;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
  text-decoration: none;
}

.cr-btn-icon:hover {
  background: rgba(0,0,0,0.04);
  color: #0071e3;
  transform: translateY(-1px);
}

/* ===== Toast ===== */
#toast, .cr-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 28px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  max-width: 90vw;
  text-align: center;
  border: 1px solid rgba(0,0,0,0.06);
}

#toast.show, .cr-toast.show {
  opacity: 1;
}

#toast.success, .cr-toast.success {
  background: #30c452;
  color: white;
}

#toast.error, .cr-toast.error {
  background: #ff372a;
  color: white;
}

#toast.info, .cr-toast.info {
  background: #0071e3;
  color: white;
}

/* ===== 容器 ===== */
.cr-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
  position: relative;
  z-index: 1;
}

/* ===== 装饰横幅 ===== */
.cr-banner {
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cr-banner-learn {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(5, 150, 105, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #059669;
}

.cr-banner-quiz {
  background: linear-gradient(135deg, rgba(62, 131, 198, 0.12), rgba(101, 177, 214, 0.08));
  border: 1px solid rgba(62, 131, 198, 0.2);
  color: #3e83c6;
}

/* ===== Badge ===== */
.cr-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.cr-badge-common { background: rgba(153, 153, 153, 0.12); color: #666666; }
.cr-badge-rare { background: rgba(62, 131, 198, 0.12); color: #3e83c6; }
.cr-badge-epic { background: rgba(248, 171, 50, 0.12); color: #f8ab32; }
.cr-badge-legendary { background: rgba(248, 171, 50, 0.12); color: #f8ab32; }

/* ===== Modal ===== */
.cr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.cr-modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.cr-modal-box {
  background: #ffffff;
  border: 1px solid #e5e5e7;
  border-radius: 20px;
  padding: 28px;
  max-width: 520px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: cr-modal-in 0.3s ease;
}

@keyframes cr-modal-in {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.cr-modal-title {
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 20px;
  color: #1d1d1f;
}

/* ===== 统计数字 ===== */
.cr-stat-value {
  font-size: 28px;
  font-weight: 800;
}

.cr-stat-label {
  font-size: 12px;
  color: var(--cr-text-secondary);
  font-weight: 600;
}

/* ===== 动画 ===== */
@keyframes cr-card-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes cr-glow-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(248, 171, 50, 0.2); }
  50% { box-shadow: 0 0 30px rgba(248, 171, 50, 0.4); }
}

@keyframes cr-slide-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.cr-slide-in {
  animation: cr-slide-in 0.4s ease both;
}

/* ===== 颜色选择器 ===== */
.cr-color-swatch {
  width: 48px; height: 24px; border-radius: 4px;
  cursor: pointer; display: inline-flex;
  overflow: hidden; border: 2px solid rgba(0,0,0,0.1);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.cr-color-swatch .cr-swatch-light,
.cr-color-swatch .cr-swatch-dark {
  width: 50%; height: 100%; display: block;
}
.cr-color-swatch.cr-color-active {
  border-color: var(--cr-gold) !important;
  transform: scale(1.15);
  box-shadow: var(--cr-glow-gold);
}

/* ===== 皮肤选择器 ===== */
.cr-skin-item {
  background: rgba(0,0,0,0.03);
  border: 2px solid rgba(0,0,0,0.06);
  border-radius: 10px;
  padding: 6px 4px 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.cr-skin-item:hover {
  background: rgba(0,0,0,0.05);
  border-color: var(--cr-accent);
  transform: translateY(-2px);
}
.cr-skin-item.cr-skin-active {
  border-color: var(--cr-accent) !important;
  background: rgba(0,113,227,0.06);
  box-shadow: none;
}

/* ===== 响应式 ===== */
/* ===== 紧凑版 Header（用于答题/结果/创建作业等棋盘页面） ===== */
.cr-header-compact {
  padding: 4px 14px;
}
.cr-header-compact .cr-header-title {
  font-size: 14px;
}
.cr-header-compact .cr-btn-icon {
  width: 28px;
  height: 28px;
  font-size: 14px;
}
.cr-header-compact .cr-btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}
.cr-header-compact .cr-header-right {
  gap: 4px;
}

/* ===== 导航链接 ===== */
.cr-header-nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.cr-header-nav a {
  padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 700;
  color: rgba(0,0,0,0.6); text-decoration: none; transition: all 0.15s;
}
.cr-header-nav a:hover { background: rgba(0,0,0,0.04); color: #1d1d1f; }
.cr-header-nav a.active { background: rgba(0,0,0,0.06); color: #0071e3; }

@media (max-width: 768px) {
  .cr-header {
    padding: 10px 14px;
  }
  .cr-header-title {
    font-size: 16px;
  }
  .cr-header-compact {
    padding: 3px 10px;
  }
  .cr-header-compact .cr-header-title {
    font-size: 12px;
  }
  .cr-container {
    padding: 16px 12px;
  }
  .cr-card {
    padding: 16px;
    border-radius: 14px;
  }
  .cr-modal-box {
    padding: 20px;
    width: 94vw;
    border-radius: 16px;
  }
  .cr-btn-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
}

/* ===== iOS Toggle Switch ===== */
.cr-toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.cr-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.cr-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ddd;
  border-radius: 12px;
  transition: background 0.2s;
}
.cr-toggle-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.cr-toggle-switch input:checked + .cr-toggle-slider {
  background: #0071e3;
}
.cr-toggle-switch input:checked + .cr-toggle-slider::before {
  transform: translateX(20px);
}
