* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  color: #23272e;
  background: #f5f6f8;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 150px;
}

h1 { font-size: 24px; margin: 8px 0 12px; }
h2 { font-size: 17px; margin: 0 0 8px; }

h1[tabindex="-1"]:focus { outline: none; }

:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

.page-tip { color: #5b6470; font-size: 13px; margin: 0 0 8px; }

/* ---------- 关卡列表 ---------- */

.chapter {
  background: #fff;
  border: 1px solid #e2e5ea;
  border-radius: 8px;
  padding: 14px 16px;
  margin: 14px 0;
}

ul.levels { list-style: none; margin: 4px 0 0; padding: 0; }
ul.levels li { margin: 6px 0; }

button.level-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  background: #fafbfc;
  border: 1px solid #d9dee5;
  border-radius: 6px;
  cursor: pointer;
}

button.level-btn:hover:not(:disabled),
a.level-btn:hover { background: #eef3fb; border-color: #b9cdf0; }

button.level-btn:disabled { color: #9aa1ab; cursor: not-allowed; background: #f2f3f5; }

a.level-btn { text-decoration: none; color: inherit; }

.lv-status { font-weight: 600; flex-shrink: 0; }
.lv-status.passed { color: #1a7f37; }
.lv-status.todo { color: #b25000; }
.lv-status.locked { color: #9aa1ab; }

/* ---------- 关卡页 ---------- */

.panel {
  background: #fff;
  border: 1px solid #e2e5ea;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 12px 0;
}

#level-desc p, #level-hint p { margin: 0 0 10px; line-height: 1.7; }
#level-desc p:last-child, #level-hint p:last-child { margin-bottom: 0; }

details.panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
}

label[for="code"] { display: block; font-weight: 600; margin: 14px 0 6px; }

.edit-hint { color: #6b7280; font-size: 12px; margin: 6px 0 10px; }

/* ---------- 代码编辑器（textarea + 高亮层叠） ---------- */

.editor-wrap {
  position: relative;
  background: #1e1e1e;
  border: 1px solid #333a44;
  border-radius: 8px;
  overflow: hidden;
}

.editor-wrap pre,
.editor-wrap textarea {
  margin: 0;
  padding: 12px 14px;
  border: 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.55;
  tab-size: 4;
  white-space: pre;
  overflow: auto;
  scrollbar-gutter: stable;
}

.editor-wrap pre {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: #d4d4d4;
  pointer-events: none;
}

.editor-wrap textarea {
  display: block;
  position: relative;
  width: 100%;
  height: 300px;
  min-height: 200px;
  resize: vertical;
  background: transparent;
  color: transparent;
  caret-color: #fff;
}

.editor-wrap textarea::selection { background: rgba(59, 130, 246, 0.40); }
.editor-wrap textarea:focus { outline: none; }
.editor-wrap:focus-within { border-color: #2563eb; }

.tok-kw  { color: #569cd6; }
.tok-str { color: #ce9178; }
.tok-com { color: #6a9955; }
.tok-num { color: #b5cea8; }
.tok-bi  { color: #dcdcaa; }

/* ---------- 按钮 ---------- */

.btn {
  padding: 8px 22px;
  font-size: 15px;
  font-family: inherit;
  border-radius: 6px;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
}

.btn:hover:not(:disabled) { background: #1d4fd7; }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn[aria-disabled="true"] { opacity: 0.55; cursor: wait; }

a.btn {
  text-decoration: none;
  display: inline-block;
}

.btn.secondary,
a.btn.secondary {
  background: #fff;
  color: #2563eb;
}

.btn.secondary:hover:not(:disabled),
a.btn.secondary:hover { background: #eef3fb; }

/* ---------- 底部状态栏 ---------- */

#bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top: 1px solid #d9dee5;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

#bottom-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px 12px;
}

#statusbar { min-height: 26px; }

#verdict { margin: 0; font-size: 15px; min-height: 22px; }
#verdict.ok   { color: #1a7f37; font-weight: 600; }
#verdict.bad  { color: #c0392b; font-weight: 600; }
#verdict.busy { color: #5b6470; }

#output-box {
  border-bottom: 1px dashed #d9dee5;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

#output-box h2 { font-size: 13px; margin: 0 0 4px; color: #5b6470; font-weight: 600; }

#program-output {
  margin: 0;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  background: #f4f5f7;
  padding: 8px 10px;
  border-radius: 6px;
  max-height: 150px;
  overflow: auto;
}

/* ---------- 用户栏 ---------- */

.user-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin: 0 0 4px;
  font-size: 14px;
  color: #5b6470;
}

.user-bar .btn { padding: 4px 14px; font-size: 13px; }

/* ---------- 登录 / 注册 / 找回密码 ---------- */

.auth-card {
  max-width: 380px;
  margin: 48px auto 0;
  background: #fff;
  border: 1px solid #e2e5ea;
  border-radius: 8px;
  padding: 28px 28px 22px;
}

.auth-card h1 { margin: 0 0 18px; font-size: 22px; text-align: center; }

.auth-input {
  display: block;
  width: 100%;
  margin: 0 0 14px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid #d9dee5;
  border-radius: 6px;
  background: #fafbfc;
}

.auth-input:focus { outline: none; border-color: #2563eb; background: #fff; }

.remember-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -4px 0 14px;
  font-size: 14px;
  color: #5b6470;
  cursor: pointer;
  user-select: none;
}

.remember-row input { width: 15px; height: 15px; cursor: pointer; }

.auth-btn { width: 100%; margin-top: 4px; }

.auth-msg {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 14px;
  color: #1a7f37;
  text-align: center;
  overflow-wrap: anywhere;
}

.auth-msg.bad { color: #c0392b; }

.auth-links { margin-top: 16px; border-top: 1px solid #eef0f3; padding-top: 12px; }
.auth-links p { margin: 6px 0; text-align: center; color: #5b6470; font-size: 14px; }
.auth-links a { color: #2563eb; }

/* 邮箱 + 发送验证码 一行布局 */
.code-row { display: flex; gap: 10px; }
.code-row .auth-input { flex: 1; min-width: 0; }
.code-row .btn { flex-shrink: 0; padding: 8px 14px; font-size: 14px; }

/* ---------- 封禁提示页 ---------- */

.ban-card {
  max-width: 420px;
  margin: 56px auto 0;
  background: #fff;
  border: 1px solid #e2e5ea;
  border-top: 4px solid #c0392b;
  border-radius: 8px;
  padding: 30px 32px 26px;
  text-align: center;
}

.ban-badge {
  display: inline-block;
  padding: 3px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 4px;
  color: #c0392b;
  background: #fdeeec;
  border-radius: 999px;
  margin-bottom: 14px;
}

.ban-card h1 { margin: 0 0 10px; font-size: 24px; }

.ban-reason { margin: 0 0 20px; color: #5b6470; line-height: 1.7; }

.ban-countdown {
  background: #f4f5f7;
  border-radius: 8px;
  padding: 14px 12px;
  margin: 0 0 20px;
}

.ban-countdown-label {
  display: block;
  font-size: 12px;
  color: #8a929e;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.ban-countdown-value {
  font-family: Consolas, "Courier New", monospace;
  font-size: 34px;
  font-weight: 700;
  color: #c0392b;
  font-variant-numeric: tabular-nums;
}

.ban-divider {
  border-top: 1px solid #eef0f3;
  margin: 0 0 18px;
}

.ban-text {
  margin: 0 0 10px;
  line-height: 1.8;
  color: #4b5260;
}

.ban-actions { margin-top: 20px; }
.ban-actions .btn { min-width: 180px; }

/* ---------- 自由控制台 ---------- */

#console-code {
  display: block;
  width: 100%;
  min-height: 200px;
  margin: 6px 0 4px;
  padding: 12px 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre;
  overflow: auto;
  resize: vertical;
  background: #1e1e1e;
  color: #f5f5f5;
  border: 1px solid #333a44;
  border-radius: 8px;
  tab-size: 4;
}

#console-code:focus { outline: none; border-color: #2563eb; }

#console-output { min-height: 24px; }

.console-block {
  margin: 8px 0;
  padding: 8px 10px;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  background: #f4f5f7;
  border-radius: 6px;
  overflow-wrap: anywhere;
}

.console-block.console-error { color: #c0392b; }

.console-sep {
  border: 0;
  border-top: 1px dashed #b9c2cc;
  margin: 12px 0;
}

#console-entry { margin: 4px 0 0; }
#console-entry .btn { padding: 4px 14px; font-size: 13px; }

/* ---------- 程序运行页 ---------- */

.run-toolbar { display: flex; align-items: center; gap: 14px; margin: 0 0 4px; }
.run-toolbar .btn { padding: 4px 14px; font-size: 13px; }
.run-state { font-size: 13px; color: #5b6470; }

.run-terminal {
  background: #1e1e1e;
  color: #e6e6e6;
  border: 1px solid #333a44;
  border-radius: 8px;
  padding: 12px 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.6;
  min-height: 300px;
  max-height: 70vh;
  overflow: auto;
}

.run-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.run-line.run-error { color: #f87171; }

.run-input-row { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.run-prompt { white-space: pre; flex-shrink: 0; }

.run-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: #fff;
  font: inherit;
  caret-color: #fff;
  padding: 0;
}

/* ---------- 个人中心 / 我的关卡 ---------- */

.profile-info {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px 12px;
  margin: 0;
}

.profile-info dt { color: #5b6470; }
.profile-info dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

a.profile-mylevels { display: flex; }

.my-code {
  margin: 6px 0 0;
  padding: 8px 10px;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  background: #1e1e1e;
  color: #d4d4d4;
  border-radius: 6px;
  max-height: 220px;
  overflow: auto;
}

.my-code-empty { margin: 6px 0 0 4px; font-size: 13px; color: #9aa1ab; }

.dev-list { list-style: none; margin: 10px 0 0; padding: 0; }
.dev-list li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 4px; border-bottom: 1px solid #eef0f3; font-size: 14px;
}
.dev-list li:last-child { border-bottom: 0; }
.dev-meta { color: #8a929e; font-size: 12px; flex-shrink: 0; }
.dev-empty { color: #9aa1ab; }

/* ---------- 开发者：关卡创作 / 审核 / 帮助 ---------- */

.dev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dev-grid label, .dev-label { display: block; font-weight: 600; margin: 10px 0 0; }
.dev-grid .auth-input, .dev-label textarea { margin-top: 6px; font-weight: 400; }

.dev-textarea, .dev-code {
  display: block;
  width: 100%;
  margin: 6px 0 0;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.55;
  border: 1px solid #d9dee5;
  border-radius: 6px;
  background: #fafbfc;
  resize: vertical;
  font-family: inherit;
}

.dev-code {
  font-family: Consolas, "Courier New", monospace;
  background: #1e1e1e;
  color: #f5f5f5;
  border-color: #333a44;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
}

.dev-textarea:focus, .dev-code:focus { outline: none; border-color: #2563eb; }

.dev-level-list { list-style: none; margin: 0; padding: 0; }
.dev-level-list li { margin: 6px 0; }
.dev-note { margin: 4px 0 0 6px; font-size: 13px; color: #c0392b; }

.dev-result { margin-top: 12px; }
.dev-result pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  background: #f4f5f7;
  border-radius: 6px;
  max-height: 200px;
  overflow: auto;
}
#test-verdict.ok { color: #1a7f37; font-weight: 600; }
#test-verdict.bad { color: #c0392b; font-weight: 600; }

.review-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.review-text { white-space: pre-wrap; line-height: 1.7; margin: 6px 0 0; }
.review-actions { display: flex; gap: 10px; align-items: center; margin: 14px 0 0; }
.review-actions .auth-input { flex: 1; margin: 0; }

.help-page h3 { font-size: 15px; margin: 14px 0 6px; }
.help-page ul, .help-page ol { line-height: 1.8; padding-left: 22px; }
.help-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.help-table th, .help-table td { border: 1px solid #e2e5ea; padding: 6px 10px; text-align: left; vertical-align: top; }
.help-table th { background: #f4f5f7; }

@media (max-width: 640px) { .dev-grid { grid-template-columns: 1fr; } }

/* ---------- 排行榜 ---------- */

.lb-list { list-style: none; margin: 0; padding: 0; }

.lb-item {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 10px 12px;
  border-bottom: 1px solid #eef0f3;
  font-size: 15px;
}

.lb-item:last-child { border-bottom: 0; }
.lb-item.top1 { background: #fffbe8; border-radius: 6px; }

.lb-rank { font-weight: 600; color: #b25000; flex-shrink: 0; min-width: 58px; }
.lb-item.top1 .lb-rank { color: #c0392b; }

.lb-name { font-weight: 600; overflow-wrap: anywhere; }

.lb-pos { margin-left: auto; color: #5b6470; flex-shrink: 0; }

.lb-empty { color: #5b6470; padding: 10px 4px; }
