/* ============================================================
   信息科技编程教学平台 · V3 像素闯关风 全站样式
   设计语言：奶黄格纹底 + 黑描边 + 硬投影 + 无圆角无渐变
   强调色：柠檬黄 / 珊瑚红 / 草绿 / 天蓝 / 紫
   说明：底部标签栏 .mtabbar 桌面端隐藏，仅 ≤640px 显示（替代侧栏）
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #faf3dd;            /* 奶黄底 */
  --ink: #1b1b1e;           /* 描边黑 */
  --yellow: #ffd23f;        /* 柠檬黄 */
  --red: #ff5252;           /* 珊瑚红 */
  --green: #06d6a0;         /* 草绿 */
  --blue: #3a86ff;          /* 天蓝 */
  --purple: #9b5de5;        /* 紫 */
  --orange: #ff9f1c;        /* 橙（徽章/警告） */
  --card: #ffffff;
  --line: var(--ink);
  --text: var(--ink);
  --muted: #7a7668;
  --sidebar: #1b1b1e;
  --sidebar-text: #d8d2c0;
  --primary: var(--blue);
  --primary-dark: #2f6fe0;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-lg: 7px 7px 0 var(--ink);
  --bd: 3px solid var(--ink);
  --bd2: 2px solid var(--ink);
  --radius: 0;
  --pixel: "Press Start 2P", "Cascadia Code", monospace;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
}
body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.75;
  /* 像素格纹底 */
  background-image:
    linear-gradient(rgba(27,27,30,.05) 2px, transparent 2px),
    linear-gradient(90deg, rgba(27,27,30,.05) 2px, transparent 2px);
  background-size: 32px 32px;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
::placeholder { color: #b8b2a0; font-weight: 400; }

/* ---------- 表单 ---------- */
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 10px 12px;
  border: var(--bd2); border-radius: 0; width: 100%;
  background: #fffdf6; color: var(--ink);
  transition: box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--shadow); }
label { display: block; font-size: 13px; font-weight: 700; color: var(--ink); margin: 12px 0 4px; }

/* ---------- 按钮：硬投影 + 按下位移 ---------- */
.btn {
  border: var(--bd2); border-radius: 0; padding: 9px 16px; font-size: 14px; font-weight: 700;
  background: #fff; color: var(--ink); box-shadow: 3px 3px 0 var(--ink);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--blue); color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.3); }
.btn.green { background: var(--green); color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.3); }
.btn.orange { background: var(--yellow); color: var(--ink); }
.btn.red { background: var(--red); color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.3); }
.btn.ghost { background: transparent; color: inherit; border: var(--bd2); box-shadow: none; }
.btn.ghost:hover { transform: none; background: rgba(255,255,255,.12); box-shadow: none; }
.btn.small { padding: 5px 10px; font-size: 13px; box-shadow: 2px 2px 0 var(--ink); }
.btn.block { width: 100%; margin-top: 18px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- 登录页：游戏开机画面 ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; position: relative; overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,210,63,.35) 0 46px, transparent 47px),
    radial-gradient(circle at 88% 12%, rgba(58,134,255,.28) 0 60px, transparent 61px),
    radial-gradient(circle at 82% 82%, rgba(6,214,160,.3) 0 52px, transparent 53px),
    linear-gradient(rgba(27,27,30,.05) 2px, transparent 2px),
    linear-gradient(90deg, rgba(27,27,30,.05) 2px, transparent 2px);
  background-size: 96px 96px, 120px 120px, 104px 104px, 32px 32px, 32px 32px;
}
.auth-card { background: var(--card); border: var(--bd); box-shadow: var(--shadow-lg); width: 430px; max-width: 96vw; }
.auth-head { background: var(--ink); color: #fff; padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; }
.auth-head .t { font-weight: 900; font-size: 16px; letter-spacing: .12em; }
.auth-head .p { font-family: var(--pixel); font-size: 9px; color: var(--yellow); }
.auth-logo { font-size: 42px; text-align: center; padding-top: 22px; }
.auth-card h1 { font-size: 20px; text-align: center; margin-top: 4px; text-shadow: 2px 2px 0 var(--yellow); }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; font-weight: 700; margin: 6px 0 16px; }
.auth-body { padding: 18px 26px 26px; }

/* Tab（登录/注册） */
.tabs { display: flex; border-bottom: var(--bd); }
.tab {
  flex: 1; border: none; border-right: var(--bd2); background: var(--bg);
  padding: 11px; font-size: 15px; font-weight: 900; color: var(--muted);
  transition: background .15s ease, color .15s ease;
}
.tab:last-child { border-right: none; }
.tab.active { background: var(--yellow); color: var(--ink); }
.error-text { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; font-weight: 700; }

/* ---------- 布局：黑底游戏菜单侧栏 ---------- */
#mainView { display: flex; min-height: 100vh; }
.sidebar { width: 224px; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; }
.brand { font-size: 16px; font-weight: 900; color: #fff; padding: 20px 18px 16px; border-bottom: 2px solid #3a3a40; display: flex; align-items: center; gap: 10px; }
.brand .sprite { width: 34px; height: 34px; display: grid; place-items: center; background: var(--yellow); border: 2px solid #000; font-size: 19px; }
#navMenu { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: block; padding: 10px 13px; color: var(--sidebar-text); text-decoration: none;
  font-size: 14px; font-weight: 700; border: 2px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: #2c2c31; color: #fff; }
.nav-item.active { background: var(--yellow); color: var(--ink); border-color: #000; }
.nav-item.active::before { content: "▶ "; }
.sidebar-foot { padding: 16px 14px; border-top: 2px solid #3a3a40; display: flex; flex-direction: column; gap: 8px; }
.whoami { font-size: 13px; line-height: 1.6; }
.whoami b { color: var(--yellow); }
.whoami .coin { font-family: var(--pixel); font-size: 10px; color: var(--yellow); }
.content { flex: 1; margin-left: 224px; padding: 28px 34px 60px; max-width: 1200px; }

/* 页面标题：黄色硬投影 */
.page-title { font-size: 25px; font-weight: 900; margin-bottom: 4px; text-shadow: 3px 3px 0 var(--yellow); }
.page-desc { color: var(--muted); font-size: 13px; font-weight: 700; margin-bottom: 22px; }
.world-tag {
  display: inline-block; font-family: var(--pixel); font-size: 10px;
  background: var(--blue); color: #fff; border: var(--bd2); box-shadow: 3px 3px 0 var(--ink);
  padding: 8px 12px; margin-bottom: 14px; text-shadow: 1px 1px 0 rgba(0,0,0,.35);
}

/* ---------- 卡片：白底黑边硬投影 ---------- */
.card { background: var(--card); border: var(--bd); box-shadow: var(--shadow); padding: 18px 18px 16px; margin-bottom: 20px; }
.card h3 { font-size: 16px; font-weight: 900; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }
.code-inline { font-family: var(--mono); background: var(--yellow); border: 2px solid var(--ink); padding: 2px 8px; font-weight: 700; letter-spacing: 2px; }

/* ---------- 徽章：直角小旗 ---------- */
.badge { display: inline-block; padding: 1px 9px; border: 2px solid var(--ink); font-size: 12px; font-weight: 700; }
.badge.gray { background: #efe9d5; color: var(--muted); }
.badge.blue { background: var(--blue); color: #fff; }
.badge.green { background: var(--green); color: #fff; }
.badge.orange { background: var(--yellow); color: var(--ink); }
.badge.red { background: var(--red); color: #fff; }

/* ---------- 表格：黄表头硬横条 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 2px solid #f0ead8; }
th { color: var(--ink); font-weight: 900; font-size: 13px; background: var(--yellow); border-bottom: var(--bd2); }
tr.clickable:hover { background: #fff7d6; cursor: pointer; }

/* ---------- 弹窗：复古警告框 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(27,27,30,.62); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 24px;
  background-image: radial-gradient(rgba(255,255,255,.07) 2px, transparent 2px); background-size: 8px 8px; }
.modal { background: var(--card); border: var(--bd); box-shadow: var(--shadow-lg); padding: 24px; width: 720px; max-width: 96vw; max-height: 90vh; overflow: auto; }
.modal h2 { font-size: 18px; font-weight: 900; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* 切页警告专用：红头警报 */
.modal.warn { border-color: var(--red); box-shadow: 7px 7px 0 var(--red); }
.modal.warn .warn-head { background: var(--red); color: #fff; margin: -24px -24px 16px; padding: 12px 20px; font-weight: 900; font-size: 16px; letter-spacing: .14em; display: flex; justify-content: space-between; }
.modal.warn .warn-head .p { font-family: var(--pixel); font-size: 9px; }

/* ---------- 提示气泡 ---------- */
.toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--yellow); padding: 10px 22px; border: 2px solid var(--yellow); font-weight: 700; font-size: 14px; z-index: 200; box-shadow: var(--shadow); }
.toast.err { background: var(--red); color: #fff; border-color: var(--ink); }
.toast.ok { background: var(--green); color: #fff; border-color: var(--ink); }

/* ---------- 编辑器：像素外壳 + 深色游戏机屏幕 ---------- */
.work-layout { display: grid; grid-template-columns: 310px minmax(0,1fr); gap: 20px; align-items: start; }
.work-layout.wide-left { grid-template-columns: minmax(0, 1fr) 330px; }
.editor-panel { background: #1e2330; border: var(--bd); box-shadow: var(--shadow); overflow: hidden; }
.editor-head { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: var(--yellow); color: var(--ink); font-size: 13px; font-weight: 900; border-bottom: var(--bd); }
.editor-head .dot { font-family: var(--pixel); font-size: 9px; color: var(--ink); opacity: .65; }
.editor-body { display: flex; height: 460px; }
.gutter { width: 48px; background: #171b25; color: #566180; text-align: right; padding: 12px 8px 12px 0; font-family: var(--mono); font-size: 14px; line-height: 1.55; overflow: hidden; user-select: none; white-space: pre; border-right: 2px solid #2a3040; }
#codeArea, #labCode { flex: 1; background: #1e2330; color: #e6e9f2; border: none; resize: none; font-family: var(--mono); font-size: 14px; line-height: 1.55; padding: 12px 14px; tab-size: 4; white-space: pre; }
#codeArea:focus, #labCode:focus { outline: none; }
.output-panel { background: #12151d; border: var(--bd); box-shadow: var(--shadow); margin-top: 18px; overflow: hidden; }
.output-head { padding: 8px 14px; background: #171b25; color: var(--yellow); font-family: var(--pixel); font-size: 9px; display: flex; gap: 10px; align-items: center; border-bottom: 2px solid #2a3040; }
#outputArea { padding: 14px; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; color: #cdd6ea; white-space: pre-wrap; word-break: break-all; min-height: 60px; max-height: 260px; overflow: auto; }
.out-err { color: #ff8f8f; }

/* 经验条（任务进度） */
.progress-bar { height: 16px; background: #efe9d5; border: var(--bd2); overflow: hidden; }
.progress-bar > div { height: 100%; background: repeating-linear-gradient(-45deg, var(--green) 0 8px, #05bd8f 8px 16px); border-right: 2px solid var(--ink); width: 0; transition: width .25s; }

/* ---------- 我的代码库：项目列表 ---------- */
.snip-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fff; border: var(--bd2); cursor: pointer; font-family: var(--mono); font-size: 13px; margin-bottom: 6px; }
.snip-item:hover { background: #fff3c4; }
.snip-item.active { background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); font-weight: 700; }
.snip-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 判题结果 / 测试用例 ---------- */
.verdict { padding: 11px 16px; border: var(--bd2); font-weight: 900; font-size: 16px; letter-spacing: .08em; }
.verdict.ok { background: var(--green); color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.35); }
.verdict.fail { background: var(--red); color: #fff; text-shadow: 1px 1px 0 rgba(0,0,0,.35); }
.points-gain { margin: 10px 0; padding: 9px 14px; border: var(--bd2); background: var(--yellow); color: var(--ink); font-size: 13.5px; font-weight: 900; }
.test-row { display: grid; grid-template-columns: 110px 1fr 1fr 36px; gap: 8px; margin-bottom: 8px; align-items: start; }
.test-view { background: #fffdf6; border: var(--bd2); padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
.test-view .pass { color: #0a9b76; font-weight: 900; }
.test-view .fail { color: var(--red); font-weight: 900; }
pre.code-view { font-family: var(--mono); font-size: 13px; background: #1e2330; color: #e6e9f2; border: var(--bd2); padding: 14px; white-space: pre-wrap; word-break: break-all; max-height: 340px; overflow: auto; }
.feedback-box { background: #fffdf6; border: var(--bd2); border-left: 6px solid var(--blue); padding: 12px 14px; font-size: 13.5px; white-space: pre-wrap; line-height: 1.7; margin-top: 10px; }
.ai-box { background: #f2fbf5; border: var(--bd2); border-left: 6px solid var(--green); padding: 12px 14px; font-size: 13.5px; white-space: pre-wrap; line-height: 1.7; margin-top: 10px; }
.mini-err { margin-top: 4px; background: #fff7f7; border: 2px dashed var(--red); padding: 6px 10px; font-size: 12.5px; color: #8a3d3d; font-weight: 700; }

/* 运行错误中文卡片 */
.err-card { background: #fff; border: var(--bd2); border-left: 8px solid var(--red); box-shadow: 3px 3px 0 var(--ink); padding: 14px 16px; margin-bottom: 12px; color: #3d2a2a; font-size: 13.5px; white-space: normal; word-break: normal; }
.err-card .err-head { font-size: 15px; font-weight: 900; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.err-card .err-type { font-family: var(--mono); font-size: 12px; background: var(--red); color: #fff; padding: 2px 8px; font-weight: 700; }
.err-card .err-line { font-size: 12px; background: var(--yellow); color: var(--ink); padding: 2px 8px; font-weight: 700; }
.err-card .err-detail { margin: 8px 0 4px; color: #7a4a4a; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.err-card .err-sec { margin-top: 8px; line-height: 1.7; }
.err-card .err-sec ul { margin: 4px 0 0 20px; }
.err-card .err-foot { margin-top: 12px; display: flex; gap: 10px; }
.raw-err { margin-top: 10px; font-size: 12px; color: var(--muted); }
.raw-err summary { cursor: pointer; font-weight: 700; }

/* ---------- 知识库 ---------- */
.kb-card { text-decoration: none; color: inherit; display: block; transition: transform .12s ease, box-shadow .12s ease; }
.kb-card:hover { transform: translate(-2px,-2px); box-shadow: var(--shadow-lg); }
.kb-detail h2 { font-size: 21px; font-weight: 900; margin-bottom: 4px; text-shadow: 2px 2px 0 var(--yellow); }
.kb-content { font-size: 14.5px; line-height: 1.85; margin-top: 10px; }
.kb-content .md-p { margin: 8px 0; }
.kb-content .md-list { margin: 8px 0 8px 24px; }
.kb-content .md-list li { margin: 4px 0; }
.kb-content .md-pre { font-family: var(--mono); background: #1e2330; color: #e6e9f2; border: var(--bd2); padding: 12px 14px; margin: 10px 0; white-space: pre-wrap; word-break: break-all; font-size: 13.5px; line-height: 1.6; }
.kb-content .md-code { font-family: var(--mono); background: var(--yellow); border: 1px solid var(--ink); padding: 1px 6px; font-size: 13px; }
.kb-content table { margin: 10px 0; }

/* ---------- 挑战广场 ---------- */
.plaza-card { text-decoration: none; color: inherit; display: block; transition: transform .12s ease, box-shadow .12s ease; }
.plaza-card:hover { transform: translate(-2px,-2px); box-shadow: var(--shadow-lg); }
.plaza-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-block; padding: 1px 9px; border: 2px solid var(--ink); font-size: 12px; font-weight: 700; background: #fff; color: var(--ink); }
.pill.gold { background: var(--yellow); }
.pill.muted { background: transparent; color: var(--muted); border-color: transparent; padding-left: 0; }
.stars { color: var(--orange); letter-spacing: 2px; font-size: 13px; text-shadow: 1px 1px 0 rgba(0,0,0,.2); }
.rank-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rank-table td { padding: 7px 6px; border-bottom: 2px dashed #e8e1cc; }
.rank-table tr:last-child td { border-bottom: none; }
.rank-table td.rk { width: 42px; color: var(--muted); text-align: center; font-family: var(--pixel); font-size: 10px; }
.rank-table td.rk b { display: inline-grid; place-items: center; width: 26px; height: 26px; border: 2px solid var(--ink); color: #fff; font-family: var(--mono); font-size: 13px; }
.rank-table td.rk b.g1 { background: var(--yellow); color: var(--ink); }
.rank-table td.rk b.g2 { background: #cfd6e0; }
.rank-table td.rk b.g3 { background: var(--orange); }
.rank-table td.num { text-align: right; font-family: var(--mono); color: #4a5468; white-space: nowrap; }
.rank-table td.gain { color: #0a9b76; font-weight: 900; }
.rank-table tr.me { background: #fff7d6; }
.rank-title { margin: 14px 0 6px; font-size: 14px; font-weight: 900; }
.rank-title .muted { font-weight: 400; }
.sample-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.sample-table th { text-align: left; padding: 6px; }
.sample-table td { padding: 6px; vertical-align: top; border-bottom: 2px dashed #e8e1cc; }
.sample-table pre { font-family: var(--mono); margin: 0; white-space: pre-wrap; word-break: break-all; }

/* ---------- 积分 / 个人中心 ---------- */
.points-hero { display: flex; align-items: center; gap: 22px; margin-bottom: 16px; }
.points-num { font-family: var(--pixel); font-size: 34px; color: var(--blue); line-height: 1.3; text-shadow: 3px 3px 0 var(--yellow); }
.points-title { font-size: 18px; font-weight: 900; margin-bottom: 4px; }

/* ---------- 帖子讨论 ---------- */
.cmt { padding: 10px 0; border-bottom: 2px dashed #e8e1cc; }
.cmt:last-child { border-bottom: none; }
.cmt-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.cmt-body { font-size: 13.5px; color: #3b3b40; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

/* ---------- 其他 ---------- */
#adminDot { position: fixed; right: 8px; bottom: 4px; color: rgba(27,27,30,.15); font-size: 22px; line-height: 1; text-decoration: none; z-index: 90; user-select: none; }
#adminDot:hover { color: var(--primary); }
#mainView.no-sidebar .content { margin-left: 0; max-width: 100%; }
#mainView.no-sidebar .sidebar { display: none; }

/* 底部标签栏：桌面端隐藏，仅手机端（≤640px）显示 */
.mtabbar { display: none; }

/* ---------- 响应式：平板收窄 ---------- */
@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .brand { font-size: 18px; padding: 16px 0; justify-content: center; }
  .brand .txt, .nav-item { font-size: 12px; }
  .nav-item { text-align: center; padding: 10px 4px; }
  .nav-item.active::before { content: ""; }
  .sidebar-foot { align-items: center; }
  .content { margin-left: 64px; padding: 18px; }
  .work-layout, .work-layout.wide-left { grid-template-columns: 1fr; }
  .editor-body { height: 380px; }
}

/* ---------- 响应式：手机端（侧栏交给底部标签栏，由 app.js 渲染） ---------- */
@media (max-width: 640px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 14px 14px 76px; max-width: 100%; }
  .page-title { font-size: 21px; text-shadow: 2px 2px 0 var(--yellow); }
  .work-layout, .work-layout.wide-left { display: block; }
  .editor-body { height: 250px; }
  .editor-head { flex-wrap: wrap; }
  .editor-head .btn { padding: 4px 8px; font-size: 12px; }
  .card { padding: 14px; box-shadow: 3px 3px 0 var(--ink); }
  .card[style*="padding:0"] { padding: 0; }
  .modal { padding: 16px; }
  .test-row { grid-template-columns: 1fr; }
  /* 底部标签栏（手机端导航，由 app.js 注入） */
  .mtabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--sidebar); border-top: 3px solid #000; z-index: 80; }
  .mtab { flex: 1; text-align: center; padding: 7px 2px 6px; color: var(--sidebar-text); text-decoration: none; font-size: 11px; font-weight: 700; }
  .mtab .ico { display: block; font-size: 17px; line-height: 1.3; }
  .mtab.active { background: var(--yellow); color: var(--ink); border-top: 2px solid #000; }
}
