/* EGame 样式表
   设计目标：
   1. 投影时后排也要看得清 —— 基础字号偏大，关键数字更大
   2. 手机上要好点 —— 触控目标不小于 44px
   3. 不依赖任何外部字体或图标库，全部使用系统字体与 Unicode 符号 */

:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --border: #334155;
  --border-strong: #475569;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 10px;
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
  --font: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

/* ---- 布局 ---- */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem;
}

.page-narrow { max-width: 460px; }

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 1rem; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .85rem;
}

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: .875rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---- 顶栏 ---- */

.topbar {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: .6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-brand {
  font-weight: 600;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.who {
  color: var(--text-dim);
  font-size: .9rem;
}

/* ---- 标签页 ---- */

.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  overflow-x: auto;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: .6rem .9rem;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---- 表单 ---- */

label { display: block; font-size: .9rem; color: var(--text-dim); margin-bottom: .3rem; }

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  padding: .65rem .75rem;
  font-size: 1rem;
  font-family: inherit;
  min-height: 44px;
}

textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, Consolas, monospace; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .18);
}

.field { margin-bottom: .9rem; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row > * { flex: 1 1 180px; }

/* ---- 按钮 ---- */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  background: var(--primary-dark);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .6rem 1rem;
  font-size: .95rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: filter .15s, background .15s;
}

button:hover:not(:disabled), .btn:hover { filter: brightness(1.12); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.secondary, .btn.secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

button.danger { background: #b91c1c; }
button.success { background: #047857; }
button.link {
  background: none;
  border: none;
  color: var(--primary);
  padding: .25rem .4rem;
  min-height: auto;
  text-decoration: underline;
  font-size: .875rem;
}
button.link.danger-text { color: var(--danger); }
button.block { width: 100%; }
button.sm { min-height: 34px; padding: .35rem .6rem; font-size: .85rem; }

.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* 分组行内的「改名 / 删除」按钮。
   分组侧栏只有 200~260px 宽，因此把按钮压到最小，
   并始终可见 —— 老师可能用平板，不能依赖 hover 才出现。 */
.group-item button.link {
  flex: 0 0 auto;
  font-size: .78rem;
  padding: .2rem .25rem;
  min-height: auto;
}

/* ---- 表格 ---- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }

th, td {
  text-align: left;
  padding: .6rem .55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: .82rem;
  text-transform: none;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

tbody tr:hover { background: rgba(148, 163, 184, .06); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- 标签徽章 ---- */

.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge.super { background: rgba(168, 85, 247, .18); color: #d8b4fe; border-color: rgba(168, 85, 247, .4); }
.badge.teacher { background: rgba(56, 189, 248, .16); color: #7dd3fc; border-color: rgba(56, 189, 248, .4); }
.badge.ok { background: rgba(52, 211, 153, .16); color: #6ee7b7; border-color: rgba(52, 211, 153, .4); }
.badge.off { background: rgba(148, 163, 184, .16); color: #cbd5e1; border-color: rgba(148, 163, 184, .35); }
.badge.warn { background: rgba(251, 191, 36, .16); color: #fcd34d; border-color: rgba(251, 191, 36, .4); }
.badge.danger { background: rgba(248, 113, 113, .16); color: #fca5a5; border-color: rgba(248, 113, 113, .4); }

/* ---- 统计卡片 ---- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .75rem;
}

.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem;
}

.stat-label { color: var(--text-dim); font-size: .82rem; }

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.info-list { display: grid; grid-template-columns: auto 1fr; gap: .35rem .9rem; font-size: .9rem; }
.info-list dt { color: var(--text-dim); }
.info-list dd { margin: 0; word-break: break-all; }

/* ---- 提示 ---- */

.alert {
  border-radius: 8px;
  padding: .7rem .85rem;
  font-size: .9rem;
  border: 1px solid;
  margin-bottom: .9rem;
}

.alert.info { background: rgba(56, 189, 248, .1); border-color: rgba(56, 189, 248, .35); color: #bae6fd; }
.alert.warn { background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .35); color: #fde68a; }
.alert.danger { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .35); color: #fecaca; }
.alert.success { background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .35); color: #a7f3d0; }

/* ---- 弹层 ---- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1.25rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}

/* ---- 提示条 ---- */

#toast-host {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 200;
  max-width: min(360px, calc(100vw - 2rem));
}

.toast {
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: .65rem .85rem;
  font-size: .9rem;
  box-shadow: var(--shadow);
  animation: toast-in .18s ease-out;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- 口令展示（仅显示一次的初始口令）---- */

.secret-box {
  background: var(--bg-input);
  border: 1px dashed var(--primary);
  border-radius: 8px;
  padding: .75rem;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.15rem;
  letter-spacing: .06em;
  text-align: center;
  word-break: break-all;
  margin: .6rem 0;
}

/* ---- 空状态 ---- */

.empty {
  text-align: center;
  color: var(--text-faint);
  padding: 2rem 1rem;
  font-size: .95rem;
}

/* ---- 手机适配 ---- */

@media (max-width: 560px) {
  .page { padding: .85rem; }
  .card { padding: 1rem; }
  h1 { font-size: 1.35rem; }
  .stat-value { font-size: 1.45rem; }
  .hide-sm { display: none; }
}
