.rhythm-shell {
  padding: 1.25rem;
  margin: 1.4rem auto;
}

.rhythm-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.2rem;
  align-items: stretch;
}

.rhythm-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.rhythm-hero__panel {
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  background: linear-gradient(150deg, rgba(34, 211, 238, 0.08), rgba(168, 85, 247, 0.1));
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.rhythm-hero__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 0.6rem;
}

.rhythm-stat {
  font-size: 1.5rem;
  font-weight: 800;
}

.rhythm-hero__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.rhythm-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.rhythm-board {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  background: radial-gradient(circle at 20% 20%, rgba(34, 211, 238, 0.12), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(168, 85, 247, 0.12), transparent 32%),
    rgba(255, 255, 255, 0.02);
}

.rhythm-board__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.rhythm-board__controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.rhythm-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

.rhythm-inline input[type="range"] {
  width: 120px;
}

.rhythm-inline input[type="checkbox"] {
  accent-color: var(--accent-primary, #22d3ee);
  width: 18px;
  height: 18px;
}

.rhythm-inline select {
  appearance: none;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 0.35rem 0.7rem;
  color: #e2e8f0;
  font-weight: 700;
  min-width: 140px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.rhythm-inline select option {
  background: #0f172a;
  color: #e2e8f0;
  font-weight: 700;
}

.rhythm-inline select:focus {
  border-color: rgba(79, 223, 255, 0.6);
  box-shadow: 0 0 0 2px rgba(79, 223, 255, 0.12);
}

.rhythm-value {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 42px;
  text-align: right;
}

.rhythm-progress {
  height: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.25);
}

.rhythm-progress__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22d3ee, #a855f7, #f472b6);
  box-shadow: 0 0 18px rgba(168, 85, 247, 0.6);
  transition: width 0.16s ease;
}

.rhythm-stage {
  position: relative;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.8), rgba(8, 12, 24, 0.95)),
    radial-gradient(circle at 50% -20%, rgba(79, 223, 255, 0.12), transparent 45%),
    radial-gradient(circle at 10% 50%, rgba(244, 114, 182, 0.12), transparent 30%);
  padding: 0.85rem;
  min-height: 440px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.rhythm-lanes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  height: 100%;
  position: relative;
}

.rhythm-lane {
  position: relative;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.rhythm-lane::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.03),
      transparent 35%,
      transparent 65%,
      rgba(255, 255, 255, 0.03)
    ),
    linear-gradient(transparent 90%, rgba(255, 255, 255, 0.06) 100%);
  pointer-events: none;
}

.rhythm-lane__label {
  position: absolute;
  top: 0.45rem;
  left: 0.55rem;
  right: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text-muted);
  mix-blend-mode: screen;
  text-transform: uppercase;
}

.rhythm-lane.is-pressed {
  box-shadow: inset 0 0 0 2px rgba(34, 211, 238, 0.4), 0 0 18px rgba(34, 211, 238, 0.3);
}

.rhythm-note {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 50px;
  border-radius: 12px;
  padding: 0.4rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #e5f6ff;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
  transform: translateY(-120px);
}

.rhythm-note .note-symbol {
  font-size: 1.2rem;
}

.rhythm-note .note-time {
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0.8;
}

.rhythm-note.lane-0 {
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
  border: 1px solid rgba(34, 211, 238, 0.6);
}

.rhythm-note.lane-1 {
  background: linear-gradient(135deg, #fbbf24, #fb7185);
  border: 1px solid rgba(251, 191, 36, 0.6);
}

.rhythm-note.lane-2 {
  background: linear-gradient(135deg, #a855f7, #6366f1);
  border: 1px solid rgba(168, 85, 247, 0.6);
}

.rhythm-note.lane-3 {
  background: linear-gradient(135deg, #4ade80, #22c55e);
  border: 1px solid rgba(74, 222, 128, 0.6);
}

.rhythm-note.judged {
  opacity: 0.2;
  transform: scale(0.96);
}

.rhythm-note.judged.perfect {
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.6);
}

.rhythm-note.judged.great {
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.55);
}

.rhythm-note.judged.good {
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.rhythm-judge-line {
  position: absolute;
  left: 0.8rem;
  right: 0.8rem;
  bottom: 12%;
  height: 4px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.8), rgba(168, 85, 247, 0.8), rgba(244, 114, 182, 0.85));
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.55);
}

.rhythm-judge {
  position: absolute;
  bottom: 4%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 800;
  letter-spacing: 0.05em;
}

.rhythm-countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(2.6rem, 8vw, 4.2rem);
  font-weight: 900;
  color: #e0f2fe;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.rhythm-judge[data-state="perfect"] {
  color: #7dd3fc;
}

.rhythm-judge[data-state="great"] {
  color: #c084fc;
}

.rhythm-judge[data-state="good"] {
  color: #facc15;
}

.rhythm-judge[data-state="miss"] {
  color: #f87171;
}

.rhythm-feed {
  margin-top: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.02);
  max-height: 180px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.rhythm-feed__item {
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rhythm-feed__item:last-child {
  border-bottom: none;
}

.rhythm-editor {
  margin-top: 0.6rem;
  padding: 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  display: grid;
  gap: 0.5rem;
}

.rhythm-editor.subtle {
  box-shadow: none;
}

.rhythm-editor__header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.rhythm-editor textarea {
  width: 100%;
  min-height: 120px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  padding: 0.6rem;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.95rem;
  resize: vertical;
}

.rhythm-editor__actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.rhythm-panel {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rhythm-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.rhythm-leaderboard {
  margin-top: 1rem;
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.rhythm-leaderboard__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.rhythm-leaderboard__table {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.rhythm-leaderboard__body {
  display: grid;
  gap: 0.35rem;
  padding: 0.5rem 0.8rem 0.8rem;
}

.rhythm-leaderboard__empty {
  grid-column: 1 / -1;
  padding: 0.2rem 0.1rem;
  text-align: left;
  color: var(--text-muted);
}

.rhythm-leaderboard__row {
  display: grid;
  grid-template-columns: 48px 1.15fr 1fr 1.1fr 0.95fr 0.95fr;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.85rem;
  justify-items: start;
}

.rhythm-leaderboard__head {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: left;
}

.rhythm-leaderboard__cell {
  font-weight: 700;
  text-align: left;
}

.rhythm-leaderboard__cell--rank {
  color: var(--text-muted);
}

.rhythm-leaderboard__cell--title {
  font-weight: 800;
}

.rhythm-leaderboard__cell--meta {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.rhythm-leaderboard__cell--player {
  color: var(--text-muted);
}

.rhythm-leaderboard__cell--score,
.rhythm-leaderboard__cell--accuracy {
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.rhythm-tip-list {
  list-style: disc;
  padding-left: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--text-muted);
}

.rhythm-legend {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.6rem 0;
}

.rhythm-legend__item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 0.65rem;
  align-items: center;
}

.rhythm-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px currentColor;
}

.rhythm-dot.lane-0 {
  color: #22d3ee;
}

.rhythm-dot.lane-1 {
  color: #fbbf24;
}

.rhythm-dot.lane-2 {
  color: #a855f7;
}

.rhythm-dot.lane-3 {
  color: #4ade80;
}

.rhythm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 24, 0.7);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  z-index: 50;
}

.rhythm-overlay__card {
  padding: 1.1rem;
  border-radius: 18px;
  min-width: min(420px, 92vw);
  display: grid;
  gap: 0.7rem;
  text-align: center;
}

.rhythm-grade {
  font-size: clamp(2.4rem, 4vw, 3rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #a855f7;
}

.rhythm-overlay__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
}

.rhythm-overlay__stats dt {
  color: var(--text-muted);
  font-weight: 700;
}

.rhythm-overlay__stats dd {
  font-weight: 800;
  font-size: 1.15rem;
}

.rhythm-overlay__actions {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .rhythm-leaderboard__row {
    grid-template-columns: 36px 1fr 1fr;
    grid-template-areas:
      "rank title title"
      "player player player"
      "meta score accuracy";
    gap: 0.35rem 0.6rem;
  }

  .rhythm-leaderboard__cell--rank {
    grid-area: rank;
  }

  .rhythm-leaderboard__cell--title {
    grid-area: title;
  }

  .rhythm-leaderboard__cell--player {
    grid-area: player;
  }

  .rhythm-leaderboard__cell--meta {
    grid-area: meta;
  }

  .rhythm-leaderboard__cell--score {
    grid-area: score;
  }

  .rhythm-leaderboard__cell--accuracy {
    grid-area: accuracy;
  }
}

@media (max-width: 1024px) {
  .rhythm-hero {
    grid-template-columns: 1fr;
  }

  .rhythm-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .rhythm-inline input[type="range"] {
    width: 100px;
  }

  .rhythm-lanes {
    gap: 0.35rem;
  }

  .rhythm-hero__grid {
    grid-template-columns: 1fr 1fr;
  }
}
