.rt-shell {
  max-width: min(92vw, 720px);
  margin: 0 auto;
  padding: 0 4px 24px;
  color: var(--cg-ink);
  font-family: Inter, Arial, sans-serif;
}

.rt-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.rt-stats {
  display: flex;
  flex: 1 1 auto;
  gap: 6px;
}

.rt-stat {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  background: var(--cg-panel);
  box-shadow: 0 8px 18px rgba(33, 43, 40, 0.07);
  text-align: center;
}

.rt-stat span {
  display: block;
  overflow: hidden;
  color: var(--cg-muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.rt-stat strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
  line-height: 1;
}

.rt-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.rt-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.rt-btn:focus-visible,
.rt-lane:focus-visible,
.rt-chip:focus-visible,
.rt-calib input:focus-visible {
  outline: 3px solid rgba(120, 160, 255, 0.6);
  outline-offset: 2px;
}

.rt-icon {
  padding: 0;
  font-size: 18px;
}

.rt-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #7c5cff, #e0457b);
  color: #fff;
}

.rt-stage {
  position: relative;
  height: clamp(400px, 62vh, 560px);
  overflow: hidden;
  border: 1px solid #232b46;
  border-radius: 18px;
  background: #141a2e;
  box-shadow: 0 18px 44px rgba(20, 26, 46, 0.32);
  touch-action: none;
  user-select: none;
}

.rt-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.rt-hud {
  position: absolute;
  z-index: 4;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(10, 14, 26, 0.78), rgba(10, 14, 26, 0));
  pointer-events: none;
}

.rt-now {
  flex: 1 1 auto;
  min-width: 0;
}

.rt-now b {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-now span {
  display: block;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-health {
  flex: 0 1 130px;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.rt-health i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2fb9d6, #7cf5b4);
  transition: width 140ms linear;
}

.rt-health i.rt-low {
  background: linear-gradient(90deg, #ff7a59, #e0457b);
}

.rt-clock {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.rt-keys {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.rt-lane {
  position: relative;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.rt-lane span {
  position: absolute;
  right: 7px;
  bottom: 14px;
  left: 7px;
  display: grid;
  height: 62px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.72);
  font-size: 17px;
  font-weight: 900;
  transition: background 90ms ease, color 90ms ease;
}

.rt-lane-on span,
.rt-lane:active span {
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.rt-judge {
  position: absolute;
  z-index: 5;
  top: 46%;
  left: 0;
  width: 100%;
  font-size: 27px;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-align: center;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.rt-j-perfect { color: #7cf5b4; }
.rt-j-great { color: #6fd3ff; }
.rt-j-good { color: #ffd166; }
.rt-j-miss { color: #ff7a97; }
.rt-pop { animation: rt-pop 320ms ease; }

.rt-panel {
  position: absolute;
  z-index: 8;
  top: 50%;
  left: 50%;
  display: grid;
  gap: 10px;
  width: min(86%, 330px);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(16, 21, 38, 0.93);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.45);
  color: #fff;
  text-align: center;
  transform: translate(-50%, -50%);
}

.rt-panel strong { font-size: 22px; }
.rt-panel p { margin: 0; color: rgba(255, 255, 255, 0.68); font-size: 13px; line-height: 1.45; }
.rt-panel .rt-btn { justify-self: center; min-width: 140px; }
.rt-hide { display: none !important; }

.rt-grade {
  justify-self: center;
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(140deg, #7c5cff, #2fb9d6);
  color: #fff;
  font-size: 36px;
  font-weight: 950;
}

.rt-grade-s { background: linear-gradient(140deg, #ffd166, #f0a11c); }
.rt-grade-a { background: linear-gradient(140deg, #7cf5b4, #1d7f62); }
.rt-grade-f { background: linear-gradient(140deg, #ff7a97, #a51f43); }

.rt-result-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.rt-result-actions .rt-btn { min-width: 0; padding: 0 14px; }
.rt-result-actions .rt-btn:not(.rt-primary) { border-color: rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.08); color: #fff; }

.rt-below {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.rt-row {
  display: grid;
  gap: 6px;
  padding: 11px 12px;
  border: 1px solid var(--cg-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.74);
}

.rt-row-split {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.rt-label {
  display: block;
  color: var(--cg-muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.rt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.rt-chip {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--cg-line);
  border-radius: 999px;
  background: #fff;
  color: var(--cg-ink);
  font: inherit;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}

.rt-chip-on {
  border-color: transparent;
  background: linear-gradient(135deg, #7c5cff, #e0457b);
  color: #fff;
}

.rt-calib label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--cg-muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.rt-calib b {
  color: var(--cg-ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.rt-calib input {
  width: 100%;
  height: 34px;
  margin-top: 4px;
  accent-color: #7c5cff;
}

.rt-modal {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 21, 38, 0.5);
}

.rt-modal[hidden] { display: none; }

.rt-modal-card {
  position: relative;
  width: min(100%, 440px);
  padding: 22px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(20, 26, 46, 0.35);
}

.rt-modal-card h2 { margin: 0 48px 12px 0; }
.rt-modal-card p { color: var(--cg-muted); line-height: 1.5; }

.rt-close {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 22px;
  cursor: pointer;
}

@keyframes rt-pop {
  0% { opacity: 0; transform: scale(0.72); }
  40% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 0.9; transform: scale(1); }
}

@media (max-width: 640px) {
  .rt-shell { max-width: 100%; padding: 0 2px 20px; }
  .rt-stat { padding: 6px 4px; }
  .rt-stat strong { font-size: 15px; }
  .rt-stage { height: clamp(400px, 58vh, 520px); border-radius: 14px; }
  .rt-row-split { grid-template-columns: minmax(0, 1fr); }
  .rt-chip { font-size: 12px; padding: 0 10px; }
  .rt-judge { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .rt-pop { animation-duration: 1ms; }
  .rt-health i { transition-duration: 1ms; }
}
