/**
 * grade-legend.css — Form legend + Thresholds button + modal panel.
 * Standalone (NO @import). Link LAST after arena/match CSS so button resets lose.
 */

/* ── Legend under Form / Match ── */
#match-vitals .grade-legend,
.grade-legend {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  margin-top: 6px !important;
  padding-top: 6px !important;
  border-top: 1px solid rgba(0, 255, 136, 0.14) !important;
  font-family: "Courier New", Courier, monospace !important;
  font-size: 0.58rem !important;
  color: #9fbf9f !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.grade-legend__row {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 0 !important;
}

.grade-legend__row--tools {
  margin-top: 2px !important;
}

.grade-legend__label {
  flex: 0 0 3.2rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase !important;
  opacity: 0.75 !important;
}

.grade-legend__val {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  text-align: right !important;
  font-variant-numeric: tabular-nums !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.grade-legend__pips {
  display: inline-flex !important;
  gap: 3px !important;
  flex: 0 0 auto !important;
}

.grade-pip {
  display: inline-block !important;
  width: 0.55rem !important;
  height: 0.55rem !important;
  border-radius: 50% !important;
  border: 1px solid rgba(0, 255, 136, 0.45) !important;
  background: rgba(0, 255, 136, 0.35) !important;
  box-shadow: 0 0 4px rgba(0, 255, 120, 0.25) !important;
}

.grade-pip.is-used {
  background: rgba(80, 40, 40, 0.6) !important;
  border-color: rgba(255, 100, 100, 0.45) !important;
  box-shadow: none !important;
  opacity: 0.7 !important;
}

.grade-pip.is-none {
  background: transparent !important;
  border-style: dashed !important;
  opacity: 0.4 !important;
}

/* ── Thresholds open button ── */
#grade-threshold-open,
button#grade-threshold-open,
.grade-legend__tune,
#match-vitals .grade-legend__tune {
  appearance: none !important;
  -webkit-appearance: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.35rem !important;
  width: auto !important;
  min-width: 7.5rem !important;
  min-height: 30px !important;
  margin: 4px 0 0 auto !important;
  padding: 0.4rem 0.7rem !important;
  border: 1px solid rgba(0, 255, 136, 0.45) !important;
  border-radius: 6px !important;
  background: linear-gradient(165deg, rgba(0, 48, 26, 0.98), rgba(0, 18, 10, 0.99)) !important;
  color: #9fefb0 !important;
  font-family: "Courier New", Courier, monospace !important;
  font-size: 0.64rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  text-decoration: none !important;
  box-shadow: 0 0 12px rgba(0, 255, 120, 0.15) !important;
  cursor: pointer !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  line-height: 1.1 !important;
}

#grade-threshold-open:hover,
.grade-legend__tune:hover {
  border-color: rgba(0, 255, 136, 0.75) !important;
  color: #ffffff !important;
  background: linear-gradient(165deg, rgba(0, 100, 52, 0.98), rgba(0, 40, 22, 0.99)) !important;
}

/* ── Modal panel (MUST be fixed overlay — else footer jumps into view) ── */
#grade-threshold-panel.grade-threshold-panel,
.grade-threshold-panel,
body > #grade-threshold-panel {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  z-index: 50000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 16px !important;
  box-sizing: border-box !important;
  background: rgba(0, 6, 4, 0.78) !important;
  backdrop-filter: blur(3px) !important;
  -webkit-backdrop-filter: blur(3px) !important;
  overflow: auto !important;
  pointer-events: auto !important;
}

#grade-threshold-panel[hidden],
.grade-threshold-panel[hidden],
body > #grade-threshold-panel[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.grade-threshold-panel__card {
  position: relative !important;
  width: min(420px, 96vw) !important;
  max-height: min(88vh, 640px) !important;
  overflow: auto !important;
  border-radius: 10px !important;
  border: 1px solid rgba(0, 255, 136, 0.35) !important;
  background: linear-gradient(180deg, rgba(0, 22, 12, 0.99), rgba(0, 10, 6, 0.99)) !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6) !important;
  padding: 12px 14px 14px !important;
  color: #cfe8d0 !important;
  font-family: "Courier New", Courier, monospace !important;
  margin: auto !important;
  flex: 0 1 auto !important;
}

.grade-threshold-panel__head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  margin-bottom: 8px !important;
  font-size: 0.85rem !important;
  letter-spacing: 0.04em !important;
  color: #d8f5e0 !important;
}

.grade-threshold-panel__x {
  appearance: none !important;
  border: 1px solid rgba(0, 255, 136, 0.3) !important;
  background: transparent !important;
  color: #9fdfb0 !important;
  width: 1.7rem !important;
  height: 1.7rem !important;
  border-radius: 4px !important;
  cursor: pointer !important;
  font-size: 0.9rem !important;
  line-height: 1 !important;
  padding: 0 !important;
}

.grade-threshold-panel__help {
  margin: 0 0 10px !important;
  font-size: 0.62rem !important;
  line-height: 1.4 !important;
  opacity: 0.85 !important;
  color: #a8c8b0 !important;
}

.grade-threshold-panel__field {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  margin-bottom: 10px !important;
  font-size: 0.68rem !important;
  color: #cfe8d0 !important;
}

.grade-threshold-panel__field input,
.grade-threshold-band input {
  width: 3.4rem !important;
  background: rgba(0, 0, 0, 0.45) !important;
  border: 1px solid rgba(0, 255, 136, 0.3) !important;
  color: #e0ffe8 !important;
  border-radius: 4px !important;
  padding: 0.25rem 0.35rem !important;
  font: inherit !important;
}

.grade-threshold-band {
  display: grid !important;
  grid-template-columns: 4.2rem 1fr 1fr !important;
  gap: 6px !important;
  align-items: center !important;
  margin-bottom: 6px !important;
  font-size: 0.62rem !important;
  color: #cfe8d0 !important;
}

.grade-threshold-band__lv {
  font-weight: 800 !important;
  color: #7dffb0 !important;
}

.grade-threshold-band label {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 4px !important;
  color: #a8c8b0 !important;
}

.grade-threshold-panel__actions {
  display: flex !important;
  gap: 6px !important;
  margin-top: 12px !important;
  flex-wrap: wrap !important;
}

.grade-threshold-panel__btn {
  appearance: none !important;
  flex: 1 1 auto !important;
  border: 1px solid rgba(0, 255, 136, 0.35) !important;
  background: rgba(0, 255, 136, 0.08) !important;
  color: #b8f0c8 !important;
  font: inherit !important;
  font-size: 0.62rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  padding: 0.45rem 0.55rem !important;
  border-radius: 4px !important;
  cursor: pointer !important;
  min-height: 34px !important;
}

.grade-threshold-panel__btn.is-primary {
  border-color: rgba(0, 255, 136, 0.6) !important;
  color: #3dffa0 !important;
  background: rgba(0, 255, 136, 0.14) !important;
}

.grade-threshold-panel__btn:hover {
  background: rgba(0, 255, 136, 0.2) !important;
  color: #fff !important;
}

.grade-threshold-panel__status {
  margin: 8px 0 0 !important;
  font-size: 0.6rem !important;
}

.grade-threshold-panel__status.is-ok {
  color: #7dffb0 !important;
}

.grade-threshold-panel__status.is-err {
  color: #ff9a9a !important;
}
