:root {
  --hud-bg: #114e4a;
  --hud-surface: #0d3f3c;
  --hud-border: #1d6661;
  --hud-text: #f0fdfa;
  --hud-muted: #99d5cf;
  --hud-accent: #5eead4;
}

* { box-sizing: border-box; }

html, body, #app {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.hidden { display: none !important; }

button { touch-action: manipulation; }

.app-root {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* 手机浏览器地址栏伸缩时仍铺满 */
  overflow: hidden;
}

.board-stage {
  position: absolute;
  inset: 0;
  cursor: default;
}

#board-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.disconnect-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(153, 27, 27, 0.94);
  color: #fef2f2;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.top-stats-pill {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 500;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  white-space: nowrap;
}

.dot-sep { opacity: 0.5; }

.pill-mine-label {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.22);
  color: #7dd3fc;
  font-weight: 700;
  font-size: 11px;
}

.hud-stack {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 30;
  width: 318px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-card {
  background: var(--hud-bg);
  color: var(--hud-text);
  border: 1px solid var(--hud-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.hud-profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
}

.hud-profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 2px 6px 2px 2px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

.hud-profile-btn:hover { background: rgba(255, 255, 255, 0.08); }

.flag-icon-img {
  border-radius: 4px;
  display: block;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.hud-username {
  max-width: 155px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-profile-actions { display: flex; align-items: center; gap: 4px; }

.hud-icon-btn {
  background: transparent;
  border: none;
  color: var(--hud-text);
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1;
}

.hud-icon-btn:hover { background: rgba(255, 255, 255, 0.12); }

.hud-minimap-card { display: flex; flex-direction: column; }

.hud-minimap-canvas {
  display: block;
  width: 318px;
  height: 158px;
  cursor: pointer;
}

.hud-location-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--hud-bg);
  border-top: 1px solid var(--hud-border);
  gap: 4px;
}

.hud-loc-icon-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--hud-text);
  font-size: 15px;
  cursor: pointer;
}

.hud-loc-icon-btn:hover { background: rgba(255, 255, 255, 0.12); }

.hud-loc-code-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--hud-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  text-align: left;
}

.hud-loc-code-btn:hover { background: rgba(255, 255, 255, 0.1); }

.hud-loc-copy-group { display: inline-flex; gap: 4px; }

.hud-mini-pill {
  background: rgba(255, 255, 255, 0.15);
  color: var(--hud-text);
  border: none;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.hud-mini-pill:hover { background: rgba(255, 255, 255, 0.25); }

.hud-score-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
}

.hud-score-card:hover { filter: brightness(1.08); }

.hud-score-left { display: flex; align-items: center; gap: 12px; }

.trophy-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
}

.trophy-icon { font-size: 22px; }

.trophy-window {
  position: absolute;
  bottom: -2px;
  right: -4px;
  background: var(--hud-surface);
  color: var(--hud-accent);
  border: 1px solid var(--hud-border);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  padding: 0 3px;
}

.hud-metric { display: flex; flex-direction: column; gap: 1px; }

.hud-score-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
}

.hud-metric-label { font-size: 11px; color: var(--hud-accent); font-weight: 600; }
.hud-metric-value { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.hud-rank-row { display: flex; align-items: baseline; gap: 6px; }
.hud-rank-gap { font-size: 11px; font-weight: 700; color: var(--hud-muted); }

.hud-onboarding-toast {
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-onboarding-actions { display: flex; align-items: center; justify-content: space-between; }

.bottom-left-pill {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(34, 34, 38, 0.86);
  color: #f4f4f5;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.pill-btn {
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  color: #ffffff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.pill-btn:hover { background: rgba(255, 255, 255, 0.16); }
.pill-divider { width: 1px; height: 16px; background: rgba(255, 255, 255, 0.2); }
.online-indicator { display: inline-flex; align-items: center; gap: 6px; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.online { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.status-dot.offline { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }

.bottom-right-toast {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 32, 36, 0.9);
  color: #f8fafc;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.cell-mini-box {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
  flex-shrink: 0;
}

.cell-mini-box.unrevealed { background: #d4d4d8; border: 1.5px solid #71717a; }
.cell-mini-box.gold {
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  border: 1.5px solid #b45309;
  font-size: 12px;
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.6);
}
.cell-mini-box.revealed { background: #ffffff; color: #111827; }
.cell-mini-box.n-1 { color: #2563eb; }
.cell-mini-box.n-2 { color: #00b800; }
.cell-mini-box.n-3 { color: #ff421c; }
.cell-mini-box.n-4 { color: #3b28cc; }
.cell-mini-box.n-5 { color: #b91c1c; }
.cell-mini-box.n-6 { color: #0891b2; }
.cell-mini-box.mine { background: #ef4444; color: #000000; }

.star-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.14);
  color: #fde68a;
  font-size: 11px;
  font-weight: 700;
}

/* Landing */
.landing-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(4px);
  overflow-y: auto;
  user-select: text;
}

.landing-scroll {
  max-width: 920px;
  margin: 0 auto;
  padding: 56px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 44px;
}

.landing-hero-card {
  background: #ffffff;
  color: #0f172a;
  border-radius: 16px;
  padding: 44px 36px 32px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f0fdfa;
  color: #115e59;
  border: 1px solid #99f6e4;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.landing-title { margin: 0; font-size: 64px; font-weight: 900; letter-spacing: 0.08em; color: #114e4a; }
.landing-tagline { margin: 12px 0 8px; font-size: 22px; font-weight: 700; color: #1e293b; }
.landing-subtext { margin: 0 auto 28px; max-width: 540px; color: #475569; font-size: 15px; line-height: 1.6; }
.landing-cta-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.learn-more-link { color: #0f766e; font-size: 14px; font-weight: 600; text-decoration: none; }

.landing-section {
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
}

.landing-section h2 { margin: 0 0 20px; font-size: 24px; color: #114e4a; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.feature-card { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; }
.feature-card h3 { margin: 0 0 6px; font-size: 16px; color: #0f172a; }
.feature-card p { margin: 0; font-size: 14px; line-height: 1.5; color: #475569; }

.how-to-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.how-to-list li { display: flex; align-items: center; gap: 14px; font-size: 15px; color: #334155; }
.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #114e4a;
  color: #ffffff;
  font-weight: 800;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  max-width: 96vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: text;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--hud-bg);
  border-bottom: 1px solid var(--hud-border);
  gap: 12px;
}

.modal-header h3 { margin: 0; font-size: 16px; color: var(--hud-text); }
.modal-header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.tab-row { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tab-row::-webkit-scrollbar { display: none; }
.tab-btn { flex-shrink: 0; white-space: nowrap; }

.tab-btn {
  background: transparent;
  border: none;
  color: var(--hud-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn:hover { color: var(--hud-text); background: rgba(255, 255, 255, 0.08); }
.tab-btn.active { background: rgba(255, 255, 255, 0.16); color: #ffffff; }

.icon-action-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.icon-action-btn:hover, .icon-action-btn.active { background: rgba(255, 255, 255, 0.24); }

.leaderboard-card { width: 520px; }
.leaderboard-card.pinned-panel {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 35;
  width: 390px;
  max-height: calc(100vh - 80px);
}

.leaderboard-body { overflow-y: auto; max-height: 400px; }

/* 个人资料 / 商店 / 分数榜：弹窗尺寸固定为最大尺寸，切换页签时不再忽大忽小；内容区内部滚动 */
.modal-card.settings-card,
.modal-card.shop-card,
.modal-card.leaderboard-card:not(.pinned-panel) {
  height: min(760px, 90vh);
  height: min(760px, 90dvh);
}
.settings-card > .settings-body,
.shop-card > .shop-body,
.leaderboard-card:not(.pinned-panel) > .leaderboard-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}
.settings-card > .modal-header,
.shop-card > .modal-header,
.shop-card > .shop-footer,
.leaderboard-card > .modal-header,
.leaderboard-card > .leaderboard-around-me { flex-shrink: 0; }
.leaderboard-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.leaderboard-table th {
  position: sticky;
  top: 0;
  background: #1e293b;
  color: #94a3b8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: 8px 14px;
}

.leaderboard-table td { padding: 8px 14px; border-bottom: 1px solid #1e293b; }
.leaderboard-table tr.is-me { background: rgba(20, 184, 166, 0.18); }
.rank-col { font-family: ui-monospace, monospace; font-weight: 700; color: #94a3b8; }
.player-cell { display: inline-flex; align-items: center; gap: 8px; }
.player-name { font-weight: 600; }
.score-col { text-align: right; font-family: ui-monospace, monospace; font-weight: 700; }
.empty-state { text-align: center; color: #94a3b8; padding: 32px 16px !important; }

.leaderboard-around-me {
  border-top: 1px solid #334155;
  background: #1e293b;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.around-me-label { font-size: 11px; text-transform: uppercase; color: #94a3b8; font-weight: 700; }
.around-me-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
}
.around-me-row.is-me { background: rgba(20, 184, 166, 0.25); font-weight: 700; }

.large-map-card { width: 680px; }
.large-map-canvas { display: block; width: 100%; height: auto; cursor: default; border-bottom: 1px solid #334155; }
.large-map-form { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.large-map-input-wrap { flex: 1; }
.large-map-buttons { display: flex; gap: 8px; }
.large-map-share { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.map-share-btn { border: 1px solid #334155; color: #cbd5e1; padding: 5px 10px; }
.map-share-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.map-copy-tip { font-size: 12px; color: #6ee7b7; }
.map-copy-tip.err { color: #fca5a5; }

.site-copyright { margin: 28px 0 8px; text-align: center; font-size: 12px; color: #94a3b8; opacity: 0.85; }
.help-body .site-copyright { margin: 18px 0 0; }

.settings-card { width: 600px; }
.settings-body { padding: 20px; overflow-y: auto; }
.profile-panel { display: flex; flex-direction: column; gap: 18px; }
.profile-identity { display: flex; align-items: center; gap: 14px; }
.profile-name-row { display: flex; align-items: center; gap: 8px; }
.profile-name-row h4 { margin: 0; font-size: 20px; }
.profile-meta { font-size: 13px; color: #94a3b8; margin-top: 2px; }
.nickname-form { margin: 0; }
.nickname-row { display: flex; gap: 8px; align-items: stretch; }
.nickname-row .text-input { flex: 1; min-width: 0; }
.nickname-row .btn-primary { flex: 0 0 auto; }
.profile-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-stats-grid-3 { grid-template-columns: repeat(3, 1fr); }
.profile-section-title { margin: 16px 0 8px; font-size: 14px; color: #cbd5e1; }
.stat-bad { color: #f87171; }
.fx-group { background: #1e293b; border: 1px solid #334155; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.fx-group-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: #e2e8f0; margin-bottom: 8px; }
.fx-group-head .btn-ghost-sm { margin-left: auto; color: #fde68a; }
.fx-chip-row { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.fx-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: #0f172a; color: #e2e8f0; border: 1.5px solid #334155; border-radius: 999px;
  padding: 5px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.fx-chip:hover { background: #273549; }
.fx-chip.selected { border-color: #a78bfa; background: rgba(139, 92, 246, 0.2); }
.fx-chip-icon { font-size: 15px; line-height: 1; }
.fx-chip-on { background: #7c3aed; color: #fff; border-radius: 999px; padding: 1px 6px; font-size: 10px; }
@media (max-width: 640px) { .profile-stats-grid-3 { grid-template-columns: 1fr 1fr; } }
.profile-stat-box { background: #1e293b; border: 1px solid #334155; border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 12px; color: #94a3b8; }
.profile-stat-box strong { font-size: 20px; }

.guest-banner { background: rgba(20, 184, 166, 0.12); border: 1px solid rgba(45, 212, 191, 0.3); border-radius: 10px; padding: 14px; }
.guest-banner p { margin: 0 0 12px; font-size: 13px; line-height: 1.5; color: #cbd5e1; }

.flags-section-title { font-size: 13px; font-weight: 700; color: #cbd5e1; margin-bottom: 10px; }
.muted-inline { font-weight: 400; color: #94a3b8; }
.flags-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }

.flag-choice {
  background: #1e293b;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #e2e8f0;
  font-size: 12px;
  cursor: pointer;
}

.flag-choice:hover { background: #273549; }
.flag-choice.selected { border-color: #2dd4bf; background: rgba(45, 212, 191, 0.14); }
.flag-choice.locked { opacity: 0.65; }

/* 设置弹窗：旗帜分组 / 特效页签 */
.cosmetic-section + .cosmetic-section { margin-top: 18px; }
.fx-tab-head { display: flex; align-items: flex-start; gap: 10px; }
.fx-tab-head > span { flex: 1; line-height: 1.5; }
.fx-tab-head .btn-ghost-sm { flex: 0 0 auto; color: #fde68a; }
.fx-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.fx-choice-wrap { position: relative; display: flex; }
.fx-choice-wrap > .fx-choice { flex: 1; min-height: 92px; justify-content: center; text-align: center; }
.fx-choice.selected { border-color: #a78bfa; background: rgba(139, 92, 246, 0.2); }
.fx-choice-icon { font-size: 28px; line-height: 1.1; }
.fx-preview-btn {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; border-radius: 6px;
  border: none; background: rgba(15, 23, 42, 0.7); color: #e2e8f0;
  font-size: 13px; line-height: 1; cursor: pointer; opacity: 0.75;
}
.fx-preview-btn:hover { opacity: 1; background: #334155; }

.themes-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.theme-choice {
  background: #1e293b;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  color: #f8fafc;
  cursor: pointer;
}
.theme-choice.selected { border-color: #2dd4bf; }

.theme-preview { display: grid; grid-template-columns: repeat(4, 34px); border: 1px solid #475569; border-radius: 6px; overflow: hidden; }
.tp-cell { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 16px; border: 1px solid transparent; }
.theme-name { font-size: 13px; font-weight: 700; }

.auth-card, .terms-card { width: 420px; }
.help-card { width: 540px; }
.auth-form, .terms-body, .help-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.auth-note { margin: 0; font-size: 13px; color: #99f6e4; background: rgba(20, 184, 166, 0.14); padding: 10px 12px; border-radius: 8px; }
.form-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #cbd5e1; }

.text-input {
  width: 100%;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 10px 12px;
  color: #f8fafc;
  font-size: 14px;
  outline: none;
}

.text-input:focus { border-color: #2dd4bf; }
.form-error { color: #fca5a5; font-size: 13px; margin-top: 4px; }

.help-intro { margin: 0; color: #cbd5e1; font-size: 14px; line-height: 1.5; }
.help-body h4 { margin: 6px 0 0; color: #5eead4; font-size: 14px; }
.controls-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: #e2e8f0; line-height: 1.45; }
kbd { background: #1e293b; border: 1px solid #475569; border-radius: 4px; padding: 1px 6px; font-family: ui-monospace, monospace; font-size: 12px; }
.score-pos { color: #4ade80; font-weight: 700; }
.score-neg { color: #f87171; font-weight: 700; }

.btn-row { display: flex; gap: 10px; align-items: center; }
.btn-primary, .btn-secondary, .btn-ghost, .btn-accent-sm, .btn-ghost-sm {
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: filter 0.15s ease, background 0.15s ease;
}

.btn-primary { background: #0d9488; color: #ffffff; padding: 9px 18px; font-size: 14px; }
.btn-primary:hover { background: #0f766e; }
.btn-secondary { background: #334155; color: #f8fafc; padding: 9px 18px; font-size: 14px; }
.btn-secondary:hover { background: #475569; }
.btn-ghost { background: transparent; color: #0f172a; border: 1.5px solid #cbd5e1; padding: 9px 18px; font-size: 14px; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-accent-sm { background: #2dd4bf; color: #042f2e; padding: 5px 10px; font-size: 12px; }
.btn-ghost-sm { background: transparent; color: var(--hud-muted); padding: 4px 6px; font-size: 12px; }
.full-width { width: 100%; }

/* ───────── 金币 / 商店 / 道具 ───────── */
/* 桌面端：金币区不压缩；道具栏放得下就同一行，放不下自动换到第二行（道具按钮本身也可换行），不需要左右滑动 */
.hud-coin-card { display: flex; flex-wrap: wrap; align-items: stretch; min-width: 0; }

.hud-coin-main {
  flex: 1 0 auto;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(90deg, rgba(250, 204, 21, 0.16), rgba(250, 204, 21, 0));
  border: none;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.hud-coin-main:hover { filter: brightness(1.12); }

.hud-coin-icon { width: 26px; height: 26px; display: inline-block; filter: drop-shadow(0 0 4px rgba(250, 204, 21, 0.6)); user-select: none; }

/* 全站统一的行内金币图标（沃雷币） */
.coin-ic {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.22em;
  user-select: none;
  pointer-events: none;
}
.hud-coin-icon.spin { animation: coin-spin 0.6s ease; }

#hud-coin-value { color: #fde047; }
#hud-coin-value.bump-up { animation: coin-bump-up 0.7s ease; }
#hud-coin-value.bump-down { animation: coin-bump-down 0.7s ease; }

.hud-shop-chip {
  margin-left: auto;
  background: rgba(250, 204, 21, 0.2);
  color: #fde68a;
  border: 1px solid rgba(250, 204, 21, 0.45);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
}

.hud-tools {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 8px;
  /* 同行时只露出左分隔线、换行后只露出上分隔线：另一条被卡片 overflow:hidden 裁掉 */
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  margin: -1px 0 0 -1px;
}
.hud-tool-btn { white-space: nowrap; }

.hud-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--hud-text);
  border: 1.5px solid transparent;
  border-radius: 7px;
  padding: 4px 7px;
  font-size: 14px;
  cursor: pointer;
}

.hud-tool-btn:hover { background: rgba(255, 255, 255, 0.2); }
.hud-tool-btn.active { border-color: #38bdf8; background: rgba(56, 189, 248, 0.25); box-shadow: 0 0 10px rgba(56, 189, 248, 0.5); }
.hud-tool-btn.empty { opacity: 0.5; }
.hud-tool-btn.passive { cursor: help; }
.hud-tool-count { font-size: 12px; font-weight: 800; min-width: 10px; text-align: center; }

@keyframes coin-spin {
  0% { transform: rotateY(0deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.3); }
  100% { transform: rotateY(360deg) scale(1); }
}

@keyframes coin-bump-up {
  0% { transform: scale(1); color: #fde047; }
  30% { transform: scale(1.35); color: #4ade80; text-shadow: 0 0 10px rgba(74, 222, 128, 0.8); }
  100% { transform: scale(1); color: #fde047; }
}

@keyframes coin-bump-down {
  0% { transform: translateX(0); color: #fde047; }
  20% { transform: translateX(-4px); color: #f87171; }
  40% { transform: translateX(4px); color: #f87171; }
  60% { transform: translateX(-3px); }
  100% { transform: translateX(0); color: #fde047; }
}

.tool-banner {
  position: fixed;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 32;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(12, 74, 110, 0.94);
  border: 1px solid #38bdf8;
  color: #e0f2fe;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 16px rgba(56, 189, 248, 0.35);
}

.tool-banner .btn-ghost-sm { color: #bae6fd; border: 1px solid rgba(186, 230, 253, 0.4); }
.tool-banner-actions { display: inline-flex; gap: 8px; flex-shrink: 0; }
.touch-only { display: none; }
html.is-touch .touch-only { display: inline-flex; }
html.is-touch .tool-banner { flex-wrap: wrap; justify-content: center; border-radius: 14px; }
html.is-touch .tool-banner-actions .btn-ghost-sm,
html.is-touch .tool-banner-actions .btn-accent-sm { min-width: 72px; min-height: 36px; justify-content: center; align-items: center; font-size: 14px; }
#btn-tool-confirm:disabled { opacity: 0.45; filter: grayscale(0.5); cursor: not-allowed; }

.game-toast {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: toast-in 0.25s ease;
}

.game-toast.success { border: 1px solid #22c55e; }
.game-toast.warn { border: 1px solid #f59e0b; }
.game-toast.danger { border: 1px solid #ef4444; background: rgba(69, 10, 10, 0.95); }
.game-toast.gold { border: 1px solid #facc15; background: linear-gradient(90deg, rgba(113, 63, 18, 0.96), rgba(66, 32, 6, 0.96)); color: #fef9c3; }
.game-toast strong { color: #fde047; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.shop-body {
  padding: 16px;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  align-content: start;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.modal-card.shop-card { width: 640px; }

.shop-balance {
  background: rgba(250, 204, 21, 0.18);
  color: #fde047;
  border: 1px solid rgba(250, 204, 21, 0.4);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 800;
}

.shop-item {
  display: flex;
  gap: 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px;
}

.shop-item.owned { border-color: rgba(45, 212, 191, 0.45); }
.shop-body > .empty-state { grid-column: 1 / -1; text-align: center; color: #94a3b8; padding: 32px 0; }

.shop-preview {
  width: 72px;
  min-width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  border-radius: 8px;
}

.shop-icon { font-size: 38px; }
.shop-fx-icon { position: relative; line-height: 1; }
.shop-theme-preview { grid-template-columns: repeat(2, 30px); }
.shop-theme-preview .tp-cell { width: 30px; height: 30px; font-size: 14px; }

.shop-info { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.shop-name-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.shop-name { font-weight: 800; font-size: 15px; }
.shop-owned { font-size: 11px; font-weight: 700; color: #94a3b8; background: rgba(148, 163, 184, 0.14); padding: 2px 6px; border-radius: 5px; }
.shop-owned.owned { color: #5eead4; background: rgba(45, 212, 191, 0.16); }
.shop-desc { margin: 0; font-size: 12px; color: #94a3b8; line-height: 1.45; }
.shop-actions { display: flex; gap: 6px; margin-top: auto; flex-wrap: wrap; }
.shop-actions .btn-primary, .shop-actions .btn-secondary { padding: 6px 12px; font-size: 13px; }
.shop-buy-btn { background: linear-gradient(90deg, #ca8a04, #eab308); color: #1c1917; }
.shop-buy-btn:hover { background: linear-gradient(90deg, #a16207, #ca8a04); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.4); }

.shop-footer {
  padding: 10px 16px;
  border-top: 1px solid #334155;
  font-size: 12px;
  color: #94a3b8;
  background: #111827;
}

.theme-choice.locked, .flag-choice.premium.locked { opacity: 0.7; }
.flag-choice.premium:not(.locked) { border-color: rgba(250, 204, 21, 0.35); }
.profile-stat-box.coin-stat strong { color: #fde047; }

/* ───────── 触屏控件（仅触屏设备显示） ───────── */
.touch-controls {
  display: none;
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 26;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

html.is-touch .touch-controls { display: flex; }
html.is-touch .bottom-right-toast { display: none; } /* 触屏没有悬停，隐藏格子信息提示 */
html.is-touch .desktop-only { display: none; }

.touch-round-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--hud-border);
  background: rgba(17, 78, 74, 0.92);
  color: var(--hud-text);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.touch-round-btn:active { transform: scale(0.92); }

/* ───────── 游戏内全服广播 ───────── */
.notify-stack {
  position: fixed;
  top: calc(54px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 58; /* 高于 HUD / 提示条，低于弹窗遮罩 */
  width: min(430px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.notify-card {
  pointer-events: auto;
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 34px 14px 12px;
  border-radius: 14px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(250, 204, 21, 0.28), transparent 55%),
    linear-gradient(135deg, #78350f 0%, #451a03 55%, #1c1917 100%);
  border: 1.5px solid #facc15;
  color: #fef3c7;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(250, 204, 21, 0.15), 0 0 26px rgba(250, 204, 21, 0.35);
  animation: notify-in 0.45s cubic-bezier(0.2, 1.3, 0.4, 1);
  overflow: hidden;
}
/* 掠过卡片的高光 */
.notify-card::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  animation: notify-shine 2.4s ease-in-out 0.3s 2;
  pointer-events: none;
}
.notify-card.leaving { animation: notify-out 0.3s ease forwards; }
.notify-badge {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #fde68a, #f59e0b 60%, #b45309);
  box-shadow: 0 0 0 2px rgba(254, 243, 199, 0.6), 0 0 18px rgba(250, 204, 21, 0.7);
  animation: notify-badge 1.2s ease-in-out infinite;
}
.notify-icon { font-size: 26px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35)); }
.notify-body { min-width: 0; flex: 1; }
.notify-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 900;
  color: #fde047;
  text-shadow: 0 1px 0 #78350f, 0 0 10px rgba(250, 204, 21, 0.5);
  letter-spacing: 0.5px;
}
.notify-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-shadow: none;
  color: #451a03;
  background: #fde047;
  border-radius: 999px;
  padding: 1px 7px;
}
.notify-text { margin-top: 2px; }
.notify-text strong { color: #ffffff; }
.notify-amount { display: inline-flex; align-items: center; gap: 3px; font-weight: 900; color: #fde047; white-space: nowrap; }
.notify-amount img { width: 15px; height: 15px; vertical-align: -2px; }
.notify-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.notify-go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #fde047, #f59e0b);
  color: #451a03;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 #92400e, 0 4px 10px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s ease, filter 0.15s ease;
}
.notify-go:hover { filter: brightness(1.08); }
.notify-go:active { transform: translateY(2px); box-shadow: 0 1px 0 #92400e; }
.notify-loc { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.notify-dist { font-size: 11px; color: #e7d6a3; }
.notify-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #fde68a;
  font-size: 13px;
  cursor: pointer;
}
.notify-close:hover { background: rgba(255, 255, 255, 0.14); }
.notify-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, #fde047, #f59e0b);
  transform-origin: left;
  animation: notify-timer linear forwards;
}
.notify-card:hover .notify-timer { animation-play-state: paused; }
@keyframes notify-in {
  0% { opacity: 0; transform: translateY(-28px) scale(0.92); }
  60% { opacity: 1; transform: translateY(4px) scale(1.02); }
  100% { opacity: 1; transform: none; }
}
@keyframes notify-out { to { opacity: 0; transform: translateY(-16px) scale(0.96); } }
@keyframes notify-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes notify-shine { from { left: -60%; } to { left: 130%; } }
@keyframes notify-badge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08) rotate(-6deg); } }

/* 中等宽度：右侧 HUD 占位，广播放到左侧，避免与 HUD 重叠 */
@media (min-width: 641px) and (max-width: 1100px) {
  .notify-stack { left: calc(12px + env(safe-area-inset-left)); transform: none; width: min(400px, calc(100vw - 360px)); min-width: 280px; }
}
/* 安全区（刘海屏 / 底部手势条） */
.hud-stack { top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); }
.bottom-left-pill { bottom: calc(12px + env(safe-area-inset-bottom)); left: calc(12px + env(safe-area-inset-left)); }
.bottom-right-toast { bottom: calc(12px + env(safe-area-inset-bottom)); }

@media (max-width: 1280px) {
  .top-stats-pill {
    left: 12px;
    transform: none;
    max-width: calc(100vw - 348px);
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 780px) {
  .top-stats-pill { display: none; }
}

/* ───────── 手机竖屏布局 ───────── */
@media (max-width: 640px) {
  /* 顶部 HUD：两行紧凑卡片铺满宽度，小地图隐藏（位置栏仍可点开大地图） */
  .hud-stack {
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    top: calc(8px + env(safe-area-inset-top));
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .hud-stack > .hud-card { flex: 1 1 calc(50% - 3px); min-width: 0; }
  .hud-stack > .hud-onboarding-toast { flex-basis: 100%; }
  .hud-profile-bar { padding: 4px 6px; }
  .hud-profile-btn { gap: 6px; font-size: 13px; min-width: 0; }
  .hud-username { max-width: 90px; }
  .hud-icon-btn { padding: 6px; }
  .hud-minimap-canvas { display: none; }
  .hud-minimap-card .hud-location-bar { border-top: none; padding: 4px 6px; height: 100%; }
  .hud-loc-code-btn { font-size: 12px; padding: 4px; min-width: 0; overflow: hidden; white-space: nowrap; }
  .hud-loc-copy-group { display: none !important; }
  .hud-score-card { padding: 6px 10px; }
  .hud-score-left { gap: 8px; }
  .trophy-badge { width: 24px; height: 24px; }
  .trophy-icon { font-size: 18px; }
  .hud-metric-value { font-size: 15px; }
  .hud-score-right { padding-left: 10px; }
  .hud-coin-main { padding: 6px 10px; gap: 8px; min-width: 0; }
  .hud-metric { min-width: 0; }
  .hud-metric-label { white-space: nowrap; }
  .hud-coin-icon { width: 22px; height: 22px; }
  .hud-shop-chip { display: none; }
  /* 道具栏：金币区保持完整，道具按钮放不下时可左右滑动 */
  .hud-coin-card { flex-wrap: nowrap; }
  .hud-coin-main { flex: 0 1 auto; }
  .hud-tools {
    flex: 1 1 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    border-top: none;
    margin: 0;
    min-width: 0;
    padding: 4px 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 14px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 14px), transparent);
  }
  .hud-tools::-webkit-scrollbar { display: none; }
  .hud-tools.scrolled-end { -webkit-mask-image: none; mask-image: none; }
  .hud-tool-btn { padding: 6px 6px; flex-shrink: 0; }

  .bottom-left-pill { padding: 6px 10px; }
  .pill-btn { width: 28px; height: 28px; font-size: 14px; }

  /* 手机：广播放在顶部 HUD 下方，铺满宽度 */
  .notify-stack {
    top: calc(104px + env(safe-area-inset-top));
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
    transform: none;
    width: auto;
  }
  .notify-card { font-size: 12px; padding: 10px 30px 12px 10px; gap: 10px; }
  .notify-badge { width: 38px; height: 38px; }
  .notify-icon { font-size: 21px; }
  .notify-title { font-size: 14px; }

  /* 提示条放到顶部 HUD 下方，避开右下角的触屏按钮 */
  .tool-banner {
    top: calc(104px + env(safe-area-inset-top));
    max-width: calc(100vw - 24px);
    white-space: normal;
    text-align: center;
  }
  .game-toast {
    top: calc(104px + env(safe-area-inset-top));
    bottom: auto;
    font-size: 13px;
    padding: 9px 14px;
  }
  @keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, -10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
  }

  /* 弹窗：铺满宽度，内容可滚动 */
  .modal-backdrop { padding: 8px; padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .modal-card { width: 100% !important; max-width: 100%; max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .modal-header { padding: 10px 12px; flex-wrap: wrap; }
  /* 页签过多时：余额 + 关闭固定在第一行右侧，页签整行放到下方并可横向滑动 */
  .modal-header-actions { order: 1; margin-left: auto; }
  /* 直接放在标题栏里的关闭按钮（个人资料、登录等）同样固定在第一行右上角 */
  .modal-header > .icon-action-btn { order: 1; margin-left: auto; }
  /* 固定尺寸弹窗在手机上占满可用高度 */
  .modal-card.settings-card,
  .modal-card.shop-card,
  .modal-card.leaderboard-card:not(.pinned-panel) {
    height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  .modal-header > .tab-row { order: 2; flex: 1 1 100%; max-width: 100%; -webkit-overflow-scrolling: touch; }
  .tab-btn { white-space: nowrap; padding: 8px 10px; }
  .icon-action-btn { padding: 8px 12px; font-size: 13px; }
  .leaderboard-body { max-height: none; flex: 1 1 auto; }
  .leaderboard-table th, .leaderboard-table td { padding: 8px 10px; }
  .leaderboard-card.pinned-panel {
    top: auto;
    left: 8px;
    right: 64px; /* 留出右侧缩放按钮 */
    bottom: calc(56px + env(safe-area-inset-bottom));
    width: auto !important;
    max-height: 40dvh;
  }
  .large-map-form { flex-direction: column; align-items: stretch; }
  .large-map-buttons { justify-content: flex-end; }
  .settings-body { padding: 14px; }
  .profile-stats-grid { gap: 8px; }
  .themes-grid { gap: 8px; }
  .theme-preview { grid-template-columns: repeat(4, 28px); }
  .tp-cell { width: 28px; height: 28px; font-size: 14px; }
  .shop-body { grid-template-columns: 1fr; padding: 12px; }
  .help-body, .auth-form, .terms-body { padding: 14px; }
  .text-input { font-size: 16px; } /* 避免 iOS 聚焦输入框时自动放大 */

  /* 首页 */
  .landing-scroll { padding: calc(20px + env(safe-area-inset-top)) 12px calc(40px + env(safe-area-inset-bottom)); gap: 20px; }
  .landing-hero-card { padding: 28px 18px 22px; }
  .landing-title { font-size: 44px; }
  .landing-tagline { font-size: 18px; }
  .landing-subtext { font-size: 14px; }
  .landing-cta-row .btn-lg { flex: 1 1 100%; }
  .landing-section { padding: 20px 16px; }
  .how-to-list li { align-items: flex-start; font-size: 14px; }
}

/* 横屏手机：高度很矮时隐藏小地图，紧凑 HUD */
@media (max-height: 480px) and (pointer: coarse) {
  .hud-minimap-canvas { display: none; }
  .hud-stack { width: 260px; gap: 6px; }
  .hud-shop-chip { display: none; }
  .hud-score-card, .hud-coin-main { padding: 6px 10px; }
  .hud-profile-bar, .hud-location-bar { padding: 4px 6px; }
  .top-stats-pill { display: none; }
  .touch-controls { gap: 6px; bottom: calc(12px + env(safe-area-inset-bottom)); flex-direction: row; align-items: flex-end; }
}

/* ───────── 新手教程 ───────── */
.help-tutorial-banner {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 12px 14px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.16), rgba(167, 139, 250, 0.16));
  border: 1px solid rgba(125, 211, 252, 0.35); border-radius: 10px;
}
.help-tutorial-banner > div { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: #cbd5e1; }
.help-tutorial-banner b { color: #f8fafc; font-size: 14px; }
.help-tutorial-banner .btn-primary { flex-shrink: 0; }

.tut-backdrop {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(15, 23, 42, 0.62); backdrop-filter: blur(3px);
}
.tut-card {
  width: 560px; max-width: 100%;
  height: min(640px, 92vh); height: min(640px, 92dvh);
  display: flex; flex-direction: column; overflow: hidden;
  background: #0f172a; color: #e2e8f0;
  border: 1px solid #334155; border-radius: 14px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
.tut-card.tut-enter { animation: tut-in 0.22s ease-out; }
@keyframes tut-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

.tut-header {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; flex-shrink: 0;
  background: #111c33; border-bottom: 1px solid #1e293b;
}
.tut-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tut-title h3 { margin: 0; font-size: 17px; color: #f8fafc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tut-badge { font-size: 11px; font-weight: 700; color: #7dd3fc; letter-spacing: 0.04em; }
.tut-mode { display: inline-flex; background: #1e293b; border-radius: 8px; padding: 2px; flex-shrink: 0; }
.tut-mode button {
  border: none; background: transparent; color: #94a3b8; font-size: 12px; font-weight: 700;
  padding: 5px 9px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.tut-mode button.active { background: #38bdf8; color: #082f49; }
.tut-close {
  flex-shrink: 0; border: none; background: rgba(255, 255, 255, 0.1); color: #fff;
  border-radius: 6px; padding: 6px 10px; font-weight: 700; cursor: pointer;
}
.tut-close:hover { background: rgba(255, 255, 255, 0.22); }

.tut-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 20px; font-size: 14px; line-height: 1.65; }
.tut-body p { margin: 0 0 10px; }
.tut-lead { font-size: 15px; color: #f1f5f9; }
.tut-note { font-size: 12.5px; color: #94a3b8; margin-top: 12px !important; }
.tut-points { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.tut-points li { background: #1e293b; border: 1px solid #273449; border-radius: 8px; padding: 9px 12px; }
.tut-body kbd {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 4px; font-size: 12px; line-height: 18px;
  text-align: center; background: #334155; color: #f8fafc; border-bottom: 2px solid #1e293b;
}

.tut-rule-row { display: flex; align-items: center; gap: 18px; }
.tut-diagram { display: grid; grid-template-columns: repeat(3, 38px); gap: 3px; flex-shrink: 0; }
.tut-dcell {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 5px;
  background: #cbd5e1; font-size: 18px; font-weight: 800;
}
.tut-dcell.mine { background: #fecaca; }
.tut-dcell.center { outline: 2px solid #38bdf8; outline-offset: 1px; }

.tut-controls { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-size: 13.5px; }
.tut-controls th {
  text-align: left; white-space: nowrap; vertical-align: top; color: #fde68a;
  background: #1e293b; padding: 8px 10px; border-radius: 8px 0 0 8px; width: 1%;
}
.tut-controls td { background: #1e293b; padding: 8px 10px; border-radius: 0 8px 8px 0; color: #e2e8f0; }

.tut-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tut-summary > div {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px;
  background: #1e293b; border: 1px solid #334155; border-radius: 10px;
}
.tut-summary span { font-size: 12.5px; color: #94a3b8; }
.tut-summary b { font-size: 17px; color: #f8fafc; }

/* 练习棋盘 */
.tut-task { background: #1e293b; border-left: 3px solid #38bdf8; border-radius: 6px; padding: 10px 12px; }
.tut-board-wrap { display: flex; justify-content: center; margin: 14px 0 10px; }
.tut-board {
  --tut-cell: 46px;
  display: grid; grid-template-columns: repeat(var(--tut-cols), var(--tut-cell)); gap: 3px;
  padding: 6px; background: #1e293b; border-radius: 10px;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tut-cell {
  width: var(--tut-cell); height: var(--tut-cell); padding: 0; border: none; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; font-weight: 900; font-family: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none;
  transition: transform 0.08s, background 0.15s;
}
.tut-cell.is-hidden, .tut-cell.is-flag {
  background: linear-gradient(160deg, #94a3b8, #64748b);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}
.tut-cell.is-hidden:hover { filter: brightness(1.1); }
.tut-cell.is-pressed { transform: scale(0.92); filter: brightness(0.9); }
.tut-cell.is-open { background: #e2e8f0; color: #334155; cursor: default; }
.tut-cell.is-fresh { animation: tut-open 0.2s ease-out; }
@keyframes tut-open { from { transform: scale(0.85); } to { transform: none; } }
.tut-cell.n1, .tut-dcell.n1 { color: #2563eb; }
.tut-cell.n2, .tut-dcell.n2 { color: #16a34a; }
.tut-cell.n3 { color: #dc2626; }
.tut-cell.is-open.n1, .tut-cell.is-open.n2, .tut-cell.is-open.n3 { cursor: pointer; }
.tut-cell.is-target { position: relative; z-index: 1; animation: tut-pulse 1.1s ease-in-out infinite; }
@keyframes tut-pulse {
  0%, 100% { box-shadow: 0 0 0 2px #facc15, 0 0 0 4px rgba(250, 204, 21, 0.25); }
  50% { box-shadow: 0 0 0 3px #facc15, 0 0 14px 6px rgba(250, 204, 21, 0.55); }
}
.tut-cell.is-hint { box-shadow: 0 0 0 3px #38bdf8; }

.tut-feedback {
  min-height: 46px; padding: 9px 12px; border-radius: 8px; font-size: 13.5px; text-align: center;
  color: #94a3b8;
}
.tut-feedback.is-ok { background: rgba(34, 197, 94, 0.14); border: 1px solid rgba(74, 222, 128, 0.4); color: #bbf7d0; text-align: left; }
.tut-feedback.is-warn { background: rgba(250, 204, 21, 0.12); border: 1px solid rgba(250, 204, 21, 0.4); color: #fef08a; text-align: left; animation: tut-shake 0.3s; }
@keyframes tut-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.tut-legend { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; font-size: 12px; }
.tut-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.tut-legend .lg-target { box-shadow: 0 0 0 2px #facc15; }
.tut-legend .lg-hint { box-shadow: 0 0 0 2px #38bdf8; }

.tut-progress { display: flex; justify-content: center; gap: 5px; padding: 8px 0 0; flex-shrink: 0; }
.tut-dot { width: 7px; height: 7px; border-radius: 50%; background: #334155; transition: all 0.2s; }
.tut-dot.practice { border-radius: 2px; }
.tut-dot.past { background: #0ea5e9; }
.tut-dot.active { background: #facc15; width: 18px; border-radius: 4px; }

.tut-footer {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.tut-spacer { flex: 1; }
.tut-link { color: #94a3b8; font-size: 13px; padding: 8px 6px; }
.tut-link:hover { color: #f8fafc; }

@media (max-width: 640px) {
  .tut-backdrop { padding: 0; }
  .tut-card { width: 100%; height: 100%; max-height: none; border-radius: 0; border: none; padding-top: env(safe-area-inset-top); }
  .tut-header { padding: 10px 12px; }
  .tut-title h3 { font-size: 16px; }
  .tut-body { padding: 14px; }
  .tut-board { --tut-cell: min(48px, calc((100vw - 64px) / 6)); }
  .tut-footer { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .tut-footer .btn-primary, .tut-footer .btn-secondary { padding: 10px 14px; }
  .tut-rule-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .tut-controls th { white-space: normal; width: 34%; }
  .help-tutorial-banner { flex-direction: column; align-items: stretch; }
}

/* ───────── 多语言 ───────── */
/* 非中文时先隐藏，等 i18n.js 翻译完静态文案再显示，避免闪一下中文；脚本异常时 1.5 秒后兜底显示 */
html.i18n-pending body { visibility: hidden; animation: i18n-reveal 0s 1.5s forwards; }
@keyframes i18n-reveal { to { visibility: visible; } }
.lang-row { display: flex; flex-wrap: wrap; gap: 6px; }
.lang-btn {
  background: #1e293b; border: 1px solid #334155; color: #cbd5e1;
  border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.lang-btn:hover { border-color: #5eead4; color: #f8fafc; }
.lang-btn.active { background: #0f766e; border-color: #5eead4; color: #ffffff; }
.landing-lang { display: inline-flex; align-items: center; gap: 6px; margin-left: 16px; font-size: 14px; vertical-align: middle; }
.landing-lang-select {
  border: 1px solid #99f6e4; background: #ffffff; color: #0f766e; font-weight: 600;
  border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer;
}