.card-score-view[hidden] {
  display: none !important;
}

.card-score-board-wrap:not([hidden]) {
  display: flex;
  flex-direction: column;
}

.card-score-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-score-list-desc {
  display: none;
  margin: 0 0 16px;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
}

.card-score-note {
  margin: 16px 0 0;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
}

.card-score-board-wrap {
  padding-bottom: 16px;
}

.card-score-board-wrap:not([hidden]) .card-score-scroll {
  margin-bottom: 0;
}

@media (min-width: 769px) {
  .card-score-board-wrap:not([hidden]) .card-score-scroll {
    margin-bottom: 0;
  }

  .card-score-footer {
    margin-bottom: 16px;
  }
}

.card-score-board-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
}

.card-score-scroll {
  overflow: auto;
  max-width: none;
  margin-bottom: 0;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}

/* 表尾固定在分数区下方（不 sticky），避免盖住上一行、底边悬空 */
.card-score-footer {
  flex-shrink: 0;
  border-top: 1px solid #ddd;
  background: #fff;
}

.card-score-footer-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.card-score-footer-scroll::-webkit-scrollbar {
  display: none;
}

.card-score-grid-scores {
  border-bottom: none;
}

.card-score-grid-footer {
  border-top: none;
}

/* 末列不画右边框，避免与外框叠成双线 */
.card-score-players .card-score-player-col:last-child .card-score-cell,
.card-score-players .card-score-player-col:last-child .card-score-name-input,
.card-score-players .card-score-player-col:last-child .card-score-delete-btn {
  border-right: none;
}

/* 表尾末行底边靠外框收口 */
.card-score-grid-footer .card-score-left .card-score-cell:last-child,
.card-score-grid-footer .card-score-player-col > *:last-child {
  border-bottom: none;
}

.card-score-grid {
  display: flex;
  width: max-content;
  min-width: 100%;
  border-top: none;
  border-left: none;
  --cs-left-width: 72px;
  --cs-cell-height: 40px;
  --cs-font-size: 14px;
}

.card-score-left {
  width: var(--cs-left-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.card-score-players {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}

.card-score-player-col {
  flex: 1;
  min-width: 88px;
  display: flex;
  flex-direction: column;
}

.card-score-cell {
  border-right: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  min-height: var(--cs-cell-height);
  line-height: var(--cs-cell-height);
  text-align: center;
  font-size: var(--cs-font-size);
  background: #fff;
  box-sizing: border-box;
  padding: 0 2px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-score-cell.is-label {
  background: #f9fafb;
  color: #374151;
  font-weight: 500;
  font-size: calc(var(--cs-font-size) - 1px);
}

.card-score-cell.is-round-meta {
  display: flex;
  padding: 0;
  overflow: hidden;
  line-height: var(--cs-cell-height);
}

.card-score-cell.is-round-meta .round-index {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #111827;
  font-size: calc(var(--cs-font-size) - 1px);
  font-weight: 500;
}

.card-score-cell.is-round-meta .round-sum {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid #ddd;
  font-weight: 600;
  font-size: calc(var(--cs-font-size) - 1px);
}

.card-score-cell.is-round-meta .round-sum.zero {
  color: #2563eb;
}

.card-score-cell.is-round-meta .round-sum.positive {
  color: #f5653b;
}

.card-score-cell.is-round-meta .round-sum.negative {
  color: #52c41a;
}

.card-score-cell.is-player-total {
  font-weight: 700;
  color: #111827;
}

.card-score-cell.is-score {
  cursor: pointer;
  user-select: none;
  color: #f5653b;
}

.card-score-cell.is-score.negative {
  color: #52c41a;
}

.card-score-cell.is-score.active {
  background: #f8f9fa;
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.card-score-cell.is-score .cursor {
  animation: card-score-blink 1s infinite;
  margin-left: 1px;
  color: #2196f3;
}

@keyframes card-score-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.card-score-name-input {
  width: 100%;
  height: var(--cs-cell-height);
  border: none;
  border-right: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  text-align: center;
  font: inherit;
  font-size: var(--cs-font-size);
  box-sizing: border-box;
  background: #fff;
  min-width: 0;
}

.card-score-name-input:focus {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.card-score-delete-btn {
  border: none;
  border-right: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  min-height: var(--cs-cell-height);
  background: #fff;
  color: #f5653b;
  font: inherit;
  font-size: calc(var(--cs-font-size) - 1px);
  cursor: pointer;
  padding: 0 2px;
}

.card-score-delete-btn:hover {
  background: #fef2f2;
}

.card-score-add-btn {
  flex-shrink: 0;
}

.card-score-keyboard {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--cs-vv-offset-bottom, 0);
  z-index: 1000;
  transform: translateY(110%);
  transition: transform 0.22s ease;
  pointer-events: none;
}

.card-score-keyboard.is-open {
  transform: translateY(0);
  pointer-events: auto;
}

.card-score-keyboard-panel {
  background: #f7f7f7;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.card-score-keyboard-header {
  background: #fff;
  height: 36px;
  line-height: 36px;
  text-align: center;
  font-size: 14px;
  margin-bottom: 6px;
  border-radius: 8px;
  position: relative;
  color: #374151;
}

.card-score-keyboard-close {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  font-size: 28px;
  line-height: 1;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 8px;
}

.card-score-key-row {
  display: flex;
  gap: 5px;
  margin-bottom: 5px;
}

.card-score-key-row:last-child {
  margin-bottom: 0;
}

.card-score-key {
  flex: 1;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card-score-key:active {
  background: #eee;
}

.recipe-toast {
  position: fixed;
  left: 50%;
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  padding: 10px 18px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10001;
  max-width: min(92vw, 420px);
  text-align: center;
}

.recipe-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
  body.card-score-page:not(.card-score-board-active) .card-score-list-desc {
    display: block;
  }

  body.card-score-page .tool-card:not(.card-score-board-wrap) {
    margin: 0;
    padding: 16px;
  }

  body.card-score-board-active {
    overflow: hidden;
  }

  body.card-score-board-active .container {
    height: var(--cs-vv-height, 100dvh);
    min-height: var(--cs-vv-height, 100dvh);
  }

  body.card-score-board-active .content {
    padding: 4px 4px 0;
    box-shadow: none;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
  }

  body.card-score-board-active .tool-header,
  body.card-score-board-active .tool-mobile-bar {
    display: none !important;
  }

  body.card-score-board-active .card-score-board-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    min-height: 0;
    overflow: hidden;
  }

  /* 与联机一致：手机全屏仍保留外框，末列/表尾靠外框收口，避免总分周围缺边 */
  body.card-score-board-active .card-score-board-inner {
    border-radius: 0;
  }

  body.card-score-board-active .card-score-scroll {
    flex: 1;
    min-height: 0;
    margin-bottom: 0;
  }

  body.card-score-board-active .card-score-footer {
    flex-shrink: 0;
  }

  body.card-score-board-active.keyboard-open .card-score-add-btn {
    display: none;
  }

  body.card-score-board-active .card-score-grid {
    width: 100%;
    min-width: 0;
  }

  body.card-score-board-active .card-score-player-col {
    flex: 1 1 0;
    min-width: 0;
    width: 0;
  }

  body.card-score-board-active .card-score-add-btn {
    width: calc(100% - 8px);
    margin: 0 4px 8px;
    padding: 8px 16px;
    font-size: 14px;
    flex-shrink: 0;
  }

  body.card-score-board-active .card-score-key {
    height: 36px;
    font-size: 15px;
  }
}

@media (min-width: 769px) {
  .card-score-keyboard {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 320px;
    transform: translateY(calc(100% + 24px));
  }

  .card-score-keyboard.is-open {
    transform: translateY(0);
  }

  .card-score-keyboard-panel {
    border-radius: 12px;
    overflow: hidden;
  }
}
