/* =============================================================
 * 夜神主站 · 视觉补丁 CSS
 * 用法：把本文件放到主站目录，在 index.html 的 <head> 里
 *       </head> 前加一行：<link rel="stylesheet" href="yeshen-patch.css">
 * 作用：修复「算法区文字与图表重叠」+ 美化「在线编辑器」+ 卡片留白
 * 说明：只覆盖样式，不改任何 JS 逻辑，可随时删掉还原。
 * ============================================================= */

/* ---------- 1. 算法神域：图表与底部统计不再重叠 ---------- */
.algo-lab {
  border-radius: 18px;
  padding: 22px 22px 26px;
  background: linear-gradient(180deg, rgba(124, 108, 255, .06), rgba(124, 108, 255, .01));
  border: 1px solid rgba(124, 108, 255, .18);
}
.algo-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 20px;
  margin-bottom: 18px;
}
.algo-controls .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 150px;
}
/* 关键：给画布底部留出空间，避免统计文字压到柱子上 */
#sortCanvas {
  display: block;
  width: 100% !important;
  border-radius: 12px;
  background: rgba(10, 10, 31, .6);
  border: 1px solid rgba(124, 108, 255, .15);
  margin-bottom: 16px;
}
.algo-meta {
  display: block;
  margin-top: 4px;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(10, 10, 31, .55);
  border: 1px solid rgba(124, 108, 255, .15);
  font-size: .95rem;
  color: #b9b9d6;
  line-height: 1.7;
}
.algo-meta b { color: #c7c7ff; }
.algo-meta code {
  background: rgba(124, 108, 255, .15);
  padding: 2px 8px;
  border-radius: 6px;
  color: #ffcf5c;
}

/* ---------- 2. 在线编辑器：美化（更精致、有层次） ---------- */
.editor-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  border-radius: 18px;
  overflow: hidden;
}
@media (max-width: 960px) {
  .editor-wrap { grid-template-columns: 1fr; }
}
.editor-pane, .preview-pane {
  background: #0d0d24;
  border: 1px solid rgba(124, 108, 255, .2);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.editor-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  background: rgba(124, 108, 255, .07);
  border-bottom: 1px solid rgba(124, 108, 255, .15);
}
.editor-tabs .tab {
  border: none;
  background: transparent;
  color: #8b8bb0;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
  transition: all .18s;
}
.editor-tabs .tab:hover { background: rgba(124, 108, 255, .12); color: #c7c7ff; }
.editor-tabs .tab.active {
  background: linear-gradient(135deg, #7c6cff, #a855f7);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 108, 255, .4);
}
.editor-area {
  width: 100%;
  min-height: 320px;
  padding: 16px 18px;
  border: none;
  outline: none;
  resize: vertical;
  background: #0a0a1f;
  color: #d7d7f0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.7;
  tab-size: 2;
}
.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(124, 108, 255, .07);
  border-bottom: 1px solid rgba(124, 108, 255, .15);
}
.preview-label { color: #a9a9c9; font-size: .88rem; letter-spacing: .5px; }
.preview-actions { display: flex; align-items: center; gap: 12px; }
.btn-run {
  border: none;
  background: linear-gradient(135deg, #6cffb0, #3ee08d);
  color: #052012;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 16px rgba(108, 255, 176, .3);
}
.btn-run:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(108, 255, 176, .45); }
#preview {
  width: 100%;
  height: 360px;
  border: none;
  background: #fff;
  display: block;
}
.console-panel { border-top: 1px solid rgba(124, 108, 255, .15); }
.console-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(0, 0, 0, .3);
  color: #8b8bb0;
  font-size: .82rem;
}
.console-bar button {
  background: transparent;
  border: 1px solid rgba(124, 108, 255, .3);
  color: #8b8bb0;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .78rem;
}
.console-out {
  max-height: 130px;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: ui-monospace, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #9cffb0;
}

/* ---------- 3. 语言圣殿卡片：加大点击感与留白 ---------- */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.lang-grid > * {
  transition: transform .2s, box-shadow .2s, border-color .2s;
  cursor: pointer;
}
.lang-grid > *:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 34px rgba(124, 108, 255, .3);
  border-color: rgba(124, 108, 255, .6) !important;
}

/* ---------- 4. 通用：避免任何绝对定位元素压字 ---------- */
.section-title, .section-desc { line-height: 1.4; }
.algo-lab, .editor-wrap { position: relative; }

/* =============================================================
 * 5. 代码演练场弹窗（由 yeshen-patch.js 创建）
 * ============================================================= */
#yeshen-playground {
  position: fixed; inset: 0; z-index: 9999;
  display: none; align-items: center; justify-content: center;
}
#yeshen-playground.open { display: flex; }
.ypg-backdrop { position: absolute; inset: 0; background: rgba(3,3,12,.82); backdrop-filter: blur(4px); }
.ypg-panel {
  position: relative; width: min(1000px, 94vw); height: min(620px, 90vh);
  background: #0d0d24; border: 1px solid rgba(124,108,255,.4);
  border-radius: 16px; display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(124,108,255,.3); overflow: hidden;
}
.ypg-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; background: rgba(124,108,255,.08);
  border-bottom: 1px solid rgba(124,108,255,.18);
}
.ypg-title { color: #c7c7ff; font-weight: 700; font-size: 1.05rem; }
.ypg-lang {
  color: #ffcf5c; font-size: .85rem; padding: 2px 10px;
  background: rgba(255,207,92,.12); border-radius: 20px;
}
.ypg-close {
  margin-left: auto; background: transparent; border: none; color: #8b8bb0;
  font-size: 1.2rem; cursor: pointer; padding: 4px 10px; border-radius: 8px;
}
.ypg-close:hover { background: rgba(255,124,108,.15); color: #ff7c6c; }
.ypg-body { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: rgba(124,108,255,.15); min-height: 0; }
.ypg-code {
  width: 100%; height: 100%; border: none; outline: none; resize: none;
  padding: 16px 18px; background: #0a0a1f; color: #d7d7f0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px; line-height: 1.7; tab-size: 2;
}
.ypg-right { display: flex; flex-direction: column; background: #0a0a1f; min-height: 0; }
.ypg-preview-label { padding: 8px 14px; color: #8b8bb0; font-size: .8rem; border-bottom: 1px solid rgba(124,108,255,.12); }
.ypg-frame { flex: 1; border: none; background: #fff; width: 100%; }
.ypg-console {
  max-height: 130px; overflow-y: auto; padding: 10px 14px;
  background: #06061a; color: #9cffb0; font-family: ui-monospace, monospace;
  font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; border-top: 1px solid rgba(124,108,255,.12);
}
.ypg-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; background: rgba(124,108,255,.06);
  border-top: 1px solid rgba(124,108,255,.18);
}
.ypg-hint { color: #8b8bb0; font-size: .82rem; flex: 1; }
.ypg-actions { display: flex; gap: 10px; }
.ypg-actions button {
  border: none; padding: 8px 18px; border-radius: 10px; cursor: pointer;
  font-weight: 600; font-size: .88rem;
}
.ypg-copy { background: rgba(124,108,255,.18); color: #c7c7ff; }
.ypg-copy:hover { background: rgba(124,108,255,.3); }
.ypg-run { background: linear-gradient(135deg,#6cffb0,#3ee08d); color: #052012; box-shadow: 0 4px 16px rgba(108,255,176,.3); }
.ypg-run:hover { transform: translateY(-1px); }

/* =============================================================
 * 6. 手动排序挑战小游戏（由 yeshen-patch.js 注入）
 * ============================================================= */
#ypg-sortgame {
  margin-top: 22px; padding: 18px 20px;
  border-radius: 14px; background: rgba(108,255,176,.05);
  border: 1px solid rgba(108,255,176,.25);
}
.ypg-sg-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  color: #c7ffdf; font-weight: 700; margin-bottom: 8px;
}
.ypg-sg-stat { margin-left: auto; color: #8b8bb0; font-weight: 400; font-size: .88rem; }
.ypg-sg-stat b { color: #6cffb0; }
.sg-reset {
  border: 1px solid rgba(108,255,176,.4); background: transparent; color: #6cffb0;
  padding: 5px 14px; border-radius: 8px; cursor: pointer; font-size: .82rem;
}
.sg-reset:hover { background: rgba(108,255,176,.15); }
.ypg-sg-tip { color: #8b8bb0; font-size: .84rem; margin-bottom: 14px; }
.ypg-sg-bars {
  display: flex; align-items: flex-end; gap: 6px; height: 200px;
  padding: 10px; background: rgba(10,10,31,.5); border-radius: 10px;
}
.sg-bar {
  flex: 1; background: linear-gradient(180deg,#7c9cff,#c58cff);
  border-radius: 6px 6px 0 0; cursor: pointer; transition: all .18s;
  min-height: 8px;
}
.sg-bar:hover { filter: brightness(1.25); }
.sg-bar.sel { background: linear-gradient(180deg,#ffcf5c,#ff9c6c); box-shadow: 0 0 16px rgba(255,207,92,.6); }

/* 通用轻提示 */
#ypg-toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px);
  background: rgba(20,20,40,.96); color: #c7ffdf; padding: 12px 22px; border-radius: 30px;
  border: 1px solid rgba(108,255,176,.4); font-size: .9rem; z-index: 10000;
  opacity: 0; pointer-events: none; transition: all .3s;
}
#ypg-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .ypg-body { grid-template-columns: 1fr; }
  .ypg-frame { min-height: 200px; }
}
