/* View-specific styles for the SPA shell. Base/shared pieces live in theme.css
   and cost.css; login and the game are scoped to their own roots. */

/* ===== Home (portal) ===== */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid #eef0f4;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(31, 35, 41, 0.05);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.tool-card:hover {
  transform: translateY(-2px);
  border-color: #dfe3ea;
  box-shadow: 0 16px 40px rgba(31, 35, 41, 0.10);
}

.tool-icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1f2329;
}

.tool-icon .icon {
  width: 28px;
  height: 28px;
}

.tool-text {
  min-width: 0;
}

.tool-title {
  font-size: 16px;
  font-weight: 650;
  color: #1f2329;
  margin-bottom: 2px;
}

.tool-desc {
  font-size: 13px;
  color: #8c93a3;
  line-height: 1.4;
}

/* ===== Login (scoped) ===== */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-view .card {
  width: min(100%, 420px);
  background: #ffffff;
  border: 1px solid #eef0f4;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(31, 35, 41, 0.08);
  padding: 32px 28px;
}

.login-view .card-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-view .card-header h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 650;
}

.login-view .subtitle {
  margin: 0;
  color: #5f6673;
  font-size: 14px;
  line-height: 1.5;
}

.login-view .qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-view .qr-wrap {
  display: grid;
  place-items: center;
  min-height: 252px;
  border: 1px solid #eef0f4;
  border-radius: 10px;
  background: #fbfcfe;
  padding: 16px;
  width: 100%;
}

.login-view .qr-wrap svg {
  width: min(100%, 220px);
  height: auto;
  display: block;
}

.login-view .qr-status {
  min-height: 22px;
  margin: 18px 0 0;
  color: #374151;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.login-view .qr-actions {
  display: flex;
  justify-content: center;
  margin-top: 18px;
  gap: 12px;
}

.login-view .btn-primary {
  background: #ffffff;
  border-color: #dfe3ea;
  color: #1f2329;
  font-weight: 700;
}

.login-view .btn-primary:hover:not(:disabled) {
  background: #f5f7fb;
}

.login-view .btn-secondary {
  background: #eef0f4;
  color: #1f2329;
}

.login-view .btn-secondary:hover:not(:disabled) {
  background: #e2e5ea;
}

.login-view .mp-menu {
  position: relative;
  display: inline-block;
}

.login-view .mp-trigger {
  border: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 10px;
  margin: 0 2px;
  border-radius: 999px;
  background: #e8f8ef;
  color: #07c160;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.15s, color 0.15s;
}

.login-view .mp-menu:hover .mp-trigger,
.login-view .mp-menu.is-open .mp-trigger {
  background: #07c160;
  color: #ffffff;
}

.login-view .mp-popover {
  position: absolute;
  top: 100%;
  left: 50%;
  padding-top: 10px;
  transform: translate(-50%, -4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s, transform 0.15s;
  z-index: 30;
}

.login-view .mp-menu:hover .mp-popover,
.login-view .mp-menu.is-open .mp-popover {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.login-view .mp-popover-inner {
  display: block;
  width: 200px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid #eef0f4;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(31, 35, 41, 0.14);
  text-align: center;
}

.login-view .mp-code {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.login-view .mp-caption {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  color: #5f6673;
}

/* Login overlay: the card over the current page, so logging in no longer
   throws the page away. Above every page layer (the 2048 game runs to
   z-index 200); deliberately not dismissible, so it has no close affordance. */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
}

.login-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 35, 41, 0.42);
}

.login-overlay .login-view {
  position: relative;
}

/* ===== Messages ===== */
.columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.page-fill .columns {
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.page-fill .col {
  min-height: 0;
}

/* Messages: keep the row content-sized (no full-viewport stretch) and let each
   column's last card fill, so the test-push card bottom aligns with the
   webhook card bottom on the left. */
.message-columns {
  align-content: start;
}

.message-columns > .col > .card:last-child {
  flex: 1;
  min-height: 0;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(31, 35, 41, 0.05);
  padding: 18px 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 650;
  color: #1f2329;
  margin: 0;
}

.count-badge {
  font-size: 12px;
  font-weight: 600;
  color: #5f6673;
  background: #eef0f4;
  border-radius: 999px;
  padding: 1px 8px;
}

.quota-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.quota-number {
  font-size: 34px;
  font-weight: 750;
  color: #1f2329;
  line-height: 1;
}

.quota-slash {
  font-size: 22px;
  color: #c0c6d0;
}

.quota-total {
  font-size: 20px;
  font-weight: 600;
  color: #8c93a3;
}

.quota-unit {
  font-size: 13px;
  color: #8c93a3;
}

.card-hint {
  margin-top: 10px;
  font-size: 13px;
  color: #5f6673;
  line-height: 1.5;
}

.card-note {
  margin-top: 4px;
  font-size: 13px;
  color: #8c93a3;
}

.webhook-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #1f2329;
  background: #f5f7fb;
  border-radius: 8px;
  padding: 10px 12px;
  word-break: break-all;
  line-height: 1.5;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.btn-sm {
  border: 1px solid #eef0f4;
  background: #ffffff;
  color: #5f6673;
  font: inherit;
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 9px;
  cursor: pointer;
}

.btn-sm:hover {
  background: #f5f7fb;
  color: #1f2329;
}

.btn-sm.is-danger {
  color: #e5484d;
  border-color: #f4dcdc;
}

.btn-sm.is-danger:hover {
  background: #fdf3f3;
  color: #cf3b40;
}

/* 开关式小按钮的按下态（如文件列表的「按设备分组」）。 */
.btn-sm.is-active,
.btn-sm.is-active:hover {
  background: #1f2329;
  border-color: #1f2329;
  color: #ffffff;
}

.field {
  position: relative;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 13px;
  color: #5f6673;
  margin-bottom: 6px;
}

.field-input {
  width: 100%;
  border: 1px solid #eef0f4;
  background: #ffffff;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: #1f2329;
}

.field-input:focus {
  outline: none;
  border-color: #cfd6e0;
}

textarea.field-input {
  resize: vertical;
  min-height: 72px;
}

/* 带计数的输入框：右侧留位，避免文字写到计数下面 */
.field:has(.field-count) .field-input {
  padding-right: 56px;
}

/* 计数器叠在框内右下角 */
.field-count {
  position: absolute;
  right: 8px;
  bottom: 6px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 12px;
  color: #8c93a3;
  pointer-events: none;
}

@media (max-width: 820px) {
  .columns {
    grid-template-columns: 1fr;
  }

  .page-fill:has(.columns) {
    height: auto;
  }

  .page-fill .columns {
    align-items: start;
  }
}

/* ===== MCP ===== */
/* 两列底部齐平：.columns 默认 align-items: start，这里拉到 stretch 让两列等高。
   左列地址卡吸收剩余高度、警告卡贴底；右列工具卡填满，表格过长时在卡内滚动
   （滚动条沿用列表页 .list-card 的样式）。 */
.mcp-columns {
  align-items: stretch;
}

.mcp-grow {
  flex: 1;
  min-height: 0;
}

.mcp-tools {
  display: flex;
  flex-direction: column;
}

.mcp-scroll {
  flex: 1;
  min-height: 0;
  max-height: 60dvh;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #dbe0e7 transparent;
}

.mcp-scroll::-webkit-scrollbar {
  width: 10px;
}

.mcp-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.mcp-scroll::-webkit-scrollbar-thumb {
  background: #dbe0e7;
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

.mcp-scroll::-webkit-scrollbar-thumb:hover {
  background: #c6ccd6;
  background-clip: padding-box;
}

.code-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #1f2329;
  background: #f5f7fb;
  border-radius: 8px;
  padding: 12px 14px;
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.6;
  margin: 14px 0 0;
}

/* 自测结果框：与上方按钮行留出间距，常驻不隐藏。 */
.mcp-result {
  margin-top: 14px;
}

.tool-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tool-table th {
  text-align: left;
  font-weight: 600;
  color: #8c93a3;
  padding: 0 8px 8px 0;
  border-bottom: 1px solid #eef0f4;
}

.tool-table td {
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid #f5f7fb;
  color: #5f6673;
  vertical-align: top;
  line-height: 1.5;
}

.tool-table tr:last-child td {
  border-bottom: none;
}

.tool-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #1f2329;
  white-space: nowrap;
}

.tool-args {
  font-size: 12px;
  color: #8c93a3;
}

/* 常驻提示：AI 可写删数据，写操作须用户手动确认。作为左列的一张卡，
   固定自身高度、间距交给 .col 的 gap，不参与拉伸。 */
.mcp-warning {
  flex: 0 0 auto;
  border-left: 3px solid #e5484d;
  font-size: 13px;
  color: #5f6673;
  line-height: 1.6;
}

.mcp-warning strong {
  color: #cf3b40;
}

/* ===== 2048 (scoped to .game-root, a fixed full-viewport layer) ===== */
.game-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    linear-gradient(135deg, rgba(38, 126, 240, 0.10), transparent 36%),
    linear-gradient(315deg, rgba(24, 160, 88, 0.08), transparent 32%),
    #f5f7fb;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  flex-direction: column;
}

.game-root * {
  -webkit-tap-highlight-color: transparent;
}

.game-root .topbar-wrap {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 20px 0;
  box-sizing: border-box;
  flex: none;
}

.game-root .stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden;
}

.game-root .container {
  position: relative;
  width: 100%;
  max-width: 500px;
  height: 100%;
  background:
    linear-gradient(135deg, rgba(38, 126, 240, 0.10), transparent 36%),
    linear-gradient(315deg, rgba(24, 160, 88, 0.08), transparent 32%),
    #f5f7fb;
  display: flex;
  flex-direction: column;
  padding: 8px 20px 36px;
  touch-action: none;
}

.game-root .title-bar {
  text-align: center;
  margin-bottom: 16px;
}

.game-root .title-bar h1 {
  font-size: 40px;
  font-weight: 800;
  color: #776e65;
  letter-spacing: 2px;
}

.game-root .score-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.game-root .score-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 64px;
  border-radius: 6px;
  background: #bbada0;
  cursor: default;
}

.game-root .score-box--best {
  cursor: pointer;
  position: relative;
}

.game-root .score-label {
  color: #eee4da;
  font-size: 12px;
  line-height: 1;
  margin-bottom: 2px;
}

.game-root .score-value {
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.game-root .board-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  background: #bbada0;
  overflow: hidden;
}

.game-root .grid {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}

.game-root .grid-row {
  flex: 1;
  display: flex;
  gap: 8px;
  min-height: 0;
}

.game-root .grid-cell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-weight: 700;
  line-height: 1;
  transition: background 0.1s ease;
  position: relative;
}

.game-root .grid-cell--new {
  animation: cell-pop-in 0.2s ease;
}

@keyframes cell-pop-in {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.game-root .action-bar {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 18px;
}

.game-root .action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  border: none;
  border-radius: 6px;
  background: #8f7a66;
  color: #f9f6f2;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.game-root .action-btn:active {
  transform: scale(0.96);
}

.game-root .action-btn--disabled {
  opacity: 0.4;
  pointer-events: none;
}

.game-root .hint {
  margin-top: 14px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
  line-height: 1.4;
}

.game-root .toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 16px 28px;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
}

.game-root .toast--show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.game-root .overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(238, 228, 218, 0.73);
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  z-index: 10;
}

.game-root .overlay--show {
  opacity: 1;
  pointer-events: auto;
}

.game-root .overlay-title {
  font-size: 36px;
  font-weight: 800;
  color: #776e65;
  margin-bottom: 12px;
}

.game-root .overlay-sub {
  font-size: 16px;
  color: #776e65;
  margin-bottom: 20px;
}

.game-root .overlay-btn {
  padding: 12px 36px;
  border: none;
  border-radius: 6px;
  background: #8f7a66;
  color: #f9f6f2;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}

.game-root .overlay-btn:active {
  transform: scale(0.96);
}

/* Shared game modal: 2048's theme picker and the sudoku/minesweeper difficulty
   picker are the same component. */
.game-root .game-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 200;
}

.game-root .game-modal--show {
  opacity: 1;
  pointer-events: auto;
}

.game-root .game-modal-content {
  background: #fff;
  border-radius: 14px;
  padding: 20px 0;
  width: 260px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.game-root .game-modal-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: #776e65;
  padding: 0 20px 12px;
  border-bottom: 1px solid #eee;
}

.game-root .game-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 16px;
  color: #776e65;
}

.game-root .game-option:active {
  background: #f5f2ed;
}

.game-root .game-option--current {
  font-weight: 700;
}

.game-root .game-check {
  color: #4f46e5;
  font-weight: 700;
}

@media (min-width: 521px) {
  .game-root .stage {
    align-items: center;
    padding: 16px 0 24px;
  }
  .game-root .container {
    border-radius: 16px;
    height: auto;
    min-height: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  }
}

/* ===== Sudoku / minesweeper chrome (scoped to .game-root) ===== */
.game-root .action-btn--active {
  background: #4f46e5;
}

.game-root .score-box--tap {
  position: relative;
  cursor: pointer;
}

.game-root .score-box--tap:active {
  transform: scale(0.97);
}

/* These screens fill the viewport and scale their board to fit, so the page
   never scrolls — the same fixed-layer feel 2048 has, but adaptive. */
.game-root--fit .container {
  height: 100%;
  overflow: hidden;
  touch-action: auto;
  display: flex;
  flex-direction: column;
}

.game-root--fit .title-bar {
  flex: none;
  margin-bottom: 12px;
}

.game-root--fit .score-bar,
.game-root--fit .action-bar,
.game-root--fit .sudoku-pad,
.game-root--fit .sudoku-toolbar,
.game-root--fit .hint {
  flex: none;
}

/* ===== Sudoku ===== */
.game-root .sudoku-board-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  overflow: auto;
}

.game-root .sudoku-frame {
  --sudoku-cell: 40px;
  position: relative;
  flex: none;
  margin: auto;
  width: calc(var(--sudoku-cell) * 9);
  height: calc(var(--sudoku-cell) * 9);
}

.game-root .sudoku-board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  background: #ffffff;
  border: 2px solid #344861;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(31, 35, 41, 0.10);
}

.game-root .sudoku-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #d6dce5;
  border-bottom: 1px solid #d6dce5;
  font-size: calc(var(--sudoku-cell) * 0.56);
  font-weight: 600;
  color: #2f6fd0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.1s ease;
}

.game-root .sudoku-cell:nth-child(9n) {
  border-right: none;
}

.game-root .sudoku-cell:nth-child(n+73) {
  border-bottom: none;
}

.game-root .sudoku-cell--br {
  border-right: 2px solid #344861;
}

.game-root .sudoku-cell--bb {
  border-bottom: 2px solid #344861;
}

.game-root .sudoku-cell--given {
  color: #1f2329;
  font-weight: 700;
}

.game-root .sudoku-cell--peer {
  background: #eef3fb;
}

.game-root .sudoku-cell--same {
  background: #dbe8fb;
}

.game-root .sudoku-cell--selected {
  background: #c9def9;
}

.game-root .sudoku-cell--error {
  color: #d64545;
}

.game-root .sudoku-cell--hint {
  color: #17a673;
}

.game-root .sudoku-notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 1px;
  box-sizing: border-box;
}

.game-root .sudoku-note {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--sudoku-cell) * 0.24);
  font-weight: 500;
  color: #8c93a3;
  line-height: 1;
}

.game-root .sudoku-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.game-root .sudoku-pad-key {
  height: 46px;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  background: #ffffff;
  color: #2f6fd0;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}

.game-root .sudoku-pad-key:active {
  transform: scale(0.96);
}

.game-root .sudoku-pad-key--erase {
  font-size: 15px;
  color: #5f6673;
}

.game-root .sudoku-pad-key--done {
  opacity: 0.35;
}

.game-root .sudoku-toolbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.game-root .sudoku-toolbar .action-btn {
  height: 42px;
  font-size: 14px;
}

/* ===== Minesweeper ===== */
.game-root .container.mine-container {
  max-width: 1000px;
}

.game-root .mine-container > .overlay,
.game-root .sudoku-frame > .overlay {
  background: rgba(245, 247, 251, 0.88);
  border-radius: 12px;
}

.game-root .mine-container > .overlay .overlay-title,
.game-root .mine-container > .overlay .overlay-sub,
.game-root .sudoku-frame > .overlay .overlay-title,
.game-root .sudoku-frame > .overlay .overlay-sub {
  color: #1f2329;
}

.game-root .mine-board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  overflow: auto;
}

.game-root .mine-board {
  --mine-cell: 32px;
  flex: none;
  margin: auto;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--mine-cell));
  grid-auto-rows: var(--mine-cell);
  width: max-content;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(31, 35, 41, 0.10);
}

.game-root .mine-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #c7ccd6;
  border-bottom: 1px solid #c7ccd6;
  background: #dfe3ea;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.game-root .mine-cell svg {
  width: 66%;
  height: 66%;
}

.game-root .mine-cell--revealed {
  background: #f2f4f8;
  cursor: default;
}

.game-root .mine-cell--flag svg {
  color: #d64545;
}

.game-root .mine-cell--mine {
  background: #f6d6d6;
}

.game-root .mine-cell--mine svg {
  color: #1f2329;
}

.game-root .mine-cell--hit {
  background: #e5484d;
}

.game-root .mine-cell--hit svg {
  color: #ffffff;
}

.game-root .mine-cell--wrong svg {
  color: #9aa2af;
}

.game-root .mine-num {
  font-size: calc(var(--mine-cell) * 0.56);
  font-weight: 700;
  line-height: 1;
}

.game-root .mine-num--1 { color: #2f6fd0; }
.game-root .mine-num--2 { color: #1a8f5a; }
.game-root .mine-num--3 { color: #d64545; }
.game-root .mine-num--4 { color: #6b3fb0; }
.game-root .mine-num--5 { color: #b25a1c; }
.game-root .mine-num--6 { color: #0f9ca8; }
.game-root .mine-num--7 { color: #1f2329; }
.game-root .mine-num--8 { color: #7b7f8a; }

@media (max-height: 700px) {
  .game-root--fit .sudoku-pad-key {
    height: 40px;
    font-size: 18px;
  }
  .game-root--fit .title-bar h1 {
    font-size: 30px;
  }
  .game-root--fit .score-box {
    height: 56px;
  }
}

/* ===== P2P 传输 ===== */
/* 房间号是念给另一台设备抄的，不是给机器读的：等宽、拉开字距、居中。 */
.p2p-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #1f2329;
  background: #f5f7fb;
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
  word-break: break-all;
}

.p2p-code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-align: center;
}

.p2p-room-meta {
  margin-top: 8px;
  font-size: 12px;
  color: #8c93a3;
}

.p2p-drop {
  border: 1px dashed #dfe3ea;
  border-radius: 12px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.p2p-drop:hover,
.p2p-drop.is-over {
  border-color: #267ef0;
  background: rgba(38, 126, 240, 0.06);
}

.p2p-drop-text {
  font-size: 14px;
  font-weight: 600;
  color: #1f2329;
}

.p2p-drop-sub {
  margin-top: 6px;
  font-size: 12px;
  color: #8c93a3;
  word-break: break-all;
}

/* 筛选标签：五等分一行排开，数字跟着类走。选中态反色，一眼看出在看哪一类。 */
.p2p-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 14px;
}

.p2p-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  border: 1px solid #eef0f4;
  background: #ffffff;
  color: #5f6673;
  font: inherit;
  font-size: 12px;
  padding: 6px 2px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}

.p2p-filter:hover {
  background: #f5f7fb;
  color: #1f2329;
}

.p2p-filter.is-active {
  background: #1f2329;
  border-color: #1f2329;
  color: #ffffff;
}

.p2p-filter-count {
  font-size: 11px;
  color: #8c93a3;
}

.p2p-filter.is-active .p2p-filter-count {
  color: #c7ccd6;
}

/* 文件卡头部右侧的两个小按钮（分组开关 / 清空）。 */
.p2p-head-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* 按设备分组时的一段：组标题带这一组的条数，行里不再重复来源。 */
.p2p-group {
  margin-top: 12px;
}

.p2p-group:first-child {
  margin-top: 0;
}

.p2p-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  color: #8c93a3;
  letter-spacing: 0.4px;
}

.p2p-group-title + .p2p-file {
  border-top: none;
}

/* 加入其他账号房间的输入行：输入框占满，按钮贴右。 */
.p2p-join {
  display: flex;
  gap: 8px;
}

.p2p-join .field-input {
  flex: 1;
  min-width: 0;
}

/* 接收进度条：接收中的文件行挂在名称下面。 */
.p2p-progress {
  margin-top: 6px;
  height: 6px;
  border-radius: 999px;
  background: #eef0f4;
  overflow: hidden;
}

.p2p-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: #267ef0;
  transition: width 0.15s linear;
}

/* 设备列表：一台一行，名称与连接状态各一层，重拨贴右侧。本机那行没有操作，
   用浅底纹区分，避免被当成可以重拨的对端。 */
.p2p-device {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid #eef0f4;
}

.p2p-device:first-child,
.p2p-device.is-self {
  border-top: none;
}

.p2p-device.is-self {
  padding: 6px 0 10px;
}

.p2p-device-main {
  min-width: 0;
}

/* 设备名一行：型号图标 + 浏览器 + id 尾巴，图标跟着文字基线居中。 */
.p2p-device-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: #1f2329;
  word-break: break-word;
}

.p2p-device-name .icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: #5f6673;
}

.p2p-device-tag {
  font-size: 12px;
  font-weight: 500;
  color: #8c93a3;
}

.p2p-device-status {
  margin-top: 2px;
  font-size: 12px;
  color: #8c93a3;
}

/* 传输中的设备状态染成主题蓝，跟「已直连但闲着」区分开。 */
.p2p-device-status.is-active {
  color: #267ef0;
}

/* 每台设备最近一条事件，落在这台设备自己那一行。 */
.p2p-device-event {
  margin-top: 2px;
  font-size: 12px;
  color: #5f6673;
  word-break: break-word;
}

.p2p-divider {
  height: 1px;
  background: #eef0f4;
  margin: 14px 0;
}

.p2p-list-empty {
  font-size: 12px;
  color: #b3b9c4;
  padding: 6px 0 2px;
}

/* 文件行：名称一层，来源与状态一层，操作贴右侧。名字是对方发来的任意字符串，
   所以必须能折行、不能把行撑破。 */
.p2p-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid #eef0f4;
}

.p2p-file-main {
  min-width: 0;
}

.p2p-file-name {
  font-size: 14px;
  font-weight: 600;
  color: #1f2329;
  word-break: break-all;
}

.p2p-file-meta {
  margin-top: 2px;
  font-size: 12px;
  color: #8c93a3;
  word-break: break-word;
}

.p2p-file-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
