/* 双子棋局 · 蓝白轻玻璃 · 移动优先 */
:root {
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: rgba(15, 23, 42, 0.08);
  --brand: #2563eb;
  --brand-2: #3b82f6;
  --brand-soft: #eff6ff;
  --warm: #e11d48;
  --bg: #f7f9fc;
  --card: rgba(255, 255, 255, 0.72);
  --card-solid: #ffffff;
  --shadow-s: 0 1px 2px rgba(15, 23, 42, 0.04), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-m: 0 2px 6px rgba(15, 23, 42, 0.05), 0 12px 32px rgba(15, 23, 42, 0.07);
  --shadow-l: 0 4px 12px rgba(15, 23, 42, 0.06), 0 24px 64px rgba(15, 23, 42, 0.09);
  --r-s: 12px;
  --r-m: 18px;
  --r-l: 26px;
  --ff: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--ff);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  overflow-x: hidden;
}

/* 背景：极淡光晕 + 细网格，避免"AI 味"插画 */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); }
.bg::before, .bg::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.55;
}
.bg::before { width: 620px; height: 620px; left: -180px; top: -220px; background: radial-gradient(circle, #dbeafe 0%, rgba(219,234,254,0) 70%); }
.bg::after { width: 720px; height: 720px; right: -260px; top: 120px; background: radial-gradient(circle, #e0e7ff 0%, rgba(224,231,255,0) 70%); }
.bg-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(15,23,42,.028) 1px, transparent 1px), linear-gradient(90deg, rgba(15,23,42,.028) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 26%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 26%, #000 0%, transparent 78%);
}

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  background: rgba(247, 249, 252, 0.72);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; font-size: 15px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 9px;
  background: linear-gradient(145deg, #2563eb, #60a5fa);
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 11px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66); color: var(--ink-2);
  display: grid; place-items: center; cursor: pointer; transition: .18s;
}
.icon-btn:hover { background: #fff; color: var(--brand); border-color: rgba(37, 99, 235, 0.28); }
.icon-btn.on { color: var(--brand); border-color: rgba(37, 99, 235, 0.32); background: var(--brand-soft); }
.ghost-btn {
  height: 34px; padding: 0 14px; border-radius: 11px; border: 1px solid var(--line);
  background: rgba(255,255,255,.66); color: var(--ink-2); font-size: 13px; font-family: var(--ff);
  cursor: pointer; transition: .18s;
}
.ghost-btn:hover { background: #fff; color: var(--brand); border-color: rgba(37,99,235,.28); }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-m);
  border-radius: var(--r-l);
  backdrop-filter: saturate(150%) blur(14px); -webkit-backdrop-filter: saturate(150%) blur(14px);
}
.card-flat { background: var(--card-solid); border: 1px solid var(--line); box-shadow: var(--shadow-s); border-radius: var(--r-m); }

/* 首页 */
.hero { padding: 64px 0 30px; text-align: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600; margin-bottom: 18px;
}
.eyebrow::before, .eyebrow::after { content: ""; width: 22px; height: 1px; background: var(--line); }
h1.title {
  font-size: clamp(34px, 8vw, 62px); line-height: 1.06; margin: 0 0 16px;
  letter-spacing: -0.035em; font-weight: 700;
}
h1.title em {
  font-style: normal;
  background: linear-gradient(100deg, #2563eb 0%, #7c3aed 55%, #db2777 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { color: var(--ink-2); font-size: clamp(14px, 3.4vw, 16px); margin: 0 auto; max-width: 460px; }

.enter-card { margin: 34px auto 0; max-width: 460px; padding: 26px 24px 24px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; letter-spacing: .02em; }
.input {
  width: 100%; height: 50px; padding: 0 15px; font-size: 15px; font-family: var(--ff);
  color: var(--ink); background: rgba(255,255,255,.9);
  border: 1px solid rgba(15,23,42,.1); border-radius: 14px; outline: none;
  transition: .18s;
}
.input::placeholder { color: #b6c2d4; }
.input:focus { border-color: rgba(37,99,235,.55); box-shadow: 0 0 0 4px rgba(37,99,235,.1); background: #fff; }
.input.code { letter-spacing: .12em; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; text-transform: uppercase; }
.btn {
  width: 100%; height: 52px; border-radius: 15px; border: 0; cursor: pointer;
  font-family: var(--ff); font-size: 15px; font-weight: 650; letter-spacing: .01em;
  color: #fff; background: linear-gradient(180deg, #3b82f6, #2563eb);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.28), inset 0 1px 0 rgba(255,255,255,.22);
  transition: .18s; position: relative; overflow: hidden;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .6; cursor: default; }
.btn.soft { background: rgba(255,255,255,.9); color: var(--brand); border: 1px solid rgba(37,99,235,.28); box-shadow: var(--shadow-s); }
.hint { margin-top: 14px; font-size: 12.5px; color: var(--ink-3); text-align: center; line-height: 1.7; }
.hint b { color: var(--ink-2); font-weight: 600; }
.err { margin-top: 12px; font-size: 13px; color: var(--warm); text-align: center; min-height: 18px; }

.feats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 30px auto 70px; max-width: 780px; }
.feat { padding: 18px 16px; }
.feat .n { font-size: 11px; letter-spacing: .16em; color: var(--ink-3); font-weight: 700; }
.feat .t { margin-top: 8px; font-size: 14px; font-weight: 650; }
.feat .d { margin-top: 4px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
@media (max-width: 640px) {
  .feats { grid-template-columns: 1fr; }
  .hero { padding: 40px 0 22px; }
}

/* 房间页 */
.room-head { padding: 22px 0 14px; }
.players { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.player {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 16px;
  background: rgba(255,255,255,.7); border: 1px solid var(--line); box-shadow: var(--shadow-s);
  min-width: 0; transition: .25s;
}
.player.turn { border-color: rgba(37,99,235,.4); box-shadow: 0 0 0 3px rgba(37,99,235,.08), var(--shadow-s); }
.player.me { background: rgba(239,246,255,.82); }
.stone { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto; }
.stone.b { background: radial-gradient(circle at 32% 28%, #4b5563, #111827 70%); box-shadow: inset 0 -2px 4px rgba(0,0,0,.4); }
.stone.w { background: radial-gradient(circle at 32% 28%, #fff, #d7dee8 76%); border: 1px solid rgba(15,23,42,.12); }
.player .nm { font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .st { font-size: 11.5px; color: var(--ink-3); }
.vs { font-size: 11px; letter-spacing: .14em; color: var(--ink-3); font-weight: 700; }

.board-wrap { position: relative; margin: 8px auto 0; max-width: 560px; }
.board-card { padding: 12px; border-radius: var(--r-l); }
#board { display: block; width: 100%; height: auto; border-radius: 16px; background: #f6f1e7; touch-action: manipulation; cursor: pointer; }
.board-glow { position: absolute; inset: 0; border-radius: var(--r-l); pointer-events: none; box-shadow: 0 18px 50px rgba(15,23,42,.12); }

.status-bar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 14px auto 0; font-size: 13.5px; color: var(--ink-2); min-height: 22px; text-align: center;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }
.dot.wait { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,.14); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.bottom-actions { display: flex; gap: 10px; max-width: 560px; margin: 16px auto 60px; }
.bottom-actions .btn { height: 46px; font-size: 14px; }

/* 弹层 */
.sheet-mask {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: rgba(15, 23, 42, 0.36); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 18px; overflow-y: auto;
}
.sheet-mask.show { display: flex; align-items: center; justify-content: center; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 440px; background: #fff; border-radius: 24px; padding: 26px 24px 22px;
  box-shadow: var(--shadow-l); animation: rise .28s cubic-bezier(.2,.8,.25,1);
  position: relative; margin: auto;
}
@keyframes rise { from { transform: translateY(16px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .kicker { font-size: 11.5px; letter-spacing: .18em; color: var(--ink-3); font-weight: 700; text-transform: uppercase; }
.sheet h3 { margin: 8px 0 6px; font-size: 22px; letter-spacing: -.02em; }
.sheet p.lead { margin: 0 0 18px; color: var(--ink-2); font-size: 13.5px; }
.task-box {
  margin: 16px 0 4px; padding: 20px 18px; border-radius: 18px;
  background: linear-gradient(180deg, #f8fbff, #f1f6ff); border: 1px solid rgba(37,99,235,.16);
  font-size: 16px; line-height: 1.7; color: var(--ink); position: relative;
}
.task-box::before { content: "“"; position: absolute; left: 12px; top: -2px; font-size: 40px; color: rgba(37,99,235,.16); font-family: Georgia, serif; }
.task-box.warm { background: linear-gradient(180deg, #fff8fa, #fff1f5); border-color: rgba(225,29,72,.16); }
.task-box.warm::before { color: rgba(225,29,72,.16); }
.task-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.tag {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 650;
  background: var(--brand-soft); color: var(--brand); letter-spacing: .02em;
}
.tag.warm { background: #fff1f5; color: var(--warm); }
.tag.mute { background: #f1f5f9; color: var(--ink-2); }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { height: 48px; }
.sheet-actions .btn.soft { flex: 0 0 40%; }
.tabs { display: flex; gap: 6px; padding: 4px; background: #f1f5f9; border-radius: 13px; margin: 4px 0 14px; }
.tabs button {
  flex: 1; height: 38px; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  font-family: var(--ff); font-size: 13.5px; font-weight: 600; color: var(--ink-2); transition: .18s;
}
.tabs button.on { background: #fff; color: var(--brand); box-shadow: var(--shadow-s); }

/* 提示条 */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px); z-index: 90;
  padding: 11px 18px; border-radius: 13px; background: rgba(15,23,42,.92); color: #fff;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100vw - 40px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 等待遮罩 */
.waiting-card { padding: 26px 22px; text-align: center; max-width: 560px; margin: 20px auto; }
.waiting-ring { width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 50%; border: 2px solid rgba(37,99,235,.16); border-top-color: var(--brand); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.copy-row { display: flex; gap: 8px; margin-top: 16px; }
.copy-row .input { height: 44px; font-size: 13.5px; }

/* 后台 */
.admin-shell { display: flex; min-height: 100vh; }
.admin-side {
  width: 216px; flex: 0 0 216px; padding: 22px 14px; border-right: 1px solid var(--line);
  background: rgba(255,255,255,.6); backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.admin-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; font-weight: 680; font-size: 14.5px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; border-radius: 12px;
  font-size: 13.5px; color: var(--ink-2); cursor: pointer; border: 0; background: transparent;
  font-family: var(--ff); text-align: left; transition: .16s; width: 100%;
}
.menu-item:hover { background: rgba(15,23,42,.04); color: var(--ink); }
.menu-item.on { background: #fff; color: var(--brand); box-shadow: var(--shadow-s); font-weight: 650; }
.menu-item .ico { width: 18px; display: grid; place-items: center; opacity: .85; }
.admin-side .foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.admin-main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.admin-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.admin-head h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.admin-head .sub2 { font-size: 13px; color: var(--ink-3); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { padding: 20px; }
.kpi .k { font-size: 12px; color: var(--ink-3); font-weight: 600; letter-spacing: .04em; }
.kpi .v { font-size: clamp(28px, 5vw, 40px); font-weight: 700; letter-spacing: -.04em; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .m { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.trend-card { padding: 20px 22px; margin-top: 16px; }
.trend-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.trend-head .t { font-size: 13.5px; font-weight: 650; }
.trend-head .n { font-size: 12px; color: var(--ink-3); margin-left: auto; }
.trend svg { display: block; width: 100%; height: 118px; overflow: visible; }

.panel { padding: 20px 22px; margin-top: 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.panel-head .grow { flex: 1; }
.mini-input {
  height: 36px; padding: 0 12px; font-size: 13px; font-family: var(--ff); border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); outline: none;
}
.mini-input:focus { border-color: rgba(37,99,235,.5); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.mini-btn {
  height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); font-size: 13px; font-family: var(--ff); cursor: pointer; transition: .16s;
}
.mini-btn:hover { color: var(--brand); border-color: rgba(37,99,235,.3); }
.mini-btn.primary { background: linear-gradient(180deg,#3b82f6,#2563eb); color: #fff; border: 0; box-shadow: 0 4px 12px rgba(37,99,235,.22); }
.mini-btn.danger:hover { color: var(--warm); border-color: rgba(225,29,72,.3); }

table.tb { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tb th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tb td { padding: 11px 10px; border-bottom: 1px solid rgba(15,23,42,.05); vertical-align: middle; }
table.tb tr:last-child td { border-bottom: 0; }
table.tb tr:hover td { background: rgba(239,246,255,.5); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; font-size: 12.5px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.badge.unused { background: #f1f5f9; color: #64748b; }
.badge.active { background: #ecfdf5; color: #059669; }
.badge.disabled { background: #fef2f2; color: #dc2626; }
.badge.forever { background: var(--brand-soft); color: var(--brand); }
.pager { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 14px; font-size: 12.5px; color: var(--ink-3); }
.row-actions { display: flex; gap: 6px; }
.empty { padding: 34px; text-align: center; color: var(--ink-3); font-size: 13px; }

.login-mask {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: var(--bg);
}
.login-card { width: 100%; max-width: 380px; padding: 30px 26px 26px; }
.login-card h1 { font-size: 21px; margin: 12px 0 4px; letter-spacing: -.02em; }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .admin-side { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: .24s; box-shadow: var(--shadow-l); }
  .admin-side.open { transform: none; }
  .admin-main { padding: 20px 16px 60px; }
  .admin-menu-btn { display: grid !important; }
}
.admin-menu-btn { display: none; }
@media (max-width: 560px) {
  .players { grid-template-columns: 1fr; gap: 8px; }
  .vs { display: none; }
  .task-box { font-size: 15px; padding: 18px 15px 16px; }
  .sheet { padding: 22px 18px 18px; border-radius: 22px; }
}
