/* 二级 C 语言选择题练习 —— 样式 */
:root {
  --bg: #eef1f5;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #6b7685;
  --line: #dfe4ea;
  --accent: #1466c4;
  --accent-soft: #e8f1fc;
  --ok: #17864a;
  --ok-soft: #e7f6ee;
  --bad: #c0392b;
  --bad-soft: #fdecea;
  --warn: #b9770e;
  --warn-soft: #fef5e7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 18px 60px; }
.screen { display: none; }
.screen.active { display: block; }

/* ---------- 首页 ---------- */
.hero { text-align: center; padding: 34px 10px 10px; }
.hero h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: .5px; }
.hero .sub { color: var(--muted); font-size: 14px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  margin: 18px 0;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.panel h2 { font-size: 16px; margin: 0 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.info-cell { background: #f7f9fb; border-radius: 8px; padding: 10px 12px; }
.info-cell .k { font-size: 12px; color: var(--muted); }
.info-cell .v { font-size: 17px; font-weight: 600; margin-top: 2px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

button { font-family: inherit; cursor: pointer; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  transition: .15s;
}
.btn:hover { border-color: #b8c3d1; background: #f7f9fb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #0f56a6; border-color: #0f56a6; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 6px 12px; font-size: 13px; }

.cat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.cat-item {
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 14px; background: #fff; font-size: 14px; text-align: left; transition: .15s;
}
.cat-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.cat-item .cnt { color: var(--muted); font-size: 13px; }

.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px;
}
.history li:last-child { border-bottom: none; }
.history .t { color: var(--muted); font-size: 13px; }

.hint { font-size: 13px; color: var(--muted); }
.hint b { color: var(--ink); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* ---------- 考试顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 18px; margin-bottom: 14px;
  position: sticky; top: 8px; z-index: 20;
  box-shadow: 0 2px 8px rgba(16, 24, 40, .06);
}
.topbar .title { font-weight: 600; font-size: 15px; }
.topbar .spacer { flex: 1; }
.timer {
  font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700;
  letter-spacing: 1px; color: var(--ink); padding: 2px 12px;
  border-radius: 8px; background: #f2f5f9;
}
.timer.warning { color: #fff; background: var(--bad); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .72; } }
.progress { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- 题目区 ---------- */
.exam-body { display: grid; grid-template-columns: 1fr 240px; gap: 16px; align-items: start; }
@media (max-width: 820px) {
  .exam-body { grid-template-columns: 1fr; }
  .card-panel { order: 2; }
}

.q-panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 22px 24px 18px; min-height: 360px;
}
.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.q-no { font-weight: 700; font-size: 16px; }
.badge {
  font-size: 12px; color: var(--accent); background: var(--accent-soft);
  padding: 2px 9px; border-radius: 20px;
}
.badge.mark { color: var(--warn); background: var(--warn-soft); }

.q-stem { font-size: 15.5px; margin-bottom: 14px; white-space: pre-wrap; }
.q-code {
  background: #f6f8fa; border: 1px solid var(--line); border-left: 3px solid #b8c3d1;
  border-radius: 6px; padding: 12px 14px; margin: 0 0 16px;
  font-family: Consolas, "Courier New", monospace; font-size: 13.5px;
  line-height: 1.55; white-space: pre; overflow-x: auto;
}

.opts { display: flex; flex-direction: column; gap: 9px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; text-align: left;
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 11px 14px; font-size: 14.5px; line-height: 1.55;
  transition: .12s; color: var(--ink);
  font-family: inherit;
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: #fafcff; }
.opt .tag {
  flex: 0 0 24px; height: 24px; line-height: 24px; text-align: center;
  border-radius: 50%; background: #f0f3f7; font-weight: 700; font-size: 13px;
  color: var(--muted); transition: .12s;
}
.opt.picked { border-color: var(--accent); background: var(--accent-soft); }
.opt.picked .tag { background: var(--accent); color: #fff; }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .tag { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .tag { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; }

.q-exp {
  margin-top: 16px; border-top: 1px dashed var(--line);
  padding-top: 14px; font-size: 14px;
}
.q-exp .verdict { font-weight: 700; margin-bottom: 6px; }
.q-exp .verdict.ok { color: var(--ok); }
.q-exp .verdict.bad { color: var(--bad); }
.q-exp .body { color: #37414f; }

.q-nav { display: flex; gap: 10px; margin-top: 20px; align-items: center; }
.q-nav .spacer { flex: 1; }

/* ---------- 答题卡 ---------- */
.card-panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px; position: sticky; top: 84px;
}
.card-panel h3 { font-size: 14px; margin: 0 0 12px; }
.grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.grid button {
  aspect-ratio: 1 / 1; border: 1px solid var(--line); background: #fff;
  border-radius: 5px; font-size: 12.5px; color: var(--muted); padding: 0;
  font-variant-numeric: tabular-nums;
}
.grid button:hover { border-color: var(--accent); }
.grid button.done { background: var(--accent); border-color: var(--accent); color: #fff; }
.grid button.cur { outline: 2px solid #0d1b2a; outline-offset: 1px; }
.grid button.marked { border-color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn-soft); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- 成绩页 ---------- */
.score-box { text-align: center; padding: 26px 10px 12px; }
.score-box .big { font-size: 58px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.score-box .unit { font-size: 18px; color: var(--muted); margin-left: 4px; }
.score-box .cap { color: var(--muted); margin-top: 10px; font-size: 14px; }
.pass { color: var(--ok); }
.fail { color: var(--bad); }

.stat-row { display: flex; justify-content: center; gap: 30px; flex-wrap: wrap; margin-top: 18px; }
.stat-row div { text-align: center; }
.stat-row .n { font-size: 22px; font-weight: 700; }
.stat-row .l { font-size: 12.5px; color: var(--muted); }

.cat-stat { margin: 6px 0; }
.cat-stat .row { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 4px; }
.bar { height: 7px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar.low > i { background: var(--bad); }
.bar.mid > i { background: var(--warn); }
.bar.high > i { background: var(--ok); }

.wrong-item {
  border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
  margin-bottom: 12px; background: #fff;
}
.wrong-item .w-head { font-size: 14px; margin-bottom: 8px; }
.wrong-item .w-head .no { font-weight: 700; margin-right: 8px; }
.wrong-item .w-row { font-size: 13.5px; margin: 3px 0; }
.wrong-item .mine { color: var(--bad); }
.wrong-item .right { color: var(--ok); }
.wrong-item .explain {
  margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line);
  font-size: 13.5px; color: #37414f;
}
.wrong-item .code-mini {
  background: #f6f8fa; border-radius: 6px; padding: 9px 11px; margin: 8px 0;
  font-family: Consolas, "Courier New", monospace; font-size: 12.5px;
  white-space: pre; overflow-x: auto; border: 1px solid var(--line);
}

.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; padding: 24px 26px; max-width: 420px; width: 100%;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
}
.modal h3 { margin: 0 0 10px; font-size: 17px; }
.modal p { margin: 0 0 18px; font-size: 14px; color: var(--muted); }
.modal .actions { justify-content: flex-end; }
.modal.wide { max-width: 720px; }

textarea {
  width: 100%;
  min-height: 190px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink);
  background: #fafbfc;
  resize: vertical;
  outline: none;
}
textarea:focus { border-color: var(--accent); background: #fff; }

.file-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0 4px;
  font-size: 13px;
}
.file-row input[type="file"] { font-size: 12.5px; }

.imp-msg {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13.5px;
}
.imp-msg.ok { color: var(--ok); background: var(--ok-soft); }
.imp-msg.bad { color: var(--bad); background: var(--bad-soft); }
.imp-msg.warn { color: var(--warn); background: var(--warn-soft); }
.imp-err { font-size: 12.5px; color: var(--muted); margin: 3px 0 0 8px; }

code {
  background: #f0f3f7;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
}

/* ---------- 开关 ---------- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.switch-label { font-size: 14.5px; font-weight: 600; margin-bottom: 3px; }
.switch { position: relative; display: inline-block; width: 50px; height: 27px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #c9d2dd; border-radius: 27px; transition: .22s;
}
.switch .slider::before {
  content: ""; position: absolute;
  width: 21px; height: 21px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .22s;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .25);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(23px); }

/* ---------- 彩蛋拦截页 ---------- */
.gate-card {
  max-width: 580px;
  margin: 40px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px 28px 26px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(16, 24, 40, .08);
}
.mascot-wrap { margin: 0 auto 14px; }
.mascot-wrap img {
  width: 190px; height: 190px;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(54, 82, 150, .22));
}
.gate-bubble {
  display: inline-block;
  position: relative;
  background: var(--accent-soft);
  color: #14497e;
  border: 1px solid #cfe1f6;
  border-radius: 14px;
  padding: 12px 20px;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 18px;
}
.gate-bubble::after {
  content: "";
  position: absolute;
  bottom: -7px; left: 50%;
  width: 12px; height: 12px;
  margin-left: -6px;
  background: var(--accent-soft);
  border-right: 1px solid #cfe1f6;
  border-bottom: 1px solid #cfe1f6;
  transform: rotate(45deg);
}
.gate-q {
  font-size: 18px;
  font-weight: 600;
  margin: 6px 0 22px;
  line-height: 1.65;
}
.gate-opts { display: flex; flex-direction: column; gap: 11px; max-width: 380px; margin: 0 auto; }
.gate-opts button {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 13px 18px;
  font-size: 15.5px; font-family: inherit; text-align: left;
  transition: .14s;
}
.gate-opts button:hover { border-color: var(--accent); background: #fafcff; transform: translateY(-1px); }
.gate-opts .tag {
  flex: 0 0 26px; height: 26px; line-height: 26px; text-align: center;
  border-radius: 50%; background: #f0f3f7; font-weight: 700; font-size: 13px; color: var(--muted);
}
.gate-opts button:hover .tag { background: var(--accent); color: #fff; }

/* ---------- 彩蛋结果页 ---------- */
.gag-card {
  border: 1px solid #f3c9c4;
  background: linear-gradient(180deg, #fff6f5 0%, #ffffff 70%);
  border-radius: 12px;
  padding: 24px 22px;
  text-align: center;
  margin-bottom: 16px;
}
.gag-card img { width: 160px; height: 160px; object-fit: contain; margin-bottom: 10px; }
.gag-say {
  display: inline-block;
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid #f3c9c4;
  border-radius: 12px;
  padding: 11px 20px;
  font-size: 17px;
  font-weight: 700;
}
.gag-sub { margin-top: 14px; font-size: 13.5px; color: var(--muted); }

/* 股东大人支线：满分版，换成绿色 */
.gag-card.gag-ok {
  border-color: #bfe3cd;
  background: linear-gradient(180deg, #f4fbf6 0%, #ffffff 70%);
}
.gag-say.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #bfe3cd;
}

.hide { display: none !important; }

/* ---------- 首页四大入口 ---------- */
.modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin: 18px 0 4px;
}
.mode-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px 18px;
  text-align: left; transition: .16s; font-family: inherit;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.mode-card:hover:not(:disabled) {
  border-color: var(--accent); transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(20, 102, 196, .12);
}
.mode-card:disabled { opacity: .5; cursor: not-allowed; }
.mc-icon {
  flex: 0 0 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 13px;
}
.mc-title { font-size: 15.5px; font-weight: 600; color: var(--ink); }
.mc-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- 代码编辑器 ---------- */
.editor-wrap {
  display: flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.gutter {
  flex: 0 0 46px;
  padding: 12px 8px 12px 0;
  text-align: right;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.65;
  color: #a6b0bd;
  background: #f7f9fb;
  border-right: 1px solid var(--line);
  overflow: hidden;
  user-select: none;
  white-space: pre;
}
/* 纵向滚动交给 textarea 自己，两层盒子严格同尺寸，高亮层只跟随 */
.code-scroll { flex: 1; min-width: 0; position: relative; }
.code-area { position: relative; height: 460px; }

#big-hl, #big-code {
  margin: 0;
  padding: 12px 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.65;
  font-weight: 400;
  font-style: normal;
  letter-spacing: 0;
  word-spacing: 0;
  font-kerning: none;
  font-variant-ligatures: none;
  text-rendering: optimizeSpeed;
  white-space: pre;
  tab-size: 4;
  -moz-tab-size: 4;
  border: 0;
  box-sizing: border-box;
}
#big-hl {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  color: #22303f;
}
#big-code {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: #111;
  overflow: auto;
}
#big-code::selection { background: rgba(20, 102, 196, .18); }

/* 高亮配色（注释不加斜体：斜体字符宽度会变，导致高亮层与输入层错位） */
.t-kw { color: #a626a4; }
.t-str { color: #2f8a3b; }
.t-com { color: #98a1ad; }
.t-num { color: #b76b01; }
.t-pp { color: #0f7b8a; }
.t-op { color: #5a6572; }
.t-fn { color: #1466c4; }

/* ---------- 大题题目区 ---------- */
.big-title { font-size: 17px; font-weight: 700; }
.big-type-tag {
  display: inline-block; font-size: 12px; padding: 2px 9px;
  border-radius: 20px; background: var(--accent-soft); color: var(--accent);
  margin: 6px 0 10px;
}
.big-desc-text { font-size: 14.5px; line-height: 1.75; color: #37414f; }

/* ---------- 运行结果 ---------- */
.run-head {
  font-size: 15px; font-weight: 700; margin-bottom: 10px;
  display: flex; align-items: center; gap: 10px;
}
.run-head.ok { color: var(--ok); }
.run-head.mid { color: var(--warn); }
.run-head.bad { color: var(--bad); }
.run-pct {
  font-size: 13px; font-weight: 600; padding: 2px 9px;
  border-radius: 20px; background: #f0f3f7; color: var(--ink);
}
.run-err {
  font-family: Consolas, monospace; font-size: 13px;
  background: var(--bad-soft); color: var(--bad);
  padding: 10px 12px; border-radius: 8px;
}
.err-line { font-size: 12.5px; opacity: .85; }
.run-tip, .run-ok-tip { margin-top: 10px; font-size: 13px; color: var(--muted); }
.run-ok-tip { color: var(--ok); }

.diff {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-top: 10px; background: #fafbfc;
}
.diff-head { font-size: 13px; font-weight: 600; color: var(--warn); margin-bottom: 6px; }
.diff-row { display: flex; gap: 10px; align-items: baseline; font-size: 13px; margin: 3px 0; }
.diff-row .k { flex: 0 0 34px; color: var(--muted); font-size: 12.5px; }
.diff-row code {
  background: #fff; border: 1px solid var(--line); border-radius: 5px;
  padding: 3px 8px; font-size: 12.5px; word-break: break-all;
}
.diff-row code.bad { border-color: #f0c4be; color: var(--bad); background: #fff8f7; }

/* ---------- 大题解析 ---------- */
.exp-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.exp-body { font-size: 14px; line-height: 1.8; color: #37414f; }
.exp-sub { font-size: 13.5px; font-weight: 600; margin: 16px 0 8px; color: var(--ink); }
.exp-list { margin: 0; padding-left: 22px; font-size: 13.5px; line-height: 1.9; }
.exp-list code {
  background: #f0f3f7; padding: 2px 7px; border-radius: 5px;
  font-family: Consolas, monospace; font-size: 12.5px;
}
.exp-list code.bad { background: var(--bad-soft); color: var(--bad); }
.exp-list code.ok { background: var(--ok-soft); color: var(--ok); }
.exp-code {
  background: #f7f9fb; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; font-family: Consolas, monospace; font-size: 12.5px;
  line-height: 1.6; overflow-x: auto; white-space: pre; margin: 0;
}
.exp-tip { margin-top: 8px; font-size: 13px; color: var(--muted); }
