/* 舒尔特方格 · 网页版：视觉沿用 iOS 设计稿（docs/DESIGN.md）的深蓝底 + 靛蓝/青/薄荷强调色。 */
:root {
  --bg: #0B1326;
  --surface: #171F33;
  --surface-low: #131B2E;
  --surface-elevated: #222A3D;
  --surface-highest: #2D3449;
  --surface-lowest: #060E20;
  --stroke: #2A3349;
  --accent: #4F46E5;
  --accent-bright: #6366F1;
  --cyan: #4CD7F6;
  --mint: #4EDEA3;
  --indigo: #C3C0FF;
  --rose: #FB7185;
  --gold: #FCD34D;
  --silver: #918FA1;
  --bronze: #D97706;
  --text: #F8FAFC;
  --text-2: #B8C2D9;
  --text-3: #7C8AA5;
  --radius: 20px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.up { text-transform: uppercase; letter-spacing: .1em; }
.muted { color: var(--text-3); }
.dim { color: var(--text-2); }
.mint { color: var(--mint); }
.rose { color: var(--rose); }
.cyan { color: var(--cyan); }

/* 手机浏览器：100% / 100vh 会按「地址栏收起」的高度算，底部会被顶出屏幕。
   --app-h 由 js/viewport.js 用 visualViewport 的真实可视高度写进来（内嵌浏览器也准）；
   svh/dvh 只是脚本还没跑起来时的兜底。 */
.app { display: flex; flex-direction: column; height: var(--app-h, 100%); max-width: 560px; margin: 0 auto; }
@supports (height: 100svh) {
  /* 先按「地址栏常驻」的小高度兜底，支持 dvh 的浏览器再跟着地址栏伸缩。 */
  .app { height: var(--app-h, 100svh); }
}
@supports (height: 100dvh) {
  .app { height: var(--app-h, 100dvh); }
}
.screen { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 16px calc(20px + var(--safe-bottom)); }
.screen.no-scroll { overflow: hidden; padding: 0; }

/* ── 顶栏 ───────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 8px;
}
.brand { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.brand b { font-size: 17px; letter-spacing: .02em; }
.brand span { font-size: 10px; letter-spacing: .18em; color: var(--text-3); text-transform: uppercase; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 17px;
  background: var(--surface-low); border: 1px solid var(--stroke); color: var(--text-2);
  transition: transform .12s ease, background .12s ease;
}
.icon-btn:active { transform: scale(.92); background: var(--surface-elevated); }
.chip {
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgba(79, 70, 229, .35); color: var(--indigo); text-transform: uppercase; letter-spacing: .06em;
}
.chip.solid { background: rgba(76, 215, 246, .15); color: var(--cyan); }
.chip.mint { background: rgba(78, 222, 163, .15); color: var(--mint); }
.chip.rose { background: rgba(251, 113, 133, .15); color: var(--rose); }

/* ── 底部 tab ──────────────────────────────────────── */
.tabbar {
  display: flex; gap: 6px; padding: 8px 12px calc(8px + var(--safe-bottom));
  background: linear-gradient(to top, rgba(11,19,38,.98), rgba(11,19,38,.86));
  border-top: 1px solid var(--stroke);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 4px; border-radius: 14px; font-size: 10px; letter-spacing: .06em;
  color: var(--text-3); text-transform: uppercase;
}
.tabbar button svg { width: 20px; height: 20px; }
.tabbar button.active { color: var(--text); background: var(--surface); }

/* ── 卡片 / 通用 ───────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--stroke);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card.tight { padding: 12px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h2 { flex: 1; margin: 0; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-2); }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px; border-radius: 16px; font-weight: 700; font-size: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  color: #fff; box-shadow: 0 10px 24px rgba(79,70,229,.28);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn:active { transform: translateY(1px) scale(.985); box-shadow: 0 6px 16px rgba(79,70,229,.22); }
.btn.ghost { background: var(--surface-elevated); color: var(--text); box-shadow: none; border: 1px solid var(--stroke); }
.btn.cyan { background: linear-gradient(135deg, #1E9FBF, var(--cyan)); color: #00323D; box-shadow: 0 10px 24px rgba(76,215,246,.22); }
.btn.small { padding: 11px 14px; font-size: 13px; border-radius: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric {
  background: var(--surface-lowest); border-radius: var(--radius-sm); padding: 10px 12px;
}
.metric .k { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }
.metric .v { font-family: var(--mono); font-size: 16px; font-weight: 700; margin-top: 3px; }
.bar { height: 8px; border-radius: 999px; background: var(--surface-highest); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--cyan)); }

/* ── 首页 ──────────────────────────────────────────── */
.hero { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #04121F;
  background: linear-gradient(135deg, var(--cyan), var(--mint));
}
.hero .name { font-size: 19px; font-weight: 700; }
.hero .sub { font-size: 12px; color: var(--text-3); letter-spacing: .04em; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  position: relative; text-align: left; padding: 13px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--stroke);
  transition: transform .12s ease, border-color .12s ease;
}
.tile:active { transform: scale(.975); border-color: var(--accent); }
.tile .badge { font-family: var(--mono); font-size: 19px; font-weight: 800; }
.tile .title { margin-top: 8px; font-size: 14px; font-weight: 700; }
.tile .desc { margin-top: 2px; font-size: 11px; color: var(--text-3); min-height: 28px; }
.tile .stats { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--stroke); display: flex; justify-content: space-between; }
.tile .stats div { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.tile .stats b { display: block; font-family: var(--mono); font-size: 13px; margin-top: 2px; color: var(--text); }
.stars { color: var(--gold); letter-spacing: 2px; font-size: 11px; }

/* ── 游戏 ──────────────────────────────────────────── */
.play {
  display: flex; flex-direction: column; height: 100%; min-height: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px calc(10px + var(--safe-bottom)); gap: 10px;
}
.play-top { display: flex; align-items: center; gap: 10px; }
.timer { font-family: var(--mono); font-size: 30px; font-weight: 800; letter-spacing: -.01em; }
.hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.hud .metric { padding: 8px 9px; }
.hud .metric .v { font-size: 14px; }
.board-wrap { flex: 1; display: grid; place-items: center; min-height: 0; overflow: hidden; }
.board {
  /* 尺寸由 game.js 的 fitBoard() 按可用空间写死成正方形；
     这里的 100% + aspect-ratio 只是首帧兜底。 */
  display: grid; gap: 8px; width: 100%; aspect-ratio: 1 / 1; max-width: 100%; max-height: 100%;
}
/* 列数必须显式写出来：只写 display:grid 会退化成单列（一列竖排）。 */
.board[data-side="3"] { grid-template-columns: repeat(3, 1fr); }
.board[data-side="5"] { grid-template-columns: repeat(5, 1fr); }
.board[data-side="7"] { grid-template-columns: repeat(7, 1fr); }
.cell {
  display: grid; place-items: center; border-radius: 14px; border: 1px solid var(--stroke);
  background: var(--surface); color: var(--text);
  font-family: var(--mono); font-weight: 800; font-size: clamp(15px, 5.4vw, 30px);
  transition: transform .1s ease, background .16s ease, opacity .16s ease;
  user-select: none;
}
.board[data-side="7"] { gap: 5px; }
.board[data-side="7"] .cell { border-radius: 9px; font-size: clamp(11px, 3.4vw, 20px); }
.cell:active { transform: scale(.94); }
.cell.done { background: var(--surface-lowest); color: var(--text-3); opacity: .55; border-color: transparent; }
.cell.wrong { background: rgba(251,113,133,.22); border-color: var(--rose); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.countdown {
  position: absolute; inset: 0; display: grid; place-items: center; gap: 14px;
  background: rgba(6,14,32,.86); backdrop-filter: blur(6px); z-index: 5;
  border-radius: 24px;
}
.countdown .phase { font-family: var(--mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--cyan); }
.countdown .digit { font-family: var(--mono); font-size: 92px; font-weight: 800; line-height: 1; animation: pop .5s ease; }
.countdown .hint { font-size: 12px; color: var(--text-3); }

/* 矮屏（横屏、手机地址栏常驻）：固定元素收紧，把高度让给棋盘。 */
@media (max-height: 720px) {
  .play { gap: 6px; padding-top: calc(env(safe-area-inset-top, 0px) + 4px); }
  .timer { font-size: 22px; }
  .hud .metric { padding: 6px 8px; }
  .hud .metric .v { font-size: 13px; }
  .countdown .digit { font-size: 64px; }
  .countdown .hint { display: none; }
}
@media (max-height: 560px) {
  .play-top .chip { display: none; }
  .hud { grid-template-columns: repeat(2, 1fr); }
  .countdown .phase { display: none; }
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.play-stage { position: relative; flex: 1; display: flex; min-height: 0; }

/* ── 结算 ──────────────────────────────────────────── */
.result-head { text-align: center; padding: 6px 0 14px; }
.result-head .over { font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: var(--text-3); }
.result-head .big { font-family: var(--mono); font-size: 46px; font-weight: 800; margin-top: 6px; line-height: 1; }
.result-head .big small { font-size: 18px; color: var(--mint); }
.result-head .badge {
  display: inline-block; margin-bottom: 8px; padding: 5px 12px; border-radius: 999px;
  font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
.blocks { display: flex; flex-direction: column; gap: 9px; }
.block { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
.block .label { font-size: 12px; color: var(--text-2); }
.block .value { font-family: var(--mono); font-size: 12px; }
.block .track { grid-column: 1 / -1; }
.heat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; width: 66px; flex: none; }
.heat i { display: block; aspect-ratio: 1; border-radius: 4px; background: var(--surface-highest); }
.heat i.hot { background: var(--rose); }
.heat i.fix { background: var(--mint); }
.diagnosis { font-size: 12px; color: var(--text-2); margin-top: 8px; line-height: 1.5; }
.compare { display: flex; flex-direction: column; gap: 12px; }
.compare .side { flex: 1; min-width: 0; }
.compare .side .nick { font-size: 13px; font-weight: 700; }
.compare .side .tag { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }
.split { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-highest); }
.split > i { display: block; height: 100%; }

/* ── 榜单 ──────────────────────────────────────────── */
.segments { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-lowest); margin-bottom: 10px; }
.segments button {
  flex: 1; padding: 9px 4px; border-radius: 10px; font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.segments button.active { background: var(--surface-elevated); color: var(--text); font-weight: 600; }
.pills { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.pills button {
  padding: 7px 12px; border-radius: 999px; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3); border: 1px solid var(--stroke);
}
.pills button.active { background: rgba(76,215,246,.15); border-color: transparent; color: var(--cyan); }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; text-align: center; margin-bottom: 14px; }
.podium .p { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.podium .p .who { font-size: 12px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .p .time { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.podium .p .tier { font-size: 10px; color: var(--text-3); letter-spacing: .06em; }
.podium .p .col {
  width: 100%; border-radius: 10px 10px 0 0; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 800; color: var(--text);
  background: linear-gradient(180deg, var(--surface-elevated), var(--surface));
}
.podium .p .medal { font-size: 15px; }
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 16px; background: var(--surface); border: 1px solid var(--stroke);
}
.rank-row.me { border-color: var(--cyan); }
.rank-row .r { font-family: var(--mono); font-size: 14px; width: 22px; color: var(--text-3); }
.rank-row .who { flex: 1; min-width: 0; }
.rank-row .who b { font-size: 13.5px; }
.rank-row .who span { display: block; font-size: 10.5px; color: var(--text-3); }
.rank-row .right { text-align: right; font-family: var(--mono); font-size: 13px; }
.rank-row .right span { display: block; font-size: 10.5px; color: var(--text-3); }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.xs { width: 26px; height: 26px; font-size: 11px; }

/* ── 个人页 ────────────────────────────────────────── */
.field {
  display: flex; align-items: center; gap: 8px; padding: 11px 12px;
  border-radius: 14px; background: var(--surface-lowest); border: 1px solid var(--stroke);
}
.field input {
  flex: 1; min-width: 0; background: none; border: 0; color: var(--text);
  font: inherit; font-weight: 600; outline: none;
}
.field .count { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.ability { display: grid; grid-template-columns: 92px 1fr 42px; gap: 8px; align-items: center; font-size: 11.5px; margin-bottom: 8px; }
.ability .n { color: var(--text-2); }
.ability .v { font-family: var(--mono); text-align: right; }

/* ── 弹层 ──────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: rgba(6,14,32,.78); backdrop-filter: blur(4px); padding: 20px;
  /* 键盘弹出时 js/viewport.js 会把可视高度写进 height/top，让弹窗落在键盘上方；
     内容比可视区还高时允许滚动，别被裁掉。 */
  overflow-y: auto; overscroll-behavior: contain;
}
.sheet {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--stroke);
  border-radius: 22px; padding: 18px; animation: pop .22s ease;
}
.sheet h3 { margin: 0 0 6px; font-size: 17px; }
.sheet p { margin: 0 0 14px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.sheet .actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet .actions .btn { padding: 12px; }

/* ── 提示条 ────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 50; padding: 10px 16px; border-radius: 999px; font-size: 12.5px;
  background: var(--surface-elevated); border: 1px solid var(--stroke); color: var(--text);
  animation: pop .2s ease; max-width: 88vw; text-align: center;
}
.empty { text-align: center; color: var(--text-3); font-size: 12.5px; padding: 26px 0; }
.skeleton { height: 60px; border-radius: 16px; background: linear-gradient(90deg, var(--surface), var(--surface-elevated), var(--surface)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; margin-bottom: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* 中文不适用英文那套“全大写 + 大字距”，汉字会显得松散且单位字母会被大写化。 */
html[lang="zh-Hans"] :is(.up, .chip, .countdown .phase, .result-head .over, .compare .side .tag, .tile .stats div) {
  text-transform: none;
  letter-spacing: .04em;
}
html[lang="zh-Hans"] :is(.card-head h2, .metric .k) { text-transform: none; letter-spacing: .08em; }

/* ── 通用小组件（首页入口 / 头像） ─────────────────────────────────── */
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); display: inline-block; flex: 0 0 auto; }
.dot.cyan { background: var(--cyan); } .dot.mint { background: var(--mint); } .dot.grey { background: var(--text-3); }
.dot.ping { animation: dotPing 1.6s ease-out infinite; }
@keyframes dotPing { 0% { box-shadow: 0 0 0 0 rgba(76,215,246,.5); } 70% { box-shadow: 0 0 0 7px rgba(76,215,246,0); } 100% { box-shadow: 0 0 0 0 rgba(76,215,246,0); } }

.avatar-disc { border-radius: 50%; overflow: hidden; background: var(--surface-highest); position: relative; flex: 0 0 auto; display: grid; place-items: center; }
.avatar-disc img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-disc.ring { box-shadow: 0 0 0 1.5px rgba(255,255,255,.14), 0 0 0 3.5px rgba(76,215,246,.55), 0 0 0 5px rgba(79,70,229,.4); }
.avatar-disc.ring.cyan { box-shadow: 0 0 0 1.5px rgba(255,255,255,.14), 0 0 0 3.5px rgba(76,215,246,.65); }
.avatar-disc.ring.indigo { box-shadow: 0 0 0 1.5px rgba(255,255,255,.14), 0 0 0 3.5px rgba(195,192,255,.6); }
.avatar-disc.glow { animation: pulse 3.2s ease-in-out infinite; }
.avatar-disc.tap:active { transform: scale(.95); }
.avatar-disc.checked::after { content: "✓"; position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--mint); color: #06231A; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }

.cta { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; border-radius: var(--radius); background: linear-gradient(135deg, rgba(79,70,229,.28), rgba(23,31,51,.9)); border: 1px solid rgba(99,102,241,.55); box-shadow: 0 4px 0 0 #3323CC; }
.cta:active { transform: scale(.98); }
.cta .bolt { width: 40px; height: 40px; border-radius: 12px; background: rgba(76,215,246,.16); color: var(--cyan); display: grid; place-items: center; font-size: 18px; }
.cta .grow { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.cta .over { display: flex; align-items: center; gap: 6px; font-size: 9.5px; letter-spacing: .18em; color: var(--cyan); text-transform: uppercase; }
.cta .over .pill { font-size: 9px; letter-spacing: .06em; padding: 2px 6px; border-radius: 999px; background: rgba(76,215,246,.16); }
.cta .title { font-size: 19px; font-weight: 700; }
.cta .desc { font-size: 11px; color: var(--text-3); }
.cta .play { width: 40px; height: 40px; border-radius: 50%; background: var(--cyan); color: #05202B; display: grid; place-items: center; font-size: 14px; }

.link-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--stroke); }
.link-row:active { transform: scale(.98); }
.link-row .mark { width: 34px; height: 34px; border-radius: 11px; background: var(--surface-highest); display: grid; place-items: center; font-size: 16px; }
.link-row .grow { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.link-row .title { font-size: 14px; font-weight: 600; }
.link-row .desc { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-3); }
.link-row .pill-cta { padding: 7px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--mint); color: #06231A; }
.link-row .pill-cta.ghost { background: transparent; border: 1px solid var(--stroke); color: var(--text-2); }

/* ── 档案 / 头像设置页（stitch_8） ─────────────────────────────────── */
.profile { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 28px; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 4px 0 2px; }
.sheet-head .grabber { width: 48px; height: 5px; border-radius: 999px; background: var(--surface-highest); }
.sheet-head .sheet-title { display: flex; align-items: center; gap: 8px; flex: 1; font-family: var(--mono); font-size: 10px; letter-spacing: .16em; color: var(--cyan); text-transform: uppercase; }
.icon-btn.round { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-elevated); display: grid; place-items: center; }
.preview { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px 0 26px; }
.preview .pills { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 10px; }
.avatar-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border-radius: var(--radius-sm); border: 1px solid var(--stroke); background: var(--surface-low); }
.avatar-cell.selected { border: 2px solid var(--cyan); box-shadow: 0 0 14px rgba(76,215,246,.28); }
.avatar-cell .state { font-family: var(--mono); font-size: 8.5px; letter-spacing: .08em; color: var(--text-3); text-transform: uppercase; }
.avatar-cell.selected .state { color: var(--cyan); }
.name-row { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-lowest); border: 1px solid var(--stroke); }
.name-row .prompt { font-family: var(--mono); color: var(--cyan); font-size: 13px; }
.name-row .name { font-size: 15px; font-weight: 600; }
.name-row .sub { font-size: 10px; color: var(--text-3); }
/* .btn 默认 width:100%，放在这一行里会把昵称挤成 0 宽（文字直接看不见），这里按内容宽度收回来。 */
.name-row .btn { flex: none; width: auto; }
.sheet-footer { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 6px; }
.sheet-footer .btn { width: 100%; }

.modal { width: min(342px, 92vw); max-height: 100%; overflow-y: auto; border-radius: 16px; background: var(--surface); border: 1px solid rgba(76,215,246,.55); padding: 16px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.modal::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; border-radius: 16px 16px 0 0; background: linear-gradient(90deg, var(--cyan), var(--accent-bright)); }
.modal-head { display: flex; align-items: center; gap: 8px; }
.modal-head h3 { flex: 1; margin: 4px 0 0; font-family: var(--mono); font-size: 12px; letter-spacing: .14em; }
.modal-label { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-3); letter-spacing: .08em; }
.modal-label b { color: var(--text-2); }
.modal-hint { margin: 0; font-size: 11px; color: var(--text-3); line-height: 1.5; }
.modal input { width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-lowest); border: 1px solid var(--stroke); color: var(--text); font: inherit; font-size: 16px; }
.modal-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 4px; }
.modal-actions .btn { width: 100%; }

/* ── 1v1 速配页（stitch_13） ───────────────────────────────────────── */
.match { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 12px 0 24px; }
.match-connecting { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--surface-highest); border-top-color: var(--cyan); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-pill { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px; border-radius: 999px; background: var(--surface-low); border: 1px solid rgba(76,215,246,.22); font-family: var(--mono); font-size: 10px; letter-spacing: .18em; color: var(--cyan); text-transform: uppercase; }
.match-search { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.radar { position: relative; width: 232px; height: 232px; display: grid; place-items: center; }
.radar .radar-ring { position: absolute; border-radius: 50%; border: 1px solid rgba(76,215,246,.18); }
.radar .radar-ring.r1 { width: 112px; height: 112px; } .radar .radar-ring.r2 { width: 168px; height: 168px; } .radar .radar-ring.r3 { width: 220px; height: 220px; }
.radar .sweep { position: absolute; width: 220px; height: 220px; border-radius: 50%; background: conic-gradient(from 0deg, rgba(76,215,246,.28), rgba(76,215,246,0) 45deg); animation: spin 2.6s linear infinite; }
.radar .wave { position: absolute; width: 96px; height: 96px; border-radius: 50%; border: 1px solid rgba(76,215,246,.4); animation: radarWave 2.85s ease-out infinite; }
.radar .wave.d1 { animation-delay: .95s; } .radar .wave.d2 { animation-delay: 1.9s; }
.radar .core { position: relative; z-index: 1; }
/* 探测波从 96px 扩到 2×（设计稿尺寸），最大 192px，始终落在 232px 的雷达框里。 */
@keyframes radarWave { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(2); opacity: 0; } }
.elapsed { display: flex; flex-direction: column; align-items: center; }
.elapsed b { font-size: 40px; }
.elapsed span { font-family: var(--mono); font-size: 8px; letter-spacing: .24em; color: var(--text-3); }
.queue { font-size: 11px; }
.tip { font-size: 12px; color: var(--text-2); text-align: center; transition: opacity .32s ease; min-height: 34px; max-width: 300px; }
.match .btn.hold { width: min(300px, 80vw); height: 46px; }
.server { font-size: 8px; color: var(--text-3); letter-spacing: .12em; text-transform: uppercase; }

.match-locked { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.match-locked .meta { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 9px; letter-spacing: .12em; color: var(--text-3); text-transform: uppercase; text-align: center; flex-wrap: wrap; justify-content: center; }
.match-locked .meta .mint { color: var(--mint); }
.cd-ring-wrap { position: relative; width: 152px; height: 152px; display: grid; place-items: center; }
.cd-ring { position: absolute; inset: 0; width: 152px; height: 152px; transform: rotate(-90deg); }
.cd-ring circle { fill: none; stroke-width: 6; }
.cd-ring .track { stroke: var(--surface-highest); }
.cd-ring .progress { stroke: var(--cyan); stroke-linecap: round; }
.cd-ring-center { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.cd-ring-center b { font-size: 58px; color: var(--cyan); text-shadow: 0 0 22px rgba(76,215,246,.45); }
.cd-ring-center span { font-family: var(--mono); font-size: 8px; letter-spacing: .22em; color: var(--text-3); }
.cd-ring-pill { position: absolute; bottom: -14px; padding: 5px 12px; border-radius: 999px; background: rgba(76,215,246,.12); font-family: var(--mono); font-size: 8.5px; letter-spacing: .14em; color: var(--cyan); }
.duelists { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; width: 100%; margin-top: 22px; }
.duelist-slot { min-width: 0; }
.duelist { position: relative; height: 128px; border-radius: var(--radius-sm); background: var(--surface-low); border: 1px solid var(--stroke); padding: 10px; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.duelist.you { border-color: rgba(195,192,255,.55); }
.duelist.rival { border-color: rgba(76,215,246,.4); }
.duelist .face { display: flex; justify-content: center; margin-bottom: 2px; }
.duelist .who { display: flex; align-items: center; gap: 5px; min-width: 0; }
.duelist .who b { font-size: 13px; }
.duelist .badge { font-family: var(--mono); font-size: 7.5px; letter-spacing: .12em; padding: 1px 5px; border-radius: 999px; background: var(--surface-highest); color: var(--text-2); }
.duelist .tier { font-size: 10px; color: var(--indigo); }
.duelist.rival .tier { color: var(--cyan); }
.duelist .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; font-family: var(--mono); font-size: 7.5px; letter-spacing: .1em; color: var(--text-3); text-transform: uppercase; margin-top: auto; }
.duelist .stats b { display: block; font-size: 12px; color: var(--text); }
.duelist.you .stats b { color: var(--mint); }
.duelist.rival .stats b { color: var(--cyan); }
.duelist .ready { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 4px; padding: 3px 7px; border-radius: 999px; background: rgba(78,222,163,.15); font-family: var(--mono); font-size: 7.5px; letter-spacing: .1em; color: var(--mint); }
.vs { width: 46px; height: 46px; border-radius: 50%; background: var(--surface-highest); border: 1px solid rgba(99,102,241,.7); box-shadow: 0 0 18px rgba(99,102,241,.35); display: grid; place-items: center; font-size: 15px; font-weight: 700; color: var(--indigo); transform: rotate(-6deg); animation: pulse 2.4s ease-in-out infinite; }
.match-failed { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.match-failed .glyph { width: 64px; height: 64px; border-radius: 50%; background: rgba(251,113,133,.14); color: var(--rose); display: grid; place-items: center; font-size: 26px; }
.match-failed h2 { margin: 0; font-size: 18px; }
.match-failed p { margin: 0; color: var(--text-2); font-size: 12px; max-width: 300px; }
.match-failed .btn { width: min(300px, 80vw); }

/* ── 1v1 结算（stitch_9 第二套版式） ──────────────────────────────── */
.duel-result { display: flex; flex-direction: column; gap: 12px; padding-bottom: 24px; }
.duel-result .overline { text-align: center; font-family: var(--mono); font-size: 10px; letter-spacing: .16em; color: var(--text-3); text-transform: uppercase; }
.duel-result .overline i { color: var(--cyan); }
.verdict-host { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.verdict { margin: 0; font-size: 40px; letter-spacing: .06em; display: flex; align-items: center; gap: 8px; }
.verdict.mint { color: var(--mint); text-shadow: 0 0 26px rgba(78,222,163,.35); }
.verdict.rose { color: var(--rose); text-shadow: 0 0 26px rgba(251,113,133,.3); }
.verdict.cyan { color: var(--cyan); text-shadow: 0 0 26px rgba(76,215,246,.3); }
.verdict-sub { margin: 0; font-size: 11.5px; color: var(--text-2); text-align: center; }
.reward { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 10px; }
/* 1fr 的自动最小尺寸是 min-content：昵称 / 「+0.35s slower」这类只有一边有的内容，
   会把那一列撑宽、两张卡就不一样大。minmax(0,1fr) + min-width:0 让两列严格等宽，内容该省略就省略，
   align-items: stretch 让两张卡等高（不然落后方的卡片会因为多一枚 chip 变高）。 */
.duel-cards { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: stretch; }
.duel-card { min-width: 0; border-radius: var(--radius-sm); border: 1px solid var(--stroke); background: var(--surface); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
/* VS 是悬浮在两卡之间的 32pt 圆牌（设计稿 `absolute left-1/2 top-1/2` + `w-8 h-8`），
   不单独占一列——占列会白吃掉 66pt，卡片只剩 146pt，昵称全被省略号切掉。 */
.duel-cards > .vs { position: absolute; left: 50%; top: 50%; z-index: 2; width: 32px; height: 32px; margin: -16px 0 0 -16px; font-size: 10px; }
.duel-card.win { background: rgba(78,222,163,.1); border-color: rgba(78,222,163,.55); }
.duel-card.lose { background: rgba(251,113,133,.09); border-color: rgba(251,113,133,.45); }
.duel-card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.duel-card-head .name { font-size: 13px; font-weight: 600; }
.duel-card-head .tag { font-family: var(--mono); font-size: 8px; letter-spacing: .12em; color: var(--text-3); text-transform: uppercase; }
.duel-card .state-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.duel-card .state { display: flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-highest); font-family: var(--mono); font-size: 8px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }
.duel-card .state.pending { color: var(--cyan); }
.duel-card.win .state { background: rgba(78,222,163,.18); color: var(--mint); }
.duel-card.lose .state { background: rgba(251,113,133,.16); color: var(--rose); }
.duel-card .slower { font-family: var(--mono); font-size: 9px; color: var(--rose); }
.duel-card .big { font-size: 26px; font-weight: 700; }
.duel-card .duel-stats { display: flex; flex-direction: column; gap: 5px; border-top: 1px solid var(--stroke); padding-top: 8px; }
.duel-card .duel-stats div { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-3); }
.duel-card .duel-stats b { color: var(--text); font-size: 11px; }
.legend { display: flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 9px; color: var(--text-3); }
.legend .dot + .dot { margin-left: 6px; }
.h2h { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--stroke); }
.h2h:last-child { border-bottom: 0; }
.h2h-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-2); }
.h2h-head b { font-size: 11px; }
.h2h-head i { color: var(--text-3); font-style: normal; }
.bars { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.bars .bar { height: 6px; border-radius: 999px; background: var(--surface-highest); overflow: hidden; display: flex; }
.bars .bar:first-child { justify-content: flex-end; }
.bars .bar i { display: block; height: 100%; border-radius: 999px; }
.bars .bar.pending { animation: pulse 1.8s ease-in-out infinite; }
.edge-line { margin: 0; font-size: 11px; color: var(--text-2); }
.result-actions { display: flex; flex-direction: column; gap: 8px; }
.result-actions .btn { width: 100%; }

.range-row { display: flex; align-items: center; gap: 10px; }
.range-row .pills { flex: 1; margin-bottom: 12px; }
.range-reset { font-size: 9px; color: var(--text-3); white-space: nowrap; margin-bottom: 12px; text-transform: uppercase; letter-spacing: .08em; }
.podium .p .face { position: relative; display: inline-flex; }
.podium-badge { position: absolute; bottom: -7px; padding: 2px 7px; border-radius: 999px; background: var(--surface-highest); font-family: var(--mono); font-size: 8px; letter-spacing: .08em; color: var(--text-2); }
.podium .p:has(.col[style*="gold"]) .podium-badge { background: var(--gold); color: #3B2A00; }

/* ── 模块间距 ────────────────────────────────────────
   视图根容器统一用 .stack 分配间距（设计 §0.1：模块之间 16，组内 8），
   不再依赖各模块自带的 margin-bottom——漏掉一个就会出现两块模块贴在一起。
   flex 容器的 gap 和子元素 margin 会**相加**，所以 stack 子孙元素自身的 margin 归零。 */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.sm { gap: 8px; }
.stack > * { margin-top: 0; margin-bottom: 0; }
