/* 铁一中学生论坛 · 主样式 */
:root {
  --primary: #802028;      /* 校徽深枣红 */
  --primary-dark: #5e161e;
  --primary-light: #faf0f0;
  --accent: #c8352b;       /* 亮红点缀（按钮/徽标） */
  --accent-dark: #a52820;
  --bg: #faf7f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(128, 32, 40, 0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; width: 100%; }
main.wrap { flex: 1; padding-top: 20px; padding-bottom: 40px; }

/* ---- 顶栏 ---- */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-banner { height: 42px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 18px; letter-spacing: 1px; }
.brand-text small { font-size: 11px; opacity: .75; }
.main-nav { display: flex; gap: 4px; margin-left: 8px; }
.main-nav a {
  color: rgba(255,255,255,.85); padding: 8px 14px; border-radius: 8px; font-size: 15px;
}
.main-nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; color: #fff; }
.main-nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.main-nav a.nav-admin { color: #ffd978; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.username { color: #fff; font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-toggle { display: none; background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 8px; font-size: 18px; padding: 4px 10px; cursor: pointer; }

/* ---- 头像 ---- */
.avatar {
  --hue: 210;
  width: 32px; height: 32px; border-radius: 50%;
  background: hsl(var(--hue), 55%, 45%);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.avatar.lg { width: 44px; height: 44px; font-size: 20px; }
.avatar-img {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0; background: #ddd;
}
.avatar-img.lg { width: 44px; height: 44px; }
.user-sign { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4;
  word-break: break-all; }

/* ---- 等级徽章 / 信用点 ---- */
.level-badge {
  --lc: #6b7280;
  display: inline-block; font-size: 11px; font-weight: 700; color: #fff;
  background: var(--lc); border-radius: 10px; padding: 1px 8px; white-space: nowrap;
}
.level-badge.sm { font-size: 10px; padding: 0 6px; }
.credits-pill {
  font-size: 12px; font-weight: 700; color: #92600a; background: #fef3c7;
  border: 1px solid #fcd34d; border-radius: 12px; padding: 3px 10px; white-space: nowrap;
}
.post-side .level-badge { margin-top: 4px; }

/* ---- 全服公告弹窗 ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: #fff; border-radius: 16px; max-width: 480px; width: 100%;
  padding: 24px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  animation: modal-pop 0.25s ease-out;
}
@keyframes modal-pop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-head {
  font-size: 18px; font-weight: 700; color: var(--primary);
  margin-bottom: 12px; text-align: center;
}
.modal-body {
  font-size: 15px; line-height: 1.7; margin-bottom: 18px;
  max-height: 50vh; overflow-y: auto; word-break: break-word;
}

/* ---- 按钮 / 表单 ---- */
.btn {
  display: inline-block; border: none; cursor: pointer; border-radius: 8px;
  padding: 10px 20px; font-size: 15px; font-weight: 600; text-align: center;
}
.btn:hover { text-decoration: none; filter: brightness(.96); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 16px; border: 1px solid var(--border);
}
.card h2, .card h3 { margin-top: 0; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.form-control {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; font-family: inherit; background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea.form-control { resize: vertical; min-height: 120px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.flash-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ---- 公告条 ---- */
.announce-bar { background: #fff7e6; border-bottom: 1px solid #f5d78e; color: #8a5a00; font-size: 14px; }
.announce-bar .wrap { padding-top: 8px; padding-bottom: 8px; }
.announce-bar a { color: #8a5a00; font-weight: 600; }

/* ---- 首页 ---- */
.hero {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary) 60%, #a03a44);
  border-radius: var(--radius); color: #fff; padding: 36px 28px; margin-bottom: 20px;
  display: flex; align-items: center; gap: 24px; box-shadow: var(--shadow);
}
.hero-logo { width: 96px; height: 96px; border-radius: 50%; object-fit: contain; flex-shrink: 0; }
.hero h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: 2px; }
.hero p { margin: 0; opacity: .85; font-size: 14px; }
.hero .motto { margin-top: 10px; font-size: 15px; letter-spacing: 6px; color: #ffd978; font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.section-title { font-size: 17px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 4px; height: 18px; background: var(--accent); border-radius: 2px; }

.thread-row {
  display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); align-items: flex-start;
}
.thread-row:last-child { border-bottom: none; }
.thread-main { flex: 1; min-width: 0; }
.thread-title { font-size: 15px; font-weight: 600; color: var(--text); display: block; }
.thread-title:hover { color: var(--primary); }
.thread-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 20px; font-weight: 600; margin-right: 6px; vertical-align: 1px; }
.badge-pin { background: var(--accent); color: #fff; }
.badge-lock { background: #6b7280; color: #fff; }
.badge-board { background: var(--primary-light); color: var(--primary); }
.stat-num { font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }
.stat-num b { color: var(--primary); font-size: 16px; }

.board-row { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.board-row:last-child { border-bottom: none; }
.board-icon { font-size: 26px; }
.board-info { flex: 1; }
.board-info a { font-size: 16px; font-weight: 700; color: var(--text); }
.board-info a:hover { color: var(--primary); }
.board-info p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow); border: 1px solid var(--border); }
.stat-card b { display: block; font-size: 24px; color: var(--primary); }
.stat-card span { font-size: 12px; color: var(--muted); }

.quick-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.quick-link {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 12px; text-align: center; box-shadow: var(--shadow); transition: transform .15s;
}
.quick-link:hover { text-decoration: none; transform: translateY(-2px); }
.quick-link .ql-icon { font-size: 34px; display: block; margin-bottom: 8px; }
.quick-link b { color: var(--text); font-size: 15px; display: block; }
.quick-link small { color: var(--muted); font-size: 12px; }

/* ---- 帖子页 ---- */
.thread-head { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 6px; }
.thread-head h1 { font-size: 22px; margin: 0 0 8px; }
.post-row { display: flex; gap: 14px; padding: 18px 4px; border-bottom: 1px solid var(--border); }
.post-side { width: 64px; text-align: center; flex-shrink: 0; }
.post-side .username { display: block; font-size: 12px; margin-top: 6px; word-break: break-all; }
.post-body { flex: 1; min-width: 0; }
.post-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.post-content { font-size: 15px; word-break: break-word; }
.post-actions { margin-top: 10px; display: flex; gap: 8px; }
.like-btn { background: var(--primary-light); color: var(--primary); border: none; border-radius: 20px; padding: 5px 14px; font-size: 13px; cursor: pointer; font-weight: 600; }
.like-btn.liked { background: var(--accent); color: #fff; }
.floor-tag { background: #f3f4f6; color: var(--muted); font-size: 11px; padding: 2px 8px; border-radius: 10px; }

.pagination { display: flex; gap: 6px; justify-content: center; margin: 20px 0; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 14px; padding: 0 10px;
}
.pagination a:hover { border-color: var(--primary); text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }

/* ---- 聊天室 ---- */
.chat-layout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
.room-list { display: flex; flex-direction: column; gap: 6px; }
.room-item { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.room-item:hover { border-color: var(--primary); }
.room-item.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.room-item.active small { color: rgba(255,255,255,.8); }
.room-item b { display: block; font-size: 14px; }
.room-item small { font-size: 12px; color: var(--muted); }
.chat-box { display: flex; flex-direction: column; height: 560px; }
.chat-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 0; }
.chat-head h3 { margin: 0; font-size: 16px; }
.online-count { font-size: 12px; color: var(--muted); background: #f3f4f6; padding: 3px 10px; border-radius: 12px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px 4px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { display: flex; gap: 8px; align-items: flex-start; }
.chat-msg .avatar { width: 28px; height: 28px; font-size: 13px; }
.chat-msg .avatar-img { width: 28px; height: 28px; }
.chat-bubble { background: #f3f4f6; border-radius: 4px 12px 12px 12px; padding: 8px 12px; max-width: 75%; font-size: 14px; word-break: break-word; }
.chat-bubble .cm-user { font-size: 12px; color: var(--primary); font-weight: 700; display: block; margin-bottom: 2px; }
.chat-bubble .cm-time { font-size: 10px; color: var(--muted); margin-left: 6px; font-weight: 400; }
.chat-msg.mine { flex-direction: row-reverse; }
.chat-msg.mine .chat-bubble { background: var(--primary-light); border-radius: 12px 4px 12px 12px; }
.chat-input-row { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; }
.admin-tag { background: var(--accent); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 8px; margin-left: 4px; }

/* ---- 游戏 ---- */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.game-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; text-align: center; box-shadow: var(--shadow); }
.game-card:hover { transform: translateY(-3px); transition: transform .15s; }
.game-card .g-icon { font-size: 48px; }
.game-card h3 { margin: 10px 0 6px; }
.game-card p { font-size: 13px; color: var(--muted); margin: 0 0 12px; min-height: 40px; }
.game-card .my-best { font-size: 12px; color: var(--accent); font-weight: 700; }
.leaderboard { list-style: none; margin: 0; padding: 0; }
.leaderboard li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.leaderboard li:last-child { border-bottom: none; }
.rank { width: 26px; height: 26px; border-radius: 50%; background: #f3f4f6; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.rank.r1 { background: #fbbf24; color: #fff; }
.rank.r2 { background: #d1d5db; color: #fff; }
.rank.r3 { background: #d97706; color: #fff; }
.lb-score { margin-left: auto; font-weight: 700; color: var(--primary); }
.game-play-wrap { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; }
.game-stage { text-align: center; }
.game-canvas { border: 2px solid var(--primary); border-radius: 12px; background: #fafafa; touch-action: none; max-width: 100%; }
.game-controls { margin-top: 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.score-line { font-size: 16px; margin: 10px 0; }
.score-line b { color: var(--accent); font-size: 22px; }

/* 2048 */
.tfe-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; background: #bbada0; padding: 8px; border-radius: 12px; width: 320px; max-width: 92vw; margin: 0 auto; touch-action: none; }
.tfe-cell { aspect-ratio: 1; background: #cdc1b4; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; color: #776e65; }
.tfe-cell.n2 { background: #eee4da; } .tfe-cell.n4 { background: #ede0c8; }
.tfe-cell.n8 { background: #f2b179; color: #fff; } .tfe-cell.n16 { background: #f59563; color: #fff; }
.tfe-cell.n32 { background: #f67c5f; color: #fff; } .tfe-cell.n64 { background: #f65e3b; color: #fff; }
.tfe-cell.n128 { background: #edcf72; color: #fff; font-size: 20px; } .tfe-cell.n256 { background: #edcc61; color: #fff; font-size: 20px; }
.tfe-cell.n512 { background: #edc850; color: #fff; font-size: 20px; } .tfe-cell.n1024 { background: #edc53f; color: #fff; font-size: 18px; }
.tfe-cell.n2048 { background: #edc22e; color: #fff; font-size: 18px; } .tfe-cell.nbig { background: #3c3a32; color: #fff; font-size: 16px; }

/* ---- 页脚 ---- */
.site-footer { background: var(--primary-dark); color: rgba(255,255,255,.8); margin-top: auto; }
.site-footer .wrap { padding-top: 24px; padding-bottom: 24px; text-align: center; font-size: 13px; }
.site-footer p { margin: 6px 0; }
.site-footer .disclaimer { font-size: 12px; opacity: .7; }
.site-footer .copyright { font-size: 12px; opacity: .6; }

/* ---- 认证页 ---- */
.auth-wrap { max-width: 420px; margin: 30px auto; }
.auth-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px 28px; border: 1px solid var(--border); }
.auth-card h2 { text-align: center; margin: 0 0 6px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.auth-logo { display: block; width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%; border: 2px solid var(--primary-light); object-fit: contain; }

/* ---- 搜索 ---- */
.search-row { display: flex; gap: 8px; margin-bottom: 16px; }
.search-row input { flex: 1; }

/* ---- 错误页 ---- */
.error-page { text-align: center; padding: 60px 20px; }
.error-page h1 { font-size: 64px; margin: 0; color: var(--primary); }
.error-page p { color: var(--muted); }

/* ---- 响应式 ---- */
@media (max-width: 860px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .quick-links { grid-template-columns: repeat(3, 1fr); }
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--primary-dark); flex-direction: column; padding: 8px; margin: 0;
  }
  .main-nav.open { display: flex; }
  .site-header { position: sticky; }
  .header-inner { position: relative; }
  .nav-toggle { display: block; }
  .username { display: none; }
  .brand-text small { display: none; }
  .brand-banner { height: 32px; }
  .credits-pill { display: none; }
  .chat-layout { grid-template-columns: 1fr; }
  .room-list { flex-direction: row; overflow-x: auto; }
  .room-item { white-space: nowrap; }
  .chat-box { height: 480px; }
  .game-play-wrap { grid-template-columns: 1fr; }
  .hero { padding: 24px 18px; }
  .hero h1 { font-size: 21px; }
  .hero-logo { width: 72px; height: 72px; }
  .post-side { width: 48px; }
}
