
.level-open {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  z-index: 3;
  height: 44px;
  margin-top: -22px;
  border-radius: 22px;
}

.level-open:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -4px;
}

.level:has(.level-open:active) .level-star {
  transform: scale(0.92);
}

.level.ready::after {
  content: "!";
  position: absolute;
  left: 25px;
  top: -9px;
  z-index: 2;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #ff7a86, var(--ruby) 50%, #a0001a);
  border: 2px solid #fff;
  color: #fff;
  font-family: var(--display);
  font-size: 0.72rem;
  line-height: 14px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.rank-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 2px 10px;
}

.level-star.rank-star {
  width: 78px;
  height: 78px;
  margin: 0;
  font-size: 1.55rem;
  filter: drop-shadow(0 0 10px rgba(255, 211, 77, 0.85));
}

.level-star.rank-star > span {
  margin-top: 8px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.level-star.rank-star.long {
  font-size: 1.15rem;
}

.rank-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.rank-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.rank-icon {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--gold-light);
  line-height: 1;
}

.rank-name {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--display);
  font-size: 1.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background-image: var(--gold-bevel);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 var(--gold-deep)) drop-shadow(0 2px 1px rgba(0, 0, 0, 0.7));
}

.rank-bar {
  position: relative;
  height: 20px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 0 1px var(--gold-deep), inset 0 2px 3px rgba(0, 0, 0, 0.6);
}

.rank-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 55%),
    linear-gradient(90deg, var(--magenta), var(--neon-pink) 70%, var(--muted));
  transition: width 400ms ease-out;
}

.rank-xp {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-family: var(--display);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}

.rank-next {
  flex: none;
  display: grid;
  grid-template-columns: 1fr;
  margin-bottom: 0;
}

.rank-next-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 34px;
  padding: 6px 0;
  border-bottom: 1px solid var(--hairline);
}

.rank-next-icon {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--gold-light);
  line-height: 1.1;
}

.rank-next-text {
  flex: 1;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

.rank-next-label {
  color: var(--muted);
  font-family: var(--display);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 #000;
}

.rank-next-value {
  max-width: 100%;
  color: var(--gold-light);
  font-family: var(--display);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  line-height: 1.1;
  text-transform: uppercase;
  text-shadow: 0 1px 2px #000;
}

.rank-next-sub {
  color: var(--text);
  font-family: var(--display);
  font-size: 0.7rem;
  text-transform: uppercase;
  text-shadow: 0 1px 0 #000;
  white-space: nowrap;
}

.rank-next-item.rank .rank-next-text {
  row-gap: 3px;
}

.rank-next-prize {
  position: relative;
  grid-column: 2 / -1;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.rank-next-prize[hidden] {
  display: none;
}

.rank-next-coin {
  width: 18px;
  height: 18px;
}

.rank-next-amount {
  color: var(--gold-light);
  font-family: var(--display);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}

.rank-next-planet {
  display: flex;
}

.rank-next-planet .pearl {
  width: 20px;
  height: 20px;
  font-size: 20px;
}

.rank-next-said {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.rank-heading {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 5px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--hairline);
}

.rank-heading-name {
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-shadow: 0 1px 0 #000;
}

.rank-stars {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  color: var(--gold);
  font-family: var(--display);
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 0 #000;
}

.rank-stars::after,
#profile-sheet .profile-count::after {
  content: "";
  width: 0.95em;
  height: 0.95em;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  background: var(--gold-bevel);
}

.rank-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 0 0 8px;
}

.star-row {
  flex: none;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 76px;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}

.star-row.claimed {
  animation: star-row-flash 700ms ease-out;
}

.star-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--gold-light);
  line-height: 1;
}

.star-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.star-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.star-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-family: var(--display);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px #000;
  text-transform: uppercase;
}

.star-sockets {
  position: relative;
  flex: none;
  display: flex;
  gap: 4px;
}

.star-sockets::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 1px;
  background: rgba(255, 230, 160, 0.35);
}

.star-socket {
  position: relative;
  width: 17px;
  height: 17px;
}

.star-socket::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  background: rgba(200, 170, 255, 0.22);
}

.star-socket.lit::before {
  background: var(--gold-bevel);
}

.star-socket.ready::before {
  background: var(--gold-light);
}

.star-socket.ready {
  opacity: 0.85;
}

.star-socket.lighting {
  animation: star-light 700ms cubic-bezier(0.2, 1.6, 0.4, 1);
}

.star-socket.lighting::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--gold-light);
  box-shadow: 0 0 10px var(--gold);
  opacity: 0;
  animation: star-ring 700ms ease-out;
}

.star-bar {
  position: relative;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 211, 77, 0.25);
}

.star-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--violet), var(--neon-cyan));
  transition: width 400ms ease-out;
}

.star-row.ready .star-fill,
.star-row.done .star-fill {
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-light));
}

.star-count {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: var(--display);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
  text-shadow: 0 1px 0 #000;
}

.star-claim {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 48px;
  padding: 4px 2px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.35));
  border: 2px solid rgba(255, 211, 77, 0.3);
  color: var(--muted);
  font-family: var(--display);
  text-shadow: 0 1px 0 #000;
  box-shadow: 0 0 0 1px var(--gold-deep), 0 4px 0 rgba(0, 0, 0, 0.6);
}

.star-claim-label {
  font-family: var(--display);
  font-size: 1rem;
  letter-spacing: 0.08em;
  line-height: 1.1;
}

.star-claim-coins {
  font-family: var(--display);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.star-claim:not(:disabled) {
  background: var(--gold-bevel);
  border-color: var(--gold-light);
  box-shadow: 0 0 0 1px var(--gold-deep), 0 4px 0 rgba(0, 0, 0, 0.6);
  color: var(--gold-ink);
  text-shadow: none;
}

.star-claim:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 0 0 1px var(--gold-deep), 0 1px 0 rgba(0, 0, 0, 0.6);
}

.star-row.done .star-claim {
  border-color: rgba(255, 211, 77, 0.55);
  color: var(--gold);
}

.rank-icon svg,
.rank-next-icon svg,
.rank-loyalty-icon svg,
.star-icon svg,
.rank-icon img,
.rank-next-icon img,
.rank-loyalty-icon img,
.star-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.rank-panel .sheet-close {
  flex: none;
  min-height: 48px;
  margin-top: 8px;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
}

@keyframes star-socket-pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(255, 211, 77, 0.6)); }
  50% { transform: scale(1.25); filter: drop-shadow(0 0 7px rgba(255, 230, 140, 1)); }
}

@keyframes star-light {
  0% { transform: scale(0.2) rotate(-120deg); }
  60% { transform: scale(1.9) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes star-ring {
  0% { opacity: 1; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(2.4); }
}

@keyframes star-row-flash {
  0% { box-shadow: inset 0 0 30px rgba(255, 236, 160, 0.8), 0 0 24px rgba(255, 211, 77, 0.9); }
}

@keyframes star-claim-glow {
  0%, 100% { box-shadow: 0 0 0 1px var(--gold-deep), 0 3px 0 rgba(0, 0, 0, 0.6), 0 0 4px rgba(255, 211, 77, 0.4); }
  50% { box-shadow: 0 0 0 1px var(--gold-deep), 0 3px 0 rgba(0, 0, 0, 0.6), 0 0 14px rgba(255, 226, 130, 0.95); }
}

@keyframes milestone-glow {
  50% { filter: drop-shadow(0 2px 0 var(--gold-deep)) drop-shadow(0 4px 0 #5a0a50) drop-shadow(0 0 30px rgba(255, 246, 200, 1)); }
}

@keyframes rank-reveal {
  from { opacity: 0; transform: scale(0.4); letter-spacing: 0.4em; }
}

@media (prefers-reduced-motion: reduce) {
  .star-row.claimed,
  .star-socket.ready,
  .star-socket.lighting,
  .star-socket.lighting::after,
  .star-claim:not(:disabled) {
    animation: none;
  }
  .rank-fill,
  .star-fill {
    transition: none;
  }
}

