:root {
  --rm-red:        #E63936;
  --rm-red-border: rgba(230, 57, 54, 0.35);
  --rm-red-glow:   rgba(230, 57, 54, 0.12);
  --rm-green:      #00C27B;
  --rm-pill-bg:    #111820;
  --rm-card-bg:    #0C1118;
}

/* ── WRAPPER ── */

/* footer needs a positioning context for the badge */
footer {
  position: relative;
}

#rm-perf-badge-wrap {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#rm-perf-badge-wrap.rm-badge-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── LEFT POSITION OVERRIDES ── */

#rm-perf-badge-wrap[data-position="left"] {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: auto;
}

#rm-perf-badge-wrap[data-position="left"] .rm-badge {
  flex-direction: row-reverse;
}
#rm-perf-badge-wrap[data-position="left"] .rm-pill {
  border-radius: 999px 0 0 999px;
  border-right: none;
  border-left: 1.5px solid rgba(255, 255, 255, 0.08);
  margin-left: 0;
  margin-right: -22px;
  padding-left: 0;
  padding-right: 22px;
}
#rm-perf-badge-wrap[data-position="left"] .rm-badge:hover .rm-pill,
#rm-perf-badge-wrap[data-position="left"] .rm-badge.rm-expanded .rm-pill {
  border-left-color: var(--rm-red-border);
}
#rm-perf-badge-wrap[data-position="left"] .rm-pill-inner {
  padding: 0 8px 0 18px;
  transform: translateX(6px);
}
#rm-perf-badge-wrap[data-position="left"] .rm-badge:hover .rm-pill-inner,
#rm-perf-badge-wrap[data-position="left"] .rm-badge.rm-expanded .rm-pill-inner {
  transform: translateX(0);
}
#rm-perf-badge-wrap[data-position="left"] .rm-hover-card {
  right: auto;
  left: 0;
  transform-origin: bottom left;
}
#rm-perf-badge-wrap[data-position="left"] .rm-hover-card::after {
  right: auto;
  left: 16px;
}

/* ── BADGE ROW ── */

.rm-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  cursor: pointer;
}

/* Invisible bridge covering the 10px gap between badge top and card bottom.
   Without this, the mouse loses .rm-badge:hover mid-travel and pointer-events
   on the card drop to none before the user can click. */
.rm-badge::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  height: 12px;
}

/* ── BOLT CIRCLE ── */

.rm-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--rm-red);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  transition: background 0.2s, box-shadow 0.2s;
  animation: rm-idle-pulse 3.2s ease-in-out infinite;
}

@keyframes rm-idle-pulse {
  0%, 100% { box-shadow: 0 0 0 0px rgba(230, 57, 54, 0.0); }
  50%       { box-shadow: 0 0 0 5px rgba(230, 57, 54, 0.1); }
}

.rm-badge:hover .rm-icon-circle,
.rm-badge.rm-expanded .rm-icon-circle {
  animation: none;
  background: #EF4542;
  box-shadow: 0 0 0 3px rgba(230, 57, 54, 0.15);
}

/* ── PILL ── */

.rm-pill {
  height: 44px;
  background: var(--rm-pill-bg);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-left: none;
  border-radius: 0 999px 999px 0;
  width: 0;
  overflow: hidden;
  opacity: 0;
  transition: width 0.38s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease,
              border-color 0.2s;
  position: relative;
  z-index: 1;
  margin-left: -22px;
  padding-left: 22px;
  display: flex;
  align-items: center;
}

.rm-badge:hover .rm-pill,
.rm-badge.rm-expanded .rm-pill {
  width: 130px;
  opacity: 1;
  border-color: var(--rm-red-border);
}

/* ── PILL INNER TEXT ── */

.rm-pill-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 0 18px 0 8px;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s ease 0.22s, transform 0.2s ease 0.22s;
  white-space: nowrap;
}

.rm-badge:hover .rm-pill-inner,
.rm-badge.rm-expanded .rm-pill-inner {
  opacity: 1;
  transform: translateX(0);
}

.rm-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #D8E4E0;
  line-height: 1;
  display: block;
}

.rm-perf {
  font-size: 10px;
  font-weight: 300;
  text-transform: uppercase;
  color: var(--rm-red);
  line-height: 1;
  display: block;
  /* letter-spacing calibrated by JS to match .rm-name width */
}

/* ── HOVER CARD ── */

.rm-hover-card {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  width: 214px;
  background: var(--rm-card-bg);
  border: 1px solid rgba(230, 57, 54, 0.2);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.75);
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1) 0.3s,
              transform 0.22s cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
}

.rm-hover-card::after {
  content: '';
  position: absolute;
  bottom: -5px;
  right: 16px;
  width: 8px;
  height: 8px;
  background: var(--rm-card-bg);
  border-right: 1px solid rgba(230, 57, 54, 0.2);
  border-bottom: 1px solid rgba(230, 57, 54, 0.2);
  transform: rotate(45deg);
}

.rm-badge:hover .rm-hover-card {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── CARD SECTIONS ── */

.rm-card-head {
  padding: 11px 14px 10px;
  border-bottom: 1px solid rgba(230, 57, 54, 0.1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.rm-card-mark {
  width: 10px;
  height: 10px;
  background: var(--rm-red);
  border-radius: 2px;
  position: relative;
  flex-shrink: 0;
}

.rm-card-mark::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 4px;
  height: 4px;
  background: var(--rm-card-bg);
  border-radius: 1px 0 0 0;
}

.rm-card-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #D8E4E0;
}

.rm-card-title span { color: var(--rm-red); }

.rm-card-body {
  padding: 10px 14px 11px;
  display: flex;
  flex-direction: column;
  gap: 6.5px;
}

.rm-card-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 1px;
}

.rm-score-num {
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.03em;
  line-height: 1;
}

.rm-score-label-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rm-score-label-top {
  font-size: 8px;
  text-transform: uppercase;
  color: #3A4A52;
  letter-spacing: 0.06em;
}

.rm-score-label-bot {
  font-size: 8px;
  font-weight: 500;
  color: #8A9898;
  text-transform: uppercase;
}

.rm-card-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rm-card-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--rm-green);
  opacity: 0.5;
  flex-shrink: 0;
}

.rm-card-row-label {
  font-size: 8px;
  text-transform: uppercase;
  color: #456858;
  flex: 1;
  letter-spacing: 0.06em;
}

.rm-card-row-val {
  font-size: 8px;
  font-weight: 500;
  color: var(--rm-green);
  white-space: nowrap;
}

/* ── CARD FOOTER ── */

.rm-card-foot {
  border-top: 1px solid rgba(230, 57, 54, 0.1);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  transition: background 0.15s;
}

.rm-card-foot:hover { background: rgba(230, 57, 54, 0.06); }

.rm-card-foot:focus-visible {
  outline: 2px solid var(--rm-red);
  outline-offset: -2px;
}

.rm-card-foot-text {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--rm-red);
  letter-spacing: 0.1em;
}

.rm-card-foot-arrow {
  font-size: 11px;
  color: rgba(230, 57, 54, 0.4);
}

/* ── MOBILE ── */

@media (max-width: 768px) {
  /* Hover state disabled on touch — only rm-expanded class works */
  .rm-badge:hover .rm-pill  { width: 0; opacity: 0; }
  .rm-badge.rm-expanded .rm-pill { width: 158px; opacity: 1; }
}
