.lottery-workspace-panel {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.lottery-control-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.lottery-mode-block {
  min-width: 0;
}

.mode-toggle {
  display: inline-flex;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.6);
  gap: 0;
}

.mode-btn {
  padding: 9px 22px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.mode-btn.active {
  background: var(--brand);
  color: #fffaf3;
  border-radius: 999px;
}

.mode-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
  max-width: 64ch;
}

.generate-btn {
  flex-shrink: 0;
  text-align: center;
  border-radius: 14px;
  min-height: 40px;
  font-size: 15px;
}

.generate-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: not-allowed;
}

.validation-msg {
  min-height: 18px;
  margin: -4px 0 0;
  font-size: 13px;
  color: #9e3b28;
  line-height: 1.5;
}

.lottery-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.lottery-stats-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.45);
}

.lottery-stats-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.lottery-stats-grid dd {
  margin: 6px 0 0;
  font-family: var(--font-number);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
}

.match-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.match-action-btn {
  min-height: 40px;
  font-size: 14px;
  padding: 0 16px;
}

.match-cards {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;   /* room for focus ring */
}

.match-card {
  display: flex;
  flex-direction: column;
  min-width: 52px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.36);
  transition: border-color 0.15s, background 0.15s;
}

.match-card.is-included {
  border-color: var(--brand);
  background: rgba(255, 255, 255, 0.65);
}

.match-card.is-dan {
  border-color: #b84836;
}

/* Header — static label */
.match-card-header {
  padding: 7px 4px 6px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-number);
  letter-spacing: -0.01em;
  text-align: center;
  line-height: 1.2;
  user-select: none;
}

.match-card.is-included .match-card-header {
  background: var(--brand-soft);
  color: var(--brand-deep);
  border-bottom-color: rgba(171, 106, 27, 0.2);
}

/* Buttons area */
.match-card-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px 5px 5px;
}

/* Outcome buttons — full width, stacked vertically */
.outcome-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 28px;
  border: 1.5px solid var(--line-strong);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  user-select: none;
}

.outcome-btn:disabled {
  opacity: 0.22;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .outcome-btn:not(:disabled):hover {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand-deep);
  }
}

.outcome-btn.sel-win {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
}

.outcome-btn.sel-draw {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.outcome-btn.sel-loss {
  border-color: #b84836;
  background: rgba(184, 72, 54, 0.09);
  color: #9e3b28;
}

/* 胆 button — hidden in mode 14, shown in mode 9 */
.dan-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 26px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  user-select: none;
}

.match-cards.show-dan .dan-btn {
  display: flex;
}

.dan-btn:disabled {
  opacity: 0.2;
  pointer-events: none;
}

.dan-btn.dan-active {
  border-style: solid;
  border-color: #b84836;
  background: rgba(184, 72, 54, 0.1);
  color: #9e3b28;
}

@media (hover: hover) and (pointer: fine) {
  .dan-btn:not(:disabled):not(.dan-active):hover {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand-deep);
  }
}

/* ── Ticket Dan Badge ────────────────────────────────────────────────────── */

.ticket-dan-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: rgba(184, 72, 54, 0.12);
  color: #9e3b28;
  font-size: 9px;
  font-weight: 700;
  margin-left: 2px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ── Results ─────────────────────────────────────────────────────────────── */

.results-summary {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.results-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.export-btn {
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
  flex-shrink: 0;
}

.export-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.legend-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 26px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.legend-win {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
}

.legend-draw {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.legend-loss {
  background: rgba(184, 72, 54, 0.09);
  color: #9e3b28;
}

.legend-note {
  font-size: 12px;
  color: var(--muted);
  margin-left: 4px;
}

/* ── Virtual Tickets List ─────────────────────────────────────────────────── */

.tickets-viewport {
  position: relative;
  max-height: min(70vh, 720px);
  overflow: auto;
  padding-right: 6px;
  border-radius: var(--radius-sm);
  scroll-behavior: auto;
}

.tickets-viewport:focus {
  outline: 2px solid rgba(171, 106, 27, 0.28);
  outline-offset: 4px;
}

.tickets-list {
  position: relative;
  min-height: 1px;
}

.tickets-window-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ── Ticket Cards ─────────────────────────────────────────────────────────── */

.ticket-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 250, 242, 0.48)),
    rgba(255, 255, 255, 0.42);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.virtual-ticket {
  position: absolute;
  top: 0;
  left: 0;
  right: 6px;
  margin-bottom: 0;
  overflow: hidden;
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ticket-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  font-family: var(--font-number);
  letter-spacing: 0.02em;
}

.ticket-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-deep);
  font-family: var(--font-number);
}

.ticket-matches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(66px, 1fr));
  gap: 8px;
}

.ticket-match {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 4px;
  min-height: 58px;
  padding: 7px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 250, 242, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
}

.ticket-match-id {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  font-family: var(--font-number);
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--line);
}

.ticket-match-outcomes {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px;
}

.ticket-outcome {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
}

.ticket-outcome.win {
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
}

.ticket-outcome.draw {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.ticket-outcome.loss {
  background: rgba(184, 72, 54, 0.09);
  color: #9e3b28;
}

.ticket-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.ticket-combos {
  font-family: var(--font-number);
  font-weight: 600;
}

.ticket-face-value {
  font-family: var(--font-number);
  font-weight: 700;
  color: var(--text);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
  .lottery-control-strip {
    flex-direction: column;
  }

  .match-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .lottery-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .match-cards {
    grid-template-columns: repeat(7, 1fr);
  }
}

@media (max-width: 600px) {
  .lottery-workspace-panel {
    gap: 10px;
    padding: 12px;
  }

  .mode-btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .mode-hint {
    font-size: 12px;
    line-height: 1.5;
  }

  .match-actions {
    gap: 8px;
  }

  .generate-btn,
  .match-action-btn {
    min-height: 36px;
    padding: 0 12px;
    border-radius: 12px;
    font-size: 13px;
  }

  .lottery-stats-grid {
    gap: 6px;
  }

  .lottery-stats-grid div {
    padding: 8px;
    border-radius: 12px;
  }

  .lottery-stats-grid dt {
    font-size: 11px;
  }

  .lottery-stats-grid dd {
    margin-top: 4px;
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .match-cards {
    grid-template-columns: repeat(5, 1fr);
  }

  .results-actions {
    justify-content: flex-start;
  }

  .ticket-matches {
    grid-template-columns: repeat(3, 1fr);
  }

}
