* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Microsoft YaHei", Consolas, Monaco, monospace;
}

body {
  background-color: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
}

/* 顶部导航栏 */
.header-bar {
  height: 60px;
  background: #161b22;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  border-bottom: 1px solid #30363d;
  position: sticky;
  top: 0;
  z-index: 99;
}

.header-title {
  font-size: 22px;
  font-weight: 600;
  color: #58a6ff;
}

.header-info {
  display: flex;
  gap: 30px;
  font-size: 16px;
  align-items: center;
}

.header-user {
  display: flex;
  gap: 12px;
  align-items: center;
}

.header-user label {
  color: #c9d1d9;
  font-size: 14px;
}

.header-user input {
  width: 140px;
  margin-left: 6px;
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 4px;
  border: 1px solid #30363d;
  background: #0d1117;
  color: #c9d1d9;
}

.header-user input:focus {
  border-color: #58a6ff;
  outline: none;
}

.badge {
  background: #238636;
  color: #fff;
  padding: 4px 12px;
  border-radius: 12px;
}

.badge.danger {
  background: #da3633;
}

/* 主体左右布局 */
.main-wrap {
  display: grid;
  grid-template-columns: 240px 420px 1fr;
  min-height: calc(100vh - 60px);
}

/* 左侧关卡导航 */
.level-nav {
  background: #0d1117;
  border-right: 1px solid #30363d;
  padding: 16px 12px;
  overflow-y: auto;
  height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
}

/* 左侧题目面板 */
.left-panel {
  background: #161b22;
  border-right: 1px solid #30363d;
  padding: 20px;
  overflow-y: auto;
  height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
}

.level-title {
  font-size: 18px;
  color: #f0f6fc;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #30363d;
}

.require-item {
  margin: 12px 0;
  line-height: 1.7;
  font-size: 14px;
}

.require-item strong {
  color: #ffa657;
}

.demo-preview {
  border: 1px dashed #58a6ff;
  padding: 10px;
  margin: 20px 0;
  background: #0d1117;
}

.rule-tip {
  background: #21262d;
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #8b949e;
  margin-top: 20px;
  line-height: 1.6;
}

.level-list-title {
  font-size: 15px;
  margin-bottom: 12px;
  color: #58a6ff;
  font-weight: 600;
}

.level-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.level-item {
  padding: 8px 10px;
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #161b22;
  color: #c9d1d9;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
  transition: background 0.2s, border-color 0.2s;
}

.level-item:hover {
  border-color: #58a6ff;
}

.level-item.active {
  background: #1f6feb;
  border-color: #58a6ff;
  color: #fff;
}

.level-item.completed {
  color: #7ee787;
}

/* 右侧代码+预览区 */
.right-panel {
  display: flex;
  flex-direction: column;
}

/* 代码编辑器Tab */
.editor-tabs {
  display: flex;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}

.tab-btn {
  padding: 10px 20px;
  background: transparent;
  border: none;
  color: #8b949e;
  cursor: pointer;
  font-size: 14px;
}

.tab-btn.active {
  background: #0d1117;
  color: #58a6ff;
  border-bottom: 2px solid #58a6ff;
}

.editor-box {
  flex: 1;
  display: none;
  position: relative;
}

.editor-box.active {
  display: block;
}

/* 代码高亮容器 & 原始输入框重叠 */
.code-editor-wrap {
  position: relative;
  height: 280px;
  font-size: 14px;
  line-height: 1.5;
  font-family: Consolas, 'Courier New', monospace;
}

textarea.code-editor {
  width: 100%;
  height: 100%;
  background: transparent;
  color: #ccc;
  caret-color: #fff;
  border: none;
  padding: 15px;
  font-size: inherit;
  resize: none;
  outline: none;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  font-family: inherit;
  line-height: inherit;
  white-space: pre;
  tab-size: 2;
  overflow: auto;
  box-sizing: border-box;
}

/* textarea.code-editor::selection {
  background: rgba(56, 139, 253, 0.35);
  color: transparent;
}

textarea.code-editor::-moz-selection {
  background: rgba(56, 139, 253, 0.35);
  color: transparent;
} */

pre[class*="language-"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 15px;
  overflow: auto;
  z-index: 1;
  font-size: inherit;
  line-height: inherit;
  white-space: pre;
  box-sizing: border-box;
  font-family: inherit;
  pointer-events: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

pre[class*="language-"]::-webkit-scrollbar {
  display: none;
}

/* 操作按钮区 */
.btn-bar {
  padding: 12px 20px;
  background: #161b22;
  display: flex;
  gap: 15px;
  border-bottom: 1px solid #30363d;
  flex-wrap: wrap;
  align-items: center;
}

.btn-bar button {
  padding: 8px 18px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

#runBtn {
  background: #238636;
  color: white;
}

#checkBtn {
  background: #2563eb;
  color: white;
}

#resetBtn {
  background: #6e7681;
  color: white;
}

#nextLevelBtn {
  background: #c53030;
  color: white;
  display: none;
}

#exportPdfBtn {
  background: #9254de;
  color: #fff;
}

/* 沙盒预览iframe */
.sandbox-title {
  padding: 8px 20px;
  background: #21262d;
  font-size: 14px;
}

#sandboxIframe {
  width: 100%;
  height: 320px;
  border: none;
  background: #fff;
}

/* 判题日志 */
.log-area {
  padding: 15px 20px;
  min-height: 80px;
  background: #161b22;
  border-top: 1px solid #30363d;
  font-family: Consolas;
  font-size: 13px;
  white-space: pre-wrap;
}

.log-success {
  color: #3fb950;
}

.log-error {
  color: #f85149;
}

.log-warn {
  color: #ffa657;
}

/* 通关最终成绩单弹窗 */
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-card {
  background: #161b22;
  padding: 40px;
  border-radius: 10px;
  border: 1px solid #30363d;
  text-align: center;
  min-width: 520px;
}

.modal-card h2 {
  color: #58a6ff;
  margin-bottom: 20px;
}

.score-final {
  font-size: 24px;
  margin: 15px 0;
  color: #3fb950;
}

.record-list {
  text-align: left;
  max-height: 300px;
  overflow-y: auto;
  margin: 20px 0;
  padding: 15px;
  background: #0d1117;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.8;
}

.modal-btn-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 25px;
}

.modal-btn-group button {
  padding: 10px 22px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

#restartAll {
  background: #2563eb;
  color: white;
}

#modalExportPdf {
  background: #9254de;
  color: white;
}