* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  margin: 0;
  background: radial-gradient(120% 80% at 50% 0%, var(--rg-bg-2), var(--rg-bg));
  color: var(--rg-text);
  font-family: var(--rg-font);
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body.rg-scroll {
  overflow-y: auto;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.rg-app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: calc(var(--rg-safe-top) + 12px) calc(var(--rg-safe-right) + 12px)
    calc(var(--rg-safe-bottom) + 12px) calc(var(--rg-safe-left) + 12px);
}

.rg-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.rg-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.rg-subtitle {
  margin: 2px 0 0;
  color: var(--rg-muted);
  font-size: 13px;
  line-height: 1.35;
}

.rg-spacer {
  flex: 1;
}

.rg-btn {
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--rg-border);
  border-radius: 14px;
  background: var(--rg-surface);
  color: var(--rg-text);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.rg-btn:active {
  transform: scale(0.98);
}

.rg-btn--primary {
  background: var(--rg-primary);
  border-color: var(--rg-primary);
  color: #ffffff;
}

.rg-btn--accent {
  background: var(--rg-accent);
  border-color: var(--rg-accent);
  color: #ffffff;
}

.rg-btn--ghost {
  background: transparent;
}

.rg-card {
  background: var(--rg-surface);
  border: 1px solid var(--rg-border);
  border-radius: var(--rg-radius);
  box-shadow: var(--rg-shadow);
}

.rg-muted {
  color: var(--rg-muted);
}

.rg-chip {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--rg-border);
  border-radius: 999px;
  background: var(--rg-surface);
  color: var(--rg-muted);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rg-chip[aria-pressed="true"] {
  border-color: var(--rg-primary);
  background: var(--rg-primary);
  color: #ffffff;
}

.rg-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 7, 12, 0.72);
  backdrop-filter: blur(8px);
}

.rg-modal {
  width: min(100%, 360px);
  padding: 24px;
  border: 1px solid var(--rg-border);
  border-radius: 24px;
  background: var(--rg-surface);
  box-shadow: var(--rg-shadow);
  text-align: center;
}

.rg-modal h2 {
  margin: 0 0 8px;
  font-size: 19px;
}

.rg-modal p {
  margin: 0 0 18px;
  color: var(--rg-muted);
  font-size: 14px;
  line-height: 1.45;
}

.rg-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.rg-actions .rg-btn {
  min-width: 140px;
}

.rg-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rg-stat {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--rg-border);
  border-radius: 12px;
  background: var(--rg-surface);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
}

.rg-stat strong {
  font-size: 15px;
}

.rg-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--rg-safe-bottom) + 18px);
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border: 1px solid var(--rg-border);
  border-radius: 999px;
  background: var(--rg-surface);
  box-shadow: var(--rg-shadow);
  color: var(--rg-text);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

@media (min-width: 720px) {
  .rg-app {
    width: min(100%, 640px);
    margin: 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
